From da99c51f0bd53f7dd0f19b54bca0b441ef79bc1d Mon Sep 17 00:00:00 2001 From: nea Date: Fri, 21 Jul 2023 12:54:09 +0200 Subject: Code --- .../skyblockplayersanonymous/ExampleMod.java | 13 --------- .../romangraef/skyblockplayersanonymous/SPA.java | 13 +++++++++ .../mixin/MixinGuiMainMenu.java | 16 ----------- .../mixin/MixinNetHandlerPlayClient.java | 22 +++++++++++++++ .../mixin/MixinPlayerController.java | 31 ++++++++++++++++++++++ .../resources/mixins.skyblockplayersanonymous.json | 3 ++- 6 files changed, 68 insertions(+), 30 deletions(-) delete mode 100644 src/main/java/com/github/romangraef/skyblockplayersanonymous/ExampleMod.java create mode 100644 src/main/java/com/github/romangraef/skyblockplayersanonymous/SPA.java delete mode 100644 src/main/java/com/github/romangraef/skyblockplayersanonymous/mixin/MixinGuiMainMenu.java create mode 100644 src/main/java/com/github/romangraef/skyblockplayersanonymous/mixin/MixinNetHandlerPlayClient.java create mode 100644 src/main/java/com/github/romangraef/skyblockplayersanonymous/mixin/MixinPlayerController.java diff --git a/src/main/java/com/github/romangraef/skyblockplayersanonymous/ExampleMod.java b/src/main/java/com/github/romangraef/skyblockplayersanonymous/ExampleMod.java deleted file mode 100644 index 7fe7102..0000000 --- a/src/main/java/com/github/romangraef/skyblockplayersanonymous/ExampleMod.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.github.romangraef.skyblockplayersanonymous; - -import net.minecraft.init.Blocks; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; - -@Mod(modid = "skyblockplayersanonymous", useMetadata=true) -public class ExampleMod { - @Mod.EventHandler - public void init(FMLInitializationEvent event) { - System.out.println("Dirt: " + Blocks.dirt.getUnlocalizedName()); - } -} diff --git a/src/main/java/com/github/romangraef/skyblockplayersanonymous/SPA.java b/src/main/java/com/github/romangraef/skyblockplayersanonymous/SPA.java new file mode 100644 index 0000000..dd3c780 --- /dev/null +++ b/src/main/java/com/github/romangraef/skyblockplayersanonymous/SPA.java @@ -0,0 +1,13 @@ +package com.github.romangraef.skyblockplayersanonymous; + +import net.minecraft.init.Blocks; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; + +@Mod(modid = "skyblockplayersanonymous", useMetadata=true) +public class SPA { + @Mod.EventHandler + public void init(FMLInitializationEvent event) { + + } +} diff --git a/src/main/java/com/github/romangraef/skyblockplayersanonymous/mixin/MixinGuiMainMenu.java b/src/main/java/com/github/romangraef/skyblockplayersanonymous/mixin/MixinGuiMainMenu.java deleted file mode 100644 index c42ad81..0000000 --- a/src/main/java/com/github/romangraef/skyblockplayersanonymous/mixin/MixinGuiMainMenu.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.github.romangraef.skyblockplayersanonymous.mixin; - -import net.minecraft.client.gui.GuiMainMenu; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(GuiMainMenu.class) -public class MixinGuiMainMenu { - - @Inject(method = "initGui", at = @At("HEAD")) - public void onInitGui(CallbackInfo ci) { - System.out.println("Hello from Main Menu!"); - } -} diff --git a/src/main/java/com/github/romangraef/skyblockplayersanonymous/mixin/MixinNetHandlerPlayClient.java b/src/main/java/com/github/romangraef/skyblockplayersanonymous/mixin/MixinNetHandlerPlayClient.java new file mode 100644 index 0000000..2cc0a17 --- /dev/null +++ b/src/main/java/com/github/romangraef/skyblockplayersanonymous/mixin/MixinNetHandlerPlayClient.java @@ -0,0 +1,22 @@ +package com.github.romangraef.skyblockplayersanonymous.mixin; + +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.network.Packet; +import net.minecraft.network.play.client.C01PacketChatMessage; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(NetHandlerPlayClient.class) +public class MixinNetHandlerPlayClient { + @Inject(method = "addToSendQueue", cancellable = true, at = @At("HEAD")) + public void onAddtoSendQueue(Packet p_147297_1_, CallbackInfo ci) { + if (p_147297_1_ instanceof C01PacketChatMessage) { + String message = ((C01PacketChatMessage) p_147297_1_).getMessage(); + if (message != null && (message.equalsIgnoreCase("/play sb") || message.equalsIgnoreCase("/play skyblock") || message.equalsIgnoreCase("/skyblock"))) { + ci.cancel(); + } + } + } +} diff --git a/src/main/java/com/github/romangraef/skyblockplayersanonymous/mixin/MixinPlayerController.java b/src/main/java/com/github/romangraef/skyblockplayersanonymous/mixin/MixinPlayerController.java new file mode 100644 index 0000000..5ed370d --- /dev/null +++ b/src/main/java/com/github/romangraef/skyblockplayersanonymous/mixin/MixinPlayerController.java @@ -0,0 +1,31 @@ +package com.github.romangraef.skyblockplayersanonymous.mixin; + +import net.minecraft.client.multiplayer.PlayerControllerMP; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(PlayerControllerMP.class) +public class MixinPlayerController { + + @Inject(method = "windowClick", cancellable = true, at = @At("HEAD")) + public void onClick(int windowId, int slotId, int mouseButtonClicked, int mode, EntityPlayer playerIn, CallbackInfoReturnable cir) { + if (playerIn == null || playerIn.openContainer == null) return; + Slot slot = playerIn.openContainer.getSlot(slotId); + if (slot == null) { + return; + } + ItemStack stack = slot.getStack(); + if (stack == null) { + return; + } + if (stack.getItem() == Items.skull && stack.getDisplayName().startsWith("§aSkyBlock")) { + cir.setReturnValue(null); + } + } +} diff --git a/src/main/resources/mixins.skyblockplayersanonymous.json b/src/main/resources/mixins.skyblockplayersanonymous.json index 570a0d0..a869938 100644 --- a/src/main/resources/mixins.skyblockplayersanonymous.json +++ b/src/main/resources/mixins.skyblockplayersanonymous.json @@ -6,6 +6,7 @@ "mixins": [ ], "client": [ - "MixinGuiMainMenu" + "MixinNetHandlerPlayClient", + "MixinPlayerController" ] } -- cgit