mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-27 23:33:00 +00:00
Giant Inventory Refactor 2. Slots will only accept valid items
Moved logic out of Containers, the old filtered slots were not always the same logic as the IInventory. Moved ISidedInventory logic up to TileForestry and use InventoryAdapters to override only the methods we need to. Tested a ton but there will be some new issues given the scope.
This commit is contained in:
1 parent
2b3b590cf4
commit
c54b7c40bb
124 files changed
+2414
-4259
No files matched your search
@@ -230,14 +230,14 @@ public class ItemInfuser extends ItemForestry {
|
||||
// / INVENTORY MANAGMENT
|
||||
public static class InfuserInventory extends ItemInventory {
|
||||
|
||||
private final ItemStack[] inventoryStacks = new ItemStack[6];
|
||||
private final short inputSlot = 0;
|
||||
private final short outputSlot = 1;
|
||||
private final short ingredientSlot1 = 2;
|
||||
private final short ingredientSlotCount = 4;
|
||||
private final EntityPlayer player;
|
||||
|
||||
public InfuserInventory(EntityPlayer player) {
|
||||
super(ItemInfuser.class);
|
||||
public InfuserInventory(EntityPlayer player, ItemStack itemStack) {
|
||||
super(ItemInfuser.class, 6, itemStack);
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@@ -290,25 +290,6 @@ public class ItemInfuser extends ItemForestry {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
if (inventoryStacks[i] == null)
|
||||
return null;
|
||||
|
||||
ItemStack product;
|
||||
if (inventoryStacks[i].stackSize <= j) {
|
||||
product = inventoryStacks[i];
|
||||
inventoryStacks[i] = null;
|
||||
return product;
|
||||
} else {
|
||||
product = inventoryStacks[i].splitStack(j);
|
||||
if (inventoryStacks[i].stackSize == 0)
|
||||
inventoryStacks[i] = null;
|
||||
|
||||
return product;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
if (!Proxies.common.isSimulating(player.worldObj))
|
||||
@@ -316,61 +297,19 @@ public class ItemInfuser extends ItemForestry {
|
||||
trySeasoning();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
inventoryStacks[i] = itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return inventoryStacks[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inventoryStacks.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "Infuser";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
if (inventoryStacks[slot] == null)
|
||||
return null;
|
||||
ItemStack toReturn = inventoryStacks[slot];
|
||||
inventoryStacks[slot] = null;
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
|
||||
return true;
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == inputSlot) {
|
||||
ForestryItem.beverage.isItemEqual(itemStack);
|
||||
} else if (slotIndex >= ingredientSlot1 && slotIndex < ingredientSlot1 + ingredientSlotCount) {
|
||||
BeverageManager.infuserManager.isIngredient(itemStack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user