mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-24 05:54:41 +00:00
Add functionality in IItemHandler to test if a slot can accept an item (#5033)
This commit is contained in:
1 parent
eb870bc84c
commit
4acfca27f8
10 files changed
+105
-28
No files matched your search
@@ -132,4 +132,13 @@ public class CombinedInvWrapper implements IItemHandlerModifiable
|
||||
int localSlot = getSlotFromIndex(slot, index);
|
||||
return handler.getSlotLimit(localSlot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack)
|
||||
{
|
||||
int index = getIndexForSlot(slot);
|
||||
IItemHandlerModifiable handler = getHandlerFromIndex(index);
|
||||
int localSlot = getSlotFromIndex(slot, index);
|
||||
return handler.isItemValid(localSlot, stack);
|
||||
}
|
||||
}
|
||||
@@ -67,4 +67,10 @@ public class EmptyHandler implements IItemHandlerModifiable
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -179,6 +179,12 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl
|
||||
entity.setItemStackToSlot(equipmentSlot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack)
|
||||
{
|
||||
return IItemHandlerModifiable.super.isItemValid(slot, stack);
|
||||
}
|
||||
|
||||
protected EntityEquipmentSlot validateSlotIndex(final int slot)
|
||||
{
|
||||
if (slot < 0 || slot >= slots.size())
|
||||
|
||||
@@ -204,6 +204,12 @@ public class InvWrapper implements IItemHandlerModifiable
|
||||
return getInv().getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack)
|
||||
{
|
||||
return getInv().isItemValidForSlot(slot, stack);
|
||||
}
|
||||
|
||||
public IInventory getInv()
|
||||
{
|
||||
return inv;
|
||||
|
||||
@@ -105,6 +105,17 @@ public class RangedWrapper implements IItemHandlerModifiable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack)
|
||||
{
|
||||
if (checkSlot(slot))
|
||||
{
|
||||
return compose.isItemValid(slot + minSlot, stack);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkSlot(int localSlot)
|
||||
{
|
||||
return localSlot + minSlot < maxSlot;
|
||||
|
||||
@@ -230,4 +230,10 @@ public class SidedInvWrapper implements IItemHandlerModifiable
|
||||
{
|
||||
return inv.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack)
|
||||
{
|
||||
return inv.isItemValidForSlot(slot, stack);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user