|
2 | 2 |
|
3 | 3 | import com.cleanroommc.modularui.api.IMuiScreen; |
4 | 4 | import com.cleanroommc.modularui.screen.IClickableGuiContainer; |
| 5 | +import com.cleanroommc.modularui.widgets.slot.ModularSlot; |
| 6 | +import com.cleanroommc.modularui.widgets.slot.SlotGroup; |
5 | 7 |
|
6 | 8 | import net.minecraft.client.gui.inventory.GuiContainer; |
| 9 | +import net.minecraft.inventory.IInventory; |
7 | 10 | import net.minecraft.inventory.Slot; |
8 | 11 |
|
9 | 12 | import org.spongepowered.asm.lib.Opcodes; |
|
13 | 16 | import org.spongepowered.asm.mixin.injection.At; |
14 | 17 | import org.spongepowered.asm.mixin.injection.Inject; |
15 | 18 | import org.spongepowered.asm.mixin.injection.ModifyVariable; |
| 19 | +import org.spongepowered.asm.mixin.injection.Redirect; |
16 | 20 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
17 | 21 |
|
18 | 22 | @Mixin(GuiContainer.class) |
@@ -59,4 +63,17 @@ public void getSlot(int x, int y, CallbackInfoReturnable<Slot> cir) { |
59 | 63 | protected boolean mouseClickedOnSlot(boolean flag1) { |
60 | 64 | return false; |
61 | 65 | } |
| 66 | + |
| 67 | + @Redirect( |
| 68 | + method = "mouseMovedOrUp", |
| 69 | + at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/inventory/Slot;inventory:Lnet/minecraft/inventory/IInventory;") |
| 70 | + ) |
| 71 | + private IInventory checkSlotGroup(Slot slot) { |
| 72 | + if (slot instanceof ModularSlot ms) { |
| 73 | + SlotGroup slotGroup = ms.getSlotGroup(); |
| 74 | + if (slotGroup == null) return null; |
| 75 | + return slotGroup.getDummyInventoryForComparison(); |
| 76 | + } |
| 77 | + return slot.inventory; |
| 78 | + } |
62 | 79 | } |
0 commit comments