Make mixins more (m)obvious! 🐱‍🏍

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!
pull/46/head
Jarod Brennfleck 4 years ago committed by GitHub
parent 01ae0cd3ab
commit 5c00854251
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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);
}
}

Loading…
Cancel
Save