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!
This commit is contained in:
		
							parent
							
								
									01ae0cd3ab
								
							
						
					
					
						commit
						5c00854251
					
				@ -1,5 +1,6 @@
 | 
				
			|||||||
package net.fabricmc.example.mixin;
 | 
					package net.fabricmc.example.mixin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import net.minecraft.client.gui.screen.Screen;
 | 
				
			||||||
import net.minecraft.client.gui.screen.TitleScreen;
 | 
					import net.minecraft.client.gui.screen.TitleScreen;
 | 
				
			||||||
import org.spongepowered.asm.mixin.Mixin;
 | 
					import org.spongepowered.asm.mixin.Mixin;
 | 
				
			||||||
import org.spongepowered.asm.mixin.injection.At;
 | 
					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;
 | 
					import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Mixin(TitleScreen.class)
 | 
					@Mixin(TitleScreen.class)
 | 
				
			||||||
public class ExampleMixin {
 | 
					public class ExampleMixin extends Screen {
 | 
				
			||||||
	@Inject(at = @At("HEAD"), method = "init()V")
 | 
						@Inject(at = @At("HEAD"), method = "init()V")
 | 
				
			||||||
	private void init(CallbackInfo info) {
 | 
						private void init(CallbackInfo info) {
 | 
				
			||||||
		System.out.println("This line is printed by an example mod mixin!");
 | 
							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…
	
		Reference in New Issue
	
	Block a user