package at.hannibal2.skyhanni.mixins; import at.hannibal2.skyhanni.mixinhooks.GuiContainerHook; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.inventory.Slot; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(GuiContainer.class) public abstract class MixinGuiContainer extends GuiScreen { @Unique private final GuiContainerHook hook = new GuiContainerHook(this); @Inject(method = "keyTyped", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/EntityPlayerSP;closeScreen()V", shift = At.Shift.BEFORE), cancellable = true) private void closeWindowPressed(CallbackInfo ci) { hook.closeWindowPressed(ci); } @Inject(method = "drawScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;color(FFFF)V", ordinal = 1)) private void backgroundDrawn(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) { hook.backgroundDrawn(mouseX, mouseY, partialTicks, ci); } @Inject(method = "drawScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/inventory/GuiContainer;drawGuiContainerForegroundLayer(II)V", shift = At.Shift.AFTER)) private void onForegroundDraw(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) { hook.foregroundDrawn(mouseX, mouseY, partialTicks, ci); } @Inject(method = "drawSlot", at = @At("HEAD"), cancellable = true) private void onDrawSlot(Slot slot, CallbackInfo ci) { hook.onDrawSlot(slot, ci); } @Inject(method = "drawSlot", at = @At("RETURN"), cancellable = true) private void onDrawSlotPost(Slot slot, CallbackInfo ci) { hook.onDrawSlotPost(slot, ci); } @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) { hook.onMouseClick(slot, slotId, clickedButton, clickType, ci); } }