From 5c00854251c0af2f6c790c1ee24bfb156cc6c98d Mon Sep 17 00:00:00 2001 From: Jarod Brennfleck Date: Wed, 25 Mar 2020 13:37:01 +1100 Subject: [PATCH] =?UTF-8?q?Make=20mixins=20more=20(m)obvious!=20?= =?UTF-8?q?=F0=9F=90=B1=E2=80=8D=F0=9F=8F=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reading through the Mixin Intro and found that it's ideal to extend the parent of the target class - so let's do it! Also show off a neat feature of mixins! --- src/main/java/net/fabricmc/example/mixin/ExampleMixin.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/fabricmc/example/mixin/ExampleMixin.java b/src/main/java/net/fabricmc/example/mixin/ExampleMixin.java index 83ee1a8..00de763 100644 --- a/src/main/java/net/fabricmc/example/mixin/ExampleMixin.java +++ b/src/main/java/net/fabricmc/example/mixin/ExampleMixin.java @@ -1,5 +1,6 @@ package net.fabricmc.example.mixin; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.TitleScreen; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -7,9 +8,13 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(TitleScreen.class) -public class ExampleMixin { +public class ExampleMixin extends Screen { @Inject(at = @At("HEAD"), method = "init()V") private void init(CallbackInfo info) { System.out.println("This line is printed by an example mod mixin!"); } + @Inject(method = "render(IIF)V", at = @At("RETURN")) + public void render(int mouseX, int mouseY, float delta, CallbackInfo info) { + this.font.draw("Fabric Test Mod", 2, this.height - 30, -1); + } }