Move some methods to RSUtils
This commit is contained in:
		| @@ -1,11 +1,25 @@ | |||||||
| package refinedstorage; | package refinedstorage; | ||||||
|  |  | ||||||
| import io.netty.buffer.ByteBuf; | import io.netty.buffer.ByteBuf; | ||||||
|  | import net.minecraft.inventory.IInventory; | ||||||
|  | import net.minecraft.inventory.ISidedInventory; | ||||||
| import net.minecraft.item.Item; | import net.minecraft.item.Item; | ||||||
| import net.minecraft.item.ItemStack; | import net.minecraft.item.ItemStack; | ||||||
|  | import net.minecraft.nbt.NBTTagCompound; | ||||||
|  | import net.minecraft.nbt.NBTTagList; | ||||||
|  | import net.minecraft.tileentity.TileEntity; | ||||||
|  | import net.minecraft.util.EnumFacing; | ||||||
|  | import net.minecraftforge.common.util.Constants; | ||||||
| import net.minecraftforge.fluids.FluidRegistry; | import net.minecraftforge.fluids.FluidRegistry; | ||||||
| import net.minecraftforge.fluids.FluidStack; | import net.minecraftforge.fluids.FluidStack; | ||||||
|  | import net.minecraftforge.fluids.capability.CapabilityFluidHandler; | ||||||
|  | import net.minecraftforge.fluids.capability.IFluidHandler; | ||||||
|  | import net.minecraftforge.fluids.capability.wrappers.FluidHandlerWrapper; | ||||||
| import net.minecraftforge.fml.common.network.ByteBufUtils; | import net.minecraftforge.fml.common.network.ByteBufUtils; | ||||||
|  | import net.minecraftforge.items.CapabilityItemHandler; | ||||||
|  | import net.minecraftforge.items.IItemHandler; | ||||||
|  | import net.minecraftforge.items.wrapper.InvWrapper; | ||||||
|  | import net.minecraftforge.items.wrapper.SidedInvWrapper; | ||||||
| import refinedstorage.api.network.INetworkMaster; | import refinedstorage.api.network.INetworkMaster; | ||||||
| import refinedstorage.apiimpl.API; | import refinedstorage.apiimpl.API; | ||||||
| import refinedstorage.apiimpl.storage.fluid.FluidStorageNBT; | import refinedstorage.apiimpl.storage.fluid.FluidStorageNBT; | ||||||
| @@ -14,6 +28,9 @@ import refinedstorage.apiimpl.storage.item.ItemStorageNBT; | |||||||
| import java.util.function.Function; | import java.util.function.Function; | ||||||
|  |  | ||||||
| public final class RSUtils { | public final class RSUtils { | ||||||
|  |     private static final String NBT_INVENTORY = "Inventory_%d"; | ||||||
|  |     private static final String NBT_SLOT = "Slot"; | ||||||
|  |  | ||||||
|     public static void writeItemStack(ByteBuf buf, INetworkMaster network, ItemStack stack) { |     public static void writeItemStack(ByteBuf buf, INetworkMaster network, ItemStack stack) { | ||||||
|         buf.writeInt(Item.getIdFromItem(stack.getItem())); |         buf.writeInt(Item.getIdFromItem(stack.getItem())); | ||||||
|         buf.writeInt(stack.stackSize); |         buf.writeInt(stack.stackSize); | ||||||
| @@ -42,4 +59,108 @@ public final class RSUtils { | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public static void writeItems(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 readItems(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)); | ||||||
|  |  | ||||||
|  |                 if (slot >= 0 && slot < handler.getSlots()) { | ||||||
|  |                     handler.insertItem(slot, stack, false); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public static void writeItemsLegacy(IInventory inventory, int id, NBTTagCompound nbt) { | ||||||
|  |         NBTTagList tagList = new NBTTagList(); | ||||||
|  |  | ||||||
|  |         for (int i = 0; i < inventory.getSizeInventory(); i++) { | ||||||
|  |             if (inventory.getStackInSlot(i) != null) { | ||||||
|  |                 NBTTagCompound compoundTag = new NBTTagCompound(); | ||||||
|  |  | ||||||
|  |                 compoundTag.setInteger(NBT_SLOT, i); | ||||||
|  |  | ||||||
|  |                 inventory.getStackInSlot(i).writeToNBT(compoundTag); | ||||||
|  |  | ||||||
|  |                 tagList.appendTag(compoundTag); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         nbt.setTag(String.format(NBT_INVENTORY, id), tagList); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public static void readItemsLegacy(IInventory inventory, 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)); | ||||||
|  |  | ||||||
|  |                 inventory.setInventorySlotContents(slot, stack); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public static IItemHandler getItemHandler(TileEntity tile, EnumFacing side) { | ||||||
|  |         if (tile == null) { | ||||||
|  |             return null; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         IItemHandler handler = tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side) ? tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side) : null; | ||||||
|  |  | ||||||
|  |         if (handler == null) { | ||||||
|  |             if (side != null && tile instanceof ISidedInventory) { | ||||||
|  |                 handler = new SidedInvWrapper((ISidedInventory) tile, side); | ||||||
|  |             } else if (tile instanceof IInventory) { | ||||||
|  |                 handler = new InvWrapper((IInventory) tile); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return handler; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public static IFluidHandler getFluidHandler(TileEntity tile, EnumFacing side) { | ||||||
|  |         if (tile == null) { | ||||||
|  |             return null; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         IFluidHandler handler = null; | ||||||
|  |  | ||||||
|  |         if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) { | ||||||
|  |             handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side); | ||||||
|  |         } else if (tile instanceof net.minecraftforge.fluids.IFluidHandler) { | ||||||
|  |             handler = new FluidHandlerWrapper((net.minecraftforge.fluids.IFluidHandler) tile, side); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return handler; | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -3,7 +3,7 @@ package refinedstorage.inventory; | |||||||
| import net.minecraft.item.ItemStack; | import net.minecraft.item.ItemStack; | ||||||
| import net.minecraft.nbt.NBTTagCompound; | import net.minecraft.nbt.NBTTagCompound; | ||||||
| import net.minecraftforge.items.ItemStackHandler; | import net.minecraftforge.items.ItemStackHandler; | ||||||
| import refinedstorage.tile.TileBase; | import refinedstorage.RSUtils; | ||||||
|  |  | ||||||
| public class ItemHandlerGridFilter extends ItemStackHandler { | public class ItemHandlerGridFilter extends ItemStackHandler { | ||||||
|     private ItemStack stack; |     private ItemStack stack; | ||||||
| @@ -14,7 +14,7 @@ public class ItemHandlerGridFilter extends ItemStackHandler { | |||||||
|         this.stack = stack; |         this.stack = stack; | ||||||
|  |  | ||||||
|         if (stack.hasTagCompound()) { |         if (stack.hasTagCompound()) { | ||||||
|             TileBase.readItems(this, 0, stack.getTagCompound()); |             RSUtils.readItems(this, 0, stack.getTagCompound()); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -26,7 +26,7 @@ public class ItemHandlerGridFilter extends ItemStackHandler { | |||||||
|             stack.setTagCompound(new NBTTagCompound()); |             stack.setTagCompound(new NBTTagCompound()); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         TileBase.writeItems(this, 0, stack.getTagCompound()); |         RSUtils.writeItems(this, 0, stack.getTagCompound()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public ItemStack[] getFilteredItems() { |     public ItemStack[] getFilteredItems() { | ||||||
|   | |||||||
| @@ -1,11 +1,7 @@ | |||||||
| package refinedstorage.tile; | package refinedstorage.tile; | ||||||
|  |  | ||||||
| import net.minecraft.block.state.IBlockState; | import net.minecraft.block.state.IBlockState; | ||||||
| import net.minecraft.inventory.IInventory; |  | ||||||
| import net.minecraft.inventory.ISidedInventory; |  | ||||||
| import net.minecraft.item.ItemStack; |  | ||||||
| import net.minecraft.nbt.NBTTagCompound; | import net.minecraft.nbt.NBTTagCompound; | ||||||
| import net.minecraft.nbt.NBTTagList; |  | ||||||
| import net.minecraft.network.NetworkManager; | import net.minecraft.network.NetworkManager; | ||||||
| import net.minecraft.network.play.server.SPacketUpdateTileEntity; | import net.minecraft.network.play.server.SPacketUpdateTileEntity; | ||||||
| import net.minecraft.tileentity.TileEntity; | import net.minecraft.tileentity.TileEntity; | ||||||
| @@ -13,14 +9,7 @@ import net.minecraft.util.EnumFacing; | |||||||
| import net.minecraft.util.ITickable; | import net.minecraft.util.ITickable; | ||||||
| import net.minecraft.util.math.BlockPos; | import net.minecraft.util.math.BlockPos; | ||||||
| import net.minecraft.world.World; | import net.minecraft.world.World; | ||||||
| import net.minecraftforge.common.util.Constants; |  | ||||||
| import net.minecraftforge.fluids.capability.CapabilityFluidHandler; |  | ||||||
| import net.minecraftforge.fluids.capability.IFluidHandler; |  | ||||||
| import net.minecraftforge.fluids.capability.wrappers.FluidHandlerWrapper; |  | ||||||
| import net.minecraftforge.items.CapabilityItemHandler; |  | ||||||
| import net.minecraftforge.items.IItemHandler; | import net.minecraftforge.items.IItemHandler; | ||||||
| import net.minecraftforge.items.wrapper.InvWrapper; |  | ||||||
| import net.minecraftforge.items.wrapper.SidedInvWrapper; |  | ||||||
| import refinedstorage.tile.data.TileDataManager; | import refinedstorage.tile.data.TileDataManager; | ||||||
|  |  | ||||||
| import javax.annotation.Nullable; | import javax.annotation.Nullable; | ||||||
| @@ -28,9 +17,6 @@ import javax.annotation.Nullable; | |||||||
| public abstract class TileBase extends TileEntity implements ITickable { | public abstract class TileBase extends TileEntity implements ITickable { | ||||||
|     private static final String NBT_DIRECTION = "Direction"; |     private static final String NBT_DIRECTION = "Direction"; | ||||||
|  |  | ||||||
|     private static final String NBT_INVENTORY = "Inventory_%d"; |  | ||||||
|     private static final String NBT_SLOT = "Slot"; |  | ||||||
|  |  | ||||||
|     private EnumFacing direction = EnumFacing.NORTH; |     private EnumFacing direction = EnumFacing.NORTH; | ||||||
|  |  | ||||||
|     protected TileDataManager dataManager = new TileDataManager(this); |     protected TileDataManager dataManager = new TileDataManager(this); | ||||||
| @@ -133,111 +119,6 @@ public abstract class TileBase extends TileEntity implements ITickable { | |||||||
|         return null; |         return null; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void writeItems(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 readItems(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)); |  | ||||||
|  |  | ||||||
|                 if (slot >= 0 && slot < handler.getSlots()) { |  | ||||||
|                     handler.insertItem(slot, stack, false); |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public static void writeItemsLegacy(IInventory inventory, int id, NBTTagCompound nbt) { |  | ||||||
|         NBTTagList tagList = new NBTTagList(); |  | ||||||
|  |  | ||||||
|         for (int i = 0; i < inventory.getSizeInventory(); i++) { |  | ||||||
|             if (inventory.getStackInSlot(i) != null) { |  | ||||||
|                 NBTTagCompound compoundTag = new NBTTagCompound(); |  | ||||||
|  |  | ||||||
|                 compoundTag.setInteger(NBT_SLOT, i); |  | ||||||
|  |  | ||||||
|                 inventory.getStackInSlot(i).writeToNBT(compoundTag); |  | ||||||
|  |  | ||||||
|                 tagList.appendTag(compoundTag); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         nbt.setTag(String.format(NBT_INVENTORY, id), tagList); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public static void readItemsLegacy(IInventory inventory, 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)); |  | ||||||
|  |  | ||||||
|                 inventory.setInventorySlotContents(slot, stack); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public static IItemHandler getItemHandler(TileEntity tile, EnumFacing side) { |  | ||||||
|         if (tile == null) { |  | ||||||
|             return null; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         IItemHandler handler = tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side) ? tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side) : null; |  | ||||||
|  |  | ||||||
|         if (handler == null) { |  | ||||||
|             if (side != null && tile instanceof ISidedInventory) { |  | ||||||
|                 handler = new SidedInvWrapper((ISidedInventory) tile, side); |  | ||||||
|             } else if (tile instanceof IInventory) { |  | ||||||
|                 handler = new InvWrapper((IInventory) tile); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return handler; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @SuppressWarnings("deprecation") |  | ||||||
|     protected IFluidHandler getFluidHandler(TileEntity tile, EnumFacing side) { |  | ||||||
|         if (tile == null) { |  | ||||||
|             return null; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         IFluidHandler handler = null; |  | ||||||
|  |  | ||||||
|         if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) { |  | ||||||
|             handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side); |  | ||||||
|         } else if (tile instanceof net.minecraftforge.fluids.IFluidHandler) { |  | ||||||
|             handler = new FluidHandlerWrapper((net.minecraftforge.fluids.IFluidHandler) tile, side); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return handler; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean equals(Object o) { |     public boolean equals(Object o) { | ||||||
|         return o instanceof TileBase && ((TileBase) o).getPos().equals(pos) && ((TileBase) o).getWorld().provider.getDimension() == worldObj.provider.getDimension(); |         return o instanceof TileBase && ((TileBase) o).getPos().equals(pos) && ((TileBase) o).getWorld().provider.getDimension() == worldObj.provider.getDimension(); | ||||||
|   | |||||||
| @@ -16,6 +16,7 @@ import net.minecraftforge.fluids.FluidStack; | |||||||
| import net.minecraftforge.items.CapabilityItemHandler; | import net.minecraftforge.items.CapabilityItemHandler; | ||||||
| import net.minecraftforge.items.IItemHandler; | import net.minecraftforge.items.IItemHandler; | ||||||
| import refinedstorage.RS; | import refinedstorage.RS; | ||||||
|  | import refinedstorage.RSUtils; | ||||||
| import refinedstorage.api.util.IComparer; | import refinedstorage.api.util.IComparer; | ||||||
| import refinedstorage.container.slot.SlotSpecimen; | import refinedstorage.container.slot.SlotSpecimen; | ||||||
| import refinedstorage.inventory.ItemHandlerBasic; | import refinedstorage.inventory.ItemHandlerBasic; | ||||||
| @@ -144,9 +145,9 @@ public class TileConstructor extends TileMultipartNode implements IComparable, I | |||||||
|             type = tag.getInteger(NBT_TYPE); |             type = tag.getInteger(NBT_TYPE); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         readItems(itemFilters, 0, tag); |         RSUtils.readItems(itemFilters, 0, tag); | ||||||
|         readItems(upgrades, 1, tag); |         RSUtils.readItems(upgrades, 1, tag); | ||||||
|         readItems(fluidFilters, 2, tag); |         RSUtils.readItems(fluidFilters, 2, tag); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -156,9 +157,9 @@ public class TileConstructor extends TileMultipartNode implements IComparable, I | |||||||
|         tag.setInteger(NBT_COMPARE, compare); |         tag.setInteger(NBT_COMPARE, compare); | ||||||
|         tag.setInteger(NBT_TYPE, type); |         tag.setInteger(NBT_TYPE, type); | ||||||
|  |  | ||||||
|         writeItems(itemFilters, 0, tag); |         RSUtils.writeItems(itemFilters, 0, tag); | ||||||
|         writeItems(upgrades, 1, tag); |         RSUtils.writeItems(upgrades, 1, tag); | ||||||
|         writeItems(fluidFilters, 2, tag); |         RSUtils.writeItems(fluidFilters, 2, tag); | ||||||
|  |  | ||||||
|         return tag; |         return tag; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -9,6 +9,7 @@ import net.minecraftforge.items.CapabilityItemHandler; | |||||||
| import net.minecraftforge.items.IItemHandler; | import net.minecraftforge.items.IItemHandler; | ||||||
| import net.minecraftforge.items.wrapper.CombinedInvWrapper; | import net.minecraftforge.items.wrapper.CombinedInvWrapper; | ||||||
| import refinedstorage.RS; | import refinedstorage.RS; | ||||||
|  | import refinedstorage.RSUtils; | ||||||
| import refinedstorage.api.autocrafting.ICraftingPattern; | import refinedstorage.api.autocrafting.ICraftingPattern; | ||||||
| import refinedstorage.api.autocrafting.ICraftingPatternContainer; | import refinedstorage.api.autocrafting.ICraftingPatternContainer; | ||||||
| import refinedstorage.api.autocrafting.ICraftingPatternProvider; | import refinedstorage.api.autocrafting.ICraftingPatternProvider; | ||||||
| @@ -134,8 +135,8 @@ public class TileCrafter extends TileNode implements ICraftingPatternContainer { | |||||||
|             triggeredAutocrafting = tag.getBoolean(NBT_TRIGGERED_AUTOCRAFTING); |             triggeredAutocrafting = tag.getBoolean(NBT_TRIGGERED_AUTOCRAFTING); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         readItems(patterns, 0, tag); |         RSUtils.readItems(patterns, 0, tag); | ||||||
|         readItems(upgrades, 1, tag); |         RSUtils.readItems(upgrades, 1, tag); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -144,8 +145,8 @@ public class TileCrafter extends TileNode implements ICraftingPatternContainer { | |||||||
|  |  | ||||||
|         tag.setBoolean(NBT_TRIGGERED_AUTOCRAFTING, triggeredAutocrafting); |         tag.setBoolean(NBT_TRIGGERED_AUTOCRAFTING, triggeredAutocrafting); | ||||||
|  |  | ||||||
|         writeItems(patterns, 0, tag); |         RSUtils.writeItems(patterns, 0, tag); | ||||||
|         writeItems(upgrades, 1, tag); |         RSUtils.writeItems(upgrades, 1, tag); | ||||||
|  |  | ||||||
|         return tag; |         return tag; | ||||||
|     } |     } | ||||||
| @@ -157,7 +158,7 @@ public class TileCrafter extends TileNode implements ICraftingPatternContainer { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public IItemHandler getFacingInventory() { |     public IItemHandler getFacingInventory() { | ||||||
|         return getItemHandler(getFacingTile(), getDirection().getOpposite()); |         return RSUtils.getItemHandler(getFacingTile(), getDirection().getOpposite()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ import net.minecraftforge.fluids.capability.wrappers.FluidBlockWrapper; | |||||||
| import net.minecraftforge.items.CapabilityItemHandler; | import net.minecraftforge.items.CapabilityItemHandler; | ||||||
| import net.minecraftforge.items.IItemHandler; | import net.minecraftforge.items.IItemHandler; | ||||||
| import refinedstorage.RS; | import refinedstorage.RS; | ||||||
|  | import refinedstorage.RSUtils; | ||||||
| import refinedstorage.api.util.IComparer; | import refinedstorage.api.util.IComparer; | ||||||
| import refinedstorage.inventory.ItemHandlerBasic; | import refinedstorage.inventory.ItemHandlerBasic; | ||||||
| import refinedstorage.inventory.ItemHandlerFluid; | import refinedstorage.inventory.ItemHandlerFluid; | ||||||
| @@ -166,9 +167,9 @@ public class TileDestructor extends TileMultipartNode implements IComparable, IF | |||||||
|             type = tag.getInteger(NBT_TYPE); |             type = tag.getInteger(NBT_TYPE); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         readItems(itemFilters, 0, tag); |         RSUtils.readItems(itemFilters, 0, tag); | ||||||
|         readItems(upgrades, 1, tag); |         RSUtils.readItems(upgrades, 1, tag); | ||||||
|         readItems(fluidFilters, 2, tag); |         RSUtils.readItems(fluidFilters, 2, tag); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -179,9 +180,9 @@ public class TileDestructor extends TileMultipartNode implements IComparable, IF | |||||||
|         tag.setInteger(NBT_MODE, mode); |         tag.setInteger(NBT_MODE, mode); | ||||||
|         tag.setInteger(NBT_TYPE, type); |         tag.setInteger(NBT_TYPE, type); | ||||||
|  |  | ||||||
|         writeItems(itemFilters, 0, tag); |         RSUtils.writeItems(itemFilters, 0, tag); | ||||||
|         writeItems(upgrades, 1, tag); |         RSUtils.writeItems(upgrades, 1, tag); | ||||||
|         writeItems(fluidFilters, 2, tag); |         RSUtils.writeItems(fluidFilters, 2, tag); | ||||||
|  |  | ||||||
|         return tag; |         return tag; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -11,6 +11,7 @@ import net.minecraftforge.fml.relauncher.Side; | |||||||
| import net.minecraftforge.items.IItemHandler; | import net.minecraftforge.items.IItemHandler; | ||||||
| import refinedstorage.RS; | import refinedstorage.RS; | ||||||
| import refinedstorage.RSBlocks; | import refinedstorage.RSBlocks; | ||||||
|  | import refinedstorage.RSUtils; | ||||||
| import refinedstorage.api.autocrafting.task.ICraftingTask; | import refinedstorage.api.autocrafting.task.ICraftingTask; | ||||||
| import refinedstorage.api.network.INetworkMaster; | import refinedstorage.api.network.INetworkMaster; | ||||||
| import refinedstorage.api.util.IComparer; | import refinedstorage.api.util.IComparer; | ||||||
| @@ -231,8 +232,8 @@ public class TileDetector extends TileNode implements IComparable, IType { | |||||||
|             type = tag.getInteger(NBT_TYPE); |             type = tag.getInteger(NBT_TYPE); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         readItems(itemFilters, 0, tag); |         RSUtils.readItems(itemFilters, 0, tag); | ||||||
|         readItems(fluidFilters, 1, tag); |         RSUtils.readItems(fluidFilters, 1, tag); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -244,8 +245,8 @@ public class TileDetector extends TileNode implements IComparable, IType { | |||||||
|         tag.setInteger(NBT_AMOUNT, amount); |         tag.setInteger(NBT_AMOUNT, amount); | ||||||
|         tag.setInteger(NBT_TYPE, type); |         tag.setInteger(NBT_TYPE, type); | ||||||
|  |  | ||||||
|         writeItems(itemFilters, 0, tag); |         RSUtils.writeItems(itemFilters, 0, tag); | ||||||
|         writeItems(fluidFilters, 1, tag); |         RSUtils.writeItems(fluidFilters, 1, tag); | ||||||
|  |  | ||||||
|         return tag; |         return tag; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -216,9 +216,9 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl | |||||||
|     public void read(NBTTagCompound tag) { |     public void read(NBTTagCompound tag) { | ||||||
|         super.read(tag); |         super.read(tag); | ||||||
|  |  | ||||||
|         readItems(disks, 0, tag); |         RSUtils.readItems(disks, 0, tag); | ||||||
|         readItems(itemFilters, 1, tag); |         RSUtils.readItems(itemFilters, 1, tag); | ||||||
|         readItems(fluidFilters, 2, tag); |         RSUtils.readItems(fluidFilters, 2, tag); | ||||||
|  |  | ||||||
|         if (tag.hasKey(NBT_PRIORITY)) { |         if (tag.hasKey(NBT_PRIORITY)) { | ||||||
|             priority = tag.getInteger(NBT_PRIORITY); |             priority = tag.getInteger(NBT_PRIORITY); | ||||||
| @@ -251,9 +251,9 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         writeItems(disks, 0, tag); |         RSUtils.writeItems(disks, 0, tag); | ||||||
|         writeItems(itemFilters, 1, tag); |         RSUtils.writeItems(itemFilters, 1, tag); | ||||||
|         writeItems(fluidFilters, 2, tag); |         RSUtils.writeItems(fluidFilters, 2, tag); | ||||||
|  |  | ||||||
|         tag.setInteger(NBT_PRIORITY, priority); |         tag.setInteger(NBT_PRIORITY, priority); | ||||||
|         tag.setInteger(NBT_COMPARE, compare); |         tag.setInteger(NBT_COMPARE, compare); | ||||||
|   | |||||||
| @@ -456,10 +456,10 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte | |||||||
|     public void read(NBTTagCompound tag) { |     public void read(NBTTagCompound tag) { | ||||||
|         super.read(tag); |         super.read(tag); | ||||||
|  |  | ||||||
|         readItems(disks, 0, tag); |         RSUtils.readItems(disks, 0, tag); | ||||||
|         readItems(itemFilters, 1, tag); |         RSUtils.readItems(itemFilters, 1, tag); | ||||||
|         readItems(fluidFilters, 2, tag); |         RSUtils.readItems(fluidFilters, 2, tag); | ||||||
|         readItems(upgrades, 3, tag); |         RSUtils.readItems(upgrades, 3, tag); | ||||||
|  |  | ||||||
|         if (tag.hasKey(NBT_COMPARE)) { |         if (tag.hasKey(NBT_COMPARE)) { | ||||||
|             compare = tag.getInteger(NBT_COMPARE); |             compare = tag.getInteger(NBT_COMPARE); | ||||||
| @@ -482,10 +482,10 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte | |||||||
|     public NBTTagCompound write(NBTTagCompound tag) { |     public NBTTagCompound write(NBTTagCompound tag) { | ||||||
|         super.write(tag); |         super.write(tag); | ||||||
|  |  | ||||||
|         writeItems(disks, 0, tag); |         RSUtils.writeItems(disks, 0, tag); | ||||||
|         writeItems(itemFilters, 1, tag); |         RSUtils.writeItems(itemFilters, 1, tag); | ||||||
|         writeItems(fluidFilters, 2, tag); |         RSUtils.writeItems(fluidFilters, 2, tag); | ||||||
|         writeItems(upgrades, 3, tag); |         RSUtils.writeItems(upgrades, 3, tag); | ||||||
|  |  | ||||||
|         tag.setInteger(NBT_COMPARE, compare); |         tag.setInteger(NBT_COMPARE, compare); | ||||||
|         tag.setInteger(NBT_MODE, mode); |         tag.setInteger(NBT_MODE, mode); | ||||||
|   | |||||||
| @@ -12,6 +12,7 @@ import net.minecraftforge.items.CapabilityItemHandler; | |||||||
| import net.minecraftforge.items.IItemHandler; | import net.minecraftforge.items.IItemHandler; | ||||||
| import net.minecraftforge.items.ItemHandlerHelper; | import net.minecraftforge.items.ItemHandlerHelper; | ||||||
| import refinedstorage.RS; | import refinedstorage.RS; | ||||||
|  | import refinedstorage.RSUtils; | ||||||
| import refinedstorage.api.util.IComparer; | import refinedstorage.api.util.IComparer; | ||||||
| import refinedstorage.inventory.ItemHandlerBasic; | import refinedstorage.inventory.ItemHandlerBasic; | ||||||
| import refinedstorage.inventory.ItemHandlerFluid; | import refinedstorage.inventory.ItemHandlerFluid; | ||||||
| @@ -57,7 +58,7 @@ public class TileExporter extends TileMultipartNode implements IComparable, ITyp | |||||||
|             int size = upgrades.hasUpgrade(ItemUpgrade.TYPE_STACK) ? 64 : 1; |             int size = upgrades.hasUpgrade(ItemUpgrade.TYPE_STACK) ? 64 : 1; | ||||||
|  |  | ||||||
|             if (type == IType.ITEMS) { |             if (type == IType.ITEMS) { | ||||||
|                 IItemHandler handler = getItemHandler(getFacingTile(), getDirection().getOpposite()); |                 IItemHandler handler = RSUtils.getItemHandler(getFacingTile(), getDirection().getOpposite()); | ||||||
|  |  | ||||||
|                 if (handler != null) { |                 if (handler != null) { | ||||||
|                     for (int i = 0; i < itemFilters.getSlots(); ++i) { |                     for (int i = 0; i < itemFilters.getSlots(); ++i) { | ||||||
| @@ -79,7 +80,7 @@ public class TileExporter extends TileMultipartNode implements IComparable, ITyp | |||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } else if (type == IType.FLUIDS) { |             } else if (type == IType.FLUIDS) { | ||||||
|                 IFluidHandler handler = getFluidHandler(getFacingTile(), getDirection().getOpposite()); |                 IFluidHandler handler = RSUtils.getFluidHandler(getFacingTile(), getDirection().getOpposite()); | ||||||
|  |  | ||||||
|                 if (handler != null) { |                 if (handler != null) { | ||||||
|                     for (FluidStack stack : fluidFilters.getFluids()) { |                     for (FluidStack stack : fluidFilters.getFluids()) { | ||||||
| @@ -130,9 +131,9 @@ public class TileExporter extends TileMultipartNode implements IComparable, ITyp | |||||||
|             type = tag.getInteger(NBT_TYPE); |             type = tag.getInteger(NBT_TYPE); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         readItems(itemFilters, 0, tag); |         RSUtils.readItems(itemFilters, 0, tag); | ||||||
|         readItems(upgrades, 1, tag); |         RSUtils.readItems(upgrades, 1, tag); | ||||||
|         readItems(fluidFilters, 2, tag); |         RSUtils.readItems(fluidFilters, 2, tag); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -142,9 +143,9 @@ public class TileExporter extends TileMultipartNode implements IComparable, ITyp | |||||||
|         tag.setInteger(NBT_COMPARE, compare); |         tag.setInteger(NBT_COMPARE, compare); | ||||||
|         tag.setInteger(NBT_TYPE, type); |         tag.setInteger(NBT_TYPE, type); | ||||||
|  |  | ||||||
|         writeItems(itemFilters, 0, tag); |         RSUtils.writeItems(itemFilters, 0, tag); | ||||||
|         writeItems(upgrades, 1, tag); |         RSUtils.writeItems(upgrades, 1, tag); | ||||||
|         writeItems(fluidFilters, 2, tag); |         RSUtils.writeItems(fluidFilters, 2, tag); | ||||||
|  |  | ||||||
|         return tag; |         return tag; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -9,6 +9,7 @@ import net.minecraftforge.fluids.FluidStack; | |||||||
| import net.minecraftforge.fluids.FluidTank; | import net.minecraftforge.fluids.FluidTank; | ||||||
| import net.minecraftforge.fluids.capability.CapabilityFluidHandler; | import net.minecraftforge.fluids.capability.CapabilityFluidHandler; | ||||||
| import refinedstorage.RS; | import refinedstorage.RS; | ||||||
|  | import refinedstorage.RSUtils; | ||||||
| import refinedstorage.api.util.IComparer; | import refinedstorage.api.util.IComparer; | ||||||
| import refinedstorage.apiimpl.storage.fluid.FluidUtils; | import refinedstorage.apiimpl.storage.fluid.FluidUtils; | ||||||
| import refinedstorage.inventory.ItemHandlerBasic; | import refinedstorage.inventory.ItemHandlerBasic; | ||||||
| @@ -165,9 +166,9 @@ public class TileFluidInterface extends TileNode implements IComparable { | |||||||
|     public NBTTagCompound write(NBTTagCompound tag) { |     public NBTTagCompound write(NBTTagCompound tag) { | ||||||
|         super.write(tag); |         super.write(tag); | ||||||
|  |  | ||||||
|         writeItems(upgrades, 0, tag); |         RSUtils.writeItems(upgrades, 0, tag); | ||||||
|         writeItems(in, 1, tag); |         RSUtils.writeItems(in, 1, tag); | ||||||
|         writeItems(out, 2, tag); |         RSUtils.writeItems(out, 2, tag); | ||||||
|  |  | ||||||
|         tag.setTag(NBT_TANK_IN, tankIn.writeToNBT(new NBTTagCompound())); |         tag.setTag(NBT_TANK_IN, tankIn.writeToNBT(new NBTTagCompound())); | ||||||
|         tag.setTag(NBT_TANK_OUT, tankOut.writeToNBT(new NBTTagCompound())); |         tag.setTag(NBT_TANK_OUT, tankOut.writeToNBT(new NBTTagCompound())); | ||||||
| @@ -181,9 +182,9 @@ public class TileFluidInterface extends TileNode implements IComparable { | |||||||
|     public void read(NBTTagCompound tag) { |     public void read(NBTTagCompound tag) { | ||||||
|         super.read(tag); |         super.read(tag); | ||||||
|  |  | ||||||
|         readItems(upgrades, 0, tag); |         RSUtils.readItems(upgrades, 0, tag); | ||||||
|         readItems(in, 1, tag); |         RSUtils.readItems(in, 1, tag); | ||||||
|         readItems(out, 2, tag); |         RSUtils.readItems(out, 2, tag); | ||||||
|  |  | ||||||
|         if (tag.hasKey(NBT_TANK_IN)) { |         if (tag.hasKey(NBT_TANK_IN)) { | ||||||
|             tankIn.readFromNBT(tag.getCompoundTag(NBT_TANK_IN)); |             tankIn.readFromNBT(tag.getCompoundTag(NBT_TANK_IN)); | ||||||
|   | |||||||
| @@ -5,6 +5,7 @@ import net.minecraft.network.datasync.DataSerializers; | |||||||
| import net.minecraftforge.fluids.FluidStack; | import net.minecraftforge.fluids.FluidStack; | ||||||
| import refinedstorage.RS; | import refinedstorage.RS; | ||||||
| import refinedstorage.RSBlocks; | import refinedstorage.RSBlocks; | ||||||
|  | import refinedstorage.RSUtils; | ||||||
| import refinedstorage.api.network.INetworkMaster; | import refinedstorage.api.network.INetworkMaster; | ||||||
| import refinedstorage.api.storage.fluid.IFluidStorage; | import refinedstorage.api.storage.fluid.IFluidStorage; | ||||||
| import refinedstorage.api.storage.fluid.IFluidStorageProvider; | import refinedstorage.api.storage.fluid.IFluidStorageProvider; | ||||||
| @@ -124,7 +125,7 @@ public class TileFluidStorage extends TileNode implements IFluidStorageProvider, | |||||||
|     public void read(NBTTagCompound tag) { |     public void read(NBTTagCompound tag) { | ||||||
|         super.read(tag); |         super.read(tag); | ||||||
|  |  | ||||||
|         readItems(filters, 0, tag); |         RSUtils.readItems(filters, 0, tag); | ||||||
|  |  | ||||||
|         if (tag.hasKey(NBT_PRIORITY)) { |         if (tag.hasKey(NBT_PRIORITY)) { | ||||||
|             priority = tag.getInteger(NBT_PRIORITY); |             priority = tag.getInteger(NBT_PRIORITY); | ||||||
| @@ -147,7 +148,7 @@ public class TileFluidStorage extends TileNode implements IFluidStorageProvider, | |||||||
|     public NBTTagCompound write(NBTTagCompound tag) { |     public NBTTagCompound write(NBTTagCompound tag) { | ||||||
|         super.write(tag); |         super.write(tag); | ||||||
|  |  | ||||||
|         writeItems(filters, 0, tag); |         RSUtils.writeItems(filters, 0, tag); | ||||||
|  |  | ||||||
|         tag.setInteger(NBT_PRIORITY, priority); |         tag.setInteger(NBT_PRIORITY, priority); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -11,6 +11,7 @@ import net.minecraftforge.fluids.capability.IFluidHandler; | |||||||
| import net.minecraftforge.items.CapabilityItemHandler; | import net.minecraftforge.items.CapabilityItemHandler; | ||||||
| import net.minecraftforge.items.IItemHandler; | import net.minecraftforge.items.IItemHandler; | ||||||
| import refinedstorage.RS; | import refinedstorage.RS; | ||||||
|  | import refinedstorage.RSUtils; | ||||||
| import refinedstorage.api.util.IComparer; | import refinedstorage.api.util.IComparer; | ||||||
| import refinedstorage.inventory.ItemHandlerBasic; | import refinedstorage.inventory.ItemHandlerBasic; | ||||||
| import refinedstorage.inventory.ItemHandlerFluid; | import refinedstorage.inventory.ItemHandlerFluid; | ||||||
| @@ -62,7 +63,7 @@ public class TileImporter extends TileMultipartNode implements IComparable, IFil | |||||||
|         int size = upgrades.hasUpgrade(ItemUpgrade.TYPE_STACK) ? 64 : 1; |         int size = upgrades.hasUpgrade(ItemUpgrade.TYPE_STACK) ? 64 : 1; | ||||||
|  |  | ||||||
|         if (type == IType.ITEMS) { |         if (type == IType.ITEMS) { | ||||||
|             IItemHandler handler = getItemHandler(getFacingTile(), getDirection().getOpposite()); |             IItemHandler handler = RSUtils.getItemHandler(getFacingTile(), getDirection().getOpposite()); | ||||||
|  |  | ||||||
|             if (getFacingTile() instanceof TileDiskDrive || handler == null) { |             if (getFacingTile() instanceof TileDiskDrive || handler == null) { | ||||||
|                 return; |                 return; | ||||||
| @@ -90,7 +91,7 @@ public class TileImporter extends TileMultipartNode implements IComparable, IFil | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } else if (type == IType.FLUIDS && ticks % upgrades.getSpeed() == 0) { |         } else if (type == IType.FLUIDS && ticks % upgrades.getSpeed() == 0) { | ||||||
|             IFluidHandler handler = getFluidHandler(getFacingTile(), getDirection().getOpposite()); |             IFluidHandler handler = RSUtils.getFluidHandler(getFacingTile(), getDirection().getOpposite()); | ||||||
|  |  | ||||||
|             if (handler != null) { |             if (handler != null) { | ||||||
|                 FluidStack stack = handler.drain(Fluid.BUCKET_VOLUME, false); |                 FluidStack stack = handler.drain(Fluid.BUCKET_VOLUME, false); | ||||||
| @@ -146,9 +147,9 @@ public class TileImporter extends TileMultipartNode implements IComparable, IFil | |||||||
|             type = tag.getInteger(NBT_TYPE); |             type = tag.getInteger(NBT_TYPE); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         readItems(itemFilters, 0, tag); |         RSUtils.readItems(itemFilters, 0, tag); | ||||||
|         readItems(upgrades, 1, tag); |         RSUtils.readItems(upgrades, 1, tag); | ||||||
|         readItems(fluidFilters, 2, tag); |         RSUtils.readItems(fluidFilters, 2, tag); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -159,9 +160,9 @@ public class TileImporter extends TileMultipartNode implements IComparable, IFil | |||||||
|         tag.setInteger(NBT_MODE, mode); |         tag.setInteger(NBT_MODE, mode); | ||||||
|         tag.setInteger(NBT_TYPE, type); |         tag.setInteger(NBT_TYPE, type); | ||||||
|  |  | ||||||
|         writeItems(itemFilters, 0, tag); |         RSUtils.writeItems(itemFilters, 0, tag); | ||||||
|         writeItems(upgrades, 1, tag); |         RSUtils.writeItems(upgrades, 1, tag); | ||||||
|         writeItems(fluidFilters, 2, tag); |         RSUtils.writeItems(fluidFilters, 2, tag); | ||||||
|  |  | ||||||
|         return tag; |         return tag; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -8,6 +8,7 @@ import net.minecraftforge.items.CapabilityItemHandler; | |||||||
| import net.minecraftforge.items.IItemHandler; | import net.minecraftforge.items.IItemHandler; | ||||||
| import net.minecraftforge.items.wrapper.CombinedInvWrapper; | import net.minecraftforge.items.wrapper.CombinedInvWrapper; | ||||||
| import refinedstorage.RS; | import refinedstorage.RS; | ||||||
|  | import refinedstorage.RSUtils; | ||||||
| import refinedstorage.api.util.IComparer; | import refinedstorage.api.util.IComparer; | ||||||
| import refinedstorage.inventory.ItemHandlerBasic; | import refinedstorage.inventory.ItemHandlerBasic; | ||||||
| import refinedstorage.inventory.ItemHandlerUpgrade; | import refinedstorage.inventory.ItemHandlerUpgrade; | ||||||
| @@ -125,10 +126,10 @@ public class TileInterface extends TileNode implements IComparable { | |||||||
|     public void read(NBTTagCompound tag) { |     public void read(NBTTagCompound tag) { | ||||||
|         super.read(tag); |         super.read(tag); | ||||||
|  |  | ||||||
|         readItems(importItems, 0, tag); |         RSUtils.readItems(importItems, 0, tag); | ||||||
|         readItems(exportSpecimenItems, 1, tag); |         RSUtils.readItems(exportSpecimenItems, 1, tag); | ||||||
|         readItems(exportItems, 2, tag); |         RSUtils.readItems(exportItems, 2, tag); | ||||||
|         readItems(upgrades, 3, tag); |         RSUtils.readItems(upgrades, 3, tag); | ||||||
|  |  | ||||||
|         if (tag.hasKey(NBT_COMPARE)) { |         if (tag.hasKey(NBT_COMPARE)) { | ||||||
|             compare = tag.getInteger(NBT_COMPARE); |             compare = tag.getInteger(NBT_COMPARE); | ||||||
| @@ -139,10 +140,10 @@ public class TileInterface extends TileNode implements IComparable { | |||||||
|     public NBTTagCompound write(NBTTagCompound tag) { |     public NBTTagCompound write(NBTTagCompound tag) { | ||||||
|         super.write(tag); |         super.write(tag); | ||||||
|  |  | ||||||
|         writeItems(importItems, 0, tag); |         RSUtils.writeItems(importItems, 0, tag); | ||||||
|         writeItems(exportSpecimenItems, 1, tag); |         RSUtils.writeItems(exportSpecimenItems, 1, tag); | ||||||
|         writeItems(exportItems, 2, tag); |         RSUtils.writeItems(exportItems, 2, tag); | ||||||
|         writeItems(upgrades, 3, tag); |         RSUtils.writeItems(upgrades, 3, tag); | ||||||
|  |  | ||||||
|         tag.setInteger(NBT_COMPARE, compare); |         tag.setInteger(NBT_COMPARE, compare); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -8,6 +8,7 @@ import net.minecraftforge.items.IItemHandler; | |||||||
| import net.minecraftforge.items.wrapper.CombinedInvWrapper; | import net.minecraftforge.items.wrapper.CombinedInvWrapper; | ||||||
| import refinedstorage.RS; | import refinedstorage.RS; | ||||||
| import refinedstorage.RSItems; | import refinedstorage.RSItems; | ||||||
|  | import refinedstorage.RSUtils; | ||||||
| import refinedstorage.inventory.ItemHandlerBasic; | import refinedstorage.inventory.ItemHandlerBasic; | ||||||
| import refinedstorage.inventory.ItemHandlerUpgrade; | import refinedstorage.inventory.ItemHandlerUpgrade; | ||||||
| import refinedstorage.inventory.ItemValidatorBasic; | import refinedstorage.inventory.ItemValidatorBasic; | ||||||
| @@ -92,8 +93,8 @@ public class TileNetworkTransmitter extends TileNode { | |||||||
|     public NBTTagCompound write(NBTTagCompound tag) { |     public NBTTagCompound write(NBTTagCompound tag) { | ||||||
|         super.write(tag); |         super.write(tag); | ||||||
|  |  | ||||||
|         writeItems(networkCard, 0, tag); |         RSUtils.writeItems(networkCard, 0, tag); | ||||||
|         writeItems(upgrades, 1, tag); |         RSUtils.writeItems(upgrades, 1, tag); | ||||||
|  |  | ||||||
|         return tag; |         return tag; | ||||||
|     } |     } | ||||||
| @@ -102,8 +103,8 @@ public class TileNetworkTransmitter extends TileNode { | |||||||
|     public void read(NBTTagCompound tag) { |     public void read(NBTTagCompound tag) { | ||||||
|         super.read(tag); |         super.read(tag); | ||||||
|  |  | ||||||
|         readItems(networkCard, 0, tag); |         RSUtils.readItems(networkCard, 0, tag); | ||||||
|         readItems(upgrades, 1, tag); |         RSUtils.readItems(upgrades, 1, tag); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -8,6 +8,7 @@ import net.minecraftforge.items.CapabilityItemHandler; | |||||||
| import net.minecraftforge.items.IItemHandler; | import net.minecraftforge.items.IItemHandler; | ||||||
| import net.minecraftforge.items.ItemHandlerHelper; | import net.minecraftforge.items.ItemHandlerHelper; | ||||||
| import refinedstorage.RSItems; | import refinedstorage.RSItems; | ||||||
|  | import refinedstorage.RSUtils; | ||||||
| import refinedstorage.inventory.ItemHandlerBasic; | import refinedstorage.inventory.ItemHandlerBasic; | ||||||
| import refinedstorage.inventory.ItemValidatorBasic; | import refinedstorage.inventory.ItemValidatorBasic; | ||||||
| import refinedstorage.item.ItemPattern; | import refinedstorage.item.ItemPattern; | ||||||
| @@ -20,8 +21,8 @@ public class TileProcessingPatternEncoder extends TileBase { | |||||||
|     public NBTTagCompound write(NBTTagCompound tag) { |     public NBTTagCompound write(NBTTagCompound tag) { | ||||||
|         super.write(tag); |         super.write(tag); | ||||||
|  |  | ||||||
|         writeItems(patterns, 0, tag); |         RSUtils.writeItems(patterns, 0, tag); | ||||||
|         writeItems(configuration, 1, tag); |         RSUtils.writeItems(configuration, 1, tag); | ||||||
|  |  | ||||||
|         return tag; |         return tag; | ||||||
|     } |     } | ||||||
| @@ -30,8 +31,8 @@ public class TileProcessingPatternEncoder extends TileBase { | |||||||
|     public void read(NBTTagCompound tag) { |     public void read(NBTTagCompound tag) { | ||||||
|         super.read(tag); |         super.read(tag); | ||||||
|  |  | ||||||
|         readItems(patterns, 0, tag); |         RSUtils.readItems(patterns, 0, tag); | ||||||
|         readItems(configuration, 1, tag); |         RSUtils.readItems(configuration, 1, tag); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void onCreatePattern() { |     public void onCreatePattern() { | ||||||
|   | |||||||
| @@ -9,6 +9,7 @@ import net.minecraftforge.items.CapabilityItemHandler; | |||||||
| import net.minecraftforge.items.IItemHandler; | import net.minecraftforge.items.IItemHandler; | ||||||
| import net.minecraftforge.items.wrapper.CombinedInvWrapper; | import net.minecraftforge.items.wrapper.CombinedInvWrapper; | ||||||
| import refinedstorage.RS; | import refinedstorage.RS; | ||||||
|  | import refinedstorage.RSUtils; | ||||||
| import refinedstorage.api.network.INetworkMaster; | import refinedstorage.api.network.INetworkMaster; | ||||||
| import refinedstorage.api.solderer.ISoldererRecipe; | import refinedstorage.api.solderer.ISoldererRecipe; | ||||||
| import refinedstorage.apiimpl.API; | import refinedstorage.apiimpl.API; | ||||||
| @@ -152,9 +153,9 @@ public class TileSolderer extends TileNode { | |||||||
|     public void read(NBTTagCompound tag) { |     public void read(NBTTagCompound tag) { | ||||||
|         super.read(tag); |         super.read(tag); | ||||||
|  |  | ||||||
|         readItems(items, 0, tag); |         RSUtils.readItems(items, 0, tag); | ||||||
|         readItems(upgrades, 1, tag); |         RSUtils.readItems(upgrades, 1, tag); | ||||||
|         readItems(result, 2, tag); |         RSUtils.readItems(result, 2, tag); | ||||||
|  |  | ||||||
|         recipe = API.instance().getSoldererRegistry().getRecipe(items); |         recipe = API.instance().getSoldererRegistry().getRecipe(items); | ||||||
|  |  | ||||||
| @@ -171,9 +172,9 @@ public class TileSolderer extends TileNode { | |||||||
|     public NBTTagCompound write(NBTTagCompound tag) { |     public NBTTagCompound write(NBTTagCompound tag) { | ||||||
|         super.write(tag); |         super.write(tag); | ||||||
|  |  | ||||||
|         writeItems(items, 0, tag); |         RSUtils.writeItems(items, 0, tag); | ||||||
|         writeItems(upgrades, 1, tag); |         RSUtils.writeItems(upgrades, 1, tag); | ||||||
|         writeItems(result, 2, tag); |         RSUtils.writeItems(result, 2, tag); | ||||||
|  |  | ||||||
|         tag.setBoolean(NBT_WORKING, working); |         tag.setBoolean(NBT_WORKING, working); | ||||||
|         tag.setInteger(NBT_PROGRESS, progress); |         tag.setInteger(NBT_PROGRESS, progress); | ||||||
|   | |||||||
| @@ -6,6 +6,7 @@ import net.minecraft.network.datasync.DataSerializers; | |||||||
| import net.minecraftforge.items.ItemHandlerHelper; | import net.minecraftforge.items.ItemHandlerHelper; | ||||||
| import refinedstorage.RS; | import refinedstorage.RS; | ||||||
| import refinedstorage.RSBlocks; | import refinedstorage.RSBlocks; | ||||||
|  | import refinedstorage.RSUtils; | ||||||
| import refinedstorage.api.network.INetworkMaster; | import refinedstorage.api.network.INetworkMaster; | ||||||
| import refinedstorage.api.storage.item.IItemStorage; | import refinedstorage.api.storage.item.IItemStorage; | ||||||
| import refinedstorage.api.storage.item.IItemStorageProvider; | import refinedstorage.api.storage.item.IItemStorageProvider; | ||||||
| @@ -136,7 +137,7 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor | |||||||
|     public void read(NBTTagCompound tag) { |     public void read(NBTTagCompound tag) { | ||||||
|         super.read(tag); |         super.read(tag); | ||||||
|  |  | ||||||
|         readItems(filters, 0, tag); |         RSUtils.readItems(filters, 0, tag); | ||||||
|  |  | ||||||
|         if (tag.hasKey(NBT_PRIORITY)) { |         if (tag.hasKey(NBT_PRIORITY)) { | ||||||
|             priority = tag.getInteger(NBT_PRIORITY); |             priority = tag.getInteger(NBT_PRIORITY); | ||||||
| @@ -163,7 +164,7 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor | |||||||
|     public NBTTagCompound write(NBTTagCompound tag) { |     public NBTTagCompound write(NBTTagCompound tag) { | ||||||
|         super.write(tag); |         super.write(tag); | ||||||
|  |  | ||||||
|         writeItems(filters, 0, tag); |         RSUtils.writeItems(filters, 0, tag); | ||||||
|  |  | ||||||
|         tag.setInteger(NBT_PRIORITY, priority); |         tag.setInteger(NBT_PRIORITY, priority); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -8,6 +8,7 @@ import net.minecraftforge.common.capabilities.Capability; | |||||||
| import net.minecraftforge.items.CapabilityItemHandler; | import net.minecraftforge.items.CapabilityItemHandler; | ||||||
| import net.minecraftforge.items.IItemHandler; | import net.minecraftforge.items.IItemHandler; | ||||||
| import refinedstorage.RS; | import refinedstorage.RS; | ||||||
|  | import refinedstorage.RSUtils; | ||||||
| import refinedstorage.api.network.IWirelessTransmitter; | import refinedstorage.api.network.IWirelessTransmitter; | ||||||
| import refinedstorage.inventory.ItemHandlerBasic; | import refinedstorage.inventory.ItemHandlerBasic; | ||||||
| import refinedstorage.inventory.ItemHandlerUpgrade; | import refinedstorage.inventory.ItemHandlerUpgrade; | ||||||
| @@ -42,14 +43,14 @@ public class TileWirelessTransmitter extends TileNode implements IWirelessTransm | |||||||
|     public void read(NBTTagCompound tag) { |     public void read(NBTTagCompound tag) { | ||||||
|         super.read(tag); |         super.read(tag); | ||||||
|  |  | ||||||
|         readItems(upgrades, 0, tag); |         RSUtils.readItems(upgrades, 0, tag); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public NBTTagCompound write(NBTTagCompound tag) { |     public NBTTagCompound write(NBTTagCompound tag) { | ||||||
|         super.write(tag); |         super.write(tag); | ||||||
|  |  | ||||||
|         writeItems(upgrades, 0, tag); |         RSUtils.writeItems(upgrades, 0, tag); | ||||||
|  |  | ||||||
|         return tag; |         return tag; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -11,6 +11,7 @@ import net.minecraftforge.fluids.capability.IFluidTankProperties; | |||||||
| import net.minecraftforge.items.IItemHandler; | import net.minecraftforge.items.IItemHandler; | ||||||
| import powercrystals.minefactoryreloaded.api.IDeepStorageUnit; | import powercrystals.minefactoryreloaded.api.IDeepStorageUnit; | ||||||
| import refinedstorage.RS; | import refinedstorage.RS; | ||||||
|  | import refinedstorage.RSUtils; | ||||||
| import refinedstorage.api.network.INetworkMaster; | import refinedstorage.api.network.INetworkMaster; | ||||||
| import refinedstorage.api.storage.fluid.IFluidStorage; | import refinedstorage.api.storage.fluid.IFluidStorage; | ||||||
| import refinedstorage.api.storage.fluid.IFluidStorageProvider; | import refinedstorage.api.storage.fluid.IFluidStorageProvider; | ||||||
| @@ -161,8 +162,8 @@ public class TileExternalStorage extends TileMultipartNode implements IItemStora | |||||||
|     public void read(NBTTagCompound tag) { |     public void read(NBTTagCompound tag) { | ||||||
|         super.read(tag); |         super.read(tag); | ||||||
|  |  | ||||||
|         readItems(itemFilters, 0, tag); |         RSUtils.readItems(itemFilters, 0, tag); | ||||||
|         readItems(fluidFilters, 1, tag); |         RSUtils.readItems(fluidFilters, 1, tag); | ||||||
|  |  | ||||||
|         if (tag.hasKey(NBT_PRIORITY)) { |         if (tag.hasKey(NBT_PRIORITY)) { | ||||||
|             priority = tag.getInteger(NBT_PRIORITY); |             priority = tag.getInteger(NBT_PRIORITY); | ||||||
| @@ -185,8 +186,8 @@ public class TileExternalStorage extends TileMultipartNode implements IItemStora | |||||||
|     public NBTTagCompound write(NBTTagCompound tag) { |     public NBTTagCompound write(NBTTagCompound tag) { | ||||||
|         super.write(tag); |         super.write(tag); | ||||||
|  |  | ||||||
|         writeItems(itemFilters, 0, tag); |         RSUtils.writeItems(itemFilters, 0, tag); | ||||||
|         writeItems(fluidFilters, 1, tag); |         RSUtils.writeItems(fluidFilters, 1, tag); | ||||||
|  |  | ||||||
|         tag.setInteger(NBT_PRIORITY, priority); |         tag.setInteger(NBT_PRIORITY, priority); | ||||||
|         tag.setInteger(NBT_COMPARE, compare); |         tag.setInteger(NBT_COMPARE, compare); | ||||||
| @@ -251,13 +252,13 @@ public class TileExternalStorage extends TileMultipartNode implements IItemStora | |||||||
|         } else if (facing instanceof IDeepStorageUnit) { |         } else if (facing instanceof IDeepStorageUnit) { | ||||||
|             itemStorages.add(new ItemStorageDSU(this, (IDeepStorageUnit) facing)); |             itemStorages.add(new ItemStorageDSU(this, (IDeepStorageUnit) facing)); | ||||||
|         } else { |         } else { | ||||||
|             IItemHandler itemHandler = getItemHandler(facing, getDirection().getOpposite()); |             IItemHandler itemHandler = RSUtils.getItemHandler(facing, getDirection().getOpposite()); | ||||||
|  |  | ||||||
|             if (itemHandler != null) { |             if (itemHandler != null) { | ||||||
|                 itemStorages.add(new ItemStorageItemHandler(this, itemHandler)); |                 itemStorages.add(new ItemStorageItemHandler(this, itemHandler)); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             IFluidHandler fluidHandler = getFluidHandler(facing, getDirection().getOpposite()); |             IFluidHandler fluidHandler = RSUtils.getFluidHandler(facing, getDirection().getOpposite()); | ||||||
|  |  | ||||||
|             if (fluidHandler != null) { |             if (fluidHandler != null) { | ||||||
|                 for (IFluidTankProperties property : fluidHandler.getTankProperties()) { |                 for (IFluidTankProperties property : fluidHandler.getTankProperties()) { | ||||||
|   | |||||||
| @@ -16,6 +16,7 @@ import net.minecraftforge.items.wrapper.InvWrapper; | |||||||
| import refinedstorage.RS; | import refinedstorage.RS; | ||||||
| import refinedstorage.RSBlocks; | import refinedstorage.RSBlocks; | ||||||
| import refinedstorage.RSItems; | import refinedstorage.RSItems; | ||||||
|  | import refinedstorage.RSUtils; | ||||||
| import refinedstorage.api.network.grid.IFluidGridHandler; | import refinedstorage.api.network.grid.IFluidGridHandler; | ||||||
| import refinedstorage.api.network.grid.IItemGridHandler; | import refinedstorage.api.network.grid.IItemGridHandler; | ||||||
| import refinedstorage.apiimpl.API; | import refinedstorage.apiimpl.API; | ||||||
| @@ -441,9 +442,9 @@ public class TileGrid extends TileNode implements IGrid { | |||||||
|     public void read(NBTTagCompound tag) { |     public void read(NBTTagCompound tag) { | ||||||
|         super.read(tag); |         super.read(tag); | ||||||
|  |  | ||||||
|         readItemsLegacy(matrix, 0, tag); |         RSUtils.readItemsLegacy(matrix, 0, tag); | ||||||
|         readItems(patterns, 1, tag); |         RSUtils.readItems(patterns, 1, tag); | ||||||
|         readItems(filter, 2, tag); |         RSUtils.readItems(filter, 2, tag); | ||||||
|  |  | ||||||
|         if (tag.hasKey(NBT_VIEW_TYPE)) { |         if (tag.hasKey(NBT_VIEW_TYPE)) { | ||||||
|             viewType = tag.getInteger(NBT_VIEW_TYPE); |             viewType = tag.getInteger(NBT_VIEW_TYPE); | ||||||
| @@ -466,9 +467,9 @@ public class TileGrid extends TileNode implements IGrid { | |||||||
|     public NBTTagCompound write(NBTTagCompound tag) { |     public NBTTagCompound write(NBTTagCompound tag) { | ||||||
|         super.write(tag); |         super.write(tag); | ||||||
|  |  | ||||||
|         writeItemsLegacy(matrix, 0, tag); |         RSUtils.writeItemsLegacy(matrix, 0, tag); | ||||||
|         writeItems(patterns, 1, tag); |         RSUtils.writeItems(patterns, 1, tag); | ||||||
|         writeItems(filter, 2, tag); |         RSUtils.writeItems(filter, 2, tag); | ||||||
|  |  | ||||||
|         tag.setInteger(NBT_VIEW_TYPE, viewType); |         tag.setInteger(NBT_VIEW_TYPE, viewType); | ||||||
|         tag.setInteger(NBT_SORTING_DIRECTION, sortingDirection); |         tag.setInteger(NBT_SORTING_DIRECTION, sortingDirection); | ||||||
|   | |||||||
| @@ -10,6 +10,7 @@ import net.minecraftforge.common.DimensionManager; | |||||||
| import net.minecraftforge.fml.common.FMLCommonHandler; | import net.minecraftforge.fml.common.FMLCommonHandler; | ||||||
| import net.minecraftforge.fml.relauncher.Side; | import net.minecraftforge.fml.relauncher.Side; | ||||||
| import refinedstorage.RS; | import refinedstorage.RS; | ||||||
|  | import refinedstorage.RSUtils; | ||||||
| import refinedstorage.api.network.grid.IFluidGridHandler; | import refinedstorage.api.network.grid.IFluidGridHandler; | ||||||
| import refinedstorage.api.network.grid.IItemGridHandler; | import refinedstorage.api.network.grid.IItemGridHandler; | ||||||
| import refinedstorage.block.EnumGridType; | import refinedstorage.block.EnumGridType; | ||||||
| @@ -19,7 +20,6 @@ import refinedstorage.inventory.ItemHandlerBasic; | |||||||
| import refinedstorage.inventory.ItemHandlerGridFilterInGrid; | import refinedstorage.inventory.ItemHandlerGridFilterInGrid; | ||||||
| import refinedstorage.item.ItemWirelessGrid; | import refinedstorage.item.ItemWirelessGrid; | ||||||
| import refinedstorage.network.MessageWirelessGridSettingsUpdate; | import refinedstorage.network.MessageWirelessGridSettingsUpdate; | ||||||
| import refinedstorage.tile.TileBase; |  | ||||||
| import refinedstorage.tile.TileController; | import refinedstorage.tile.TileController; | ||||||
| import refinedstorage.tile.data.TileDataParameter; | import refinedstorage.tile.data.TileDataParameter; | ||||||
|  |  | ||||||
| @@ -48,7 +48,7 @@ public class WirelessGrid implements IGrid { | |||||||
|                     stack.setTagCompound(new NBTTagCompound()); |                     stack.setTagCompound(new NBTTagCompound()); | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 TileBase.writeItems(this, slot, stack.getTagCompound()); |                 RSUtils.writeItems(this, slot, stack.getTagCompound()); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     }; |     }; | ||||||
| @@ -66,7 +66,7 @@ public class WirelessGrid implements IGrid { | |||||||
|  |  | ||||||
|         if (stack.hasTagCompound()) { |         if (stack.hasTagCompound()) { | ||||||
|             for (int i = 0; i < 4; ++i) { |             for (int i = 0; i < 4; ++i) { | ||||||
|                 TileBase.readItems(filter, i, stack.getTagCompound()); |                 RSUtils.readItems(filter, i, stack.getTagCompound()); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Raoul Van den Berge
					Raoul Van den Berge