NetClientHandlerMixin.java (1387B)
1 package ambos.simpletech.mixin; 2 3 import net.minecraft.client.Minecraft; 4 import net.minecraft.client.net.handler.NetClientHandler; 5 import net.minecraft.core.net.packet.Packet100OpenWindow; 6 import org.spongepowered.asm.mixin.Final; 7 import org.spongepowered.asm.mixin.Mixin; 8 import org.spongepowered.asm.mixin.Shadow; 9 import org.spongepowered.asm.mixin.injection.At; 10 import org.spongepowered.asm.mixin.injection.Inject; 11 import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 12 13 import ambos.simpletech.IPlayerDisplayer; 14 import ambos.simpletech.SimpleTech; 15 import ambos.simpletech.block.entity.TileEntityAllocator; 16 17 @Mixin(value = NetClientHandler.class, remap = false) 18 public class NetClientHandlerMixin { 19 @Final 20 @Shadow 21 private Minecraft mc; 22 23 @Inject(method = "handleOpenWindow(Lnet/minecraft/core/net/packet/Packet100OpenWindow;)V", at = @At("HEAD"), cancellable = true) 24 public void handleAllocator(Packet100OpenWindow packet100openwindow, CallbackInfo ci) { 25 if (packet100openwindow.inventoryType == SimpleTech.ALLOCATOR_GUI_ID) { 26 TileEntityAllocator tileEntityAllocator = new TileEntityAllocator(); 27 ((IPlayerDisplayer) this.mc.thePlayer).simple_tech$displayGUIAllocator(tileEntityAllocator); 28 this.mc.thePlayer.craftingInventory.windowId = packet100openwindow.windowId; 29 ci.cancel(); 30 } 31 } 32 }