Skip to content

Commit

Permalink
Fix not being able to interact with the second slot of any inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
thecatcore committed Apr 29, 2024
1 parent 84cbb3d commit 1773cc1
Showing 1 changed file with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import codechicken.nei.forge.GuiContainerManager;
import codechicken.nei.forge.IContainerClientSide;
import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mojang.blaze3d.platform.GLX;
import fr.catcore.fabricatedforge.compat.nei.NEIHandledScreen;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -140,14 +141,17 @@ public List handleItemTooltip(ItemStack stack, int mousex, int mousey, List curr
return currenttip;
}

@Inject(method = "drawSlot", at = {
@At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glEnable(I)V", ordinal = 1, remap = false),
@At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/render/item/ItemRenderer;method_1549(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/client/TextureManager;Lnet/minecraft/item/ItemStack;II)V")
})
private void renderSlotUnderlay(Slot par1Slot, CallbackInfo ci) {
@Inject(method = "drawSlot", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glEnable(I)V", ordinal = 1, remap = false))
private void flf$renderSlotUnderlay(Slot par1Slot, CallbackInfo ci) {
this.manager.renderSlotUnderlay(par1Slot);
}

@Inject(method = "drawSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/ItemRenderer;method_1549(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/client/TextureManager;Lnet/minecraft/item/ItemStack;II)V",
shift = At.Shift.AFTER))
private void flf$renderSlotOverlay(Slot par1Slot, CallbackInfo ci) {
this.manager.renderSlotOverlay(par1Slot);
}

/**
* @author ChickenBones
* @reason idk
Expand Down Expand Up @@ -177,19 +181,17 @@ protected void mouseClicked(int par1, int par2, int par3) {
}
}

@WrapWithCondition(method = "onMouseClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;clickSlot(IIIILnet/minecraft/entity/player/PlayerEntity;)Lnet/minecraft/item/ItemStack;"))
private boolean wrapClickSlot(
ClientPlayerInteractionManager interactionManager, int syncId, int slotId, int mouseButton, int actionType, PlayerEntity player
) {
if (slotId != 1) {
@WrapOperation(method = "onMouseClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;clickSlot(IIIILnet/minecraft/entity/player/PlayerEntity;)Lnet/minecraft/item/ItemStack;"))
private ItemStack flf$onMouseClick(ClientPlayerInteractionManager instance, int syncId, int slotId, int mouseButton, int actionType, PlayerEntity player, Operation<ItemStack> original) {
if (slotId != -1) {
if (this instanceof IContainerClientSide) {
this.screenHandler.onSlotClick(slotId, mouseButton, actionType, player);
return this.field_1229.playerEntity.openScreenHandler.onSlotClick(slotId, mouseButton, actionType, player);
} else {
return true;
return original.call(instance, syncId, slotId, mouseButton, actionType, player);
}
}

return false;
return null;
}

@Override
Expand All @@ -208,10 +210,7 @@ protected void keyPressed(char par1, int par2) {
if (par2 == 1) {
this.field_1229.playerEntity.closeHandledScreen();
} else if (!this.manager.lastKeyTyped(par2, par1)) {
if (!this.handleHotbarKeyPressed(par2)
&& par2 == this.field_1229.options.keyPickItem.code
&& this.focusedSlot != null
&& this.focusedSlot.hasStack()) {
if (!this.handleHotbarKeyPressed(par2) && par2 == this.field_1229.options.keyPickItem.code && this.focusedSlot != null && this.focusedSlot.hasStack()) {
this.onMouseClick(this.focusedSlot, this.focusedSlot.id, this.backgroundHeight, 3);
}

Expand Down

0 comments on commit 1773cc1

Please sign in to comment.