package pm.j4.kerosene.mixin; import java.util.Optional; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.TitleScreen; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import pm.j4.kerosene.modules.splash.SplashText; import pm.j4.kerosene.util.config.ConfigHolder; import pm.j4.kerosene.util.config.ConfigManager; /** * Mixin attached to the TitleScreen. * Currently, it is only used to display a string of text with the mod's version. * Any other modules will likely extend the options screen or pause screen, * so the module is unlikely to be used elsewhere. */ @Mixin(TitleScreen.class) public class TitleScreenMixin extends Screen { /** * The Opacity. */ private double opacity = 0; /** * The Ascending. */ private boolean ascending = false; /** * Stub method. * Since the mixin injects itself into the *actual* TitleScreen used by the game, * this should never run. * * @param title the title */ protected TitleScreenMixin(Text title) { super(title); } /** * Mixin injection into the render method. * It captures locals so that the text can be rendered alongside the * screen fade-in. * It injects before the call to @link com.mojang.bridge.game.GameVersion#getName() using INVOKE_ASSIGN, * because attempting to use a regular invoke statement on @link net.minecraft.client.gui.DrawHelper#drawStringWithShadow() * repeatedly failed. *
*
* @param matrices the matrices
* @param mouseX the mouse x
* @param mouseY the mouse y
* @param delta the delta
* @param ci the ci
* @param f the f
* @param i the
* @param j the j
* @param g the g
* @param l the l
*/
@Inject(method = "render",
at = @At(
value = "INVOKE_ASSIGN",
target = "Lcom/mojang/bridge/game/GameVersion;getName()Ljava/lang/String;",
ordinal = 0),
locals = LocalCapture.CAPTURE_FAILSOFT)
private void render(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci, float f, int i, int j, float g, int l) {
Optional