Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import com.cleanroommc.modularui.api.IMuiScreen;
import com.cleanroommc.modularui.screen.IClickableGuiContainer;
import com.cleanroommc.modularui.widgets.slot.ModularSlot;
import com.cleanroommc.modularui.widgets.slot.SlotGroup;

import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;

import org.spongepowered.asm.lib.Opcodes;
Expand All @@ -13,6 +16,7 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(GuiContainer.class)
Expand Down Expand Up @@ -59,4 +63,17 @@ public void getSlot(int x, int y, CallbackInfoReturnable<Slot> cir) {
protected boolean mouseClickedOnSlot(boolean flag1) {
return false;
}

@Redirect(
method = "mouseMovedOrUp",
at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/inventory/Slot;inventory:Lnet/minecraft/inventory/IInventory;")
)
private IInventory checkSlotGroup(Slot slot) {
if (slot instanceof ModularSlot ms) {
SlotGroup slotGroup = ms.getSlotGroup();
if (slotGroup == null) return null;
return slotGroup.getDummyInventoryForComparison();
}
return slot.inventory;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.cleanroommc.modularui.widgets.slot;

import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryBasic;
import net.minecraft.inventory.Slot;

import org.jetbrains.annotations.ApiStatus;
Expand Down Expand Up @@ -27,6 +29,7 @@ public class SlotGroup {
private final boolean allowShiftTransfer;
private boolean allowSorting = true;
private final boolean singleton;
private final IInventory dummyInventory = new InventoryBasic("[Null]", true, 0);

/**
* Creates a slot group that is only a single slot. Singleton groups don't need to be registered.
Expand Down Expand Up @@ -117,4 +120,9 @@ public SlotGroup setAllowSorting(boolean allowSorting) {
this.allowSorting = allowSorting;
return this;
}

@ApiStatus.Internal
public IInventory getDummyInventoryForComparison() {
return dummyInventory;
}
}