diff options
Diffstat (limited to 'src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java')
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java b/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java index 9301761..8846e17 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java @@ -7,6 +7,7 @@ import net.minecraft.item.ItemStack; public class ValidatedSlot extends Slot { private final int slotNumber; + private boolean modifiable = true; public ValidatedSlot(Inventory inventoryIn, int index, int xPosition, int yPosition) { super(inventoryIn, index, xPosition, yPosition); @@ -16,12 +17,12 @@ public class ValidatedSlot extends Slot { @Override public boolean canInsert(ItemStack stack) { - return inventory.isValidInvStack(slotNumber, stack); + return modifiable && inventory.isValidInvStack(slotNumber, stack); } @Override public boolean canTakeItems(PlayerEntity player) { - return inventory.canPlayerUseInv(player); + return modifiable && inventory.canPlayerUseInv(player); } @Override @@ -39,7 +40,18 @@ public class ValidatedSlot extends Slot { return result; } - + + /** + * Returns true if the item in this slot can be modified by players. + */ + public boolean isModifiable() { + return modifiable; + } + + public void setModifiable(boolean modifiable) { + this.modifiable = modifiable; + } + public int getInventoryIndex() { return slotNumber; } |