mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-20 12:09:39 +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
@@ -10,23 +10,25 @@
|
||||
******************************************************************************/
|
||||
package forestry.mail;
|
||||
|
||||
import forestry.api.mail.ILetter;
|
||||
import forestry.api.mail.IMailAddress;
|
||||
import forestry.api.mail.PostManager;
|
||||
import forestry.core.inventory.InventoryAdapter;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.WorldSavedData;
|
||||
|
||||
import forestry.api.mail.ILetter;
|
||||
import forestry.api.mail.IMailAddress;
|
||||
import forestry.api.mail.PostManager;
|
||||
import forestry.core.inventory.InvTools;
|
||||
import forestry.core.inventory.InventoryAdapter;
|
||||
|
||||
public class POBox extends WorldSavedData implements IInventory {
|
||||
|
||||
public static final String SAVE_NAME = "POBox_";
|
||||
public static final short SLOT_SIZE = 84;
|
||||
|
||||
private IMailAddress address;
|
||||
private final InventoryAdapter letters = new InventoryAdapter(SLOT_SIZE, "Letters");
|
||||
private final InventoryAdapter letters = new InventoryAdapter(SLOT_SIZE, "Letters").disableAutomation();
|
||||
|
||||
public POBox(IMailAddress address) {
|
||||
super(SAVE_NAME + address);
|
||||
@@ -69,7 +71,8 @@ public class POBox extends WorldSavedData implements IInventory {
|
||||
letterstack.setTagCompound(nbttagcompound);
|
||||
|
||||
this.markDirty();
|
||||
return this.letters.tryAddStack(letterstack, true);
|
||||
|
||||
return InvTools.tryAddStack(letters, letterstack, true);
|
||||
}
|
||||
|
||||
public POBoxInfo getPOBoxInfo() {
|
||||
@@ -151,7 +154,7 @@ public class POBox extends WorldSavedData implements IInventory {
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
|
||||
return true;
|
||||
return letters.isItemValidForSlot(i, itemstack);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user