aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/ambientaddons/mixin
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/ambientaddons/mixin')
-rw-r--r--src/main/java/com/ambientaddons/mixin/MixinGuiContainer.java37
-rw-r--r--src/main/java/com/ambientaddons/mixin/MixinNetworkManager.java20
2 files changed, 57 insertions, 0 deletions
diff --git a/src/main/java/com/ambientaddons/mixin/MixinGuiContainer.java b/src/main/java/com/ambientaddons/mixin/MixinGuiContainer.java
new file mode 100644
index 0000000..ee4b432
--- /dev/null
+++ b/src/main/java/com/ambientaddons/mixin/MixinGuiContainer.java
@@ -0,0 +1,37 @@
+package com.ambientaddons.mixin;
+
+import com.ambientaddons.events.GuiContainerEvent;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.Slot;
+import net.minecraftforge.common.MinecraftForge;
+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.callback.CallbackInfo;
+
+// credit Harry282/Skyblock-Client, under AGPL 3.0
+@Mixin(GuiContainer.class)
+public class MixinGuiContainer extends GuiScreen {
+ private final GuiContainer gui = (GuiContainer) (Object) this;
+
+ @Shadow
+ public Container inventorySlots;
+
+ @Inject(method = "drawSlot", at = @At("HEAD"), cancellable = true)
+ private void onDrawSlot(Slot slot, CallbackInfo ci) {
+ if (MinecraftForge.EVENT_BUS.post(new GuiContainerEvent.DrawSlotEvent(inventorySlots, gui, slot))) {
+ ci.cancel();
+ }
+ }
+
+ @Inject(method = "handleMouseClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/PlayerControllerMP;windowClick(IIIILnet/minecraft/entity/player/EntityPlayer;)Lnet/minecraft/item/ItemStack;"), cancellable = true)
+ private void onMouseClick(Slot slot, int slotId, int clickedButton, int clickType, CallbackInfo ci) {
+ System.out.println("Slot click");
+ if (MinecraftForge.EVENT_BUS.post(new GuiContainerEvent.SlotClickEvent(inventorySlots, gui, slot, slotId))) {
+ ci.cancel();
+ }
+ }
+}
diff --git a/src/main/java/com/ambientaddons/mixin/MixinNetworkManager.java b/src/main/java/com/ambientaddons/mixin/MixinNetworkManager.java
new file mode 100644
index 0000000..f13b41c
--- /dev/null
+++ b/src/main/java/com/ambientaddons/mixin/MixinNetworkManager.java
@@ -0,0 +1,20 @@
+package com.ambientaddons.mixin;
+
+import com.ambientaddons.events.ReceivePacketEvent;
+import io.netty.channel.ChannelHandlerContext;
+import net.minecraft.network.NetworkManager;
+import net.minecraft.network.Packet;
+import net.minecraftforge.common.MinecraftForge;
+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;
+
+// credit Harry282/Skyblock-Client, under AGPL 3.0
+@Mixin(NetworkManager.class)
+public class MixinNetworkManager {
+ @Inject(method = "channelRead0*", at = @At("HEAD"), cancellable = true)
+ private void onReceivePacket(ChannelHandlerContext context, Packet<?> packet, CallbackInfo ci) {
+ if (MinecraftForge.EVENT_BUS.post(new ReceivePacketEvent(packet))) ci.cancel();
+ }
+}