aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/ambientaddons/mixin/MixinGuiContainer.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/ambientaddons/mixin/MixinGuiContainer.java')
-rw-r--r--src/main/java/com/ambientaddons/mixin/MixinGuiContainer.java37
1 files changed, 37 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();
+ }
+ }
+}