aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
authorAppability <appable@icloud.com>2022-10-11 23:59:37 -0700
committerAppability <appable@icloud.com>2022-10-11 23:59:37 -0700
commit2c0e73deb53f54d78bd5594786313ac82151be1a (patch)
tree97fc2f389cc99d8f9e078a1cd7b0c6a5859a3f34 /src/main/java/com
parent363b2426f8d9e45e52c472750c798dcaceb05a88 (diff)
downloadAmbientAddons-2c0e73deb53f54d78bd5594786313ac82151be1a.tar.gz
AmbientAddons-2c0e73deb53f54d78bd5594786313ac82151be1a.tar.bz2
AmbientAddons-2c0e73deb53f54d78bd5594786313ac82151be1a.zip
added chest qol features (complete, i think)
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/ambientaddons/mixin/MixinGuiContainer.java37
-rw-r--r--src/main/java/com/ambientaddons/mixin/MixinNetworkManager.java20
-rw-r--r--src/main/java/com/examplemod/mixin/MixinGuiMainMenu.java16
3 files changed, 57 insertions, 16 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();
+ }
+}
diff --git a/src/main/java/com/examplemod/mixin/MixinGuiMainMenu.java b/src/main/java/com/examplemod/mixin/MixinGuiMainMenu.java
deleted file mode 100644
index 79c5db6..0000000
--- a/src/main/java/com/examplemod/mixin/MixinGuiMainMenu.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.examplemod.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!");
- }
-}