|
1 | 1 | package xyz.bluspring.technobladeneverdies.mixin; |
2 | 2 |
|
3 | | -import com.mojang.blaze3d.systems.RenderSystem; |
4 | 3 | import net.minecraft.client.MinecraftClient; |
| 4 | +import net.minecraft.client.gui.DrawContext; |
5 | 5 | import net.minecraft.client.gui.screen.TitleScreen; |
6 | | -import net.minecraft.client.util.math.MatrixStack; |
| 6 | +import net.minecraft.client.texture.TextureManager; |
7 | 7 | import net.minecraft.util.Identifier; |
8 | | -import net.minecraft.util.Util; |
9 | 8 | import net.minecraft.util.math.MathHelper; |
10 | 9 | import org.spongepowered.asm.mixin.Final; |
11 | 10 | import org.spongepowered.asm.mixin.Mixin; |
12 | 11 | import org.spongepowered.asm.mixin.Shadow; |
| 12 | +import org.spongepowered.asm.mixin.Unique; |
13 | 13 | import org.spongepowered.asm.mixin.injection.At; |
14 | 14 | import org.spongepowered.asm.mixin.injection.Inject; |
15 | | -import org.spongepowered.asm.mixin.injection.Redirect; |
16 | 15 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
| 16 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
17 | 17 | import org.spongepowered.asm.mixin.injection.callback.LocalCapture; |
| 18 | +import xyz.bluspring.technobladeneverdies.TechnobladeNeverDies; |
18 | 19 |
|
19 | | -import java.util.function.BiConsumer; |
| 20 | +import java.util.concurrent.CompletableFuture; |
| 21 | +import java.util.concurrent.Executor; |
20 | 22 |
|
21 | 23 | @Mixin(TitleScreen.class) |
22 | 24 | public class TitleScreenMixin { |
23 | 25 | @Shadow @Final private boolean doBackgroundFade; |
24 | 26 | @Shadow private long backgroundFadeStart; |
| 27 | + @Unique |
25 | 28 | private static final Identifier TECHNO_TITLE_TEXTURE = new Identifier("technoneverdies", "textures/gui/title.png"); |
26 | 29 |
|
27 | | - @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/TitleScreen;drawWithOutline(IILjava/util/function/BiConsumer;)V"), method = "render", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD) |
28 | | - public void modifyTitleTexture(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci, float f, int i, int j) { |
29 | | - var titleScreen = (TitleScreen) (Object) this; |
30 | | - |
31 | | - RenderSystem.setShaderTexture(0, TECHNO_TITLE_TEXTURE); |
32 | | - |
33 | | - titleScreen.drawWithOutline(j, 30, (x, y) -> { |
34 | | - TitleScreen.drawTexture(matrices, x + 10, y - 35, 0, 0, 256, 128, 256, 128); |
35 | | - }); |
| 30 | + @Inject(method = "loadTexturesAsync", at = @At("RETURN"), cancellable = true) |
| 31 | + private static void appendTechnoTexture(TextureManager textureManager, Executor executor, CallbackInfoReturnable<CompletableFuture<Void>> cir) { |
| 32 | + cir.setReturnValue(CompletableFuture.allOf(cir.getReturnValue(), textureManager.loadTextureAsync(TECHNO_TITLE_TEXTURE, executor))); |
36 | 33 | } |
37 | 34 |
|
38 | | - @Inject(at = @At("TAIL"), method = "render") |
39 | | - public void addCreditText(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) { |
40 | | - float f = this.doBackgroundFade ? (float)(Util.getMeasuringTimeMs() - this.backgroundFadeStart) / 1000.0f : 1.0f; |
41 | | - float g = this.doBackgroundFade ? MathHelper.clamp(f - 1.0f, 0.0f, 1.0f) : 1.0f; |
42 | | - int l = MathHelper.ceil(g * 255.0f) << 24; |
43 | | - |
44 | | - TitleScreen.drawStringWithShadow(matrices, MinecraftClient.getInstance().textRenderer, "Title text made by @MrBrose_ on Twitter", 2, ((TitleScreen) (Object) this).height - 20, 0xFFFFFF | l); |
| 35 | + @Inject(at = @At("TAIL"), method = "render", locals = LocalCapture.CAPTURE_FAILHARD) |
| 36 | + public void addCreditText(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci, float f, float g) { |
| 37 | + if (TechnobladeNeverDies.shouldReplaceTitleIcon) { |
| 38 | + int l = MathHelper.ceil(g * 255.0F) << 24; |
| 39 | + context.drawTextWithShadow(MinecraftClient.getInstance().textRenderer, "Title text made by @MrBrose_ on Twitter", 2, ((TitleScreen) (Object) this).height - 20, 0xFFFFFF | l); |
| 40 | + } |
45 | 41 | } |
46 | | - |
47 | | - @Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/TitleScreen;drawWithOutline(IILjava/util/function/BiConsumer;)V"), method = "render") |
48 | | - public void removeMinecraftText(TitleScreen instance, int i, int j, BiConsumer biConsumer) {} |
49 | | - |
50 | | - @Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/TitleScreen;drawTexture(Lnet/minecraft/client/util/math/MatrixStack;IIFFIIII)V"), method = "render") |
51 | | - public void removeEditionText(MatrixStack matrixStack, int i, int j, float m, float n, int o, int p, int q, int r) {} |
52 | 42 | } |
0 commit comments