Initial port to IItemHandler
This commit is contained in:
@@ -16,7 +16,6 @@ import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
|
||||
public class RefinedStorageUtils {
|
||||
@@ -27,7 +26,41 @@ public class RefinedStorageUtils {
|
||||
public static final int COMPARE_NBT = 2;
|
||||
public static final int COMPARE_QUANTITY = 4;
|
||||
|
||||
public static void saveInventory(IInventory inventory, int id, NBTTagCompound nbt) {
|
||||
public static void saveItems(IItemHandler handler, int id, NBTTagCompound nbt) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < handler.getSlots(); i++) {
|
||||
if (handler.getStackInSlot(i) != null) {
|
||||
NBTTagCompound compoundTag = new NBTTagCompound();
|
||||
|
||||
compoundTag.setInteger(NBT_SLOT, i);
|
||||
|
||||
handler.getStackInSlot(i).writeToNBT(compoundTag);
|
||||
|
||||
tagList.appendTag(compoundTag);
|
||||
}
|
||||
}
|
||||
|
||||
nbt.setTag(String.format(NBT_INVENTORY, id), tagList);
|
||||
}
|
||||
|
||||
public static void restoreItems(IItemHandler handler, int id, NBTTagCompound nbt) {
|
||||
String name = String.format(NBT_INVENTORY, id);
|
||||
|
||||
if (nbt.hasKey(name)) {
|
||||
NBTTagList tagList = nbt.getTagList(name, Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < tagList.tagCount(); i++) {
|
||||
int slot = tagList.getCompoundTagAt(i).getInteger(NBT_SLOT);
|
||||
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(tagList.getCompoundTagAt(i));
|
||||
|
||||
handler.insertItem(slot, stack, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveItemsLegacy(IInventory inventory, int id, NBTTagCompound nbt) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++) {
|
||||
@@ -45,7 +78,7 @@ public class RefinedStorageUtils {
|
||||
nbt.setTag(String.format(NBT_INVENTORY, id), tagList);
|
||||
}
|
||||
|
||||
public static void restoreInventory(IInventory inventory, int id, NBTTagCompound nbt) {
|
||||
public static void restoreItemsLegacy(IInventory inventory, int id, NBTTagCompound nbt) {
|
||||
String name = String.format(NBT_INVENTORY, id);
|
||||
|
||||
if (nbt.hasKey(name)) {
|
||||
@@ -99,17 +132,17 @@ public class RefinedStorageUtils {
|
||||
return compareStack(first, second, COMPARE_NBT | COMPARE_DAMAGE);
|
||||
}
|
||||
|
||||
public static int getSpeed(InventorySimple inventory) {
|
||||
return getSpeed(inventory, 9, 2, 0);
|
||||
public static int getSpeed(IItemHandler handler) {
|
||||
return getSpeed(handler, 9, 2, 0);
|
||||
}
|
||||
|
||||
public static int getSpeed(InventorySimple inventory, int speed, int speedIncrease) {
|
||||
return getSpeed(inventory, speed, speedIncrease, 0);
|
||||
public static int getSpeed(IItemHandler handler, int speed, int speedIncrease) {
|
||||
return getSpeed(handler, speed, speedIncrease, 0);
|
||||
}
|
||||
|
||||
public static int getSpeed(InventorySimple inventory, int speed, int speedIncrease, int start) {
|
||||
for (int i = start; i < inventory.getSizeInventory(); ++i) {
|
||||
if (inventory.getStackInSlot(i) != null && inventory.getStackInSlot(i).getMetadata() == ItemUpgrade.TYPE_SPEED) {
|
||||
public static int getSpeed(IItemHandler handler, int speed, int speedIncrease, int start) {
|
||||
for (int i = start; i < handler.getSlots(); ++i) {
|
||||
if (handler.getStackInSlot(i) != null && handler.getStackInSlot(i).getMetadata() == ItemUpgrade.TYPE_SPEED) {
|
||||
speed -= speedIncrease;
|
||||
}
|
||||
}
|
||||
@@ -117,19 +150,19 @@ public class RefinedStorageUtils {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public static boolean hasUpgrade(InventorySimple inventory, int type) {
|
||||
return getUpgradeCount(inventory, type) > 0;
|
||||
public static boolean hasUpgrade(IItemHandler handler, int type) {
|
||||
return getUpgradeCount(handler, type) > 0;
|
||||
}
|
||||
|
||||
public static int getUpgradeCount(InventorySimple inventory, int type) {
|
||||
return getUpgradeCount(inventory, type, 0);
|
||||
public static int getUpgradeCount(IItemHandler handler, int type) {
|
||||
return getUpgradeCount(handler, type, 0);
|
||||
}
|
||||
|
||||
public static int getUpgradeCount(InventorySimple inventory, int type, int start) {
|
||||
public static int getUpgradeCount(IItemHandler handler, int type, int start) {
|
||||
int upgrades = 0;
|
||||
|
||||
for (int i = start; i < inventory.getSizeInventory(); ++i) {
|
||||
if (inventory.getStackInSlot(i) != null && inventory.getStackInSlot(i).getMetadata() == type) {
|
||||
for (int i = start; i < handler.getSlots(); ++i) {
|
||||
if (handler.getStackInSlot(i) != null && handler.getStackInSlot(i).getMetadata() == type) {
|
||||
upgrades++;
|
||||
}
|
||||
}
|
||||
@@ -137,16 +170,16 @@ public class RefinedStorageUtils {
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
public static int getUpgradeEnergyUsage(InventorySimple inventory) {
|
||||
return getUpgradeEnergyUsage(inventory, 0);
|
||||
public static int getUpgradeEnergyUsage(IItemHandler handler) {
|
||||
return getUpgradeEnergyUsage(handler, 0);
|
||||
}
|
||||
|
||||
public static int getUpgradeEnergyUsage(InventorySimple inventory, int start) {
|
||||
public static int getUpgradeEnergyUsage(IItemHandler handler, int start) {
|
||||
int usage = 0;
|
||||
|
||||
for (int i = start; i < inventory.getSizeInventory(); ++i) {
|
||||
if (inventory.getStackInSlot(i) != null) {
|
||||
usage += ItemUpgrade.getEnergyUsage(inventory.getStackInSlot(i).getMetadata());
|
||||
for (int i = start; i < handler.getSlots(); ++i) {
|
||||
if (handler.getStackInSlot(i) != null) {
|
||||
usage += ItemUpgrade.getEnergyUsage(handler.getStackInSlot(i).getMetadata());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -17,6 +17,7 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageBlocks;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
@@ -127,8 +128,14 @@ public abstract class BlockBase extends Block {
|
||||
public void breakBlock(World world, BlockPos pos, IBlockState state) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile instanceof TileBase && ((TileBase) tile).getDroppedInventory() != null) {
|
||||
InventoryHelper.dropInventoryItems(world, pos, ((TileBase) tile).getDroppedInventory());
|
||||
if (tile instanceof TileBase && ((TileBase) tile).getDroppedItems() != null) {
|
||||
IItemHandler handler = ((TileBase) tile).getDroppedItems();
|
||||
|
||||
for (int i = 0; i < handler.getSlots(); ++i) {
|
||||
if (handler.getStackInSlot(i) != null) {
|
||||
InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), handler.getStackInSlot(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(world, pos, state);
|
||||
|
@@ -8,6 +8,7 @@ import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.container.slot.SlotDisabled;
|
||||
import refinedstorage.container.slot.SlotSpecimen;
|
||||
import refinedstorage.container.slot.SlotSpecimenLegacy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -97,6 +98,14 @@ public abstract class ContainerBase extends Container {
|
||||
slot.putStack(player.inventory.getItemStack().copy());
|
||||
}
|
||||
|
||||
return player.inventory.getItemStack();
|
||||
} else if (slot instanceof SlotSpecimenLegacy) {
|
||||
if (player.inventory.getItemStack() == null) {
|
||||
slot.putStack(null);
|
||||
} else if (slot.isItemValid(player.inventory.getItemStack())) {
|
||||
slot.putStack(player.inventory.getItemStack().copy());
|
||||
}
|
||||
|
||||
return player.inventory.getItemStack();
|
||||
} else if (slot instanceof SlotDisabled) {
|
||||
return null;
|
||||
|
@@ -1,10 +1,8 @@
|
||||
package refinedstorage.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import refinedstorage.container.slot.SlotFiltered;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import refinedstorage.container.slot.SlotSpecimenItemBlock;
|
||||
import refinedstorage.container.slot.UpgradeItemValidator;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
import refinedstorage.tile.TileConstructor;
|
||||
|
||||
public class ContainerConstructor extends ContainerBase {
|
||||
@@ -12,10 +10,10 @@ public class ContainerConstructor extends ContainerBase {
|
||||
public ContainerConstructor(EntityPlayer player, TileConstructor constructor) {
|
||||
super(player);
|
||||
|
||||
addSlotToContainer(new SlotSpecimenItemBlock(constructor.getInventory(), 0, 80, 20));
|
||||
addSlotToContainer(new SlotSpecimenItemBlock(constructor.getFilter(), 0, 80, 20));
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
addSlotToContainer(new SlotFiltered(constructor.getUpgradesInventory(), i, 187, 6 + (i * 18), new UpgradeItemValidator(ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_CRAFTING)));
|
||||
addSlotToContainer(new SlotItemHandler(constructor.getUpgrades(), i, 187, 6 + (i * 18)));
|
||||
}
|
||||
|
||||
addPlayerInventory(8, 55);
|
||||
|
@@ -3,12 +3,7 @@ package refinedstorage.container;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.container.slot.IItemValidator;
|
||||
import refinedstorage.container.slot.SlotFiltered;
|
||||
import refinedstorage.container.slot.UpgradeItemValidator;
|
||||
import refinedstorage.item.ItemPattern;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import refinedstorage.tile.autocrafting.TileCrafter;
|
||||
|
||||
public class ContainerCrafter extends ContainerStorage {
|
||||
@@ -16,16 +11,11 @@ public class ContainerCrafter extends ContainerStorage {
|
||||
super(player);
|
||||
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
addSlotToContainer(new SlotFiltered(crafter, i, 8, 19 + (i * 18), new IItemValidator() {
|
||||
@Override
|
||||
public boolean isValid(ItemStack stack) {
|
||||
return stack.getItem() == RefinedStorageItems.PATTERN && ItemPattern.isValid(stack);
|
||||
}
|
||||
}));
|
||||
addSlotToContainer(new SlotItemHandler(crafter.getPatterns(), i, 8, 19 + (i * 18)));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
addSlotToContainer(new SlotFiltered(crafter, 6 + i, 187, 6 + (i * 18), new UpgradeItemValidator(ItemUpgrade.TYPE_SPEED)));
|
||||
addSlotToContainer(new SlotItemHandler(crafter.getUpgrades(), 6 + i, 187, 6 + (i * 18)));
|
||||
}
|
||||
|
||||
addPlayerInventory(8, 144);
|
||||
|
@@ -1,10 +1,8 @@
|
||||
package refinedstorage.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import refinedstorage.container.slot.SlotFiltered;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import refinedstorage.container.slot.SlotSpecimenItemBlock;
|
||||
import refinedstorage.container.slot.UpgradeItemValidator;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
import refinedstorage.tile.TileDestructor;
|
||||
|
||||
public class ContainerDestructor extends ContainerBase {
|
||||
@@ -16,7 +14,7 @@ public class ContainerDestructor extends ContainerBase {
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
addSlotToContainer(new SlotFiltered(destructor.getUpgradesInventory(), i, 187, 6 + (i * 18), new UpgradeItemValidator(ItemUpgrade.TYPE_SPEED)));
|
||||
addSlotToContainer(new SlotItemHandler(destructor.getUpgrades(), i, 187, 6 + (i * 18)));
|
||||
}
|
||||
|
||||
addPlayerInventory(8, 55);
|
||||
|
@@ -3,9 +3,7 @@ package refinedstorage.container;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.container.slot.BasicItemValidator;
|
||||
import refinedstorage.container.slot.SlotFiltered;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import refinedstorage.tile.TileDiskDrive;
|
||||
|
||||
public class ContainerDiskDrive extends ContainerStorage {
|
||||
@@ -13,14 +11,14 @@ public class ContainerDiskDrive extends ContainerStorage {
|
||||
super(player);
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
addSlotToContainer(new SlotFiltered(drive, i, 98 + (i * 18), 78, new BasicItemValidator(RefinedStorageItems.STORAGE_DISK)));
|
||||
addSlotToContainer(new SlotItemHandler(drive.getDisks(), i, 98 + (i * 18), 78));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
addSlotToContainer(new SlotFiltered(drive, 4 + i, 98 + (i * 18), 96, new BasicItemValidator(RefinedStorageItems.STORAGE_DISK)));
|
||||
addSlotToContainer(new SlotItemHandler(drive.getDisks(), 4 + i, 98 + (i * 18), 96));
|
||||
}
|
||||
|
||||
addSpecimenAndPlayerInventorySlots(drive.getInventory());
|
||||
addSpecimenAndPlayerInventorySlots(drive.getFilters());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -1,10 +1,8 @@
|
||||
package refinedstorage.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import refinedstorage.container.slot.SlotFiltered;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import refinedstorage.container.slot.SlotSpecimen;
|
||||
import refinedstorage.container.slot.UpgradeItemValidator;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
import refinedstorage.tile.TileExporter;
|
||||
|
||||
public class ContainerExporter extends ContainerBase {
|
||||
@@ -12,11 +10,11 @@ public class ContainerExporter extends ContainerBase {
|
||||
super(player);
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
addSlotToContainer(new SlotSpecimen(exporter.getInventory(), i, 8 + (18 * i), 20, false));
|
||||
addSlotToContainer(new SlotSpecimen(exporter.getFilters(), i, 8 + (18 * i), 20, false));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
addSlotToContainer(new SlotFiltered(exporter.getUpgradesInventory(), i, 187, 6 + (i * 18), new UpgradeItemValidator(ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_CRAFTING)));
|
||||
addSlotToContainer(new SlotItemHandler(exporter.getUpgrades(), i, 187, 6 + (i * 18)));
|
||||
}
|
||||
|
||||
addPlayerInventory(8, 55);
|
||||
|
@@ -6,10 +6,13 @@ import net.minecraft.inventory.ClickType;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.block.EnumGridType;
|
||||
import refinedstorage.container.slot.*;
|
||||
import refinedstorage.container.slot.SlotDisabled;
|
||||
import refinedstorage.container.slot.SlotGridCraftingResult;
|
||||
import refinedstorage.container.slot.SlotOutput;
|
||||
import refinedstorage.container.slot.SlotSpecimenLegacy;
|
||||
import refinedstorage.network.MessageGridCraftingShift;
|
||||
import refinedstorage.tile.grid.IGrid;
|
||||
import refinedstorage.tile.grid.TileGrid;
|
||||
@@ -36,7 +39,7 @@ public class ContainerGrid extends ContainerBase {
|
||||
int y = 106;
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
Slot slot = new Slot(((TileGrid) grid).getCraftingInventory(), i, x, y);
|
||||
Slot slot = new Slot(((TileGrid) grid).getMatrix(), i, x, y);
|
||||
|
||||
craftingSlots.add(slot);
|
||||
|
||||
@@ -50,13 +53,13 @@ public class ContainerGrid extends ContainerBase {
|
||||
}
|
||||
}
|
||||
|
||||
addSlotToContainer(craftingResultSlot = new SlotGridCraftingResult(this, player, ((TileGrid) grid).getCraftingInventory(), ((TileGrid) grid).getCraftingResultInventory(), (TileGrid) grid, 0, 133 + 4, 120 + 4));
|
||||
addSlotToContainer(craftingResultSlot = new SlotGridCraftingResult(this, player, ((TileGrid) grid).getMatrix(), ((TileGrid) grid).getResult(), (TileGrid) grid, 0, 133 + 4, 120 + 4));
|
||||
} else if (grid.getType() == EnumGridType.PATTERN) {
|
||||
int x = 8;
|
||||
int y = 106;
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
addSlotToContainer(new SlotSpecimen(((TileGrid) grid).getCraftingInventory(), i, x, y, false));
|
||||
addSlotToContainer(new SlotSpecimenLegacy(((TileGrid) grid).getMatrix(), i, x, y, false));
|
||||
|
||||
x += 18;
|
||||
|
||||
@@ -66,10 +69,10 @@ public class ContainerGrid extends ContainerBase {
|
||||
}
|
||||
}
|
||||
|
||||
addSlotToContainer(patternResultSlot = new SlotDisabled(((TileGrid) grid).getCraftingResultInventory(), 0, 116 + 4, 120 + 4));
|
||||
addSlotToContainer(patternResultSlot = new SlotDisabled(((TileGrid) grid).getResult(), 0, 116 + 4, 120 + 4));
|
||||
|
||||
addSlotToContainer(new SlotFiltered(((TileGrid) grid).getPatternsInventory(), 0, 152, 104, new BasicItemValidator(RefinedStorageItems.PATTERN)));
|
||||
addSlotToContainer(new SlotOutput(((TileGrid) grid).getPatternsInventory(), 1, 152, 144));
|
||||
addSlotToContainer(new SlotItemHandler(((TileGrid) grid).getPatterns(), 0, 152, 104));
|
||||
addSlotToContainer(new SlotOutput(((TileGrid) grid).getPatterns(), 1, 152, 144));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,10 +1,8 @@
|
||||
package refinedstorage.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import refinedstorage.container.slot.SlotFiltered;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import refinedstorage.container.slot.SlotSpecimen;
|
||||
import refinedstorage.container.slot.UpgradeItemValidator;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
import refinedstorage.tile.TileImporter;
|
||||
|
||||
public class ContainerImporter extends ContainerBase {
|
||||
@@ -12,11 +10,11 @@ public class ContainerImporter extends ContainerBase {
|
||||
super(player);
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
addSlotToContainer(new SlotSpecimen(importer.getInventory(), i, 8 + (18 * i), 20, false));
|
||||
addSlotToContainer(new SlotSpecimen(importer.getFilters(), i, 8 + (18 * i), 20, false));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
addSlotToContainer(new SlotFiltered(importer.getUpgradesInventory(), i, 187, 6 + (i * 18), new UpgradeItemValidator(ItemUpgrade.TYPE_SPEED)));
|
||||
addSlotToContainer(new SlotItemHandler(importer.getUpgrades(), i, 187, 6 + (i * 18)));
|
||||
}
|
||||
|
||||
addPlayerInventory(8, 55);
|
||||
|
@@ -3,11 +3,9 @@ package refinedstorage.container;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.container.slot.SlotFiltered;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import refinedstorage.container.slot.SlotOutput;
|
||||
import refinedstorage.container.slot.SlotSpecimen;
|
||||
import refinedstorage.container.slot.UpgradeItemValidator;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
import refinedstorage.tile.TileInterface;
|
||||
|
||||
public class ContainerInterface extends ContainerBase {
|
||||
@@ -15,19 +13,19 @@ public class ContainerInterface extends ContainerBase {
|
||||
super(player);
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
addSlotToContainer(new Slot(tile, i, 8 + (18 * i), 20));
|
||||
addSlotToContainer(new SlotItemHandler(tile.getItems(), i, 8 + (18 * i), 20));
|
||||
}
|
||||
|
||||
for (int i = 9; i < 18; ++i) {
|
||||
addSlotToContainer(new SlotSpecimen(tile, i, 8 + (18 * (i - 9)), 54, true));
|
||||
addSlotToContainer(new SlotSpecimen(tile.getItems(), i, 8 + (18 * (i - 9)), 54, true));
|
||||
}
|
||||
|
||||
for (int i = 18; i < 27; ++i) {
|
||||
addSlotToContainer(new SlotOutput(tile, i, 8 + (18 * (i - 18)), 100));
|
||||
addSlotToContainer(new SlotOutput(tile.getItems(), i, 8 + (18 * (i - 18)), 100));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
addSlotToContainer(new SlotFiltered(tile.getUpgradesInventory(), i, 187, 6 + (i * 18), new UpgradeItemValidator(ItemUpgrade.TYPE_SPEED)));
|
||||
addSlotToContainer(new SlotItemHandler(tile.getUpgrades(), i, 187, 6 + (i * 18)));
|
||||
}
|
||||
|
||||
addPlayerInventory(8, 134);
|
||||
|
@@ -1,15 +1,13 @@
|
||||
package refinedstorage.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.container.slot.BasicItemValidator;
|
||||
import refinedstorage.container.slot.SlotFiltered;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import refinedstorage.container.slot.SlotOutput;
|
||||
import refinedstorage.container.slot.SlotSpecimen;
|
||||
import refinedstorage.tile.autocrafting.TileProcessingPatternEncoder;
|
||||
|
||||
public class ContainerProcessingPatternEncoder extends ContainerBase {
|
||||
public ContainerProcessingPatternEncoder(EntityPlayer player, TileProcessingPatternEncoder ppEncoder) {
|
||||
public ContainerProcessingPatternEncoder(EntityPlayer player, TileProcessingPatternEncoder processingPatternEncoder) {
|
||||
super(player);
|
||||
|
||||
int ox = 8;
|
||||
@@ -17,7 +15,7 @@ public class ContainerProcessingPatternEncoder extends ContainerBase {
|
||||
int y = 20;
|
||||
|
||||
for (int i = 0; i < 9 * 2; ++i) {
|
||||
addSlotToContainer(new SlotSpecimen(ppEncoder.getInputsOutputsInventory(), i, x, y, false));
|
||||
addSlotToContainer(new SlotSpecimen(processingPatternEncoder.getConfiguration(), i, x, y, false));
|
||||
|
||||
x += 18;
|
||||
|
||||
@@ -33,8 +31,8 @@ public class ContainerProcessingPatternEncoder extends ContainerBase {
|
||||
}
|
||||
}
|
||||
|
||||
addSlotToContainer(new SlotFiltered(ppEncoder, 0, 152, 18, new BasicItemValidator(RefinedStorageItems.PATTERN)));
|
||||
addSlotToContainer(new SlotOutput(ppEncoder, 1, 152, 58));
|
||||
addSlotToContainer(new SlotItemHandler(processingPatternEncoder.getPatterns(), 0, 152, 18));
|
||||
addSlotToContainer(new SlotOutput(processingPatternEncoder.getPatterns(), 1, 152, 58));
|
||||
|
||||
addPlayerInventory(8, 90);
|
||||
}
|
||||
|
@@ -3,10 +3,8 @@ package refinedstorage.container;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.container.slot.SlotFiltered;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import refinedstorage.container.slot.SlotOutput;
|
||||
import refinedstorage.container.slot.UpgradeItemValidator;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
import refinedstorage.tile.solderer.TileSolderer;
|
||||
|
||||
public class ContainerSolderer extends ContainerBase {
|
||||
@@ -17,15 +15,15 @@ public class ContainerSolderer extends ContainerBase {
|
||||
int y = 20;
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
addSlotToContainer(new Slot(solderer, i, x, y));
|
||||
addSlotToContainer(new SlotItemHandler(solderer.getItems(), i, x, y));
|
||||
|
||||
y += 18;
|
||||
}
|
||||
|
||||
addSlotToContainer(new SlotOutput(solderer, 3, 134, 38));
|
||||
addSlotToContainer(new SlotOutput(solderer.getItems(), 3, 134, 38));
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
addSlotToContainer(new SlotFiltered(solderer, 4 + i, 187, 6 + (i * 18), new UpgradeItemValidator(ItemUpgrade.TYPE_SPEED)));
|
||||
addSlotToContainer(new SlotItemHandler(solderer.getUpgrades(), 4 + i, 187, 6 + (i * 18)));
|
||||
}
|
||||
|
||||
addPlayerInventory(8, 95);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package refinedstorage.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import refinedstorage.container.slot.SlotSpecimen;
|
||||
|
||||
public class ContainerStorage extends ContainerBase {
|
||||
@@ -9,15 +9,15 @@ public class ContainerStorage extends ContainerBase {
|
||||
super(player);
|
||||
}
|
||||
|
||||
public ContainerStorage(EntityPlayer player, IInventory inventory) {
|
||||
public ContainerStorage(EntityPlayer player, IItemHandler filters) {
|
||||
this(player);
|
||||
|
||||
addSpecimenAndPlayerInventorySlots(inventory);
|
||||
addSpecimenAndPlayerInventorySlots(filters);
|
||||
}
|
||||
|
||||
protected void addSpecimenAndPlayerInventorySlots(IInventory inventory) {
|
||||
protected void addSpecimenAndPlayerInventorySlots(IItemHandler filters) {
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
addSlotToContainer(new SlotSpecimen(inventory, i, 8 + (18 * i), 20, false));
|
||||
addSlotToContainer(new SlotSpecimen(filters, i, 8 + (18 * i), 20, false));
|
||||
}
|
||||
|
||||
addPlayerInventory(8, 129);
|
||||
|
@@ -3,9 +3,7 @@ package refinedstorage.container;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.container.slot.SlotFiltered;
|
||||
import refinedstorage.container.slot.UpgradeItemValidator;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import refinedstorage.tile.TileWirelessTransmitter;
|
||||
|
||||
public class ContainerWirelessTransmitter extends ContainerBase {
|
||||
@@ -13,7 +11,7 @@ public class ContainerWirelessTransmitter extends ContainerBase {
|
||||
super(player);
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
addSlotToContainer(new SlotFiltered(wirelessTransmitter.getDroppedInventory(), i, 187, 6 + (i * 18), new UpgradeItemValidator(ItemUpgrade.TYPE_RANGE)));
|
||||
addSlotToContainer(new SlotItemHandler(wirelessTransmitter.getUpgrades(), i, 187, 6 + (i * 18)));
|
||||
}
|
||||
|
||||
addPlayerInventory(8, 55);
|
||||
|
@@ -1,17 +0,0 @@
|
||||
package refinedstorage.container.slot;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class BasicItemValidator implements IItemValidator {
|
||||
private Item item;
|
||||
|
||||
public BasicItemValidator(Item item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack stack) {
|
||||
return item == stack.getItem();
|
||||
}
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
package refinedstorage.container.slot;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IItemValidator {
|
||||
boolean isValid(ItemStack stack);
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
package refinedstorage.container.slot;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotFiltered extends Slot {
|
||||
private IItemValidator validator;
|
||||
|
||||
public SlotFiltered(IInventory inventory, int id, int x, int y, IItemValidator validator) {
|
||||
super(inventory, id, x, y);
|
||||
|
||||
this.validator = validator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack item) {
|
||||
return validator.isValid(item);
|
||||
}
|
||||
}
|
@@ -11,20 +11,20 @@ import refinedstorage.tile.grid.TileGrid;
|
||||
|
||||
public class SlotGridCraftingResult extends SlotCrafting {
|
||||
private ContainerGrid container;
|
||||
private IInventory craftingMatrix;
|
||||
private IInventory matrix;
|
||||
private TileGrid grid;
|
||||
|
||||
public SlotGridCraftingResult(ContainerGrid container, EntityPlayer player, InventoryCrafting craftingMatrix, IInventory craftingResult, TileGrid grid, int id, int x, int y) {
|
||||
super(player, craftingMatrix, craftingResult, id, x, y);
|
||||
public SlotGridCraftingResult(ContainerGrid container, EntityPlayer player, InventoryCrafting matrix, IInventory craftingResult, TileGrid grid, int id, int x, int y) {
|
||||
super(player, matrix, craftingResult, id, x, y);
|
||||
|
||||
this.container = container;
|
||||
this.craftingMatrix = craftingMatrix;
|
||||
this.matrix = matrix;
|
||||
this.grid = grid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer player, ItemStack stack) {
|
||||
FMLCommonHandler.instance().firePlayerCraftingEvent(player, stack, craftingMatrix);
|
||||
FMLCommonHandler.instance().firePlayerCraftingEvent(player, stack, matrix);
|
||||
|
||||
onCrafting(stack);
|
||||
|
||||
|
@@ -1,11 +1,11 @@
|
||||
package refinedstorage.container.slot;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
|
||||
public class SlotOutput extends Slot {
|
||||
public SlotOutput(IInventory inventory, int id, int x, int y) {
|
||||
public class SlotOutput extends SlotItemHandler {
|
||||
public SlotOutput(IItemHandler inventory, int id, int x, int y) {
|
||||
super(inventory, id, x, y);
|
||||
}
|
||||
|
||||
|
@@ -1,15 +1,15 @@
|
||||
package refinedstorage.container.slot;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
|
||||
public class SlotSpecimen extends Slot {
|
||||
public class SlotSpecimen extends SlotItemHandler {
|
||||
private boolean sizeAllowed;
|
||||
|
||||
public SlotSpecimen(IInventory inventory, int id, int x, int y, boolean allowSize) {
|
||||
super(inventory, id, x, y);
|
||||
public SlotSpecimen(IItemHandler handler, int id, int x, int y, boolean allowSize) {
|
||||
super(handler, id, x, y);
|
||||
|
||||
this.sizeAllowed = allowSize;
|
||||
}
|
||||
|
@@ -1,12 +1,13 @@
|
||||
package refinedstorage.container.slot;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
// @TODO: This can probably be removed?
|
||||
public class SlotSpecimenItemBlock extends SlotSpecimen {
|
||||
public SlotSpecimenItemBlock(IInventory inventory, int id, int x, int y) {
|
||||
super(inventory, id, x, y, false);
|
||||
public SlotSpecimenItemBlock(IItemHandler handler, int id, int x, int y) {
|
||||
super(handler, id, x, y, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
32
src/main/java/refinedstorage/container/slot/SlotSpecimenLegacy.java
Executable file
32
src/main/java/refinedstorage/container/slot/SlotSpecimenLegacy.java
Executable file
@@ -0,0 +1,32 @@
|
||||
package refinedstorage.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotSpecimenLegacy extends Slot {
|
||||
public SlotSpecimenLegacy(IInventory inventory, int id, int x, int y, boolean allowSize) {
|
||||
super(inventory, id, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack stack) {
|
||||
if (stack != null) {
|
||||
stack.stackSize = 1;
|
||||
}
|
||||
|
||||
super.putStack(stack);
|
||||
}
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
package refinedstorage.container.slot;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
|
||||
public class UpgradeItemValidator implements IItemValidator {
|
||||
private int[] allowedUpgrades;
|
||||
|
||||
public UpgradeItemValidator(int... allowedUpgrades) {
|
||||
this.allowedUpgrades = allowedUpgrades;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack stack) {
|
||||
if (stack.getItem() == RefinedStorageItems.UPGRADE) {
|
||||
for (int upgrade : allowedUpgrades) {
|
||||
if (upgrade == stack.getMetadata()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -49,9 +49,9 @@ public class GuiCrafter extends GuiBase {
|
||||
int x = 27;
|
||||
int y = 19 + (i * 18);
|
||||
|
||||
if (crafter.getStackInSlot(i) != null && ItemPattern.isValid(crafter.getStackInSlot(i))) {
|
||||
ItemStack pattern = crafter.getStackInSlot(i);
|
||||
ItemStack pattern = crafter.getPatterns().getStackInSlot(i);
|
||||
|
||||
if (pattern != null && ItemPattern.isValid(pattern)) {
|
||||
String text = t("gui.refinedstorage:crafter.processing");
|
||||
|
||||
if (!ItemPattern.isProcessing(pattern)) {
|
||||
|
@@ -40,7 +40,7 @@ public class GuiHandler implements IGuiHandler {
|
||||
case RefinedStorageGui.CONSTRUCTOR:
|
||||
return new ContainerConstructor(player, (TileConstructor) tile);
|
||||
case RefinedStorageGui.STORAGE:
|
||||
return new ContainerStorage(player, ((IStorageGui) tile).getInventory());
|
||||
return new ContainerStorage(player, ((IStorageGui) tile).getFilters());
|
||||
case RefinedStorageGui.RELAY:
|
||||
return new ContainerRelay(player);
|
||||
case RefinedStorageGui.INTERFACE:
|
||||
|
7
src/main/java/refinedstorage/inventory/IItemValidator.java
Executable file
7
src/main/java/refinedstorage/inventory/IItemValidator.java
Executable file
@@ -0,0 +1,7 @@
|
||||
package refinedstorage.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IItemValidator {
|
||||
boolean valid(ItemStack stack);
|
||||
}
|
48
src/main/java/refinedstorage/inventory/SimpleItemHandler.java
Executable file
48
src/main/java/refinedstorage/inventory/SimpleItemHandler.java
Executable file
@@ -0,0 +1,48 @@
|
||||
package refinedstorage.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
public class SimpleItemHandler extends ItemStackHandler {
|
||||
private TileEntity tile;
|
||||
private IItemValidator[] validators;
|
||||
|
||||
public SimpleItemHandler(int size, TileEntity tile, IItemValidator... validators) {
|
||||
super(size);
|
||||
|
||||
this.tile = tile;
|
||||
this.validators = validators;
|
||||
}
|
||||
|
||||
public SimpleItemHandler(int size, IItemValidator... validators) {
|
||||
this(size, null, validators);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
|
||||
boolean mayInsert = validators.length > 0 ? false : true;
|
||||
|
||||
for (IItemValidator validator : validators) {
|
||||
if (validator.valid(stack)) {
|
||||
mayInsert = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mayInsert) {
|
||||
return super.insertItem(slot, stack, simulate);
|
||||
} else {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onContentsChanged(int slot) {
|
||||
super.onContentsChanged(slot);
|
||||
|
||||
if (tile != null) {
|
||||
tile.markDirty();
|
||||
}
|
||||
}
|
||||
}
|
31
src/main/java/refinedstorage/inventory/SimpleItemValidator.java
Executable file
31
src/main/java/refinedstorage/inventory/SimpleItemValidator.java
Executable file
@@ -0,0 +1,31 @@
|
||||
package refinedstorage.inventory;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SimpleItemValidator implements IItemValidator {
|
||||
private Item item;
|
||||
private int damage = -1;
|
||||
|
||||
public SimpleItemValidator(Item item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
public SimpleItemValidator(Item item, int damage) {
|
||||
this.item = item;
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean valid(ItemStack stack) {
|
||||
if (stack.getItem() == item) {
|
||||
if (damage != -1 && stack.getItemDamage() != damage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -46,18 +46,18 @@ public class MessageGridCraftingClear extends MessageHandlerPlayerToServer<Messa
|
||||
|
||||
if (grid.isConnected()) {
|
||||
if (grid.getType() == EnumGridType.CRAFTING) {
|
||||
for (int i = 0; i < grid.getCraftingInventory().getSizeInventory(); ++i) {
|
||||
ItemStack slot = grid.getCraftingInventory().getStackInSlot(i);
|
||||
for (int i = 0; i < grid.getMatrix().getSizeInventory(); ++i) {
|
||||
ItemStack slot = grid.getMatrix().getStackInSlot(i);
|
||||
|
||||
if (slot != null) {
|
||||
if (grid.getController().push(slot)) {
|
||||
grid.getCraftingInventory().setInventorySlotContents(i, null);
|
||||
grid.getMatrix().setInventorySlotContents(i, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (grid.getType() == EnumGridType.PATTERN) {
|
||||
for (int i = 0; i < grid.getCraftingInventory().getSizeInventory(); ++i) {
|
||||
grid.getCraftingInventory().setInventorySlotContents(i, null);
|
||||
for (int i = 0; i < grid.getMatrix().getSizeInventory(); ++i) {
|
||||
grid.getMatrix().setInventorySlotContents(i, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -48,12 +48,12 @@ public class MessageGridCraftingPush extends MessageHandlerPlayerToServer<Messag
|
||||
if (tile instanceof TileGrid) {
|
||||
TileGrid grid = (TileGrid) tile;
|
||||
|
||||
if (grid.isConnected() && grid.getType() == EnumGridType.CRAFTING && message.craftingSlot < grid.getCraftingInventory().getSizeInventory()) {
|
||||
ItemStack stack = grid.getCraftingInventory().getStackInSlot(message.craftingSlot);
|
||||
if (grid.isConnected() && grid.getType() == EnumGridType.CRAFTING && message.craftingSlot < grid.getMatrix().getSizeInventory()) {
|
||||
ItemStack stack = grid.getMatrix().getStackInSlot(message.craftingSlot);
|
||||
|
||||
if (stack != null) {
|
||||
if (grid.getController().push(stack)) {
|
||||
grid.getCraftingInventory().setInventorySlotContents(message.craftingSlot, null);
|
||||
grid.getMatrix().setInventorySlotContents(message.craftingSlot, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,6 +21,6 @@ public class DiskStorage extends NBTStorage {
|
||||
|
||||
@Override
|
||||
public boolean mayPush(ItemStack stack) {
|
||||
return ModeFilter.respectsMode(diskDrive.getInventory(), diskDrive.getModeConfig(), diskDrive.getCompare(), stack) && super.mayPush(stack);
|
||||
return ModeFilter.respectsMode(diskDrive.getFilters(), diskDrive.getModeConfig(), diskDrive.getCompare(), stack) && super.mayPush(stack);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package refinedstorage.storage;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import refinedstorage.tile.config.ICompareConfig;
|
||||
import refinedstorage.tile.config.IModeConfig;
|
||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||
@@ -12,7 +12,7 @@ public interface IStorageGui {
|
||||
|
||||
void onPriorityChanged(int priority);
|
||||
|
||||
IInventory getInventory();
|
||||
IItemHandler getFilters();
|
||||
|
||||
IRedstoneModeConfig getRedstoneModeConfig();
|
||||
|
||||
|
@@ -20,6 +20,6 @@ public class StorageBlockStorage extends NBTStorage {
|
||||
|
||||
@Override
|
||||
public boolean mayPush(ItemStack stack) {
|
||||
return ModeFilter.respectsMode(storage.getInventory(), storage, storage.getCompare(), stack) && super.mayPush(stack);
|
||||
return ModeFilter.respectsMode(storage.getFilters(), storage, storage.getCompare(), stack) && super.mayPush(stack);
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,6 @@ package refinedstorage.tile;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
@@ -13,6 +12,7 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.network.MessageTileContainerUpdate;
|
||||
@@ -97,7 +97,7 @@ public abstract class TileBase extends TileEntity implements ITickable {
|
||||
return worldObj.getTileEntity(pos.offset(direction));
|
||||
}
|
||||
|
||||
public IInventory getDroppedInventory() {
|
||||
public IItemHandler getDroppedItems() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -4,15 +4,17 @@ import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.container.ContainerConstructor;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.inventory.SimpleItemHandler;
|
||||
import refinedstorage.inventory.SimpleItemValidator;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
import refinedstorage.tile.config.ICompareConfig;
|
||||
|
||||
@@ -21,8 +23,13 @@ public class TileConstructor extends TileMachine implements ICompareConfig {
|
||||
|
||||
public static final int BASE_SPEED = 20;
|
||||
|
||||
private InventorySimple inventory = new InventorySimple("constructor", 1, this);
|
||||
private InventorySimple upgradesInventory = new InventorySimple("upgrades", 4, this);
|
||||
private SimpleItemHandler filter = new SimpleItemHandler(1, this);
|
||||
private SimpleItemHandler upgrades = new SimpleItemHandler(
|
||||
4,
|
||||
this,
|
||||
new SimpleItemValidator(RefinedStorageItems.UPGRADE, ItemUpgrade.TYPE_SPEED),
|
||||
new SimpleItemValidator(RefinedStorageItems.UPGRADE, ItemUpgrade.TYPE_CRAFTING)
|
||||
);
|
||||
|
||||
private int compare = 0;
|
||||
|
||||
@@ -30,18 +37,18 @@ public class TileConstructor extends TileMachine implements ICompareConfig {
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
return 1 + RefinedStorageUtils.getUpgradeEnergyUsage(upgradesInventory);
|
||||
return 1 + RefinedStorageUtils.getUpgradeEnergyUsage(upgrades);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMachine() {
|
||||
if (ticks % RefinedStorageUtils.getSpeed(upgradesInventory, BASE_SPEED, 4) == 0 && inventory.getStackInSlot(0) != null) {
|
||||
if (ticks % RefinedStorageUtils.getSpeed(upgrades, BASE_SPEED, 4) == 0 && filter.getStackInSlot(0) != null) {
|
||||
BlockPos front = pos.offset(getDirection());
|
||||
|
||||
Block block = ((ItemBlock) inventory.getStackInSlot(0).getItem()).getBlock();
|
||||
Block block = ((ItemBlock) filter.getStackInSlot(0).getItem()).getBlock();
|
||||
|
||||
if (block.canPlaceBlockAt(worldObj, front)) {
|
||||
ItemStack took = controller.take(inventory.getStackInSlot(0).copy(), compare);
|
||||
ItemStack took = controller.take(filter.getStackInSlot(0).copy(), compare);
|
||||
|
||||
if (took != null) {
|
||||
scheduler.resetSchedule();
|
||||
@@ -49,8 +56,8 @@ public class TileConstructor extends TileMachine implements ICompareConfig {
|
||||
// From ItemBlock.onItemUse
|
||||
SoundType blockSound = block.getStepSound();
|
||||
worldObj.playSound(null, front, blockSound.getPlaceSound(), SoundCategory.BLOCKS, (blockSound.getVolume() + 1.0F) / 2.0F, blockSound.getPitch() * 0.8F);
|
||||
} else if (RefinedStorageUtils.hasUpgrade(upgradesInventory, ItemUpgrade.TYPE_CRAFTING)) {
|
||||
ItemStack craft = inventory.getStackInSlot(0);
|
||||
} else if (RefinedStorageUtils.hasUpgrade(upgrades, ItemUpgrade.TYPE_CRAFTING)) {
|
||||
ItemStack craft = filter.getStackInSlot(0);
|
||||
|
||||
if (scheduler.canSchedule(compare, craft)) {
|
||||
scheduler.schedule(controller, compare, craft);
|
||||
@@ -80,8 +87,8 @@ public class TileConstructor extends TileMachine implements ICompareConfig {
|
||||
compare = nbt.getInteger(NBT_COMPARE);
|
||||
}
|
||||
|
||||
RefinedStorageUtils.restoreInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.restoreInventory(upgradesInventory, 1, nbt);
|
||||
RefinedStorageUtils.restoreItems(filter, 0, nbt);
|
||||
RefinedStorageUtils.restoreItems(upgrades, 1, nbt);
|
||||
|
||||
scheduler.readFromNBT(nbt);
|
||||
}
|
||||
@@ -92,8 +99,8 @@ public class TileConstructor extends TileMachine implements ICompareConfig {
|
||||
|
||||
nbt.setInteger(NBT_COMPARE, compare);
|
||||
|
||||
RefinedStorageUtils.saveInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.saveInventory(upgradesInventory, 1, nbt);
|
||||
RefinedStorageUtils.saveItems(filter, 0, nbt);
|
||||
RefinedStorageUtils.saveItems(upgrades, 1, nbt);
|
||||
|
||||
scheduler.writeToNBT(nbt);
|
||||
}
|
||||
@@ -117,16 +124,16 @@ public class TileConstructor extends TileMachine implements ICompareConfig {
|
||||
return ContainerConstructor.class;
|
||||
}
|
||||
|
||||
public InventorySimple getUpgradesInventory() {
|
||||
return upgradesInventory;
|
||||
public IItemHandler getUpgrades() {
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
public IItemHandler getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getDroppedInventory() {
|
||||
return upgradesInventory;
|
||||
}
|
||||
|
||||
public IInventory getInventory() {
|
||||
return inventory;
|
||||
public IItemHandler getDroppedItems() {
|
||||
return upgrades;
|
||||
}
|
||||
}
|
||||
|
@@ -229,9 +229,9 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
|
||||
TileCrafter crafter = (TileCrafter) machine;
|
||||
|
||||
for (int i = 0; i < TileCrafter.PATTERN_SLOTS; ++i) {
|
||||
if (crafter.getStackInSlot(i) != null && ItemPattern.isValid(crafter.getStackInSlot(i))) {
|
||||
ItemStack pattern = crafter.getStackInSlot(i);
|
||||
ItemStack pattern = crafter.getPatterns().getStackInSlot(i);
|
||||
|
||||
if (pattern != null && ItemPattern.isValid(pattern)) {
|
||||
patterns.add(new CraftingPattern(crafter.getPos().getX(), crafter.getPos().getY(), crafter.getPos().getZ(), ItemPattern.isProcessing(pattern), ItemPattern.getInputs(pattern), ItemPattern.getOutputs(pattern)));
|
||||
}
|
||||
}
|
||||
|
@@ -4,15 +4,18 @@ import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.container.ContainerDestructor;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.inventory.SimpleItemHandler;
|
||||
import refinedstorage.inventory.SimpleItemValidator;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
import refinedstorage.tile.config.ICompareConfig;
|
||||
import refinedstorage.tile.config.IModeConfig;
|
||||
import refinedstorage.tile.config.ModeConstants;
|
||||
@@ -26,27 +29,27 @@ public class TileDestructor extends TileMachine implements ICompareConfig, IMode
|
||||
|
||||
public static final int BASE_SPEED = 20;
|
||||
|
||||
private InventorySimple inventory = new InventorySimple("destructor", 9, this);
|
||||
private InventorySimple upgradesInventory = new InventorySimple("upgrades", 4, this);
|
||||
private SimpleItemHandler filters = new SimpleItemHandler(9, this);
|
||||
private SimpleItemHandler upgrades = new SimpleItemHandler(4, this, new SimpleItemValidator(RefinedStorageItems.UPGRADE, ItemUpgrade.TYPE_SPEED));
|
||||
|
||||
private int compare = 0;
|
||||
private int mode = ModeConstants.WHITELIST;
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
return 1 + RefinedStorageUtils.getUpgradeEnergyUsage(upgradesInventory);
|
||||
return 1 + RefinedStorageUtils.getUpgradeEnergyUsage(upgrades);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMachine() {
|
||||
if (ticks % RefinedStorageUtils.getSpeed(upgradesInventory, BASE_SPEED, 4) == 0) {
|
||||
if (ticks % RefinedStorageUtils.getSpeed(upgrades, BASE_SPEED, 4) == 0) {
|
||||
BlockPos front = pos.offset(getDirection());
|
||||
|
||||
IBlockState frontBlockState = worldObj.getBlockState(front);
|
||||
Block frontBlock = frontBlockState.getBlock();
|
||||
|
||||
if (Item.getItemFromBlock(frontBlock) != null && !frontBlock.isAir(frontBlockState, worldObj, front)) {
|
||||
if (ModeFilter.respectsMode(inventory, this, compare, new ItemStack(frontBlock, 1, frontBlock.getMetaFromState(frontBlockState)))) {
|
||||
if (ModeFilter.respectsMode(filters, this, compare, new ItemStack(frontBlock, 1, frontBlock.getMetaFromState(frontBlockState)))) {
|
||||
List<ItemStack> drops = frontBlock.getDrops(worldObj, front, frontBlockState, 0);
|
||||
|
||||
worldObj.playAuxSFXAtEntity(null, 2001, front, Block.getStateId(frontBlockState));
|
||||
@@ -101,8 +104,8 @@ public class TileDestructor extends TileMachine implements ICompareConfig, IMode
|
||||
mode = nbt.getInteger(NBT_MODE);
|
||||
}
|
||||
|
||||
RefinedStorageUtils.restoreInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.restoreInventory(upgradesInventory, 1, nbt);
|
||||
RefinedStorageUtils.restoreItems(filters, 0, nbt);
|
||||
RefinedStorageUtils.restoreItems(upgrades, 1, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,8 +115,8 @@ public class TileDestructor extends TileMachine implements ICompareConfig, IMode
|
||||
nbt.setInteger(NBT_COMPARE, compare);
|
||||
nbt.setInteger(NBT_MODE, mode);
|
||||
|
||||
RefinedStorageUtils.saveInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.saveInventory(upgradesInventory, 1, nbt);
|
||||
RefinedStorageUtils.saveItems(filters, 0, nbt);
|
||||
RefinedStorageUtils.saveItems(upgrades, 1, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,16 +139,16 @@ public class TileDestructor extends TileMachine implements ICompareConfig, IMode
|
||||
return ContainerDestructor.class;
|
||||
}
|
||||
|
||||
public InventorySimple getUpgradesInventory() {
|
||||
return upgradesInventory;
|
||||
public IItemHandler getUpgrades() {
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
public IItemHandler getInventory() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getDroppedInventory() {
|
||||
return upgradesInventory;
|
||||
}
|
||||
|
||||
public IInventory getInventory() {
|
||||
return inventory;
|
||||
public IItemHandler getDroppedItems() {
|
||||
return upgrades;
|
||||
}
|
||||
}
|
||||
|
@@ -2,14 +2,14 @@ package refinedstorage.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import refinedstorage.RefinedStorageBlocks;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.container.ContainerDetector;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.inventory.SimpleItemHandler;
|
||||
import refinedstorage.storage.ItemGroup;
|
||||
import refinedstorage.tile.config.ICompareConfig;
|
||||
import refinedstorage.tile.config.RedstoneMode;
|
||||
@@ -24,7 +24,7 @@ public class TileDetector extends TileMachine implements ICompareConfig {
|
||||
public static final String NBT_AMOUNT = "Amount";
|
||||
public static final String NBT_DESC_POWERED = "Powered";
|
||||
|
||||
private InventorySimple inventory = new InventorySimple("detector", 1, this);
|
||||
private SimpleItemHandler filter = new SimpleItemHandler(1, this);
|
||||
|
||||
private int compare = 0;
|
||||
private int mode = MODE_EQUAL;
|
||||
@@ -47,7 +47,7 @@ public class TileDetector extends TileMachine implements ICompareConfig {
|
||||
@Override
|
||||
public void updateMachine() {
|
||||
if (ticks % 5 == 0) {
|
||||
ItemStack slot = inventory.getStackInSlot(0);
|
||||
ItemStack slot = filter.getStackInSlot(0);
|
||||
|
||||
boolean wasPowered = powered;
|
||||
|
||||
@@ -151,7 +151,7 @@ public class TileDetector extends TileMachine implements ICompareConfig {
|
||||
amount = nbt.getInteger(NBT_AMOUNT);
|
||||
}
|
||||
|
||||
RefinedStorageUtils.restoreInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.restoreItems(filter, 0, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -162,7 +162,7 @@ public class TileDetector extends TileMachine implements ICompareConfig {
|
||||
nbt.setInteger(NBT_MODE, mode);
|
||||
nbt.setInteger(NBT_AMOUNT, amount);
|
||||
|
||||
RefinedStorageUtils.saveInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.saveItems(filter, 0, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -202,8 +202,8 @@ public class TileDetector extends TileMachine implements ICompareConfig {
|
||||
return ContainerDetector.class;
|
||||
}
|
||||
|
||||
public IInventory getInventory() {
|
||||
return inventory;
|
||||
public IItemHandler getInventory() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -1,18 +1,17 @@
|
||||
package refinedstorage.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.block.EnumStorageType;
|
||||
import refinedstorage.container.ContainerDiskDrive;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.inventory.SimpleItemHandler;
|
||||
import refinedstorage.inventory.SimpleItemValidator;
|
||||
import refinedstorage.network.MessagePriorityUpdate;
|
||||
import refinedstorage.storage.*;
|
||||
import refinedstorage.tile.config.ICompareConfig;
|
||||
@@ -22,13 +21,13 @@ import refinedstorage.tile.config.ModeConstants;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TileDiskDrive extends TileMachine implements IStorageProvider, IStorageGui, ICompareConfig, IModeConfig, IInventory {
|
||||
public class TileDiskDrive extends TileMachine implements IStorageProvider, IStorageGui, ICompareConfig, IModeConfig {
|
||||
public static final String NBT_PRIORITY = "Priority";
|
||||
public static final String NBT_COMPARE = "Compare";
|
||||
public static final String NBT_MODE = "Mode";
|
||||
|
||||
private InventorySimple inventory = new InventorySimple("disk_drive", 8, this);
|
||||
private InventorySimple filterInventory = new InventorySimple("filters", 9, this);
|
||||
private SimpleItemHandler disks = new SimpleItemHandler(8, this, new SimpleItemValidator(RefinedStorageItems.STORAGE_DISK));
|
||||
private SimpleItemHandler filters = new SimpleItemHandler(9, this);
|
||||
|
||||
private NBTStorage storages[] = new NBTStorage[8];
|
||||
|
||||
@@ -37,10 +36,10 @@ public class TileDiskDrive extends TileMachine implements IStorageProvider, ISto
|
||||
private int mode = ModeConstants.WHITELIST;
|
||||
|
||||
public NBTStorage getStorage(int slot) {
|
||||
if (inventory.getStackInSlot(slot) == null) {
|
||||
if (disks.getStackInSlot(slot) == null) {
|
||||
storages[slot] = null;
|
||||
} else if (storages[slot] == null) {
|
||||
storages[slot] = new DiskStorage(getStackInSlot(slot), this);
|
||||
storages[slot] = new DiskStorage(disks.getStackInSlot(slot), this);
|
||||
}
|
||||
|
||||
return storages[slot];
|
||||
@@ -50,8 +49,8 @@ public class TileDiskDrive extends TileMachine implements IStorageProvider, ISto
|
||||
public int getEnergyUsage() {
|
||||
int base = 5;
|
||||
|
||||
for (int i = 0; i < getSizeInventory(); ++i) {
|
||||
if (getStackInSlot(i) != null) {
|
||||
for (int i = 0; i < disks.getSlots(); ++i) {
|
||||
if (disks.getStackInSlot(i) != null) {
|
||||
base += 2;
|
||||
}
|
||||
}
|
||||
@@ -61,11 +60,11 @@ public class TileDiskDrive extends TileMachine implements IStorageProvider, ISto
|
||||
|
||||
@Override
|
||||
public void updateMachine() {
|
||||
for (int i = 0; i < getSizeInventory(); ++i) {
|
||||
for (int i = 0; i < disks.getSlots(); ++i) {
|
||||
NBTStorage storage = getStorage(i);
|
||||
|
||||
if (storage != null && storage.isDirty()) {
|
||||
storage.writeToNBT(getStackInSlot(i).getTagCompound());
|
||||
storage.writeToNBT(disks.getStackInSlot(i).getTagCompound());
|
||||
storage.markClean();
|
||||
}
|
||||
}
|
||||
@@ -73,7 +72,7 @@ public class TileDiskDrive extends TileMachine implements IStorageProvider, ISto
|
||||
|
||||
@Override
|
||||
public void provide(List<IStorage> storages) {
|
||||
for (int i = 0; i < getSizeInventory(); ++i) {
|
||||
for (int i = 0; i < disks.getSlots(); ++i) {
|
||||
NBTStorage storage = getStorage(i);
|
||||
|
||||
if (storage != null) {
|
||||
@@ -86,8 +85,8 @@ public class TileDiskDrive extends TileMachine implements IStorageProvider, ISto
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
RefinedStorageUtils.restoreInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.restoreInventory(filterInventory, 1, nbt);
|
||||
RefinedStorageUtils.restoreItems(disks, 0, nbt);
|
||||
RefinedStorageUtils.restoreItems(filters, 1, nbt);
|
||||
|
||||
if (nbt.hasKey(NBT_PRIORITY)) {
|
||||
priority = nbt.getInteger(NBT_PRIORITY);
|
||||
@@ -106,8 +105,8 @@ public class TileDiskDrive extends TileMachine implements IStorageProvider, ISto
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
RefinedStorageUtils.saveInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.saveInventory(filterInventory, 1, nbt);
|
||||
RefinedStorageUtils.saveItems(disks, 0, nbt);
|
||||
RefinedStorageUtils.saveItems(filters, 1, nbt);
|
||||
|
||||
nbt.setInteger(NBT_PRIORITY, priority);
|
||||
nbt.setInteger(NBT_COMPARE, compare);
|
||||
@@ -167,8 +166,8 @@ public class TileDiskDrive extends TileMachine implements IStorageProvider, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventory() {
|
||||
return filterInventory;
|
||||
public IItemHandler getFilters() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -206,8 +205,8 @@ public class TileDiskDrive extends TileMachine implements IStorageProvider, ISto
|
||||
public int getStored() {
|
||||
int stored = 0;
|
||||
|
||||
for (int i = 0; i < getSizeInventory(); ++i) {
|
||||
ItemStack stack = getStackInSlot(i);
|
||||
for (int i = 0; i < disks.getSlots(); ++i) {
|
||||
ItemStack stack = disks.getStackInSlot(i);
|
||||
|
||||
if (stack != null) {
|
||||
stored += NBTStorage.getStored(stack.getTagCompound());
|
||||
@@ -221,8 +220,8 @@ public class TileDiskDrive extends TileMachine implements IStorageProvider, ISto
|
||||
public int getCapacity() {
|
||||
int capacity = 0;
|
||||
|
||||
for (int i = 0; i < getSizeInventory(); ++i) {
|
||||
ItemStack stack = getStackInSlot(i);
|
||||
for (int i = 0; i < disks.getSlots(); ++i) {
|
||||
ItemStack stack = disks.getStackInSlot(i);
|
||||
|
||||
if (stack != null) {
|
||||
int diskCapacity = EnumStorageType.getById(stack.getItemDamage()).getCapacity();
|
||||
@@ -238,93 +237,12 @@ public class TileDiskDrive extends TileMachine implements IStorageProvider, ISto
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inventory.getSizeInventory();
|
||||
public IItemHandler getDisks() {
|
||||
return disks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return inventory.getStackInSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int count) {
|
||||
return inventory.decrStackSize(slot, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int slot) {
|
||||
return inventory.removeStackFromSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inventory.setInventorySlotContents(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return inventory.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return inventory.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(EntityPlayer player) {
|
||||
inventory.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(EntityPlayer player) {
|
||||
inventory.closeInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
return stack.getItem() == RefinedStorageItems.STORAGE_DISK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getField(int id) {
|
||||
return inventory.getField(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setField(int id, int value) {
|
||||
inventory.setField(id, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFieldCount() {
|
||||
return inventory.getFieldCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
inventory.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName() {
|
||||
return inventory.hasCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName() {
|
||||
return inventory.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return inventory.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getDroppedInventory() {
|
||||
return inventory;
|
||||
public IItemHandler getDroppedItems() {
|
||||
return disks;
|
||||
}
|
||||
}
|
||||
|
@@ -2,22 +2,28 @@ package refinedstorage.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.container.ContainerExporter;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.inventory.SimpleItemHandler;
|
||||
import refinedstorage.inventory.SimpleItemValidator;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
import refinedstorage.tile.config.ICompareConfig;
|
||||
|
||||
public class TileExporter extends TileMachine implements ICompareConfig {
|
||||
public static final String NBT_COMPARE = "Compare";
|
||||
|
||||
private InventorySimple inventory = new InventorySimple("exporter", 9, this);
|
||||
private InventorySimple upgradesInventory = new InventorySimple("upgrades", 4, this);
|
||||
private SimpleItemHandler filters = new SimpleItemHandler(9, this);
|
||||
private SimpleItemHandler upgrades = new SimpleItemHandler(
|
||||
4,
|
||||
this,
|
||||
new SimpleItemValidator(RefinedStorageItems.UPGRADE, ItemUpgrade.TYPE_SPEED),
|
||||
new SimpleItemValidator(RefinedStorageItems.UPGRADE, ItemUpgrade.TYPE_CRAFTING)
|
||||
);
|
||||
|
||||
private int compare = 0;
|
||||
|
||||
@@ -25,16 +31,16 @@ public class TileExporter extends TileMachine implements ICompareConfig {
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
return 2 + RefinedStorageUtils.getUpgradeEnergyUsage(upgradesInventory);
|
||||
return 2 + RefinedStorageUtils.getUpgradeEnergyUsage(upgrades);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMachine() {
|
||||
IItemHandler handler = RefinedStorageUtils.getItemHandler(getFacingTile(), getDirection().getOpposite());
|
||||
|
||||
if (handler != null && ticks % RefinedStorageUtils.getSpeed(upgradesInventory) == 0) {
|
||||
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
||||
ItemStack slot = inventory.getStackInSlot(i);
|
||||
if (handler != null && ticks % RefinedStorageUtils.getSpeed(upgrades) == 0) {
|
||||
for (int i = 0; i < filters.getSlots(); ++i) {
|
||||
ItemStack slot = filters.getStackInSlot(i);
|
||||
|
||||
if (slot != null) {
|
||||
ItemStack took = controller.take(ItemHandlerHelper.copyStackWithSize(slot, 1), compare);
|
||||
@@ -49,7 +55,7 @@ public class TileExporter extends TileMachine implements ICompareConfig {
|
||||
}
|
||||
|
||||
controller.push(took);
|
||||
} else if (RefinedStorageUtils.hasUpgrade(upgradesInventory, ItemUpgrade.TYPE_CRAFTING)) {
|
||||
} else if (RefinedStorageUtils.hasUpgrade(upgrades, ItemUpgrade.TYPE_CRAFTING)) {
|
||||
if (scheduler.canSchedule(compare, slot)) {
|
||||
scheduler.schedule(controller, compare, slot);
|
||||
}
|
||||
@@ -79,8 +85,8 @@ public class TileExporter extends TileMachine implements ICompareConfig {
|
||||
compare = nbt.getInteger(NBT_COMPARE);
|
||||
}
|
||||
|
||||
RefinedStorageUtils.restoreInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.restoreInventory(upgradesInventory, 1, nbt);
|
||||
RefinedStorageUtils.restoreItems(filters, 0, nbt);
|
||||
RefinedStorageUtils.restoreItems(upgrades, 1, nbt);
|
||||
|
||||
scheduler.readFromNBT(nbt);
|
||||
}
|
||||
@@ -91,8 +97,8 @@ public class TileExporter extends TileMachine implements ICompareConfig {
|
||||
|
||||
nbt.setInteger(NBT_COMPARE, compare);
|
||||
|
||||
RefinedStorageUtils.saveInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.saveInventory(upgradesInventory, 1, nbt);
|
||||
RefinedStorageUtils.saveItems(filters, 0, nbt);
|
||||
RefinedStorageUtils.saveItems(upgrades, 1, nbt);
|
||||
|
||||
scheduler.writeToNBT(nbt);
|
||||
}
|
||||
@@ -116,16 +122,16 @@ public class TileExporter extends TileMachine implements ICompareConfig {
|
||||
return ContainerExporter.class;
|
||||
}
|
||||
|
||||
public IItemHandler getFilters() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
public IItemHandler getUpgrades() {
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getDroppedInventory() {
|
||||
return upgradesInventory;
|
||||
}
|
||||
|
||||
public InventorySimple getUpgradesInventory() {
|
||||
return upgradesInventory;
|
||||
}
|
||||
|
||||
public IInventory getInventory() {
|
||||
return inventory;
|
||||
public IItemHandler getDroppedItems() {
|
||||
return upgrades;
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@ package refinedstorage.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -11,7 +10,7 @@ import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.container.ContainerStorage;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.inventory.SimpleItemHandler;
|
||||
import refinedstorage.network.MessagePriorityUpdate;
|
||||
import refinedstorage.storage.IStorage;
|
||||
import refinedstorage.storage.IStorageGui;
|
||||
@@ -26,7 +25,7 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
||||
public static final String NBT_COMPARE = "Compare";
|
||||
public static final String NBT_MODE = "Mode";
|
||||
|
||||
private InventorySimple inventory = new InventorySimple("external_storage", 9, this);
|
||||
private SimpleItemHandler filters = new SimpleItemHandler(9, this);
|
||||
|
||||
private int priority = 0;
|
||||
private int compare = 0;
|
||||
@@ -77,7 +76,7 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
||||
} else {
|
||||
IItemHandler handler = getItemHandler();
|
||||
|
||||
// @todo: something goes wrong here
|
||||
// @TODO: Something goes wrong here
|
||||
if (handler != null) {
|
||||
ItemHandlerHelper.insertItem(handler, stack, false);
|
||||
}
|
||||
@@ -128,7 +127,7 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
||||
|
||||
@Override
|
||||
public boolean mayPush(ItemStack stack) {
|
||||
if (ModeFilter.respectsMode(inventory, this, compare, stack)) {
|
||||
if (ModeFilter.respectsMode(filters, this, compare, stack)) {
|
||||
IDeepStorageUnit storageUnit = getStorageUnit();
|
||||
|
||||
if (storageUnit != null) {
|
||||
@@ -210,7 +209,7 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
RefinedStorageUtils.restoreInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.restoreItems(filters, 0, nbt);
|
||||
|
||||
if (nbt.hasKey(NBT_PRIORITY)) {
|
||||
priority = nbt.getInteger(NBT_PRIORITY);
|
||||
@@ -229,7 +228,7 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
RefinedStorageUtils.saveInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.saveItems(filters, 0, nbt);
|
||||
|
||||
nbt.setInteger(NBT_PRIORITY, priority);
|
||||
nbt.setInteger(NBT_COMPARE, compare);
|
||||
@@ -324,7 +323,7 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventory() {
|
||||
return inventory;
|
||||
public IItemHandler getFilters() {
|
||||
return filters;
|
||||
}
|
||||
}
|
||||
|
@@ -2,13 +2,15 @@ package refinedstorage.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.container.ContainerImporter;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.inventory.SimpleItemHandler;
|
||||
import refinedstorage.inventory.SimpleItemValidator;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
import refinedstorage.tile.config.ICompareConfig;
|
||||
import refinedstorage.tile.config.IModeConfig;
|
||||
import refinedstorage.tile.config.ModeConstants;
|
||||
@@ -18,8 +20,8 @@ public class TileImporter extends TileMachine implements ICompareConfig, IModeCo
|
||||
public static final String NBT_COMPARE = "Compare";
|
||||
public static final String NBT_MODE = "Mode";
|
||||
|
||||
private InventorySimple inventory = new InventorySimple("importer", 9, this);
|
||||
private InventorySimple upgradesInventory = new InventorySimple("upgrades", 4, this);
|
||||
private SimpleItemHandler filters = new SimpleItemHandler(9, this);
|
||||
private SimpleItemHandler upgrades = new SimpleItemHandler(4, this, new SimpleItemValidator(RefinedStorageItems.UPGRADE, ItemUpgrade.TYPE_SPEED));
|
||||
|
||||
private int compare = 0;
|
||||
private int mode = ModeConstants.WHITELIST;
|
||||
@@ -28,7 +30,7 @@ public class TileImporter extends TileMachine implements ICompareConfig, IModeCo
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
return 2 + RefinedStorageUtils.getUpgradeEnergyUsage(upgradesInventory);
|
||||
return 2 + RefinedStorageUtils.getUpgradeEnergyUsage(upgrades);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,9 +48,9 @@ public class TileImporter extends TileMachine implements ICompareConfig, IModeCo
|
||||
if (handler.getSlots() > 0) {
|
||||
ItemStack stack = handler.getStackInSlot(currentSlot);
|
||||
|
||||
if (stack == null || !ModeFilter.respectsMode(inventory, this, compare, stack)) {
|
||||
if (stack == null || !ModeFilter.respectsMode(filters, this, compare, stack)) {
|
||||
currentSlot++;
|
||||
} else if (ticks % RefinedStorageUtils.getSpeed(upgradesInventory) == 0) {
|
||||
} else if (ticks % RefinedStorageUtils.getSpeed(upgrades) == 0) {
|
||||
ItemStack result = handler.extractItem(currentSlot, 1, true);
|
||||
|
||||
if (result != null && controller.push(result)) {
|
||||
@@ -94,8 +96,8 @@ public class TileImporter extends TileMachine implements ICompareConfig, IModeCo
|
||||
mode = nbt.getInteger(NBT_MODE);
|
||||
}
|
||||
|
||||
RefinedStorageUtils.restoreInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.restoreInventory(upgradesInventory, 1, nbt);
|
||||
RefinedStorageUtils.restoreItems(filters, 0, nbt);
|
||||
RefinedStorageUtils.restoreItems(upgrades, 1, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,8 +107,8 @@ public class TileImporter extends TileMachine implements ICompareConfig, IModeCo
|
||||
nbt.setInteger(NBT_COMPARE, compare);
|
||||
nbt.setInteger(NBT_MODE, mode);
|
||||
|
||||
RefinedStorageUtils.saveInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.saveInventory(upgradesInventory, 1, nbt);
|
||||
RefinedStorageUtils.saveItems(filters, 0, nbt);
|
||||
RefinedStorageUtils.saveItems(upgrades, 1, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -130,16 +132,16 @@ public class TileImporter extends TileMachine implements ICompareConfig, IModeCo
|
||||
return ContainerImporter.class;
|
||||
}
|
||||
|
||||
public IItemHandler getUpgrades() {
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
public IItemHandler getFilters() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getDroppedInventory() {
|
||||
return upgradesInventory;
|
||||
}
|
||||
|
||||
public InventorySimple getUpgradesInventory() {
|
||||
return upgradesInventory;
|
||||
}
|
||||
|
||||
public IInventory getInventory() {
|
||||
return inventory;
|
||||
public IItemHandler getDroppedItems() {
|
||||
return upgrades;
|
||||
}
|
||||
}
|
||||
|
@@ -1,32 +1,24 @@
|
||||
package refinedstorage.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.container.ContainerInterface;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.inventory.SimpleItemHandler;
|
||||
import refinedstorage.inventory.SimpleItemValidator;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
import refinedstorage.tile.config.ICompareConfig;
|
||||
|
||||
public class TileInterface extends TileMachine implements ICompareConfig, ISidedInventory {
|
||||
public class TileInterface extends TileMachine implements ICompareConfig {
|
||||
public static final String NBT_COMPARE = "Compare";
|
||||
|
||||
public static final int[] FACES = new int[]{
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8
|
||||
};
|
||||
public static final int[] FACES_DOWN = new int[]{
|
||||
18, 19, 20, 21, 22, 23, 24, 25, 26
|
||||
};
|
||||
|
||||
private InventorySimple inventory = new InventorySimple("interface", 9 * 3, this);
|
||||
private InventorySimple upgradesInventory = new InventorySimple("upgrades", 4, this);
|
||||
private SimpleItemHandler items = new SimpleItemHandler(9 * 3, this);
|
||||
private SimpleItemHandler upgrades = new SimpleItemHandler(4, this, new SimpleItemValidator(RefinedStorageItems.UPGRADE, ItemUpgrade.TYPE_SPEED));
|
||||
|
||||
private int compare = 0;
|
||||
|
||||
@@ -34,7 +26,7 @@ public class TileInterface extends TileMachine implements ICompareConfig, ISided
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
return 4 + RefinedStorageUtils.getUpgradeEnergyUsage(upgradesInventory);
|
||||
return 4 + RefinedStorageUtils.getUpgradeEnergyUsage(upgrades);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,21 +35,21 @@ public class TileInterface extends TileMachine implements ICompareConfig, ISided
|
||||
currentSlot = 0;
|
||||
}
|
||||
|
||||
ItemStack slot = getStackInSlot(currentSlot);
|
||||
ItemStack slot = items.getStackInSlot(currentSlot);
|
||||
|
||||
if (slot == null) {
|
||||
currentSlot++;
|
||||
} else {
|
||||
if (ticks % RefinedStorageUtils.getSpeed(upgradesInventory) == 0) {
|
||||
if (ticks % RefinedStorageUtils.getSpeed(upgrades) == 0) {
|
||||
if (controller.push(ItemHandlerHelper.copyStackWithSize(slot, 1))) {
|
||||
decrStackSize(currentSlot, 1);
|
||||
items.extractItem(currentSlot, 1, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 9; i < 18; ++i) {
|
||||
ItemStack wanted = inventory.getStackInSlot(i);
|
||||
ItemStack got = inventory.getStackInSlot(i + 9);
|
||||
ItemStack wanted = items.getStackInSlot(i);
|
||||
ItemStack got = items.getStackInSlot(i + 9);
|
||||
|
||||
if (wanted != null) {
|
||||
boolean mayTake = false;
|
||||
@@ -65,7 +57,7 @@ public class TileInterface extends TileMachine implements ICompareConfig, ISided
|
||||
if (got != null) {
|
||||
if (!RefinedStorageUtils.compareStack(wanted, got, compare)) {
|
||||
if (controller.push(got)) {
|
||||
inventory.setInventorySlotContents(i + 9, null);
|
||||
items.setStackInSlot(i + 9, null);
|
||||
}
|
||||
} else {
|
||||
mayTake = true;
|
||||
@@ -75,7 +67,7 @@ public class TileInterface extends TileMachine implements ICompareConfig, ISided
|
||||
}
|
||||
|
||||
if (mayTake) {
|
||||
got = inventory.getStackInSlot(i + 9);
|
||||
got = items.getStackInSlot(i + 9);
|
||||
|
||||
int needed = got == null ? wanted.stackSize : wanted.stackSize - got.stackSize;
|
||||
|
||||
@@ -84,7 +76,7 @@ public class TileInterface extends TileMachine implements ICompareConfig, ISided
|
||||
|
||||
if (took != null) {
|
||||
if (got == null) {
|
||||
inventory.setInventorySlotContents(i + 9, took);
|
||||
items.setStackInSlot(i + 9, took);
|
||||
} else {
|
||||
got.stackSize += took.stackSize;
|
||||
}
|
||||
@@ -93,7 +85,7 @@ public class TileInterface extends TileMachine implements ICompareConfig, ISided
|
||||
}
|
||||
} else if (got != null) {
|
||||
if (controller.push(got)) {
|
||||
inventory.setInventorySlotContents(i + 9, null);
|
||||
items.setStackInSlot(i + 9, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,8 +107,8 @@ public class TileInterface extends TileMachine implements ICompareConfig, ISided
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
RefinedStorageUtils.restoreInventory(this, 0, nbt);
|
||||
RefinedStorageUtils.restoreInventory(upgradesInventory, 1, nbt);
|
||||
RefinedStorageUtils.restoreItems(items, 0, nbt);
|
||||
RefinedStorageUtils.restoreItems(upgrades, 1, nbt);
|
||||
|
||||
if (nbt.hasKey(NBT_COMPARE)) {
|
||||
compare = nbt.getInteger(NBT_COMPARE);
|
||||
@@ -127,15 +119,13 @@ public class TileInterface extends TileMachine implements ICompareConfig, ISided
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
RefinedStorageUtils.saveInventory(this, 0, nbt);
|
||||
RefinedStorageUtils.saveInventory(upgradesInventory, 1, nbt);
|
||||
RefinedStorageUtils.saveItems(items, 0, nbt);
|
||||
RefinedStorageUtils.saveItems(upgrades, 1, nbt);
|
||||
|
||||
nbt.setInteger(NBT_COMPARE, compare);
|
||||
}
|
||||
|
||||
public InventorySimple getUpgradesInventory() {
|
||||
return upgradesInventory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void receiveContainerData(ByteBuf buf) {
|
||||
@@ -156,123 +146,28 @@ public class TileInterface extends TileMachine implements ICompareConfig, ISided
|
||||
return ContainerInterface.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inventory.getSizeInventory();
|
||||
public IItemHandler getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public IItemHandler getUpgrades() {
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return inventory.getStackInSlot(slot);
|
||||
}
|
||||
public IItemHandler getDroppedItems() {
|
||||
SimpleItemHandler dummy = new SimpleItemHandler(9 + 9 + 4);
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int count) {
|
||||
return inventory.decrStackSize(slot, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int slot) {
|
||||
return inventory.removeStackFromSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inventory.setInventorySlotContents(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return inventory.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return inventory.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(EntityPlayer player) {
|
||||
inventory.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(EntityPlayer player) {
|
||||
inventory.closeInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
return inventory.isItemValidForSlot(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getField(int id) {
|
||||
return inventory.getField(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setField(int id, int value) {
|
||||
inventory.setField(id, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFieldCount() {
|
||||
return inventory.getFieldCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
inventory.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return inventory.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName() {
|
||||
return inventory.hasCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName() {
|
||||
return inventory.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? FACES_DOWN : FACES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack stack, EnumFacing side) {
|
||||
return slot < 9;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side) {
|
||||
return slot >= 18;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getDroppedInventory() {
|
||||
InventorySimple dummy = new InventorySimple(null, 9 + 9 + 4);
|
||||
|
||||
// Importing slots
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
dummy.setInventorySlotContents(i, inventory.getStackInSlot(i));
|
||||
dummy.setStackInSlot(i, items.getStackInSlot(i));
|
||||
}
|
||||
|
||||
// Exporting slots
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
dummy.setInventorySlotContents(9 + i, inventory.getStackInSlot(18 + i));
|
||||
dummy.setStackInSlot(9 + i, items.getStackInSlot(18 + i));
|
||||
}
|
||||
|
||||
// Upgrade slots
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
dummy.setInventorySlotContents(18 + i, upgradesInventory.getStackInSlot(i));
|
||||
dummy.setStackInSlot(18 + i, upgrades.getStackInSlot(i));
|
||||
}
|
||||
|
||||
return dummy;
|
||||
|
@@ -2,15 +2,15 @@ package refinedstorage.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageBlocks;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.block.BlockStorage;
|
||||
import refinedstorage.block.EnumStorageType;
|
||||
import refinedstorage.container.ContainerStorage;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.inventory.SimpleItemHandler;
|
||||
import refinedstorage.network.MessagePriorityUpdate;
|
||||
import refinedstorage.storage.*;
|
||||
import refinedstorage.tile.config.ICompareConfig;
|
||||
@@ -26,7 +26,7 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
||||
public static final String NBT_COMPARE = "Compare";
|
||||
public static final String NBT_MODE = "Mode";
|
||||
|
||||
private InventorySimple inventory = new InventorySimple("storage", 9, this);
|
||||
private SimpleItemHandler filters = new SimpleItemHandler(9, this);
|
||||
|
||||
private NBTTagCompound storageTag = NBTStorage.createNBT();
|
||||
|
||||
@@ -67,7 +67,7 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
RefinedStorageUtils.restoreInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.restoreItems(filters, 0, nbt);
|
||||
|
||||
if (nbt.hasKey(NBT_PRIORITY)) {
|
||||
priority = nbt.getInteger(NBT_PRIORITY);
|
||||
@@ -90,7 +90,7 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
RefinedStorageUtils.saveInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.saveItems(filters, 0, nbt);
|
||||
|
||||
nbt.setInteger(NBT_PRIORITY, priority);
|
||||
nbt.setTag(NBT_STORAGE, storageTag);
|
||||
@@ -161,8 +161,8 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventory() {
|
||||
return inventory;
|
||||
public IItemHandler getFilters() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -1,21 +1,21 @@
|
||||
package refinedstorage.tile;
|
||||
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.container.ContainerWirelessTransmitter;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.inventory.SimpleItemHandler;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
|
||||
public class TileWirelessTransmitter extends TileMachine {
|
||||
public static final int RANGE_PER_UPGRADE = 8;
|
||||
|
||||
private InventorySimple inventory = new InventorySimple("upgrades", 4, this);
|
||||
private SimpleItemHandler upgrades = new SimpleItemHandler(4, this);
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
return 8 + RefinedStorageUtils.getUpgradeEnergyUsage(inventory);
|
||||
return 8 + RefinedStorageUtils.getUpgradeEnergyUsage(upgrades);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -26,18 +26,22 @@ public class TileWirelessTransmitter extends TileMachine {
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
RefinedStorageUtils.restoreInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.restoreItems(upgrades, 0, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
RefinedStorageUtils.saveInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.saveItems(upgrades, 0, nbt);
|
||||
}
|
||||
|
||||
public int getRange() {
|
||||
return 16 + (RefinedStorageUtils.getUpgradeCount(inventory, ItemUpgrade.TYPE_RANGE) * RANGE_PER_UPGRADE);
|
||||
return 16 + (RefinedStorageUtils.getUpgradeCount(upgrades, ItemUpgrade.TYPE_RANGE) * RANGE_PER_UPGRADE);
|
||||
}
|
||||
|
||||
public SimpleItemHandler getUpgrades() {
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,7 +50,7 @@ public class TileWirelessTransmitter extends TileMachine {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getDroppedInventory() {
|
||||
return inventory;
|
||||
public IItemHandler getDroppedItems() {
|
||||
return upgrades;
|
||||
}
|
||||
}
|
||||
|
@@ -1,29 +1,35 @@
|
||||
package refinedstorage.tile.autocrafting;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.container.ContainerCrafter;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.inventory.IItemValidator;
|
||||
import refinedstorage.inventory.SimpleItemHandler;
|
||||
import refinedstorage.item.ItemPattern;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
import refinedstorage.tile.TileMachine;
|
||||
import refinedstorage.tile.autocrafting.task.ICraftingTask;
|
||||
|
||||
public class TileCrafter extends TileMachine implements IInventory {
|
||||
private InventorySimple inventory = new InventorySimple("crafter", PATTERN_SLOTS + 4, this);
|
||||
public class TileCrafter extends TileMachine {
|
||||
private SimpleItemHandler patterns = new SimpleItemHandler(PATTERN_SLOTS, this, new IItemValidator() {
|
||||
@Override
|
||||
public boolean valid(ItemStack stack) {
|
||||
return stack.getItem() == RefinedStorageItems.PATTERN && ItemPattern.isValid(stack);
|
||||
}
|
||||
});
|
||||
|
||||
private SimpleItemHandler upgrades = new SimpleItemHandler(4, this);
|
||||
|
||||
public static final int PATTERN_SLOTS = 6;
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
return 2 + RefinedStorageUtils.getUpgradeEnergyUsage(inventory, PATTERN_SLOTS);
|
||||
return 2 + RefinedStorageUtils.getUpgradeEnergyUsage(upgrades);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -50,107 +56,42 @@ public class TileCrafter extends TileMachine implements IInventory {
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
RefinedStorageUtils.restoreInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.restoreItems(patterns, 0, nbt);
|
||||
RefinedStorageUtils.restoreItems(upgrades, 1, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
RefinedStorageUtils.saveInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.saveItems(patterns, 0, nbt);
|
||||
RefinedStorageUtils.saveItems(upgrades, 1, nbt);
|
||||
}
|
||||
|
||||
public int getSpeed() {
|
||||
return 20 - (RefinedStorageUtils.getUpgradeCount(inventory, ItemUpgrade.TYPE_SPEED, PATTERN_SLOTS) * 4);
|
||||
return 20 - (RefinedStorageUtils.getUpgradeCount(upgrades, ItemUpgrade.TYPE_SPEED, PATTERN_SLOTS) * 4);
|
||||
}
|
||||
|
||||
public IItemHandler getPatterns() {
|
||||
return patterns;
|
||||
}
|
||||
|
||||
public IItemHandler getUpgrades() {
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inventory.getSizeInventory();
|
||||
}
|
||||
public IItemHandler getDroppedItems() {
|
||||
SimpleItemHandler dummy = new SimpleItemHandler(PATTERN_SLOTS + 4);
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return inventory.getStackInSlot(slot);
|
||||
}
|
||||
for (int i = 0; i < PATTERN_SLOTS; ++i) {
|
||||
dummy.setStackInSlot(i, patterns.getStackInSlot(i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int count) {
|
||||
return inventory.decrStackSize(slot, count);
|
||||
}
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
dummy.setStackInSlot(PATTERN_SLOTS + i, upgrades.getStackInSlot(i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int slot) {
|
||||
return inventory.removeStackFromSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inventory.setInventorySlotContents(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return inventory.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return inventory.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(EntityPlayer player) {
|
||||
inventory.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(EntityPlayer player) {
|
||||
inventory.closeInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
return stack.getItem() == RefinedStorageItems.PATTERN && ItemPattern.isValid(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getField(int id) {
|
||||
return inventory.getField(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setField(int id, int value) {
|
||||
inventory.setField(id, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFieldCount() {
|
||||
return inventory.getFieldCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
inventory.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName() {
|
||||
return inventory.hasCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName() {
|
||||
return inventory.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return inventory.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getDroppedInventory() {
|
||||
return inventory;
|
||||
return dummy;
|
||||
}
|
||||
}
|
||||
|
@@ -1,152 +1,33 @@
|
||||
package refinedstorage.tile.autocrafting;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.inventory.SimpleItemHandler;
|
||||
import refinedstorage.inventory.SimpleItemValidator;
|
||||
import refinedstorage.item.ItemPattern;
|
||||
import refinedstorage.tile.TileBase;
|
||||
|
||||
public class TileProcessingPatternEncoder extends TileBase implements ISidedInventory {
|
||||
public static final int[] FACES = new int[]{
|
||||
0
|
||||
};
|
||||
public static final int[] FACES_DOWN = new int[]{
|
||||
1
|
||||
};
|
||||
|
||||
private InventorySimple inventory = new InventorySimple("patterns", 2, this);
|
||||
private InventorySimple inputsOutputsInventory = new InventorySimple("input_outputs", 9 * 2, this);
|
||||
public class TileProcessingPatternEncoder extends TileBase {
|
||||
private SimpleItemHandler patterns = new SimpleItemHandler(2, this, new SimpleItemValidator(RefinedStorageItems.PATTERN));
|
||||
private SimpleItemHandler configuration = new SimpleItemHandler(9 * 2, this);
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
RefinedStorageUtils.saveInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.saveInventory(inputsOutputsInventory, 1, nbt);
|
||||
RefinedStorageUtils.saveItems(patterns, 0, nbt);
|
||||
RefinedStorageUtils.saveItems(configuration, 1, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
RefinedStorageUtils.restoreInventory(inventory, 0, nbt);
|
||||
RefinedStorageUtils.restoreInventory(inputsOutputsInventory, 1, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inventory.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return inventory.getStackInSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int count) {
|
||||
return inventory.decrStackSize(slot, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int slot) {
|
||||
return inventory.removeStackFromSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inventory.setInventorySlotContents(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return inventory.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return inventory.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(EntityPlayer player) {
|
||||
inventory.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(EntityPlayer player) {
|
||||
inventory.closeInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
return stack.getItem() == RefinedStorageItems.PATTERN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getField(int id) {
|
||||
return inventory.getField(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setField(int id, int value) {
|
||||
inventory.setField(id, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFieldCount() {
|
||||
return inventory.getFieldCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
inventory.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return inventory.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName() {
|
||||
return inventory.hasCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName() {
|
||||
return inventory.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? FACES_DOWN : FACES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack stack, EnumFacing side) {
|
||||
return slot == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side) {
|
||||
return slot == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getDroppedInventory() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public InventorySimple getInputsOutputsInventory() {
|
||||
return inputsOutputsInventory;
|
||||
RefinedStorageUtils.restoreItems(patterns, 0, nbt);
|
||||
RefinedStorageUtils.restoreItems(configuration, 1, nbt);
|
||||
}
|
||||
|
||||
public void onCreatePattern() {
|
||||
@@ -156,18 +37,17 @@ public class TileProcessingPatternEncoder extends TileBase implements ISidedInve
|
||||
ItemPattern.setProcessing(pattern, true);
|
||||
|
||||
for (int i = 0; i < 18; ++i) {
|
||||
if (inputsOutputsInventory.getStackInSlot(i) != null) {
|
||||
if (configuration.getStackInSlot(i) != null) {
|
||||
if (i >= 9) {
|
||||
ItemPattern.addOutput(pattern, inputsOutputsInventory.getStackInSlot(i));
|
||||
ItemPattern.addOutput(pattern, configuration.getStackInSlot(i));
|
||||
} else {
|
||||
ItemPattern.addInput(pattern, inputsOutputsInventory.getStackInSlot(i));
|
||||
ItemPattern.addInput(pattern, configuration.getStackInSlot(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
decrStackSize(0, 1);
|
||||
|
||||
setInventorySlotContents(1, pattern);
|
||||
patterns.extractItem(0, 1, false);
|
||||
patterns.setStackInSlot(1, pattern);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,17 +55,30 @@ public class TileProcessingPatternEncoder extends TileBase implements ISidedInve
|
||||
int inputsFilled = 0, outputsFilled = 0;
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
if (inputsOutputsInventory.getStackInSlot(i) != null) {
|
||||
if (configuration.getStackInSlot(i) != null) {
|
||||
inputsFilled++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 9; i < 18; ++i) {
|
||||
if (inputsOutputsInventory.getStackInSlot(i) != null) {
|
||||
if (configuration.getStackInSlot(i) != null) {
|
||||
outputsFilled++;
|
||||
}
|
||||
}
|
||||
|
||||
return inputsFilled > 0 && outputsFilled > 0 && getStackInSlot(0) != null && getStackInSlot(1) == null;
|
||||
return inputsFilled > 0 && outputsFilled > 0 && patterns.getStackInSlot(0) != null && patterns.getStackInSlot(1) == null;
|
||||
}
|
||||
|
||||
public SimpleItemHandler getPatterns() {
|
||||
return patterns;
|
||||
}
|
||||
|
||||
public SimpleItemHandler getConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getDroppedItems() {
|
||||
return patterns;
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,15 @@
|
||||
package refinedstorage.tile.config;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
|
||||
public class ModeFilter {
|
||||
public static boolean respectsMode(IInventory filters, IModeConfig mode, int compare, ItemStack stack) {
|
||||
public static boolean respectsMode(IItemHandler filters, IModeConfig mode, int compare, ItemStack stack) {
|
||||
if (mode.getMode() == ModeConstants.WHITELIST) {
|
||||
int slots = 0;
|
||||
|
||||
for (int i = 0; i < filters.getSizeInventory(); ++i) {
|
||||
for (int i = 0; i < filters.getSlots(); ++i) {
|
||||
ItemStack slot = filters.getStackInSlot(i);
|
||||
|
||||
if (slot != null) {
|
||||
@@ -23,7 +23,7 @@ public class ModeFilter {
|
||||
|
||||
return slots == 0;
|
||||
} else if (mode.getMode() == ModeConstants.BLACKLIST) {
|
||||
for (int i = 0; i < filters.getSizeInventory(); ++i) {
|
||||
for (int i = 0; i < filters.getSlots(); ++i) {
|
||||
ItemStack slot = filters.getStackInSlot(i);
|
||||
|
||||
if (slot != null && RefinedStorageUtils.compareStack(slot, stack, compare)) {
|
||||
|
@@ -6,6 +6,8 @@ import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageBlocks;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
@@ -13,7 +15,8 @@ import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.block.BlockGrid;
|
||||
import refinedstorage.block.EnumGridType;
|
||||
import refinedstorage.container.ContainerGrid;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.inventory.SimpleItemHandler;
|
||||
import refinedstorage.inventory.SimpleItemValidator;
|
||||
import refinedstorage.item.ItemPattern;
|
||||
import refinedstorage.network.MessageGridCraftingStart;
|
||||
import refinedstorage.network.MessageGridSettingsUpdate;
|
||||
@@ -53,10 +56,10 @@ public class TileGrid extends TileMachine implements IGrid {
|
||||
onCraftingMatrixChanged();
|
||||
}
|
||||
};
|
||||
private InventoryCrafting craftingInventory = new InventoryCrafting(craftingContainer, 3, 3);
|
||||
private InventoryCraftResult craftingResultInventory = new InventoryCraftResult();
|
||||
private InventoryCrafting matrix = new InventoryCrafting(craftingContainer, 3, 3);
|
||||
private InventoryCraftResult result = new InventoryCraftResult();
|
||||
|
||||
private InventorySimple patternsInventory = new InventorySimple("patterns", 2, this);
|
||||
private SimpleItemHandler patterns = new SimpleItemHandler(2, this, new SimpleItemValidator(RefinedStorageItems.PATTERN));
|
||||
|
||||
private int sortingDirection = SORTING_DIRECTION_DESCENDING;
|
||||
private int sortingType = SORTING_TYPE_NAME;
|
||||
@@ -96,39 +99,39 @@ public class TileGrid extends TileMachine implements IGrid {
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageGridStoragePull(getPos().getX(), getPos().getY(), getPos().getZ(), id, flags));
|
||||
}
|
||||
|
||||
public InventoryCrafting getCraftingInventory() {
|
||||
return craftingInventory;
|
||||
public InventoryCrafting getMatrix() {
|
||||
return matrix;
|
||||
}
|
||||
|
||||
public InventoryCraftResult getCraftingResultInventory() {
|
||||
return craftingResultInventory;
|
||||
public InventoryCraftResult getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public InventorySimple getPatternsInventory() {
|
||||
return patternsInventory;
|
||||
public IItemHandler getPatterns() {
|
||||
return patterns;
|
||||
}
|
||||
|
||||
public void onCraftingMatrixChanged() {
|
||||
markDirty();
|
||||
|
||||
craftingResultInventory.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(craftingInventory, worldObj));
|
||||
result.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(matrix, worldObj));
|
||||
}
|
||||
|
||||
public void onCrafted(ContainerGrid container) {
|
||||
if (!worldObj.isRemote) {
|
||||
ItemStack[] remainder = CraftingManager.getInstance().func_180303_b(craftingInventory, worldObj);
|
||||
ItemStack[] remainder = CraftingManager.getInstance().func_180303_b(matrix, worldObj);
|
||||
|
||||
for (int i = 0; i < craftingInventory.getSizeInventory(); ++i) {
|
||||
for (int i = 0; i < matrix.getSizeInventory(); ++i) {
|
||||
if (remainder[i] != null) {
|
||||
craftingInventory.setInventorySlotContents(i, remainder[i].copy());
|
||||
matrix.setInventorySlotContents(i, remainder[i].copy());
|
||||
} else {
|
||||
ItemStack slot = craftingInventory.getStackInSlot(i);
|
||||
ItemStack slot = matrix.getStackInSlot(i);
|
||||
|
||||
if (slot != null) {
|
||||
if (slot.stackSize == 1 && isConnected()) {
|
||||
craftingInventory.setInventorySlotContents(i, controller.take(slot.copy()));
|
||||
matrix.setInventorySlotContents(i, controller.take(slot.copy()));
|
||||
} else {
|
||||
craftingInventory.decrStackSize(i, 1);
|
||||
matrix.decrStackSize(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,7 +146,7 @@ public class TileGrid extends TileMachine implements IGrid {
|
||||
public void onCraftedShift(ContainerGrid container, EntityPlayer player) {
|
||||
List<ItemStack> craftedItemsList = new ArrayList<ItemStack>();
|
||||
int craftedItems = 0;
|
||||
ItemStack crafted = craftingResultInventory.getStackInSlot(0);
|
||||
ItemStack crafted = result.getStackInSlot(0);
|
||||
|
||||
while (true) {
|
||||
onCrafted(container);
|
||||
@@ -152,7 +155,7 @@ public class TileGrid extends TileMachine implements IGrid {
|
||||
|
||||
craftedItems += crafted.stackSize;
|
||||
|
||||
if (!RefinedStorageUtils.compareStack(crafted, craftingResultInventory.getStackInSlot(0)) || craftedItems + crafted.stackSize > crafted.getMaxStackSize()) {
|
||||
if (!RefinedStorageUtils.compareStack(crafted, result.getStackInSlot(0)) || craftedItems + crafted.stackSize > crafted.getMaxStackSize()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -170,34 +173,34 @@ public class TileGrid extends TileMachine implements IGrid {
|
||||
|
||||
public void onCreatePattern() {
|
||||
if (mayCreatePattern()) {
|
||||
patternsInventory.decrStackSize(0, 1);
|
||||
patterns.extractItem(0, 1, false);
|
||||
|
||||
ItemStack pattern = new ItemStack(RefinedStorageItems.PATTERN);
|
||||
|
||||
ItemPattern.addOutput(pattern, craftingResultInventory.getStackInSlot(0));
|
||||
ItemPattern.addOutput(pattern, result.getStackInSlot(0));
|
||||
|
||||
ItemPattern.setProcessing(pattern, false);
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
ItemStack ingredient = craftingInventory.getStackInSlot(i);
|
||||
ItemStack ingredient = matrix.getStackInSlot(i);
|
||||
|
||||
if (ingredient != null) {
|
||||
ItemPattern.addInput(pattern, ingredient);
|
||||
}
|
||||
}
|
||||
|
||||
patternsInventory.setInventorySlotContents(1, pattern);
|
||||
patterns.setStackInSlot(1, pattern);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean mayCreatePattern() {
|
||||
return craftingResultInventory.getStackInSlot(0) != null && patternsInventory.getStackInSlot(1) == null && patternsInventory.getStackInSlot(0) != null;
|
||||
return result.getStackInSlot(0) != null && patterns.getStackInSlot(1) == null && patterns.getStackInSlot(0) != null;
|
||||
}
|
||||
|
||||
public void onRecipeTransfer(ItemStack[][] recipe) {
|
||||
if (isConnected()) {
|
||||
for (int i = 0; i < craftingInventory.getSizeInventory(); ++i) {
|
||||
ItemStack slot = craftingInventory.getStackInSlot(i);
|
||||
for (int i = 0; i < matrix.getSizeInventory(); ++i) {
|
||||
ItemStack slot = matrix.getStackInSlot(i);
|
||||
|
||||
if (slot != null) {
|
||||
if (getType() == EnumGridType.CRAFTING) {
|
||||
@@ -206,11 +209,11 @@ public class TileGrid extends TileMachine implements IGrid {
|
||||
}
|
||||
}
|
||||
|
||||
craftingInventory.setInventorySlotContents(i, null);
|
||||
matrix.setInventorySlotContents(i, null);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < craftingInventory.getSizeInventory(); ++i) {
|
||||
for (int i = 0; i < matrix.getSizeInventory(); ++i) {
|
||||
if (recipe[i] != null) {
|
||||
ItemStack[] possibilities = recipe[i];
|
||||
|
||||
@@ -219,13 +222,13 @@ public class TileGrid extends TileMachine implements IGrid {
|
||||
ItemStack took = controller.take(possibility);
|
||||
|
||||
if (took != null) {
|
||||
craftingInventory.setInventorySlotContents(i, possibility);
|
||||
matrix.setInventorySlotContents(i, possibility);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (getType() == EnumGridType.PATTERN) {
|
||||
craftingInventory.setInventorySlotContents(i, possibilities[0]);
|
||||
matrix.setInventorySlotContents(i, possibilities[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -291,8 +294,8 @@ public class TileGrid extends TileMachine implements IGrid {
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
RefinedStorageUtils.restoreInventory(craftingInventory, 0, nbt);
|
||||
RefinedStorageUtils.restoreInventory(patternsInventory, 1, nbt);
|
||||
RefinedStorageUtils.restoreItemsLegacy(matrix, 0, nbt);
|
||||
RefinedStorageUtils.restoreItems(patterns, 1, nbt);
|
||||
|
||||
if (nbt.hasKey(NBT_SORTING_DIRECTION)) {
|
||||
sortingDirection = nbt.getInteger(NBT_SORTING_DIRECTION);
|
||||
@@ -311,8 +314,8 @@ public class TileGrid extends TileMachine implements IGrid {
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
RefinedStorageUtils.saveInventory(craftingInventory, 0, nbt);
|
||||
RefinedStorageUtils.saveInventory(patternsInventory, 1, nbt);
|
||||
RefinedStorageUtils.saveItemsLegacy(matrix, 0, nbt);
|
||||
RefinedStorageUtils.saveItems(patterns, 1, nbt);
|
||||
|
||||
nbt.setInteger(NBT_SORTING_DIRECTION, sortingDirection);
|
||||
nbt.setInteger(NBT_SORTING_TYPE, sortingType);
|
||||
@@ -359,12 +362,12 @@ public class TileGrid extends TileMachine implements IGrid {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getDroppedInventory() {
|
||||
public IItemHandler getDroppedItems() {
|
||||
switch (getType()) {
|
||||
case CRAFTING:
|
||||
return craftingInventory;
|
||||
return new InvWrapper(matrix);
|
||||
case PATTERN:
|
||||
return patternsInventory;
|
||||
return patterns;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package refinedstorage.tile.solderer;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -14,7 +14,7 @@ public class SoldererRegistry {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
public static ISoldererRecipe getRecipe(IInventory inventory) {
|
||||
public static ISoldererRecipe getRecipe(IItemHandler inventory) {
|
||||
for (ISoldererRecipe recipe : recipes) {
|
||||
boolean ok = true;
|
||||
|
||||
|
@@ -1,39 +1,24 @@
|
||||
package refinedstorage.tile.solderer;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.container.ContainerSolderer;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.inventory.SimpleItemHandler;
|
||||
import refinedstorage.inventory.SimpleItemValidator;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
import refinedstorage.tile.TileMachine;
|
||||
|
||||
public class TileSolderer extends TileMachine implements ISidedInventory {
|
||||
public class TileSolderer extends TileMachine {
|
||||
public static final String NBT_WORKING = "Working";
|
||||
public static final String NBT_PROGRESS = "Progress";
|
||||
|
||||
public static final int[] FACES_UP = new int[]{
|
||||
1
|
||||
};
|
||||
public static final int[] FACES_NE = new int[]{
|
||||
0
|
||||
};
|
||||
public static final int[] FACES_SW = new int[]{
|
||||
2
|
||||
};
|
||||
public static final int[] FACES_DOWN = new int[]{
|
||||
3
|
||||
};
|
||||
|
||||
private InventorySimple inventory = new InventorySimple("solderer", 4 + 4, this);
|
||||
private SimpleItemHandler items = new SimpleItemHandler(4, this);
|
||||
private SimpleItemHandler upgrades = new SimpleItemHandler(4, this, new SimpleItemValidator(RefinedStorageItems.UPGRADE, ItemUpgrade.TYPE_SPEED));
|
||||
|
||||
private ISoldererRecipe recipe;
|
||||
|
||||
@@ -48,16 +33,16 @@ public class TileSolderer extends TileMachine implements ISidedInventory {
|
||||
|
||||
@Override
|
||||
public void updateMachine() {
|
||||
ISoldererRecipe newRecipe = SoldererRegistry.getRecipe(inventory);
|
||||
ISoldererRecipe newRecipe = SoldererRegistry.getRecipe(items);
|
||||
|
||||
boolean wasWorking = working;
|
||||
|
||||
if (newRecipe == null) {
|
||||
reset();
|
||||
} else if (newRecipe != recipe) {
|
||||
boolean isSameItem = inventory.getStackInSlot(3) != null ? RefinedStorageUtils.compareStackNoQuantity(inventory.getStackInSlot(3), newRecipe.getResult()) : false;
|
||||
boolean isSameItem = items.getStackInSlot(3) != null ? RefinedStorageUtils.compareStackNoQuantity(items.getStackInSlot(3), newRecipe.getResult()) : false;
|
||||
|
||||
if (inventory.getStackInSlot(3) == null || (isSameItem && ((inventory.getStackInSlot(3).stackSize + newRecipe.getResult().stackSize) <= inventory.getStackInSlot(3).getMaxStackSize()))) {
|
||||
if (items.getStackInSlot(3) == null || (isSameItem && ((items.getStackInSlot(3).stackSize + newRecipe.getResult().stackSize) <= items.getStackInSlot(3).getMaxStackSize()))) {
|
||||
recipe = newRecipe;
|
||||
progress = 0;
|
||||
working = true;
|
||||
@@ -65,18 +50,18 @@ public class TileSolderer extends TileMachine implements ISidedInventory {
|
||||
markDirty();
|
||||
}
|
||||
} else if (working) {
|
||||
progress += 1 + RefinedStorageUtils.getUpgradeCount(inventory, ItemUpgrade.TYPE_SPEED, 4);
|
||||
progress += 1 + RefinedStorageUtils.getUpgradeCount(upgrades, ItemUpgrade.TYPE_SPEED);
|
||||
|
||||
if (progress >= recipe.getDuration()) {
|
||||
if (inventory.getStackInSlot(3) != null) {
|
||||
inventory.getStackInSlot(3).stackSize += recipe.getResult().stackSize;
|
||||
if (items.getStackInSlot(3) != null) {
|
||||
items.getStackInSlot(3).stackSize += recipe.getResult().stackSize;
|
||||
} else {
|
||||
inventory.setInventorySlotContents(3, recipe.getResult());
|
||||
items.setStackInSlot(3, recipe.getResult());
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (recipe.getRow(i) != null) {
|
||||
inventory.decrStackSize(i, recipe.getRow(i).stackSize);
|
||||
items.extractItem(i, recipe.getRow(i).stackSize, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,9 +93,10 @@ public class TileSolderer extends TileMachine implements ISidedInventory {
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
RefinedStorageUtils.restoreInventory(this, 0, nbt);
|
||||
RefinedStorageUtils.restoreItems(items, 0, nbt);
|
||||
RefinedStorageUtils.restoreItems(upgrades, 1, nbt);
|
||||
|
||||
recipe = SoldererRegistry.getRecipe(inventory);
|
||||
recipe = SoldererRegistry.getRecipe(items);
|
||||
|
||||
if (nbt.hasKey(NBT_WORKING)) {
|
||||
working = nbt.getBoolean(NBT_WORKING);
|
||||
@@ -125,7 +111,8 @@ public class TileSolderer extends TileMachine implements ISidedInventory {
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
RefinedStorageUtils.saveInventory(this, 0, nbt);
|
||||
RefinedStorageUtils.saveItems(items, 0, nbt);
|
||||
RefinedStorageUtils.saveItems(upgrades, 1, nbt);
|
||||
|
||||
nbt.setBoolean(NBT_WORKING, working);
|
||||
nbt.setInteger(NBT_PROGRESS, progress);
|
||||
@@ -178,118 +165,16 @@ public class TileSolderer extends TileMachine implements ISidedInventory {
|
||||
return (int) ((float) progress / (float) duration * (float) i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getDroppedInventory() {
|
||||
return inventory;
|
||||
public IItemHandler getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public IItemHandler getUpgrades() {
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inventory.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return inventory.getStackInSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int count) {
|
||||
return inventory.decrStackSize(slot, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int slot) {
|
||||
return inventory.removeStackFromSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inventory.setInventorySlotContents(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return inventory.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return inventory.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(EntityPlayer player) {
|
||||
inventory.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(EntityPlayer player) {
|
||||
inventory.closeInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
return inventory.isItemValidForSlot(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getField(int id) {
|
||||
return inventory.getField(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setField(int id, int value) {
|
||||
inventory.setField(id, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFieldCount() {
|
||||
return inventory.getFieldCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
inventory.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return inventory.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName() {
|
||||
return inventory.hasCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName() {
|
||||
return inventory.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
if (side == EnumFacing.UP) {
|
||||
return FACES_UP;
|
||||
} else if (side == EnumFacing.DOWN) {
|
||||
return FACES_DOWN;
|
||||
} else if (side == EnumFacing.NORTH || side == EnumFacing.EAST) {
|
||||
return FACES_NE;
|
||||
} else if (side == EnumFacing.SOUTH || side == EnumFacing.WEST) {
|
||||
return FACES_SW;
|
||||
}
|
||||
|
||||
return FACES_UP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack stack, EnumFacing direction) {
|
||||
return slot != 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack stack, EnumFacing direction) {
|
||||
return slot == 3;
|
||||
public IItemHandler getDroppedItems() {
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user