diff options
author | SoniEx2 <endermoneymod@gmail.com> | 2022-07-03 23:12:06 -0300 |
---|---|---|
committer | SoniEx2 <endermoneymod@gmail.com> | 2022-07-03 23:12:06 -0300 |
commit | bfb981cd49a6bbcd15482dceeb4ab121c0408157 (patch) | |
tree | 54f1fca2884e68f5a8e6205bf34a01cc62c8a953 /src/main/java/ganarchy/friendcode/mixin/OpenToLanScreenMixin.java | |
parent | 0c1c11065062c745ce49529e9bee48b05aa4bc41 (diff) |
[Project] Friend Code
A Minecraft mod which adds friend codes, an easy way to play in the same world with remote friends.
Diffstat (limited to 'src/main/java/ganarchy/friendcode/mixin/OpenToLanScreenMixin.java')
-rw-r--r-- | src/main/java/ganarchy/friendcode/mixin/OpenToLanScreenMixin.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/main/java/ganarchy/friendcode/mixin/OpenToLanScreenMixin.java b/src/main/java/ganarchy/friendcode/mixin/OpenToLanScreenMixin.java new file mode 100644 index 0000000..fd2cccb --- /dev/null +++ b/src/main/java/ganarchy/friendcode/mixin/OpenToLanScreenMixin.java @@ -0,0 +1,57 @@ +package ganarchy.friendcode.mixin; + +import ganarchy.friendcode.client.FriendCodeScreen; +import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.screen.OpenToLanScreen; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.text.Text; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(OpenToLanScreen.class) +public abstract class OpenToLanScreenMixin extends Screen { + protected OpenToLanScreenMixin(Text title) { + super(title); + } + + @Shadow + private Screen parent; + + @Inject(at = @At("HEAD"), method = "init()V") + private void init(CallbackInfo info) { + // title, meet button + this.addDrawableChild(new ButtonWidget( + this.width / 2 - 155, + 50, + 310, + 20, + this.title, + button -> this.client.setScreen(new FriendCodeScreen(this.parent)) + )); + } + + @Redirect( + method = "render(Lnet/minecraft/client/util/math/MatrixStack;IIF)V", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/screen/OpenToLanScreen;drawCenteredText(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;III)V", + ordinal = 0 + ) + ) + private void removeTitle( + MatrixStack matrices, + TextRenderer renderer, + Text text, + int centerX, + int y, + int color + ) { + // literally does nothing + } +} |