diff --git a/src/main/java/li/cil/oc2/common/container/AbstractContainer.java b/src/main/java/li/cil/oc2/common/container/AbstractContainer.java index e8a71431..d81bc55d 100644 --- a/src/main/java/li/cil/oc2/common/container/AbstractContainer.java +++ b/src/main/java/li/cil/oc2/common/container/AbstractContainer.java @@ -121,7 +121,15 @@ public abstract class AbstractContainer extends AbstractContainerMenu { final int index = startIndex + row * PLAYER_INVENTORY_COLUMNS + column; final int x = startX + column * SLOT_SIZE; final int y = startY + row * SLOT_SIZE; - this.addSlot(new Slot(inventory, index, x, y)); + + final Slot slot; + if (isSlotLocked(inventory, index)) { + slot = new LockedSlot(inventory, index, x, y); + } else { + slot = new Slot(inventory, index, x, y); + } + + this.addSlot(slot); } } @@ -130,8 +138,23 @@ public abstract class AbstractContainer extends AbstractContainerMenu { protected int createHotbarSlots(final Inventory inventory, final int startIndex, final int startX, final int startY) { for (int i = 0; i < HOTBAR_SIZE; ++i) { - this.addSlot(new Slot(inventory, startIndex + i, startX + i * SLOT_SIZE, startY)); + final int index = startIndex + i; + final int x = startX + i * SLOT_SIZE; + + final Slot slot; + if (isSlotLocked(inventory, index)) { + slot = new LockedSlot(inventory, index, x, startY); + } else { + slot = new Slot(inventory, index, x, startY); + } + + this.addSlot(slot); } + return startIndex + HOTBAR_SIZE; } + + protected boolean isSlotLocked(final Inventory inventory, final int slot) { + return false; + } } diff --git a/src/main/java/li/cil/oc2/common/container/LockedSlot.java b/src/main/java/li/cil/oc2/common/container/LockedSlot.java new file mode 100644 index 00000000..5cc78715 --- /dev/null +++ b/src/main/java/li/cil/oc2/common/container/LockedSlot.java @@ -0,0 +1,24 @@ +package li.cil.oc2.common.container; + +import net.minecraft.world.Container; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; + +public final class LockedSlot extends Slot { + public LockedSlot(final Container container, final int slot, final int x, final int y) { + super(container, slot, x, y); + } + + /////////////////////////////////////////////////////////////////// + + @Override + public boolean mayPlace(final ItemStack p_40231_) { + return false; + } + + @Override + public boolean mayPickup(final Player p_40228_) { + return false; + } +}