make ItemSlots copy-able

This commit is contained in:
Salomão
2021-05-03 21:07:51 -03:00
parent b541025738
commit 0c0aafba2f
2 changed files with 37 additions and 0 deletions
@@ -55,6 +55,8 @@ class ItemHandlerIterator implements Iterator<ItemSlot>
this.itemSlot.setExtractable( !this.itemHandler.extractItem( this.slot, 1, true ).isEmpty() );
this.itemSlot.setItemStack( this.itemHandler.getStackInSlot( this.slot ) );
this.itemSlot.setSlot( this.slot );
this.itemSlot.setSlotLimit( this.itemHandler.getSlotLimit( this.slot ) );
this.itemSlot.setItemHandler( this.itemHandler );
this.slot++;
return this.itemSlot;
}
@@ -23,6 +23,7 @@ import net.minecraft.item.ItemStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.util.item.AEItemStack;
import net.minecraftforge.items.IItemHandler;
public class ItemSlot
@@ -34,6 +35,25 @@ public class ItemSlot
private IAEItemStack aeItemStack;
private ItemStack itemStack;
public void setItemHandler( IItemHandler itemHandler )
{
this.itemHandler = itemHandler;
}
private IItemHandler itemHandler;
public int getSlotLimit()
{
return slotLimit;
}
public void setSlotLimit( int slotLimit )
{
this.slotLimit = slotLimit;
}
private int slotLimit;
public ItemStack getItemStack()
{
return this.itemStack
@@ -77,4 +97,19 @@ public class ItemSlot
{
this.slot = slot;
}
public ItemSlot copy()
{
ItemSlot copy = new ItemSlot();
copy.setSlot( this.slot );
copy.setSlotLimit( this.slotLimit );
copy.setItemStack( this.getItemStack() );
copy.setExtractable( this.isExtractable );
copy.setItemHandler( this.itemHandler );
return copy;
}
public ItemStack insertItem( ItemStack sourceItemStack){
return this.itemHandler.insertItem( this.slot, sourceItemStack , true );
}
}