From 202c562936c54627d7ba53201444682367a70a17 Mon Sep 17 00:00:00 2001 From: joflashstudios Date: Sat, 6 Jun 2015 17:36:45 -0400 Subject: [PATCH 01/16] Adding fix for #19 to semifluid and thermal generators. --- .../tiles/TileSemifluidGenerator.java | 17 +++++++++-------- .../techreborn/tiles/TileThermalGenerator.java | 12 +++++++++--- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/main/java/techreborn/tiles/TileSemifluidGenerator.java b/src/main/java/techreborn/tiles/TileSemifluidGenerator.java index f20d9be71..90322b56a 100644 --- a/src/main/java/techreborn/tiles/TileSemifluidGenerator.java +++ b/src/main/java/techreborn/tiles/TileSemifluidGenerator.java @@ -97,25 +97,26 @@ public class TileSemifluidGenerator extends TileEntity implements IWrenchable, @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { - int filled = tank.fill(resource, doFill); - return filled; + int fill = tank.fill(resource, doFill); + tank.compareAndUpdate(); + return fill; } @Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { - FluidStack drained = tank.drain(resource.amount, doDrain); - tank.compareAndUpdate(); - return drained; + FluidStack drain = tank.drain(resource.amount, doDrain); + tank.compareAndUpdate(); + return drain; } @Override public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - FluidStack drained = tank.drain(maxDrain, doDrain); - tank.compareAndUpdate(); - return drained; + FluidStack drain = tank.drain(maxDrain, doDrain); + tank.compareAndUpdate(); + return drain; } @Override diff --git a/src/main/java/techreborn/tiles/TileThermalGenerator.java b/src/main/java/techreborn/tiles/TileThermalGenerator.java index e5a2af385..f02659137 100644 --- a/src/main/java/techreborn/tiles/TileThermalGenerator.java +++ b/src/main/java/techreborn/tiles/TileThermalGenerator.java @@ -77,20 +77,26 @@ public class TileThermalGenerator extends TileEntity implements IWrenchable, @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { - return tank.fill(resource, doFill); + int fill = tank.fill(resource, doFill); + tank.compareAndUpdate(); + return fill; } @Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { - return tank.drain(resource.amount, doDrain); + FluidStack drain = tank.drain(resource.amount, doDrain); + tank.compareAndUpdate(); + return drain; } @Override public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - return tank.drain(maxDrain, doDrain); + FluidStack drain = tank.drain(maxDrain, doDrain); + tank.compareAndUpdate(); + return drain; } @Override From 03c1556935bbaa494d6b0563de09da0f44d4a835 Mon Sep 17 00:00:00 2001 From: Gig Date: Sat, 6 Jun 2015 23:20:30 +0100 Subject: [PATCH 02/16] Clean this b4 people kill me --- src/main/java/techreborn/Core.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/main/java/techreborn/Core.java b/src/main/java/techreborn/Core.java index 64dcef0b6..3cfcd4cd8 100644 --- a/src/main/java/techreborn/Core.java +++ b/src/main/java/techreborn/Core.java @@ -44,8 +44,7 @@ public class Core { public static Core INSTANCE; @Mod.EventHandler - public void preinit(FMLPreInitializationEvent event) - { + public void preinit(FMLPreInitializationEvent event){ INSTANCE = this; String path = event.getSuggestedConfigurationFile().getAbsolutePath() .replace(ModInfo.MOD_ID, "TechReborn"); @@ -55,8 +54,7 @@ public class Core { } @Mod.EventHandler - public void init(FMLInitializationEvent event) - { + public void init(FMLInitializationEvent event){ // Register ModBlocks ModBlocks.init(); // Register Fluids @@ -86,8 +84,7 @@ public class Core { } @Mod.EventHandler - public void postinit(FMLPostInitializationEvent event) - { + public void postinit(FMLPostInitializationEvent event){ // Has to be done here as Buildcraft registers there recipes late RecipeManager.init(); //Has to be done after the recipes have been added @@ -102,13 +99,9 @@ public class Core { } @SubscribeEvent - public void onConfigChanged( - ConfigChangedEvent.OnConfigChangedEvent cfgChange) - { + public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent cfgChange){ if (cfgChange.modID.equals("TechReborn")) { ConfigTechReborn.Configs(); - } } - } From 65bd20379126a4b0b69f3d3c86a0f0e0c86d93d8 Mon Sep 17 00:00:00 2001 From: Gig Date: Sun, 7 Jun 2015 00:00:15 +0100 Subject: [PATCH 03/16] All machines will drop Inventory after they Implement IInventory --- .../techreborn/blocks/BlockMachineBase.java | 53 ++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/src/main/java/techreborn/blocks/BlockMachineBase.java b/src/main/java/techreborn/blocks/BlockMachineBase.java index a02ecb9a4..190edbed6 100644 --- a/src/main/java/techreborn/blocks/BlockMachineBase.java +++ b/src/main/java/techreborn/blocks/BlockMachineBase.java @@ -1,12 +1,16 @@ package techreborn.blocks; +import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EnumCreatureType; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraft.world.World; @@ -102,4 +106,51 @@ public class BlockMachineBase extends BlockContainer { { return false; } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) + { + dropInventory(world, x, y, z); + super.breakBlock(world, x, y, z, block, meta); + } + + protected void dropInventory(World world, int x, int y, int z) + { + TileEntity tileEntity = world.getTileEntity(x, y, z); + + if (!(tileEntity instanceof IInventory)) + { + return; + } + + IInventory inventory = (IInventory) tileEntity; + + for (int i = 0; i < inventory.getSizeInventory(); i++) + { + ItemStack itemStack = inventory.getStackInSlot(i); + + if (itemStack != null && itemStack.stackSize > 0) + { + Random rand = new Random(); + + float dX = rand.nextFloat() * 0.8F + 0.1F; + float dY = rand.nextFloat() * 0.8F + 0.1F; + float dZ = rand.nextFloat() * 0.8F + 0.1F; + + EntityItem entityItem = new EntityItem(world, x + dX, y + dY, z + dZ, itemStack.copy()); + + if (itemStack.hasTagCompound()) + { + entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy()); + } + + float factor = 0.05F; + entityItem.motionX = rand.nextGaussian() * factor; + entityItem.motionY = rand.nextGaussian() * factor + 0.2F; + entityItem.motionZ = rand.nextGaussian() * factor; + world.spawnEntityInWorld(entityItem); + itemStack.stackSize = 0; + } + } + } } From 7cfaac1f61bfc8459aa5c46cbb7c37c9f65d2cdb Mon Sep 17 00:00:00 2001 From: joflashstudios Date: Sat, 6 Jun 2015 22:11:13 -0400 Subject: [PATCH 04/16] Added Digital Chest, Computer Monitor --- .../techreborn/blocks/BlockDigitalChest.java | 68 ++++ .../java/techreborn/client/GuiHandler.java | 11 + .../container/ContainerDigitalChest.java | 50 +++ .../client/gui/GuiDigitalChest.java | 49 +++ src/main/java/techreborn/init/ModBlocks.java | 6 + .../itemblocks/ItemBlockDigitalChest.java | 61 ++++ src/main/java/techreborn/items/ItemParts.java | 2 +- .../techreborn/tiles/TileDigitalChest.java | 291 ++++++++++++++++++ .../assets/techreborn/lang/en_US.lang | 2 + .../items/component/computerMonitor.png | Bin 0 -> 250 bytes 10 files changed, 539 insertions(+), 1 deletion(-) create mode 100644 src/main/java/techreborn/blocks/BlockDigitalChest.java create mode 100644 src/main/java/techreborn/client/container/ContainerDigitalChest.java create mode 100644 src/main/java/techreborn/client/gui/GuiDigitalChest.java create mode 100644 src/main/java/techreborn/itemblocks/ItemBlockDigitalChest.java create mode 100644 src/main/java/techreborn/tiles/TileDigitalChest.java create mode 100644 src/main/resources/assets/techreborn/textures/items/component/computerMonitor.png diff --git a/src/main/java/techreborn/blocks/BlockDigitalChest.java b/src/main/java/techreborn/blocks/BlockDigitalChest.java new file mode 100644 index 000000000..3040b3a80 --- /dev/null +++ b/src/main/java/techreborn/blocks/BlockDigitalChest.java @@ -0,0 +1,68 @@ +package techreborn.blocks; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import techreborn.Core; +import techreborn.client.GuiHandler; +import techreborn.tiles.TileDigitalChest; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BlockDigitalChest extends BlockMachineBase { + + @SideOnly(Side.CLIENT) + private IIcon iconFront; + + @SideOnly(Side.CLIENT) + private IIcon iconTop; + + @SideOnly(Side.CLIENT) + private IIcon iconBottom; + + public BlockDigitalChest() + { + super(Material.rock); + setBlockName("techreborn.DigitalChest"); + } + + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileDigitalChest(); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, + EntityPlayer player, int side, float hitX, float hitY, float hitZ) + { + if (!player.isSneaking()) + player.openGui(Core.INSTANCE, GuiHandler.digitalChestID, world, x, + y, z); + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister icon) + { + this.blockIcon = icon.registerIcon("techreborn:machine/machine_side"); + this.iconFront = icon.registerIcon("techreborn:machine/quantum_chest"); + this.iconTop = icon.registerIcon("techreborn:machine/quantum_top"); + this.iconBottom = icon.registerIcon("techreborn:machine/machine_bottom"); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int metadata) + { + + return metadata == 0 && side == 3 ? this.iconFront + : side == 1 ? this.iconTop : + side == 0 ? this.iconBottom: (side == 0 ? this.iconTop + : (side == metadata ? this.iconFront : this.blockIcon)); + + } +} diff --git a/src/main/java/techreborn/client/GuiHandler.java b/src/main/java/techreborn/client/GuiHandler.java index 099c04f89..2784692da 100644 --- a/src/main/java/techreborn/client/GuiHandler.java +++ b/src/main/java/techreborn/client/GuiHandler.java @@ -21,6 +21,7 @@ import techreborn.client.container.ContainerMatterFabricator; import techreborn.client.container.ContainerPlateCuttingMachine; import techreborn.client.container.ContainerQuantumChest; import techreborn.client.container.ContainerQuantumTank; +import techreborn.client.container.ContainerDigitalChest; import techreborn.client.container.ContainerRollingMachine; import techreborn.client.container.ContainerThermalGenerator; import techreborn.client.container.ContainerSemifluidGenerator; @@ -43,6 +44,7 @@ import techreborn.client.gui.GuiMatterFabricator; import techreborn.client.gui.GuiPlateCuttingMachine; import techreborn.client.gui.GuiQuantumChest; import techreborn.client.gui.GuiQuantumTank; +import techreborn.client.gui.GuiDigitalChest; import techreborn.client.gui.GuiRollingMachine; import techreborn.client.gui.GuiThermalGenerator; import techreborn.client.gui.GuiSemifluidGenerator; @@ -76,6 +78,7 @@ public class GuiHandler implements IGuiHandler { public static final int chemicalReactorID = 20; public static final int semifluidGeneratorID = 21; public static final int gasTurbineID = 22; + public static final int digitalChestID = 23; @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, @@ -97,6 +100,10 @@ public class GuiHandler implements IGuiHandler { { return new ContainerQuantumTank( (TileQuantumTank) world.getTileEntity(x, y, z), player); + } else if (ID == digitalChestID) + { + return new ContainerDigitalChest( + (TileDigitalChest) world.getTileEntity(x, y, z), player); } else if (ID == quantumChestID) { return new ContainerQuantumChest( @@ -197,6 +204,10 @@ public class GuiHandler implements IGuiHandler { { return new GuiQuantumTank(player, (TileQuantumTank) world.getTileEntity(x, y, z)); + } else if (ID == digitalChestID) + { + return new GuiDigitalChest(player, + (TileDigitalChest) world.getTileEntity(x, y, z)); } else if (ID == quantumChestID) { return new GuiQuantumChest(player, diff --git a/src/main/java/techreborn/client/container/ContainerDigitalChest.java b/src/main/java/techreborn/client/container/ContainerDigitalChest.java new file mode 100644 index 000000000..eca50334a --- /dev/null +++ b/src/main/java/techreborn/client/container/ContainerDigitalChest.java @@ -0,0 +1,50 @@ +package techreborn.client.container; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Slot; +import techreborn.client.SlotFake; +import techreborn.client.SlotOutput; +import techreborn.tiles.TileDigitalChest; + +public class ContainerDigitalChest extends TechRebornContainer { + public TileDigitalChest tileDigitalChest; + public EntityPlayer player; + + public ContainerDigitalChest(TileDigitalChest tileDigitalChest, + EntityPlayer player) + { + super(); + this.tileDigitalChest = tileDigitalChest; + this.player = player; + + this.addSlotToContainer(new Slot(tileDigitalChest.inventory, 0, 80, 17)); + this.addSlotToContainer(new SlotOutput(tileDigitalChest.inventory, 1, + 80, 53)); + this.addSlotToContainer(new SlotFake(tileDigitalChest.inventory, 2, 59, + 42, false, false, Integer.MAX_VALUE)); + + int i; + + for (i = 0; i < 3; ++i) + { + for (int j = 0; j < 9; ++j) + { + this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + + 9, 8 + j * 18, 84 + i * 18)); + } + } + + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, + 142)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer player) + { + return true; + } + +} \ No newline at end of file diff --git a/src/main/java/techreborn/client/gui/GuiDigitalChest.java b/src/main/java/techreborn/client/gui/GuiDigitalChest.java new file mode 100644 index 000000000..8739ce617 --- /dev/null +++ b/src/main/java/techreborn/client/gui/GuiDigitalChest.java @@ -0,0 +1,49 @@ +package techreborn.client.gui; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import techreborn.client.container.ContainerDigitalChest; +import techreborn.tiles.TileDigitalChest; + +public class GuiDigitalChest extends GuiContainer { + + private static final ResourceLocation texture = new ResourceLocation( + "techreborn", "textures/gui/ThermalGenerator.png"); + + TileDigitalChest tile; + + public GuiDigitalChest(EntityPlayer player, TileDigitalChest tile) + { + super(new ContainerDigitalChest(tile, player)); + this.xSize = 176; + this.ySize = 167; + this.tile = tile; + } + + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, + int p_146976_2_, int p_146976_3_) + { + this.mc.getTextureManager().bindTexture(texture); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + } + + protected void drawGuiContainerForegroundLayer(int p_146979_1_, + int p_146979_2_) + { + String name = StatCollector.translateToLocal("tile.techreborn.digitalChest.name"); + this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); + this.fontRendererObj.drawString( + I18n.format("container.inventory", new Object[0]), 8, + this.ySize - 96 + 2, 4210752); + this.fontRendererObj.drawString("Amount", 10, 20, 16448255); + if (tile.storedItem != null) + this.fontRendererObj.drawString(tile.storedItem.stackSize + "", 10, + 30, 16448255); + } +} diff --git a/src/main/java/techreborn/init/ModBlocks.java b/src/main/java/techreborn/init/ModBlocks.java index ecd75cca7..5c1e25cf9 100644 --- a/src/main/java/techreborn/init/ModBlocks.java +++ b/src/main/java/techreborn/init/ModBlocks.java @@ -57,6 +57,7 @@ import techreborn.tiles.TileMachineCasing; import techreborn.tiles.TileMatterFabricator; import techreborn.tiles.TilePlateCuttingMachine; import techreborn.tiles.TileQuantumChest; +import techreborn.tiles.TileDigitalChest; import techreborn.tiles.TileQuantumTank; import techreborn.tiles.TileRollingMachine; import techreborn.tiles.TileThermalGenerator; @@ -70,6 +71,7 @@ public class ModBlocks { public static Block thermalGenerator; public static Block quantumTank; public static Block quantumChest; + public static Block digitalChest; public static Block centrifuge; public static Block RollingMachine; public static Block MachineCasing; @@ -126,6 +128,10 @@ public class ModBlocks { quantumChest = new BlockQuantumChest(); GameRegistry.registerBlock(quantumChest, ItemBlockQuantumChest.class, "techreborn.quantumChest"); GameRegistry.registerTileEntity(TileQuantumChest.class, "TileQuantumChestTR"); + + digitalChest = new BlockDigitalChest(); + GameRegistry.registerBlock(digitalChest, ItemBlockDigitalChest.class, "techreborn.digitalChest"); + GameRegistry.registerTileEntity(TileDigitalChest.class, "TileDigitalChestTR"); centrifuge = new BlockCentrifuge(); GameRegistry.registerBlock(centrifuge, "techreborn.centrifuge"); diff --git a/src/main/java/techreborn/itemblocks/ItemBlockDigitalChest.java b/src/main/java/techreborn/itemblocks/ItemBlockDigitalChest.java new file mode 100644 index 000000000..3c5e6bcd4 --- /dev/null +++ b/src/main/java/techreborn/itemblocks/ItemBlockDigitalChest.java @@ -0,0 +1,61 @@ +package techreborn.itemblocks; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import techreborn.init.ModBlocks; +import techreborn.tiles.TileDigitalChest; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ItemBlockDigitalChest extends ItemBlock { + + public ItemBlockDigitalChest(Block p_i45328_1_) + { + super(p_i45328_1_); + } + + @SuppressWarnings( + { "rawtypes", "unchecked" }) + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, + boolean par4) + { + if (stack != null && stack.hasTagCompound()) + { + if (stack.getTagCompound().getCompoundTag("tileEntity") != null) + list.add(stack.getTagCompound().getCompoundTag("tileEntity") + .getInteger("storedQuantity") + + " items"); + } + } + + @Override + public boolean placeBlockAt(ItemStack stack, EntityPlayer player, + World world, int x, int y, int z, int side, float hitX, float hitY, + float hitZ, int metadata) + { + if (!world.setBlock(x, y, z, ModBlocks.digitalChest, metadata, 3)) + { + return false; + } + if (world.getBlock(x, y, z) == ModBlocks.digitalChest) + { + world.getBlock(x, y, z).onBlockPlacedBy(world, x, y, z, player, + stack); + world.getBlock(x, y, z).onPostBlockPlaced(world, x, y, z, metadata); + } + if (stack != null && stack.hasTagCompound()) + { + ((TileDigitalChest) world.getTileEntity(x, y, z)) + .readFromNBTWithoutCoords(stack.getTagCompound() + .getCompoundTag("tileEntity")); + } + return true; + } +} diff --git a/src/main/java/techreborn/items/ItemParts.java b/src/main/java/techreborn/items/ItemParts.java index c71e31f13..342dfea5a 100644 --- a/src/main/java/techreborn/items/ItemParts.java +++ b/src/main/java/techreborn/items/ItemParts.java @@ -20,7 +20,7 @@ public class ItemParts extends Item { "bronzeGear", "ironGear", "titaniumGear", "steelGear", "tungstensteelGear", "laserFocus", "ductTape", "lazuriteChunk", "iridiumAlloyIngot", "rockCutterBlade", "superconductor", "thoriumCell", "doubleThoriumCell", "quadThoriumCell", "plutoniumCell", "doublePlutoniumCell", - "quadPlutoniumCell", "destructoPack", "iridiumNeutronReflector", "massHoleDevice" }; + "quadPlutoniumCell", "destructoPack", "iridiumNeutronReflector", "massHoleDevice", "computerMonitor" }; private IIcon[] textures; diff --git a/src/main/java/techreborn/tiles/TileDigitalChest.java b/src/main/java/techreborn/tiles/TileDigitalChest.java new file mode 100644 index 000000000..e869aacff --- /dev/null +++ b/src/main/java/techreborn/tiles/TileDigitalChest.java @@ -0,0 +1,291 @@ +package techreborn.tiles; + +import ic2.api.tile.IWrenchable; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import techreborn.init.ModBlocks; +import techreborn.util.Inventory; +import techreborn.util.ItemUtils; + +import java.util.List; + +public class TileDigitalChest extends TileMachineBase implements IInventory, + IWrenchable { + + // Slot 0 = Input + // Slot 1 = Output + // Slot 2 = Fake Item + + //TODO use long so we can have 9,223,372,036,854,775,807 items instead of 2,147,483,647 + int storage = 32767; + + public Inventory inventory = new Inventory(3, "TileDigitalChest", + storage); + + public ItemStack storedItem; + + @Override + public void updateEntity() + { + if(!worldObj.isRemote){ + if (storedItem != null) + { + ItemStack fakeStack = storedItem.copy(); + fakeStack.stackSize = 1; + setInventorySlotContents(2, fakeStack); + } else + { + setInventorySlotContents(2, null); + } + + if (getStackInSlot(0) != null) + { + if (storedItem == null) + { + storedItem = getStackInSlot(0); + setInventorySlotContents(0, null); + } else if (ItemUtils.isItemEqual(storedItem, getStackInSlot(0), + true, true)) + { + if (storedItem.stackSize <= Integer.MAX_VALUE + - getStackInSlot(0).stackSize) + { + storedItem.stackSize += getStackInSlot(0).stackSize; + decrStackSize(0, getStackInSlot(0).stackSize); + } + } + } + + if (storedItem != null && getStackInSlot(1) == null) + { + ItemStack itemStack = storedItem.copy(); + itemStack.stackSize = itemStack.getMaxStackSize(); + setInventorySlotContents(1, itemStack); + storedItem.stackSize -= itemStack.getMaxStackSize(); + } else if (ItemUtils.isItemEqual(getStackInSlot(1), storedItem, true, + true)) + { + int wanted = getStackInSlot(1).getMaxStackSize() + - getStackInSlot(1).stackSize; + if (storedItem.stackSize >= wanted) + { + decrStackSize(1, -wanted); + storedItem.stackSize -= wanted; + } else + { + decrStackSize(1, -storedItem.stackSize); + storedItem = null; + } + } + } + syncWithAll(); + } + + public Packet getDescriptionPacket() + { + NBTTagCompound nbtTag = new NBTTagCompound(); + writeToNBT(nbtTag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, + this.zCoord, 1, nbtTag); + } + + @Override + public void onDataPacket(NetworkManager net, + S35PacketUpdateTileEntity packet) + { + worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, + yCoord, zCoord); + readFromNBT(packet.func_148857_g()); + } + + @Override + public void readFromNBT(NBTTagCompound tagCompound) + { + super.readFromNBT(tagCompound); + readFromNBTWithoutCoords(tagCompound); + } + + public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) + { + inventory.readFromNBT(tagCompound); + + storedItem = null; + + if (tagCompound.hasKey("storedStack")) + { + storedItem = ItemStack + .loadItemStackFromNBT((NBTTagCompound) tagCompound + .getTag("storedStack")); + } + + if (storedItem != null) + { + storedItem.stackSize = tagCompound.getInteger("storedQuantity"); + } + } + + @Override + public void writeToNBT(NBTTagCompound tagCompound) + { + super.writeToNBT(tagCompound); + writeToNBTWithoutCoords(tagCompound); + } + + public void writeToNBTWithoutCoords(NBTTagCompound tagCompound) + { + inventory.writeToNBT(tagCompound); + if (storedItem != null) + { + tagCompound.setTag("storedStack", + storedItem.writeToNBT(new NBTTagCompound())); + tagCompound.setInteger("storedQuantity", storedItem.stackSize); + } else + tagCompound.setInteger("storedQuantity", 0); + } + + @Override + public int getSizeInventory() + { + return inventory.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int slot) + { + return inventory.getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(int slotId, int count) + { + return inventory.decrStackSize(slotId, count); + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) + { + return inventory.getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) + { + inventory.setInventorySlotContents(slot, stack); + } + + @Override + public String getInventoryName() + { + return inventory.getInventoryName(); + } + + @Override + public boolean hasCustomInventoryName() + { + return inventory.hasCustomInventoryName(); + } + + @Override + public int getInventoryStackLimit() + { + return inventory.getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) + { + return inventory.isUseableByPlayer(player); + } + + @Override + public void openInventory() + { + inventory.openInventory(); + } + + @Override + public void closeInventory() + { + inventory.closeInventory(); + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack) + { + return inventory.isItemValidForSlot(slot, stack); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) + { + return false; + } + + @Override + public short getFacing() + { + return 0; + } + + @Override + public void setFacing(short facing) + { + } + + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) + { + if (entityPlayer.isSneaking()) + { + return true; + } + return false; + } + + @Override + public float getWrenchDropRate() + { + return 1F; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) + { + return getDropWithNBT(); + } + + public ItemStack getDropWithNBT() + { + NBTTagCompound tileEntity = new NBTTagCompound(); + ItemStack dropStack = new ItemStack(ModBlocks.digitalChest, 1); + writeToNBTWithoutCoords(tileEntity); + dropStack.setTagCompound(new NBTTagCompound()); + dropStack.stackTagCompound.setTag("tileEntity", tileEntity); + return dropStack; + } + + @Override + public void addWailaInfo(List info) + { + super.addWailaInfo(info); + int size = 0; + String name = "of nothing"; + if (storedItem != null) + { + name = storedItem.getDisplayName(); + size += storedItem.stackSize; + } + if (getStackInSlot(1) != null) + { + name = getStackInSlot(1).getDisplayName(); + size += getStackInSlot(1).stackSize; + } + info.add(size + " " + name); + + } +} diff --git a/src/main/resources/assets/techreborn/lang/en_US.lang b/src/main/resources/assets/techreborn/lang/en_US.lang index a562ca425..ba0d13428 100644 --- a/src/main/resources/assets/techreborn/lang/en_US.lang +++ b/src/main/resources/assets/techreborn/lang/en_US.lang @@ -6,6 +6,7 @@ tile.techreborn.industrialBlock.name=Industrial tile.techreborn.thermalGenerator.name=Thermal Generator tile.techreborn.quantumTank.name=Quantum Tank tile.techreborn.quantumChest.name=Quantum Chest +tile.techreborn.digitalChest.name=Digital Chest tile.techreborn.centrifuge.name=Centrifuge tile.techreborn.rollingmachine.name=Rolling machine tile.techreborn.machineCasing.standard.name=Standard Machine Casing @@ -636,6 +637,7 @@ item.techreborn.part.quadPlutoniumCell.name=Quad Fuel Rod (Plutonium) item.techreborn.part.destructoPack.name=Destructopack item.techreborn.part.iridiumNeutronReflector.name=Iridium Neutron Reflector item.techreborn.part.massHoleDevice.name=Mass Hole Device +item.techreborn.part.computerMonitor.name=Computer Monitor #Tools diff --git a/src/main/resources/assets/techreborn/textures/items/component/computerMonitor.png b/src/main/resources/assets/techreborn/textures/items/component/computerMonitor.png new file mode 100644 index 0000000000000000000000000000000000000000..72e24ee53246cee1aff4cbddb18e6039b7c85c34 GIT binary patch literal 250 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt33 zJ=4@yqg0@pY)==*5DWig2d4j?M>HP%@2&3lJfvVNu-0Ri_?r8^CV8{AiR5v_7>6_{ z9LqkiZ}R^SNlk15&7Eb8R`P0Y_Tmc3Gh{lJt>?aQ)S>3qt_F#o%M3||9>$v(6&S=- n#G1c2Y*AwHnGnIl!o$O$%lOZHv8B{AptTI1u6{1-oD!M Date: Sat, 6 Jun 2015 23:39:48 -0400 Subject: [PATCH 05/16] Added QuantumTank, QuantumChest, DigitalChest, and ComputerMonitor recipes --- .../techreborn/blocks/BlockDigitalChest.java | 2 +- .../techreborn/compat/recipes/RecipesIC2.java | 52 ++++++++++++++++++- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/src/main/java/techreborn/blocks/BlockDigitalChest.java b/src/main/java/techreborn/blocks/BlockDigitalChest.java index 3040b3a80..2ddda7ea7 100644 --- a/src/main/java/techreborn/blocks/BlockDigitalChest.java +++ b/src/main/java/techreborn/blocks/BlockDigitalChest.java @@ -26,7 +26,7 @@ public class BlockDigitalChest extends BlockMachineBase { public BlockDigitalChest() { super(Material.rock); - setBlockName("techreborn.DigitalChest"); + setBlockName("techreborn.digitalChest"); } @Override diff --git a/src/main/java/techreborn/compat/recipes/RecipesIC2.java b/src/main/java/techreborn/compat/recipes/RecipesIC2.java index adc1026dc..351f7f668 100644 --- a/src/main/java/techreborn/compat/recipes/RecipesIC2.java +++ b/src/main/java/techreborn/compat/recipes/RecipesIC2.java @@ -105,6 +105,22 @@ public class RecipesIC2 { 'H', IC2Items.getItem("reinforcedGlass"), 'C', "circuitBasic", 'G', IC2Items.getItem("geothermalGenerator")}); + + CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.Gasturbine), + new Object[] + {"IAI", "WGW", "IAI", + 'I', "plateInvar", + 'A', IC2Items.getItem("advancedCircuit"), + 'W', IC2Items.getItem("windMill"), + 'G', IC2Items.getItem("reinforcedGlass")}); + + CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.Gasturbine), + new Object[] + {"IAI", "WGW", "IAI", + 'I', "plateAluminum", + 'A', IC2Items.getItem("advancedCircuit"), + 'W', IC2Items.getItem("windMill"), + 'G', IC2Items.getItem("reinforcedGlass")}); CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.Semifluidgenerator), new Object[] @@ -365,14 +381,46 @@ public class RecipesIC2 { 'C', "circuitElite", 'B', ModBlocks.HighAdvancedMachineBlock}); - - + CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.quantumTank), + new Object[] + {"EPE", "PCP", "EPE", + 'P', "platePlatinum", + 'E', "circuitMaster", + 'C', ModBlocks.quantumChest}); + + CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.quantumChest), + new Object[] + {"DCD", "ATA", "DQD", + 'D', new ItemStack(ModItems.parts, 1, 8), + 'C', new ItemStack(ModItems.parts, 1, 40), + 'A', ModBlocks.HighAdvancedMachineBlock, + 'Q', ModBlocks.digitalChest, + 'T', IC2Items.getItem("teleporter")}); + + CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.digitalChest), + new Object[] + {"PPP", "PDP", "PCP", + 'P', "plateSteel", + 'D', new ItemStack(ModItems.parts, 1, 8), + 'C', new ItemStack(ModItems.parts, 1, 40) + } + ); LogHelper.info("Added Expensive IC2 Recipes"); } public static void addShapedTrRecipes() { + CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 40), + new Object[] + { "PLP", "RGB", "PYP", + 'P', "plateAluminum", + 'L', "dyeLime", + 'R', "dyeRed", + 'G', "paneGlass", + 'B', "dyeBlue", + 'Y', Items.glowstone_dust}); + CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 4, 6), new Object[] { "EEE", "EAE", "EEE", From e00ba942f830190952667a88304fb0487fd5d1a9 Mon Sep 17 00:00:00 2001 From: joflashstudios Date: Sat, 6 Jun 2015 23:52:51 -0400 Subject: [PATCH 06/16] Created ItemParts helpers to make recipes more readable. This makes recipes easier to both write and understand, because I don't have to wonder what ModItems.parts #8 is, I can just see "dataOrb." --- src/main/java/techreborn/items/ItemParts.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/techreborn/items/ItemParts.java b/src/main/java/techreborn/items/ItemParts.java index 342dfea5a..68a2be5b4 100644 --- a/src/main/java/techreborn/items/ItemParts.java +++ b/src/main/java/techreborn/items/ItemParts.java @@ -8,8 +8,26 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import techreborn.client.TechRebornCreativeTab; +import techreborn.init.ModItems; public class ItemParts extends Item { + public static ItemStack getPartByName(String name, int count) + { + int index = -1; + for (int i = 0; i < types.length; i++) { + if (types[i].equals(name)) { + index = i; + break; + } + } + return new ItemStack(ModItems.parts, count, index); + } + + public static ItemStack getPartByName(String name) + { + return getPartByName(name, 1); + } + public static final String[] types = new String[] { "advancedCircuitParts", "basicCircuitBoard", "advancedCircuitBoard", "processorCircuitBoard", "energyFlowCircuit", "dataControlCircuit", "dataOrb", "dataStorageCircuit", From b9501055788e84a2d0e6153c55bdc99955615b0a Mon Sep 17 00:00:00 2001 From: joflashstudios Date: Sun, 7 Jun 2015 00:13:41 -0400 Subject: [PATCH 07/16] Created BlockOre helpers to make recipes more readable. These works the same as the ItemParts helpers from e00ba942f830190952667a88304fb0487fd5d1a9 --- src/main/java/techreborn/blocks/BlockOre.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/techreborn/blocks/BlockOre.java b/src/main/java/techreborn/blocks/BlockOre.java index 8c85ecf31..ef7828bfd 100644 --- a/src/main/java/techreborn/blocks/BlockOre.java +++ b/src/main/java/techreborn/blocks/BlockOre.java @@ -4,9 +4,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; - - - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -21,9 +18,27 @@ import techreborn.client.TechRebornCreativeTabMisc; import techreborn.init.ModItems; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import techreborn.init.ModBlocks; public class BlockOre extends Block { + public static ItemStack getOreByName(String name, int count) + { + int index = -1; + for (int i = 0; i < types.length; i++) { + if (types[i].equals(name)) { + index = i; + break; + } + } + return new ItemStack(ModBlocks.ore, count, index); + } + + public static ItemStack getOreByName(String name) + { + return getOreByName(name, 1); + } + public static final String[] types = new String[] { "Galena", "Iridium", "Ruby", "Sapphire", "Bauxite", "Pyrite", "Cinnabar", "Sphalerite", "Tungston", "Sheldonite", "Peridot", "Sodalite", From 9fa01eaee2d162b8d40459fa4023b0b1122f8942 Mon Sep 17 00:00:00 2001 From: joflashstudios Date: Sun, 7 Jun 2015 00:36:37 -0400 Subject: [PATCH 08/16] Added helpers for the rest of the item types --- src/main/java/techreborn/items/ItemCells.java | 20 +++++++++++++++++- .../java/techreborn/items/ItemCrushedOre.java | 18 ++++++++++++++++ .../java/techreborn/items/ItemDustTiny.java | 19 +++++++++++++++++ src/main/java/techreborn/items/ItemDusts.java | 18 ++++++++++++++++ .../java/techreborn/items/ItemDustsSmall.java | 19 +++++++++++++++++ src/main/java/techreborn/items/ItemGems.java | 21 ++++++++++++++++++- .../java/techreborn/items/ItemIngots.java | 20 +++++++++++++++++- .../java/techreborn/items/ItemNuggets.java | 19 +++++++++++++++++ .../java/techreborn/items/ItemPlates.java | 19 +++++++++++++++++ .../items/ItemPurifiedCrushedOre.java | 19 +++++++++++++++++ src/main/java/techreborn/items/ItemRods.java | 19 +++++++++++++++++ 11 files changed, 208 insertions(+), 3 deletions(-) diff --git a/src/main/java/techreborn/items/ItemCells.java b/src/main/java/techreborn/items/ItemCells.java index 162f85434..e00195ff1 100644 --- a/src/main/java/techreborn/items/ItemCells.java +++ b/src/main/java/techreborn/items/ItemCells.java @@ -8,8 +8,26 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import techreborn.client.TechRebornCreativeTab; +import techreborn.init.ModItems; -public class ItemCells extends ItemTR { +public class ItemCells extends ItemTR { + public static ItemStack getCellByName(String name, int count) + { + int index = -1; + for (int i = 0; i < types.length; i++) { + if (types[i].equals(name)) { + index = i; + break; + } + } + return new ItemStack(ModItems.cells, count, index); + } + + public static ItemStack getCellByName(String name) + { + return getCellByName(name, 1); + } + public static final String[] types = new String[] { "Berylium", "biomass", "calciumCarbonate", "calcium", "carbon", "chlorine", "deuterium", "diesel", "ethanol", "glyceryl", diff --git a/src/main/java/techreborn/items/ItemCrushedOre.java b/src/main/java/techreborn/items/ItemCrushedOre.java index 417c04a65..06d160ec8 100644 --- a/src/main/java/techreborn/items/ItemCrushedOre.java +++ b/src/main/java/techreborn/items/ItemCrushedOre.java @@ -8,8 +8,26 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import techreborn.client.TechRebornCreativeTabMisc; +import techreborn.init.ModItems; public class ItemCrushedOre extends Item { + public static ItemStack getCrushedOreByName(String name, int count) + { + int index = -1; + for (int i = 0; i < types.length; i++) { + if (types[i].equals(name)) { + index = i; + break; + } + } + return new ItemStack(ModItems.crushedOre, count, index); + } + + public static ItemStack getCrushedOreByName(String name) + { + return getCrushedOreByName(name, 1); + } + public static final String[] types = new String[] { "Aluminum", "Ardite", "Bauxite", "Cadmium", "Cinnabar", "Cobalt", "DarkIron", "Indium", "Iridium", "Nickel", "Osmium", "Platinum", diff --git a/src/main/java/techreborn/items/ItemDustTiny.java b/src/main/java/techreborn/items/ItemDustTiny.java index 81bcb5015..c5b36bf9a 100644 --- a/src/main/java/techreborn/items/ItemDustTiny.java +++ b/src/main/java/techreborn/items/ItemDustTiny.java @@ -8,8 +8,27 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import techreborn.client.TechRebornCreativeTabMisc; +import techreborn.init.ModItems; public class ItemDustTiny extends ItemTR { + + public static ItemStack getTinyDustByName(String name, int count) + { + int index = -1; + for (int i = 0; i < types.length; i++) { + if (types[i].equals(name)) { + index = i; + break; + } + } + return new ItemStack(ModItems.tinyDusts, count, index); + } + + public static ItemStack getTinyDustByName(String name) + { + return getTinyDustByName(name, 1); + } + public static final String[] types = new String[] { "Almandine", "AluminumBrass", "Aluminum", "Alumite", "Andradite", "Antimony", "Ardite", "Ashes", "Basalt", "Bauxite", "Biotite", diff --git a/src/main/java/techreborn/items/ItemDusts.java b/src/main/java/techreborn/items/ItemDusts.java index 31fbb5d49..3cf6f9841 100644 --- a/src/main/java/techreborn/items/ItemDusts.java +++ b/src/main/java/techreborn/items/ItemDusts.java @@ -8,8 +8,26 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import techreborn.client.TechRebornCreativeTabMisc; +import techreborn.init.ModItems; public class ItemDusts extends ItemTR { + public static ItemStack getDustByName(String name, int count) + { + int index = -1; + for (int i = 0; i < types.length; i++) { + if (types[i].equals(name)) { + index = i; + break; + } + } + return new ItemStack(ModItems.dusts, count, index); + } + + public static ItemStack getDustByName(String name) + { + return getDustByName(name, 1); + } + public static final String[] types = new String[] { "almandine", "aluminumBrass", "aluminum", "alumite", "andradite", "antimony", "ardite", "ashes", "basalt", "bauxite", "biotite", diff --git a/src/main/java/techreborn/items/ItemDustsSmall.java b/src/main/java/techreborn/items/ItemDustsSmall.java index b9e748256..a7f97c0cd 100644 --- a/src/main/java/techreborn/items/ItemDustsSmall.java +++ b/src/main/java/techreborn/items/ItemDustsSmall.java @@ -8,8 +8,27 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import techreborn.client.TechRebornCreativeTabMisc; +import techreborn.init.ModItems; public class ItemDustsSmall extends ItemTR { + + public static ItemStack getSmallDustByName(String name, int count) + { + int index = -1; + for (int i = 0; i < types.length; i++) { + if (types[i].equals(name)) { + index = i; + break; + } + } + return new ItemStack(ModItems.smallDusts, count, index); + } + + public static ItemStack getSmallDustByName(String name) + { + return getSmallDustByName(name, 1); + } + public static final String[] types = new String[] { "Almandine", "AluminumBrass", "Aluminum", "Alumite", "Andradite", "Antimony", "Ardite", "Ashes", "Basalt", "Bauxite", "Biotite", diff --git a/src/main/java/techreborn/items/ItemGems.java b/src/main/java/techreborn/items/ItemGems.java index c06bfaf05..bba5ff848 100644 --- a/src/main/java/techreborn/items/ItemGems.java +++ b/src/main/java/techreborn/items/ItemGems.java @@ -8,8 +8,27 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import techreborn.client.TechRebornCreativeTabMisc; +import techreborn.init.ModItems; -public class ItemGems extends Item { +public class ItemGems extends Item { + + public static ItemStack getGemByName(String name, int count) + { + int index = -1; + for (int i = 0; i < types.length; i++) { + if (types[i].equals(name)) { + index = i; + break; + } + } + return new ItemStack(ModItems.gems, count, index); + } + + public static ItemStack getGemByName(String name) + { + return getGemByName(name, 1); + } + public static final String[] types = new String[] { "ruby", "sapphire", "peridot", "redGarnet", "yellowGarnet" }; diff --git a/src/main/java/techreborn/items/ItemIngots.java b/src/main/java/techreborn/items/ItemIngots.java index e280a8d11..426daa37c 100644 --- a/src/main/java/techreborn/items/ItemIngots.java +++ b/src/main/java/techreborn/items/ItemIngots.java @@ -8,8 +8,26 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import techreborn.client.TechRebornCreativeTabMisc; +import techreborn.init.ModItems; -public class ItemIngots extends Item { +public class ItemIngots extends Item { + public static ItemStack getIngotByName(String name, int count) + { + int index = -1; + for (int i = 0; i < types.length; i++) { + if (types[i].equals(name)) { + index = i; + break; + } + } + return new ItemStack(ModItems.ingots, count, index); + } + + public static ItemStack getIngotByName(String name) + { + return getIngotByName(name, 1); + } + public static final String[] types = new String[] { "aluminum", "antimony", "batteryAlloy", "redAlloy", "blueAlloy", "brass", "bronze", "cadmium", "chrome", "copper", "cupronickel", "electrum", "indium", diff --git a/src/main/java/techreborn/items/ItemNuggets.java b/src/main/java/techreborn/items/ItemNuggets.java index ceae489dd..dbf1fad84 100644 --- a/src/main/java/techreborn/items/ItemNuggets.java +++ b/src/main/java/techreborn/items/ItemNuggets.java @@ -8,8 +8,27 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import techreborn.client.TechRebornCreativeTabMisc; +import techreborn.init.ModItems; public class ItemNuggets extends Item { + + public static ItemStack getNuggetByName(String name, int count) + { + int index = -1; + for (int i = 0; i < types.length; i++) { + if (types[i].equals(name)) { + index = i; + break; + } + } + return new ItemStack(ModItems.nuggets, count, index); + } + + public static ItemStack getNuggetByName(String name) + { + return getNuggetByName(name, 1); + } + public static final String[] types = new String[] { "aluminum", "antimony", "brass", "bronze", "chrome", "copper", "electrum", "invar", "iridium", "iron", "lead", diff --git a/src/main/java/techreborn/items/ItemPlates.java b/src/main/java/techreborn/items/ItemPlates.java index e44599c51..3007e6e9b 100644 --- a/src/main/java/techreborn/items/ItemPlates.java +++ b/src/main/java/techreborn/items/ItemPlates.java @@ -8,8 +8,27 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import techreborn.client.TechRebornCreativeTabMisc; +import techreborn.init.ModItems; public class ItemPlates extends ItemTR { + + public static ItemStack getPlateByName(String name, int count) + { + int index = -1; + for (int i = 0; i < types.length; i++) { + if (types[i].equals(name)) { + index = i; + break; + } + } + return new ItemStack(ModItems.plate, count, index); + } + + public static ItemStack getPlateByName(String name) + { + return getPlateByName(name, 1); + } + public static final String[] types = new String[] { "aluminum", "batteryAlloy", "brass", "bronze", "carbon", "chrome", "copper", "diamond", "electrum", "emerald", diff --git a/src/main/java/techreborn/items/ItemPurifiedCrushedOre.java b/src/main/java/techreborn/items/ItemPurifiedCrushedOre.java index 99a8cdfdc..d0e93c41d 100644 --- a/src/main/java/techreborn/items/ItemPurifiedCrushedOre.java +++ b/src/main/java/techreborn/items/ItemPurifiedCrushedOre.java @@ -8,8 +8,27 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import techreborn.client.TechRebornCreativeTabMisc; +import techreborn.init.ModItems; public class ItemPurifiedCrushedOre extends Item { + + public static ItemStack getPurifiedCrushedOreByName(String name, int count) + { + int index = -1; + for (int i = 0; i < types.length; i++) { + if (types[i].equals(name)) { + index = i; + break; + } + } + return new ItemStack(ModItems.purifiedCrushedOre, count, index); + } + + public static ItemStack getPurifiedCrushedOreByName(String name) + { + return getPurifiedCrushedOreByName(name, 1); + } + public static final String[] types = new String[] { "Aluminum", "Ardite", "Bauxite", "Cadmium", "Cinnabar", "Cobalt", "DarkIron", "Indium", "Iridium", "Nickel", "Osmium", "Platinum", "Pyrite", "Sphalerite", diff --git a/src/main/java/techreborn/items/ItemRods.java b/src/main/java/techreborn/items/ItemRods.java index 60c5a3aa0..27fcfa0a2 100644 --- a/src/main/java/techreborn/items/ItemRods.java +++ b/src/main/java/techreborn/items/ItemRods.java @@ -8,8 +8,27 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import techreborn.client.TechRebornCreativeTabMisc; +import techreborn.init.ModItems; public class ItemRods extends Item { + + public static ItemStack getRodByName(String name, int count) + { + int index = -1; + for (int i = 0; i < types.length; i++) { + if (types[i].equals(name)) { + index = i; + break; + } + } + return new ItemStack(ModItems.rods, count, index); + } + + public static ItemStack getRodByName(String name) + { + return getRodByName(name, 1); + } + public static final String[] types = new String[] { "brass", "bronze", "copper", "electrum", "gold", "invar", "iridium", "iron", "lead", "nickel", "platinum", From d9494c31fb635ab01b9c39dd7de4e43e038b1b5e Mon Sep 17 00:00:00 2001 From: joflashstudios Date: Sun, 7 Jun 2015 00:41:20 -0400 Subject: [PATCH 09/16] Changed QuantumChest, QuantumTank, and DigitalChest to use readability helpers. --- .../techreborn/compat/recipes/RecipesIC2.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/techreborn/compat/recipes/RecipesIC2.java b/src/main/java/techreborn/compat/recipes/RecipesIC2.java index 351f7f668..5ae97acc4 100644 --- a/src/main/java/techreborn/compat/recipes/RecipesIC2.java +++ b/src/main/java/techreborn/compat/recipes/RecipesIC2.java @@ -22,6 +22,8 @@ import techreborn.init.ModItems; import techreborn.util.CraftingHelper; import techreborn.util.LogHelper; import techreborn.util.RecipeRemover; +import techreborn.items.ItemParts; +import techreborn.blocks.BlockOre; public class RecipesIC2 { public static ConfigTechReborn config; @@ -391,8 +393,8 @@ public class RecipesIC2 { CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.quantumChest), new Object[] {"DCD", "ATA", "DQD", - 'D', new ItemStack(ModItems.parts, 1, 8), - 'C', new ItemStack(ModItems.parts, 1, 40), + 'D', ItemParts.getPartByName("dataOrb"), + 'C', ItemParts.getPartByName("computerMonitor"), 'A', ModBlocks.HighAdvancedMachineBlock, 'Q', ModBlocks.digitalChest, 'T', IC2Items.getItem("teleporter")}); @@ -401,10 +403,19 @@ public class RecipesIC2 { new Object[] {"PPP", "PDP", "PCP", 'P', "plateSteel", - 'D', new ItemStack(ModItems.parts, 1, 8), - 'C', new ItemStack(ModItems.parts, 1, 40) + 'D', ItemParts.getPartByName("dataOrb"), + 'C', BlockOre.getOreByName("computerMonitor") } ); + + CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.digitalChest), + new Object[] + {"PPP", "PDP", "PCP", + 'P', "plateAluminum", + 'D', ItemParts.getPartByName("dataOrb"), + 'C', ItemParts.getPartByName("computerMonitor") + } + ); LogHelper.info("Added Expensive IC2 Recipes"); } From 26e71488dd29e6d91cdf3f40b240ac4e6863c9c1 Mon Sep 17 00:00:00 2001 From: joflashstudios Date: Sun, 7 Jun 2015 00:45:15 -0400 Subject: [PATCH 10/16] Revert "Changed QuantumChest, QuantumTank, and DigitalChest to use readability helpers." This reverts commit d9494c31fb635ab01b9c39dd7de4e43e038b1b5e. --- .../techreborn/compat/recipes/RecipesIC2.java | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/main/java/techreborn/compat/recipes/RecipesIC2.java b/src/main/java/techreborn/compat/recipes/RecipesIC2.java index 5ae97acc4..351f7f668 100644 --- a/src/main/java/techreborn/compat/recipes/RecipesIC2.java +++ b/src/main/java/techreborn/compat/recipes/RecipesIC2.java @@ -22,8 +22,6 @@ import techreborn.init.ModItems; import techreborn.util.CraftingHelper; import techreborn.util.LogHelper; import techreborn.util.RecipeRemover; -import techreborn.items.ItemParts; -import techreborn.blocks.BlockOre; public class RecipesIC2 { public static ConfigTechReborn config; @@ -393,8 +391,8 @@ public class RecipesIC2 { CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.quantumChest), new Object[] {"DCD", "ATA", "DQD", - 'D', ItemParts.getPartByName("dataOrb"), - 'C', ItemParts.getPartByName("computerMonitor"), + 'D', new ItemStack(ModItems.parts, 1, 8), + 'C', new ItemStack(ModItems.parts, 1, 40), 'A', ModBlocks.HighAdvancedMachineBlock, 'Q', ModBlocks.digitalChest, 'T', IC2Items.getItem("teleporter")}); @@ -403,19 +401,10 @@ public class RecipesIC2 { new Object[] {"PPP", "PDP", "PCP", 'P', "plateSteel", - 'D', ItemParts.getPartByName("dataOrb"), - 'C', BlockOre.getOreByName("computerMonitor") + 'D', new ItemStack(ModItems.parts, 1, 8), + 'C', new ItemStack(ModItems.parts, 1, 40) } ); - - CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.digitalChest), - new Object[] - {"PPP", "PDP", "PCP", - 'P', "plateAluminum", - 'D', ItemParts.getPartByName("dataOrb"), - 'C', ItemParts.getPartByName("computerMonitor") - } - ); LogHelper.info("Added Expensive IC2 Recipes"); } From 123c12ae454ee1bee939abc1d0d8058c69200c16 Mon Sep 17 00:00:00 2001 From: joflashstudios Date: Sun, 7 Jun 2015 01:02:45 -0400 Subject: [PATCH 11/16] Changed QuantumChest, QuantumTank, and DigitalChest to use readability helpers. --- .../techreborn/compat/recipes/RecipesIC2.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/techreborn/compat/recipes/RecipesIC2.java b/src/main/java/techreborn/compat/recipes/RecipesIC2.java index 351f7f668..076596174 100644 --- a/src/main/java/techreborn/compat/recipes/RecipesIC2.java +++ b/src/main/java/techreborn/compat/recipes/RecipesIC2.java @@ -22,6 +22,7 @@ import techreborn.init.ModItems; import techreborn.util.CraftingHelper; import techreborn.util.LogHelper; import techreborn.util.RecipeRemover; +import techreborn.items.ItemParts; public class RecipesIC2 { public static ConfigTechReborn config; @@ -391,8 +392,8 @@ public class RecipesIC2 { CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.quantumChest), new Object[] {"DCD", "ATA", "DQD", - 'D', new ItemStack(ModItems.parts, 1, 8), - 'C', new ItemStack(ModItems.parts, 1, 40), + 'D', ItemParts.getPartByName("dataOrb"), + 'C', ItemParts.getPartByName("computerMonitor"), 'A', ModBlocks.HighAdvancedMachineBlock, 'Q', ModBlocks.digitalChest, 'T', IC2Items.getItem("teleporter")}); @@ -401,10 +402,19 @@ public class RecipesIC2 { new Object[] {"PPP", "PDP", "PCP", 'P', "plateSteel", - 'D', new ItemStack(ModItems.parts, 1, 8), - 'C', new ItemStack(ModItems.parts, 1, 40) + 'D', ItemParts.getPartByName("dataOrb"), + 'C', ItemParts.getPartByName("computerMonitor") } ); + + CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.digitalChest), + new Object[] + {"PPP", "PDP", "PCP", + 'P', "plateAluminum", + 'D', ItemParts.getPartByName("dataOrb"), + 'C', ItemParts.getPartByName("computerMonitor") + } + ); LogHelper.info("Added Expensive IC2 Recipes"); } From 92af5a1537ca7755fb55e9815ff9deafdb21cd60 Mon Sep 17 00:00:00 2001 From: joflashstudios Date: Sun, 7 Jun 2015 01:26:37 -0400 Subject: [PATCH 12/16] Fixed Digital Chest texture --- src/main/java/techreborn/blocks/BlockDigitalChest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/techreborn/blocks/BlockDigitalChest.java b/src/main/java/techreborn/blocks/BlockDigitalChest.java index 2ddda7ea7..9e1453b19 100644 --- a/src/main/java/techreborn/blocks/BlockDigitalChest.java +++ b/src/main/java/techreborn/blocks/BlockDigitalChest.java @@ -49,7 +49,7 @@ public class BlockDigitalChest extends BlockMachineBase { @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister icon) { - this.blockIcon = icon.registerIcon("techreborn:machine/machine_side"); + this.blockIcon = icon.registerIcon("techreborn:machine/qchest_side"); this.iconFront = icon.registerIcon("techreborn:machine/quantum_chest"); this.iconTop = icon.registerIcon("techreborn:machine/quantum_top"); this.iconBottom = icon.registerIcon("techreborn:machine/machine_bottom"); From 94803e88f31986760146e847ec4cb21c700fd194 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sun, 7 Jun 2015 09:21:37 +0100 Subject: [PATCH 13/16] attempt at fixing the item stack size issue --- .../java/techreborn/api/recipe/BaseRecipe.java | 18 ++++++++++++++---- .../techreborn/api/recipe/IBaseRecipeType.java | 12 +++++++++--- .../techreborn/api/recipe/RecipeCrafter.java | 14 +++++++------- .../recipe/machines/AlloySmelterRecipe.java | 2 +- .../machines/AssemblingMachineRecipe.java | 2 +- .../api/recipe/machines/CentrifugeRecipe.java | 8 ++++---- .../recipe/machines/ChemicalReactorRecipe.java | 2 +- .../api/recipe/machines/GrinderRecipe.java | 8 ++++---- .../machines/ImplosionCompressorRecipe.java | 4 ++-- .../machines/IndustrialSawmillRecipe.java | 6 +++--- .../api/recipe/machines/LatheRecipe.java | 2 +- .../machines/PlateCuttingMachineRecipe.java | 2 +- .../java/techreborn/compat/ee3/EmcValues.java | 4 ++-- .../nei/recipes/AlloySmelterRecipeHandler.java | 2 +- .../AssemblingMachineRecipeHandler.java | 4 ++-- .../nei/recipes/CentrifugeRecipeHandler.java | 16 ++++++++-------- .../recipes/ChemicalReactorRecipeHandler.java | 4 ++-- .../nei/recipes/GenericRecipeHander.java | 10 +++++----- .../nei/recipes/GrinderRecipeHandler.java | 16 ++++++++-------- .../ImplosionCompressorRecipeHandler.java | 8 ++++---- .../IndustrialSawmillRecipeHandler.java | 12 ++++++------ .../compat/nei/recipes/LatheRecipeHandler.java | 4 ++-- .../PlateCuttingMachineRecipeHandler.java | 4 ++-- 23 files changed, 90 insertions(+), 74 deletions(-) diff --git a/src/main/java/techreborn/api/recipe/BaseRecipe.java b/src/main/java/techreborn/api/recipe/BaseRecipe.java index 8566f24c7..50dae320c 100644 --- a/src/main/java/techreborn/api/recipe/BaseRecipe.java +++ b/src/main/java/techreborn/api/recipe/BaseRecipe.java @@ -13,7 +13,7 @@ public abstract class BaseRecipe implements IBaseRecipeType , Cloneable { public ArrayList inputs; - public ArrayList outputs; + private ArrayList outputs; public String name; @@ -31,11 +31,21 @@ public abstract class BaseRecipe implements IBaseRecipeType , Cloneable { } @Override - public List getOutputs() { - return (List) outputs.clone(); + public ItemStack getOutput(int i) { + return outputs.get(i).copy(); } - @Override + @Override + public int getOutputsSize() { + return outputs.size(); + } + + public void addOutput(ItemStack stack){ + outputs.add(stack); + } + + + @Override public List getInputs() { return inputs; } diff --git a/src/main/java/techreborn/api/recipe/IBaseRecipeType.java b/src/main/java/techreborn/api/recipe/IBaseRecipeType.java index a4c20dd69..3b5f54791 100644 --- a/src/main/java/techreborn/api/recipe/IBaseRecipeType.java +++ b/src/main/java/techreborn/api/recipe/IBaseRecipeType.java @@ -18,11 +18,17 @@ public interface IBaseRecipeType { public List getInputs(); /** - * Use this to get all of the outputs + * This gets the output form the array list * - * @return the List of outputs + * @return the output */ - public List getOutputs(); + public ItemStack getOutput(int i); + + /** + * + * @return The ammount of outputs + */ + public int getOutputsSize(); /** * This is the name to check that the recipe is the one that should be used in diff --git a/src/main/java/techreborn/api/recipe/RecipeCrafter.java b/src/main/java/techreborn/api/recipe/RecipeCrafter.java index 216214c00..9b8245bd1 100644 --- a/src/main/java/techreborn/api/recipe/RecipeCrafter.java +++ b/src/main/java/techreborn/api/recipe/RecipeCrafter.java @@ -118,8 +118,8 @@ public class RecipeCrafter { for (IBaseRecipeType recipe : RecipeHanderer.getRecipeClassFromName(recipeName)) { if (recipe.canCraft(parentTile) && hasAllInputs(recipe)) {//This checks to see if it has all of the inputs boolean canGiveInvAll = true; - for (int i = 0; i < recipe.getOutputs().size(); i++) {//This checks to see if it can fit all of the outputs - if (!canFitStack(recipe.getOutputs().get(i), outputSlots[i])) { + for (int i = 0; i < recipe.getOutputsSize(); i++) {//This checks to see if it can fit all of the outputs + if (!canFitStack(recipe.getOutput(i), outputSlots[i])) { canGiveInvAll = false; break; } @@ -142,17 +142,17 @@ public class RecipeCrafter { } if (currentRecipe != null && currentTickTime >= currentNeededTicks) {//If it has reached the recipe tick time boolean canGiveInvAll = true; - for (int i = 0; i < currentRecipe.getOutputs().size(); i++) {//Checks to see if it can fit the output - if (!canFitStack(currentRecipe.getOutputs().get(i), outputSlots[i])) { + for (int i = 0; i < currentRecipe.getOutputsSize(); i++) {//Checks to see if it can fit the output + if (!canFitStack(currentRecipe.getOutput(i), outputSlots[i])) { canGiveInvAll = false; } } ArrayList filledSlots = new ArrayList();//The slots that have been filled if (canGiveInvAll && currentRecipe.onCraft(parentTile)) { - for (int i = 0; i < currentRecipe.getOutputs().size(); i++) { - System.out.println(currentRecipe.getOutputs().get(i).stackSize); + for (int i = 0; i < currentRecipe.getOutputsSize(); i++) { + System.out.println(currentRecipe.getOutput(i).stackSize); if (!filledSlots.contains(outputSlots[i])) {//checks it has not been filled - fitStack(currentRecipe.getOutputs().get(i), outputSlots[i]);//fills the slot with the output stack + fitStack(currentRecipe.getOutput(i), outputSlots[i]);//fills the slot with the output stack filledSlots.add(outputSlots[i]); } } diff --git a/src/main/java/techreborn/api/recipe/machines/AlloySmelterRecipe.java b/src/main/java/techreborn/api/recipe/machines/AlloySmelterRecipe.java index b393a6f2c..12f589af4 100644 --- a/src/main/java/techreborn/api/recipe/machines/AlloySmelterRecipe.java +++ b/src/main/java/techreborn/api/recipe/machines/AlloySmelterRecipe.java @@ -12,6 +12,6 @@ public class AlloySmelterRecipe extends BaseRecipe { if (input2 != null) inputs.add(input2); if (output1 != null) - outputs.add(output1); + addOutput(output1); } } diff --git a/src/main/java/techreborn/api/recipe/machines/AssemblingMachineRecipe.java b/src/main/java/techreborn/api/recipe/machines/AssemblingMachineRecipe.java index 42dfb359e..3e4dc1921 100644 --- a/src/main/java/techreborn/api/recipe/machines/AssemblingMachineRecipe.java +++ b/src/main/java/techreborn/api/recipe/machines/AssemblingMachineRecipe.java @@ -12,6 +12,6 @@ public class AssemblingMachineRecipe extends BaseRecipe { if (input2 != null) inputs.add(input2); if (output1 != null) - outputs.add(output1); + addOutput(output1); } } diff --git a/src/main/java/techreborn/api/recipe/machines/CentrifugeRecipe.java b/src/main/java/techreborn/api/recipe/machines/CentrifugeRecipe.java index c9cb107dd..57763e052 100644 --- a/src/main/java/techreborn/api/recipe/machines/CentrifugeRecipe.java +++ b/src/main/java/techreborn/api/recipe/machines/CentrifugeRecipe.java @@ -12,12 +12,12 @@ public class CentrifugeRecipe extends BaseRecipe { if (input2 != null) inputs.add(input2); if (output1 != null) - outputs.add(output1); + addOutput(output1); if (output2 != null) - outputs.add(output2); + addOutput(output2); if (output3 != null) - outputs.add(output3); + addOutput(output3); if (output4 != null) - outputs.add(output4); + addOutput(output4); } } diff --git a/src/main/java/techreborn/api/recipe/machines/ChemicalReactorRecipe.java b/src/main/java/techreborn/api/recipe/machines/ChemicalReactorRecipe.java index b1b72ef9f..f5c5b9a62 100644 --- a/src/main/java/techreborn/api/recipe/machines/ChemicalReactorRecipe.java +++ b/src/main/java/techreborn/api/recipe/machines/ChemicalReactorRecipe.java @@ -12,6 +12,6 @@ public class ChemicalReactorRecipe extends BaseRecipe { if (input2 != null) inputs.add(input2); if (output1 != null) - outputs.add(output1); + addOutput(output1); } } diff --git a/src/main/java/techreborn/api/recipe/machines/GrinderRecipe.java b/src/main/java/techreborn/api/recipe/machines/GrinderRecipe.java index ff120d012..45569f8cc 100644 --- a/src/main/java/techreborn/api/recipe/machines/GrinderRecipe.java +++ b/src/main/java/techreborn/api/recipe/machines/GrinderRecipe.java @@ -18,13 +18,13 @@ public class GrinderRecipe extends BaseRecipe { if( input2 != null) inputs.add(input2); if (output1 != null) - outputs.add(output1); + addOutput(output1); if (output2 != null) - outputs.add(output2); + addOutput(output2); if (output3 != null) - outputs.add(output3); + addOutput(output3); if (output4 != null) - outputs.add(output4); + addOutput(output4); this.fluidStack = fluidStack; } diff --git a/src/main/java/techreborn/api/recipe/machines/ImplosionCompressorRecipe.java b/src/main/java/techreborn/api/recipe/machines/ImplosionCompressorRecipe.java index 258f60205..5a197f518 100644 --- a/src/main/java/techreborn/api/recipe/machines/ImplosionCompressorRecipe.java +++ b/src/main/java/techreborn/api/recipe/machines/ImplosionCompressorRecipe.java @@ -12,8 +12,8 @@ public class ImplosionCompressorRecipe extends BaseRecipe { if (input2 != null) inputs.add(input2); if (output1 != null) - outputs.add(output1); + addOutput(output1); if (output2 != null) - outputs.add(output2); + addOutput(output2); } } diff --git a/src/main/java/techreborn/api/recipe/machines/IndustrialSawmillRecipe.java b/src/main/java/techreborn/api/recipe/machines/IndustrialSawmillRecipe.java index 24f90168c..a5b372dc5 100644 --- a/src/main/java/techreborn/api/recipe/machines/IndustrialSawmillRecipe.java +++ b/src/main/java/techreborn/api/recipe/machines/IndustrialSawmillRecipe.java @@ -12,10 +12,10 @@ public class IndustrialSawmillRecipe extends BaseRecipe { if (input2 != null) inputs.add(input2); if (output1 != null) - outputs.add(output1); + addOutput(output1); if (output2 != null) - outputs.add(output2); + addOutput(output2); if (output3 != null) - outputs.add(output3); + addOutput(output3); } } diff --git a/src/main/java/techreborn/api/recipe/machines/LatheRecipe.java b/src/main/java/techreborn/api/recipe/machines/LatheRecipe.java index 84ccd2501..12373092c 100644 --- a/src/main/java/techreborn/api/recipe/machines/LatheRecipe.java +++ b/src/main/java/techreborn/api/recipe/machines/LatheRecipe.java @@ -10,6 +10,6 @@ public class LatheRecipe extends BaseRecipe { if (input1 != null) inputs.add(input1); if (output1 != null) - outputs.add(output1); + addOutput(output1); } } diff --git a/src/main/java/techreborn/api/recipe/machines/PlateCuttingMachineRecipe.java b/src/main/java/techreborn/api/recipe/machines/PlateCuttingMachineRecipe.java index ec5d094bb..26491c672 100644 --- a/src/main/java/techreborn/api/recipe/machines/PlateCuttingMachineRecipe.java +++ b/src/main/java/techreborn/api/recipe/machines/PlateCuttingMachineRecipe.java @@ -10,6 +10,6 @@ public class PlateCuttingMachineRecipe extends BaseRecipe { if (input1 != null) inputs.add(input1); if (output1 != null) - outputs.add(output1); + addOutput(output1); } } diff --git a/src/main/java/techreborn/compat/ee3/EmcValues.java b/src/main/java/techreborn/compat/ee3/EmcValues.java index adc5d5d0d..021a0a321 100644 --- a/src/main/java/techreborn/compat/ee3/EmcValues.java +++ b/src/main/java/techreborn/compat/ee3/EmcValues.java @@ -9,8 +9,8 @@ public class EmcValues { public static void init() { for(IBaseRecipeType recipeType : RecipeHanderer.recipeList){ - if(recipeType.getOutputs().size() == 1){ - RecipeRegistryProxy.addRecipe(recipeType.getOutputs().get(0), recipeType.getInputs()); + if(recipeType.getOutputsSize() == 1){ + RecipeRegistryProxy.addRecipe(recipeType.getOutput(0), recipeType.getInputs()); } } } diff --git a/src/main/java/techreborn/compat/nei/recipes/AlloySmelterRecipeHandler.java b/src/main/java/techreborn/compat/nei/recipes/AlloySmelterRecipeHandler.java index d353b954b..8522b207a 100644 --- a/src/main/java/techreborn/compat/nei/recipes/AlloySmelterRecipeHandler.java +++ b/src/main/java/techreborn/compat/nei/recipes/AlloySmelterRecipeHandler.java @@ -18,7 +18,7 @@ public class AlloySmelterRecipeHandler extends GenericRecipeHander implements IN PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 65 - offset, 17 - offset); input.add(pStack2); - PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset); + PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 116 - offset, 35 - offset); outputs.add(pStack3); } diff --git a/src/main/java/techreborn/compat/nei/recipes/AssemblingMachineRecipeHandler.java b/src/main/java/techreborn/compat/nei/recipes/AssemblingMachineRecipeHandler.java index dd0e00c4c..bfd699415 100644 --- a/src/main/java/techreborn/compat/nei/recipes/AssemblingMachineRecipeHandler.java +++ b/src/main/java/techreborn/compat/nei/recipes/AssemblingMachineRecipeHandler.java @@ -21,8 +21,8 @@ public class AssemblingMachineRecipeHandler extends GenericRecipeHander implemen input.add(pStack2); } - if (recipeType.getOutputs().size() > 0) { - PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset); + if (recipeType.getOutputsSize() > 0) { + PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 116 - offset, 35 - offset); outputs.add(pStack3); } diff --git a/src/main/java/techreborn/compat/nei/recipes/CentrifugeRecipeHandler.java b/src/main/java/techreborn/compat/nei/recipes/CentrifugeRecipeHandler.java index 965a1c7da..88bbabb76 100644 --- a/src/main/java/techreborn/compat/nei/recipes/CentrifugeRecipeHandler.java +++ b/src/main/java/techreborn/compat/nei/recipes/CentrifugeRecipeHandler.java @@ -21,23 +21,23 @@ public class CentrifugeRecipeHandler extends GenericRecipeHander implements INei input.add(pStack2); } - if (recipeType.getOutputs().size() > 0) { - PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 80 - offset, 5 - offset); + if (recipeType.getOutputsSize() > 0) { + PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 80 - offset, 5 - offset); outputs.add(pStack3); } - if (recipeType.getOutputs().size() > 1) { - PositionedStack pStack4 = new PositionedStack(recipeType.getOutputs().get(1), 110 - offset, 35 - offset); + if (recipeType.getOutputsSize() > 1) { + PositionedStack pStack4 = new PositionedStack(recipeType.getOutput(1), 110 - offset, 35 - offset); outputs.add(pStack4); } - if (recipeType.getOutputs().size() > 2) { - PositionedStack pStack5 = new PositionedStack(recipeType.getOutputs().get(2), 80 - offset, 65 - offset); + if (recipeType.getOutputsSize() > 2) { + PositionedStack pStack5 = new PositionedStack(recipeType.getOutput(2), 80 - offset, 65 - offset); outputs.add(pStack5); } - if (recipeType.getOutputs().size() > 3) { - PositionedStack pStack6 = new PositionedStack(recipeType.getOutputs().get(3), 50 - offset, 35 - offset); + if (recipeType.getOutputsSize() > 3) { + PositionedStack pStack6 = new PositionedStack(recipeType.getOutput(3), 50 - offset, 35 - offset); outputs.add(pStack6); } } diff --git a/src/main/java/techreborn/compat/nei/recipes/ChemicalReactorRecipeHandler.java b/src/main/java/techreborn/compat/nei/recipes/ChemicalReactorRecipeHandler.java index ce2493e96..585305f62 100644 --- a/src/main/java/techreborn/compat/nei/recipes/ChemicalReactorRecipeHandler.java +++ b/src/main/java/techreborn/compat/nei/recipes/ChemicalReactorRecipeHandler.java @@ -22,8 +22,8 @@ public class ChemicalReactorRecipeHandler extends GenericRecipeHander implements input.add(pStack2); } - if (recipeType.getOutputs().size() > 0) { - PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 80 - offset, 51 - offset); + if (recipeType.getOutputsSize() > 0) { + PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 80 - offset, 51 - offset); outputs.add(pStack3); } } diff --git a/src/main/java/techreborn/compat/nei/recipes/GenericRecipeHander.java b/src/main/java/techreborn/compat/nei/recipes/GenericRecipeHander.java index 44be5b992..d96604777 100644 --- a/src/main/java/techreborn/compat/nei/recipes/GenericRecipeHander.java +++ b/src/main/java/techreborn/compat/nei/recipes/GenericRecipeHander.java @@ -113,11 +113,11 @@ public abstract class GenericRecipeHander extends TemplateRecipeHandler { @Override public void loadCraftingRecipes(ItemStack result) { for (IBaseRecipeType recipeType : RecipeHanderer.getRecipeClassFromName(getNeiBaseRecipe().getRecipeName())) { - for (ItemStack output : recipeType.getOutputs()) { - if (ItemUtils.isItemEqual(output, result, true, false, true)) { - addCached(recipeType); - } - } + for (int i = 0; i < recipeType.getOutputsSize(); i++) { + if (ItemUtils.isItemEqual(recipeType.getOutput(i), result, true, false, true)) { + addCached(recipeType); + } + } } } diff --git a/src/main/java/techreborn/compat/nei/recipes/GrinderRecipeHandler.java b/src/main/java/techreborn/compat/nei/recipes/GrinderRecipeHandler.java index 5a6d44fc5..f7ae49570 100644 --- a/src/main/java/techreborn/compat/nei/recipes/GrinderRecipeHandler.java +++ b/src/main/java/techreborn/compat/nei/recipes/GrinderRecipeHandler.java @@ -28,23 +28,23 @@ public class GrinderRecipeHandler extends GenericRecipeHander implements INeiBas input.add(pStack2); } - if (recipeType.getOutputs().size() > 0) { - PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 2 - offset, 77 - offset); + if (recipeType.getOutputsSize() > 0) { + PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 2 - offset, 77 - offset); outputs.add(pStack3); } - if (recipeType.getInputs().size() > 1) { - PositionedStack pStack4 = new PositionedStack(recipeType.getOutputs().get(1), 2 - offset, 95 - offset); + if (recipeType.getOutputsSize() > 1) { + PositionedStack pStack4 = new PositionedStack(recipeType.getOutput(1), 2 - offset, 95 - offset); outputs.add(pStack4); } - if (recipeType.getInputs().size() > 2) { - PositionedStack pStack5 = new PositionedStack(recipeType.getOutputs().get(2), 4 - offset, 113 - offset); + if (recipeType.getOutputsSize() > 2) { + PositionedStack pStack5 = new PositionedStack(recipeType.getOutput(2), 4 - offset, 113 - offset); outputs.add(pStack5); } - if (recipeType.getInputs().size() > 3) { - PositionedStack pStack6 = new PositionedStack(recipeType.getOutputs().get(3), 5 - offset, 131 - offset); + if (recipeType.getOutputsSize() > 3) { + PositionedStack pStack6 = new PositionedStack(recipeType.getOutput(3), 5 - offset, 131 - offset); outputs.add(pStack6); } diff --git a/src/main/java/techreborn/compat/nei/recipes/ImplosionCompressorRecipeHandler.java b/src/main/java/techreborn/compat/nei/recipes/ImplosionCompressorRecipeHandler.java index 5414d74ad..e8f578738 100644 --- a/src/main/java/techreborn/compat/nei/recipes/ImplosionCompressorRecipeHandler.java +++ b/src/main/java/techreborn/compat/nei/recipes/ImplosionCompressorRecipeHandler.java @@ -22,13 +22,13 @@ public class ImplosionCompressorRecipeHandler extends GenericRecipeHander implem input.add(pStack2); } - if (recipeType.getOutputs().size() > 0) { - PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 93 - offset, 35 - offset); + if (recipeType.getOutputsSize() > 0) { + PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 93 - offset, 35 - offset); outputs.add(pStack3); } - if (recipeType.getOutputs().size() > 1) { - PositionedStack pStack4 = new PositionedStack(recipeType.getOutputs().get(1), 111 - offset, 35 - offset); + if (recipeType.getOutputsSize() > 1) { + PositionedStack pStack4 = new PositionedStack(recipeType.getOutput(1), 111 - offset, 35 - offset); outputs.add(pStack4); } } diff --git a/src/main/java/techreborn/compat/nei/recipes/IndustrialSawmillRecipeHandler.java b/src/main/java/techreborn/compat/nei/recipes/IndustrialSawmillRecipeHandler.java index ac07b8ddc..542a6ee8b 100644 --- a/src/main/java/techreborn/compat/nei/recipes/IndustrialSawmillRecipeHandler.java +++ b/src/main/java/techreborn/compat/nei/recipes/IndustrialSawmillRecipeHandler.java @@ -22,18 +22,18 @@ public class IndustrialSawmillRecipeHandler extends GenericRecipeHander implemen input.add(pStack2); } - if (recipeType.getOutputs().size() > 0) { - PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 84 - offset, 35 - offset); + if (recipeType.getOutputsSize() > 0) { + PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 84 - offset, 35 - offset); outputs.add(pStack3); } - if (recipeType.getOutputs().size() > 1) { - PositionedStack pStack4 = new PositionedStack(recipeType.getOutputs().get(1), 102 - offset, 35 - offset); + if (recipeType.getOutputsSize() > 1) { + PositionedStack pStack4 = new PositionedStack(recipeType.getOutput(1), 102 - offset, 35 - offset); outputs.add(pStack4); } - if (recipeType.getOutputs().size() > 2) { - PositionedStack pStack5 = new PositionedStack(recipeType.getOutputs().get(2), 120 - offset, 35 - offset); + if (recipeType.getOutputsSize() > 2) { + PositionedStack pStack5 = new PositionedStack(recipeType.getOutput(2), 120 - offset, 35 - offset); outputs.add(pStack5); } } diff --git a/src/main/java/techreborn/compat/nei/recipes/LatheRecipeHandler.java b/src/main/java/techreborn/compat/nei/recipes/LatheRecipeHandler.java index 8b246c315..514dcff88 100644 --- a/src/main/java/techreborn/compat/nei/recipes/LatheRecipeHandler.java +++ b/src/main/java/techreborn/compat/nei/recipes/LatheRecipeHandler.java @@ -17,8 +17,8 @@ public class LatheRecipeHandler extends GenericRecipeHander implements INeiBaseR input.add(pStack); } - if (recipeType.getOutputs().size() > 0) { - PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset); + if (recipeType.getOutputsSize() > 0) { + PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 116 - offset, 35 - offset); outputs.add(pStack3); } } diff --git a/src/main/java/techreborn/compat/nei/recipes/PlateCuttingMachineRecipeHandler.java b/src/main/java/techreborn/compat/nei/recipes/PlateCuttingMachineRecipeHandler.java index d03253ad2..dcb1ada7d 100644 --- a/src/main/java/techreborn/compat/nei/recipes/PlateCuttingMachineRecipeHandler.java +++ b/src/main/java/techreborn/compat/nei/recipes/PlateCuttingMachineRecipeHandler.java @@ -16,8 +16,8 @@ public class PlateCuttingMachineRecipeHandler extends GenericRecipeHander implem PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 56 - offset, 17 - offset); input.add(pStack); } - if (recipeType.getOutputs().size() > 0) { - PositionedStack pStack3 = new PositionedStack(recipeType.getOutputs().get(0), 116 - offset, 35 - offset); + if (recipeType.getOutputsSize() > 0) { + PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 116 - offset, 35 - offset); outputs.add(pStack3); } } From 1ac6f592f8426ef14d0b9d94aa43ef346c32bde8 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sun, 7 Jun 2015 09:31:58 +0100 Subject: [PATCH 14/16] Fixes #25 --- src/main/java/techreborn/tiles/TileGasTurbine.java | 6 +++++- src/main/java/techreborn/util/Tank.java | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/techreborn/tiles/TileGasTurbine.java b/src/main/java/techreborn/tiles/TileGasTurbine.java index 070c23dfb..f8676f114 100644 --- a/src/main/java/techreborn/tiles/TileGasTurbine.java +++ b/src/main/java/techreborn/tiles/TileGasTurbine.java @@ -174,7 +174,11 @@ public class TileGasTurbine extends TileEntity implements IWrenchable, public void updateEntity() { super.updateEntity(); - FluidUtils.drainContainers(this, inventory, 0, 1); + if(!worldObj.isRemote){ + FluidUtils.drainContainers(this, inventory, 0, 1); + tank.compareAndUpdate(); + } + energySource.updateEntity(); if (tank.getFluidAmount() > 0 && energySource.getCapacity() - energySource.getEnergyStored() >= euTick) diff --git a/src/main/java/techreborn/util/Tank.java b/src/main/java/techreborn/util/Tank.java index a04614933..697594fae 100644 --- a/src/main/java/techreborn/util/Tank.java +++ b/src/main/java/techreborn/util/Tank.java @@ -59,6 +59,9 @@ public class Tank extends FluidTank { } public void compareAndUpdate() { + if(tile.getWorldObj().isRemote){ + return; + } FluidStack current = this.getFluid(); if (current != null) { if (lastBeforeUpdate != null) { From efba3f247d16e54617617e8ca6c46a01f553891e Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sun, 7 Jun 2015 09:38:12 +0100 Subject: [PATCH 15/16] added IInventory to all machines --- .../techreborn/tiles/TileAlloyFurnace.java | 64 ++++++++++++++++++- .../techreborn/tiles/TileAlloySmelter.java | 63 +++++++++++++++++- .../java/techreborn/tiles/TileCentrifuge.java | 63 +++++++++++++++++- .../techreborn/tiles/TileChunkLoader.java | 63 +++++++++++++++++- .../tiles/TileDragonEggSiphoner.java | 63 +++++++++++++++++- .../java/techreborn/tiles/TileGrinder.java | 63 +++++++++++++++++- .../tiles/TileImplosionCompressor.java | 63 +++++++++++++++++- .../tiles/TileIndustrialSawmill.java | 63 +++++++++++++++++- .../tiles/TileMatterFabricator.java | 63 +++++++++++++++++- .../techreborn/tiles/TileRollingMachine.java | 63 +++++++++++++++++- 10 files changed, 621 insertions(+), 10 deletions(-) diff --git a/src/main/java/techreborn/tiles/TileAlloyFurnace.java b/src/main/java/techreborn/tiles/TileAlloyFurnace.java index 4017586b8..0f4789157 100644 --- a/src/main/java/techreborn/tiles/TileAlloyFurnace.java +++ b/src/main/java/techreborn/tiles/TileAlloyFurnace.java @@ -2,12 +2,14 @@ package techreborn.tiles; import ic2.api.tile.IWrenchable; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import sun.awt.IconInfo; import techreborn.init.ModBlocks; import techreborn.util.Inventory; -public class TileAlloyFurnace extends TileMachineBase implements IWrenchable { +public class TileAlloyFurnace extends TileMachineBase implements IWrenchable , IInventory{ public int tickTime; public Inventory inventory = new Inventory(4, "TileAlloyFurnace", 64); @@ -82,4 +84,64 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable { inventory.writeToNBT(tagCompound); } + + @Override + public int getSizeInventory() { + return inventory.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int slot) { + return inventory.getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(int slot, int amount) { + return inventory.decrStackSize(slot, amount); + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + return inventory.getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) { + inventory.setInventorySlotContents(slot, stack); + } + + @Override + public String getInventoryName() { + return inventory.getInventoryName(); + } + + @Override + public boolean hasCustomInventoryName() { + return inventory.hasCustomInventoryName(); + } + + @Override + public int getInventoryStackLimit() { + return inventory.getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return inventory.isUseableByPlayer(player); + } + + @Override + public void openInventory() { + inventory.openInventory(); + } + + @Override + public void closeInventory() { + inventory.closeInventory(); + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack) { + return inventory.isItemValidForSlot(slot, stack); + } } diff --git a/src/main/java/techreborn/tiles/TileAlloySmelter.java b/src/main/java/techreborn/tiles/TileAlloySmelter.java index 44ca45441..ee338e5f3 100644 --- a/src/main/java/techreborn/tiles/TileAlloySmelter.java +++ b/src/main/java/techreborn/tiles/TileAlloySmelter.java @@ -4,6 +4,7 @@ import ic2.api.energy.prefab.BasicSink; import ic2.api.energy.tile.IEnergyTile; import ic2.api.tile.IWrenchable; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import techreborn.api.recipe.RecipeCrafter; @@ -12,7 +13,7 @@ import techreborn.util.Inventory; import java.util.List; -public class TileAlloySmelter extends TileMachineBase implements IWrenchable, IEnergyTile { +public class TileAlloySmelter extends TileMachineBase implements IWrenchable, IEnergyTile, IInventory { public int tickTime; public BasicSink energy; @@ -112,4 +113,64 @@ public class TileAlloySmelter extends TileMachineBase implements IWrenchable, IE info.add("Power Usage " + crafter.currentRecipe.euPerTick() + " EU/t"); } } + + @Override + public int getSizeInventory() { + return inventory.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int slot) { + return inventory.getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(int slot, int amount) { + return inventory.decrStackSize(slot, amount); + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + return inventory.getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) { + inventory.setInventorySlotContents(slot, stack); + } + + @Override + public String getInventoryName() { + return inventory.getInventoryName(); + } + + @Override + public boolean hasCustomInventoryName() { + return inventory.hasCustomInventoryName(); + } + + @Override + public int getInventoryStackLimit() { + return inventory.getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return inventory.isUseableByPlayer(player); + } + + @Override + public void openInventory() { + inventory.openInventory(); + } + + @Override + public void closeInventory() { + inventory.closeInventory(); + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack) { + return inventory.isItemValidForSlot(slot, stack); + } } diff --git a/src/main/java/techreborn/tiles/TileCentrifuge.java b/src/main/java/techreborn/tiles/TileCentrifuge.java index 92b27ba22..78bb1466a 100644 --- a/src/main/java/techreborn/tiles/TileCentrifuge.java +++ b/src/main/java/techreborn/tiles/TileCentrifuge.java @@ -4,6 +4,7 @@ import ic2.api.energy.prefab.BasicSink; import ic2.api.energy.tile.IEnergyTile; import ic2.api.tile.IWrenchable; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import techreborn.api.recipe.RecipeCrafter; @@ -13,7 +14,7 @@ import techreborn.util.Inventory; import java.util.List; -public class TileCentrifuge extends TileMachineBase implements IWrenchable, IEnergyTile{ +public class TileCentrifuge extends TileMachineBase implements IWrenchable, IEnergyTile, IInventory{ public int tickTime; public BasicSink energy; @@ -131,4 +132,64 @@ public class TileCentrifuge extends TileMachineBase implements IWrenchable, IEn info.add("Power Usage " + crafter.currentRecipe.euPerTick() + " EU/t"); } } + + @Override + public int getSizeInventory() { + return inventory.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int slot) { + return inventory.getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(int slot, int amount) { + return inventory.decrStackSize(slot, amount); + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + return inventory.getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) { + inventory.setInventorySlotContents(slot, stack); + } + + @Override + public String getInventoryName() { + return inventory.getInventoryName(); + } + + @Override + public boolean hasCustomInventoryName() { + return inventory.hasCustomInventoryName(); + } + + @Override + public int getInventoryStackLimit() { + return inventory.getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return inventory.isUseableByPlayer(player); + } + + @Override + public void openInventory() { + inventory.openInventory(); + } + + @Override + public void closeInventory() { + inventory.closeInventory(); + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack) { + return inventory.isItemValidForSlot(slot, stack); + } } \ No newline at end of file diff --git a/src/main/java/techreborn/tiles/TileChunkLoader.java b/src/main/java/techreborn/tiles/TileChunkLoader.java index 3bb91cffd..739cf77aa 100644 --- a/src/main/java/techreborn/tiles/TileChunkLoader.java +++ b/src/main/java/techreborn/tiles/TileChunkLoader.java @@ -4,11 +4,12 @@ import ic2.api.energy.prefab.BasicSink; import ic2.api.energy.tile.IEnergyTile; import ic2.api.tile.IWrenchable; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import techreborn.init.ModBlocks; import techreborn.util.Inventory; -public class TileChunkLoader extends TileMachineBase implements IWrenchable, IEnergyTile { +public class TileChunkLoader extends TileMachineBase implements IWrenchable, IEnergyTile, IInventory { public BasicSink energy; public Inventory inventory = new Inventory(1, "TileChunkLoader", 64); @@ -88,4 +89,64 @@ public class TileChunkLoader extends TileMachineBase implements IWrenchable, IEn return false; } + @Override + public int getSizeInventory() { + return inventory.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int slot) { + return inventory.getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(int slot, int amount) { + return inventory.decrStackSize(slot, amount); + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + return inventory.getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) { + inventory.setInventorySlotContents(slot, stack); + } + + @Override + public String getInventoryName() { + return inventory.getInventoryName(); + } + + @Override + public boolean hasCustomInventoryName() { + return inventory.hasCustomInventoryName(); + } + + @Override + public int getInventoryStackLimit() { + return inventory.getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return inventory.isUseableByPlayer(player); + } + + @Override + public void openInventory() { + inventory.openInventory(); + } + + @Override + public void closeInventory() { + inventory.closeInventory(); + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack) { + return inventory.isItemValidForSlot(slot, stack); + } + } diff --git a/src/main/java/techreborn/tiles/TileDragonEggSiphoner.java b/src/main/java/techreborn/tiles/TileDragonEggSiphoner.java index 27e687220..0e1a61eb7 100644 --- a/src/main/java/techreborn/tiles/TileDragonEggSiphoner.java +++ b/src/main/java/techreborn/tiles/TileDragonEggSiphoner.java @@ -5,13 +5,14 @@ import ic2.api.energy.tile.IEnergyTile; import ic2.api.tile.IWrenchable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import techreborn.config.ConfigTechReborn; import techreborn.init.ModBlocks; import techreborn.util.Inventory; -public class TileDragonEggSiphoner extends TileMachineBase implements IWrenchable, IEnergyTile { +public class TileDragonEggSiphoner extends TileMachineBase implements IWrenchable, IEnergyTile, IInventory { public BasicSource energy; public Inventory inventory = new Inventory(3, "TileAlloySmelter", 64); @@ -110,4 +111,64 @@ public class TileDragonEggSiphoner extends TileMachineBase implements IWrenchabl energy.writeToNBT(tagCompound); } + @Override + public int getSizeInventory() { + return inventory.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int slot) { + return inventory.getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(int slot, int amount) { + return inventory.decrStackSize(slot, amount); + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + return inventory.getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) { + inventory.setInventorySlotContents(slot, stack); + } + + @Override + public String getInventoryName() { + return inventory.getInventoryName(); + } + + @Override + public boolean hasCustomInventoryName() { + return inventory.hasCustomInventoryName(); + } + + @Override + public int getInventoryStackLimit() { + return inventory.getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return inventory.isUseableByPlayer(player); + } + + @Override + public void openInventory() { + inventory.openInventory(); + } + + @Override + public void closeInventory() { + inventory.closeInventory(); + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack) { + return inventory.isItemValidForSlot(slot, stack); + } + } diff --git a/src/main/java/techreborn/tiles/TileGrinder.java b/src/main/java/techreborn/tiles/TileGrinder.java index 6515f4357..a4aaf6499 100644 --- a/src/main/java/techreborn/tiles/TileGrinder.java +++ b/src/main/java/techreborn/tiles/TileGrinder.java @@ -4,6 +4,7 @@ import ic2.api.energy.prefab.BasicSink; import ic2.api.energy.tile.IEnergyTile; import ic2.api.tile.IWrenchable; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; @@ -16,7 +17,7 @@ import techreborn.util.FluidUtils; import techreborn.util.Inventory; import techreborn.util.Tank; -public class TileGrinder extends TileMachineBase implements IWrenchable, IEnergyTile, IFluidHandler { +public class TileGrinder extends TileMachineBase implements IWrenchable, IEnergyTile, IFluidHandler, IInventory { public int tickTime; public BasicSink energy; @@ -158,4 +159,64 @@ public class TileGrinder extends TileMachineBase implements IWrenchable, IEnergy public FluidTankInfo[] getTankInfo(ForgeDirection from) { return new FluidTankInfo[] { tank.getInfo() }; } + + @Override + public int getSizeInventory() { + return inventory.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int slot) { + return inventory.getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(int slot, int amount) { + return inventory.decrStackSize(slot, amount); + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + return inventory.getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) { + inventory.setInventorySlotContents(slot, stack); + } + + @Override + public String getInventoryName() { + return inventory.getInventoryName(); + } + + @Override + public boolean hasCustomInventoryName() { + return inventory.hasCustomInventoryName(); + } + + @Override + public int getInventoryStackLimit() { + return inventory.getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return inventory.isUseableByPlayer(player); + } + + @Override + public void openInventory() { + inventory.openInventory(); + } + + @Override + public void closeInventory() { + inventory.closeInventory(); + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack) { + return inventory.isItemValidForSlot(slot, stack); + } } diff --git a/src/main/java/techreborn/tiles/TileImplosionCompressor.java b/src/main/java/techreborn/tiles/TileImplosionCompressor.java index f783a66cc..c817c2ad3 100644 --- a/src/main/java/techreborn/tiles/TileImplosionCompressor.java +++ b/src/main/java/techreborn/tiles/TileImplosionCompressor.java @@ -4,6 +4,7 @@ import ic2.api.energy.prefab.BasicSink; import ic2.api.energy.tile.IEnergyTile; import ic2.api.tile.IWrenchable; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import techreborn.api.recipe.RecipeCrafter; @@ -12,7 +13,7 @@ import techreborn.util.Inventory; import java.util.List; -public class TileImplosionCompressor extends TileMachineBase implements IWrenchable, IEnergyTile { +public class TileImplosionCompressor extends TileMachineBase implements IWrenchable, IEnergyTile, IInventory { public int tickTime; public BasicSink energy; @@ -119,4 +120,64 @@ public class TileImplosionCompressor extends TileMachineBase implements IWrencha super.onChunkUnload(); } + + @Override + public int getSizeInventory() { + return inventory.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int slot) { + return inventory.getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(int slot, int amount) { + return inventory.decrStackSize(slot, amount); + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + return inventory.getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) { + inventory.setInventorySlotContents(slot, stack); + } + + @Override + public String getInventoryName() { + return inventory.getInventoryName(); + } + + @Override + public boolean hasCustomInventoryName() { + return inventory.hasCustomInventoryName(); + } + + @Override + public int getInventoryStackLimit() { + return inventory.getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return inventory.isUseableByPlayer(player); + } + + @Override + public void openInventory() { + inventory.openInventory(); + } + + @Override + public void closeInventory() { + inventory.closeInventory(); + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack) { + return inventory.isItemValidForSlot(slot, stack); + } } diff --git a/src/main/java/techreborn/tiles/TileIndustrialSawmill.java b/src/main/java/techreborn/tiles/TileIndustrialSawmill.java index 2d76ddd48..a21899df7 100644 --- a/src/main/java/techreborn/tiles/TileIndustrialSawmill.java +++ b/src/main/java/techreborn/tiles/TileIndustrialSawmill.java @@ -4,6 +4,7 @@ import ic2.api.energy.prefab.BasicSink; import ic2.api.energy.tile.IEnergyTile; import ic2.api.tile.IWrenchable; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import techreborn.api.recipe.RecipeCrafter; @@ -12,7 +13,7 @@ import techreborn.util.Inventory; import java.util.List; -public class TileIndustrialSawmill extends TileMachineBase implements IWrenchable, IEnergyTile { +public class TileIndustrialSawmill extends TileMachineBase implements IWrenchable, IEnergyTile, IInventory { public int tickTime; public BasicSink energy; @@ -127,4 +128,64 @@ public class TileIndustrialSawmill extends TileMachineBase implements IWrenchabl } } + @Override + public int getSizeInventory() { + return inventory.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int slot) { + return inventory.getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(int slot, int amount) { + return inventory.decrStackSize(slot, amount); + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + return inventory.getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) { + inventory.setInventorySlotContents(slot, stack); + } + + @Override + public String getInventoryName() { + return inventory.getInventoryName(); + } + + @Override + public boolean hasCustomInventoryName() { + return inventory.hasCustomInventoryName(); + } + + @Override + public int getInventoryStackLimit() { + return inventory.getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return inventory.isUseableByPlayer(player); + } + + @Override + public void openInventory() { + inventory.openInventory(); + } + + @Override + public void closeInventory() { + inventory.closeInventory(); + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack) { + return inventory.isItemValidForSlot(slot, stack); + } + } diff --git a/src/main/java/techreborn/tiles/TileMatterFabricator.java b/src/main/java/techreborn/tiles/TileMatterFabricator.java index 656f18e36..f1aa23587 100644 --- a/src/main/java/techreborn/tiles/TileMatterFabricator.java +++ b/src/main/java/techreborn/tiles/TileMatterFabricator.java @@ -4,13 +4,14 @@ import ic2.api.energy.prefab.BasicSink; import ic2.api.energy.tile.IEnergyTile; import ic2.api.tile.IWrenchable; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import techreborn.config.ConfigTechReborn; import techreborn.init.ModBlocks; import techreborn.util.Inventory; -public class TileMatterFabricator extends TileMachineBase implements IWrenchable, IEnergyTile { +public class TileMatterFabricator extends TileMachineBase implements IWrenchable, IEnergyTile, IInventory { public int tickTime; public BasicSink energy; @@ -96,4 +97,64 @@ public class TileMatterFabricator extends TileMachineBase implements IWrenchable super.onChunkUnload(); } + @Override + public int getSizeInventory() { + return inventory.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int slot) { + return inventory.getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(int slot, int amount) { + return inventory.decrStackSize(slot, amount); + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + return inventory.getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) { + inventory.setInventorySlotContents(slot, stack); + } + + @Override + public String getInventoryName() { + return inventory.getInventoryName(); + } + + @Override + public boolean hasCustomInventoryName() { + return inventory.hasCustomInventoryName(); + } + + @Override + public int getInventoryStackLimit() { + return inventory.getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return inventory.isUseableByPlayer(player); + } + + @Override + public void openInventory() { + inventory.openInventory(); + } + + @Override + public void closeInventory() { + inventory.closeInventory(); + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack) { + return inventory.isItemValidForSlot(slot, stack); + } + } diff --git a/src/main/java/techreborn/tiles/TileRollingMachine.java b/src/main/java/techreborn/tiles/TileRollingMachine.java index 7241c1769..f0aa13743 100644 --- a/src/main/java/techreborn/tiles/TileRollingMachine.java +++ b/src/main/java/techreborn/tiles/TileRollingMachine.java @@ -5,6 +5,7 @@ import ic2.api.energy.tile.IEnergyTile; import ic2.api.tile.IWrenchable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -14,7 +15,7 @@ import techreborn.util.Inventory; import techreborn.util.ItemUtils; //TODO add tick and power bars. -public class TileRollingMachine extends TileMachineBase implements IWrenchable, IEnergyTile { +public class TileRollingMachine extends TileMachineBase implements IWrenchable, IEnergyTile, IInventory { public BasicSink energy; public Inventory inventory = new Inventory(2, "TileRollingMachine", 64); @@ -205,4 +206,64 @@ public class TileRollingMachine extends TileMachineBase implements IWrenchable, energy.onChunkUnload(); super.onChunkUnload(); } + + @Override + public int getSizeInventory() { + return inventory.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int slot) { + return inventory.getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(int slot, int amount) { + return inventory.decrStackSize(slot, amount); + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + return inventory.getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) { + inventory.setInventorySlotContents(slot, stack); + } + + @Override + public String getInventoryName() { + return inventory.getInventoryName(); + } + + @Override + public boolean hasCustomInventoryName() { + return inventory.hasCustomInventoryName(); + } + + @Override + public int getInventoryStackLimit() { + return inventory.getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return inventory.isUseableByPlayer(player); + } + + @Override + public void openInventory() { + inventory.openInventory(); + } + + @Override + public void closeInventory() { + inventory.closeInventory(); + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack) { + return inventory.isItemValidForSlot(slot, stack); + } } From 06c21d26681cd99e0fd140ef835547a911da373d Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sun, 7 Jun 2015 11:11:07 +0100 Subject: [PATCH 16/16] this was the issue all along This would be the easy fix to my last commit. --- src/main/java/techreborn/api/recipe/RecipeCrafter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/techreborn/api/recipe/RecipeCrafter.java b/src/main/java/techreborn/api/recipe/RecipeCrafter.java index 9b8245bd1..5414b9005 100644 --- a/src/main/java/techreborn/api/recipe/RecipeCrafter.java +++ b/src/main/java/techreborn/api/recipe/RecipeCrafter.java @@ -152,7 +152,7 @@ public class RecipeCrafter { for (int i = 0; i < currentRecipe.getOutputsSize(); i++) { System.out.println(currentRecipe.getOutput(i).stackSize); if (!filledSlots.contains(outputSlots[i])) {//checks it has not been filled - fitStack(currentRecipe.getOutput(i), outputSlots[i]);//fills the slot with the output stack + fitStack(currentRecipe.getOutput(i).copy(), outputSlots[i]);//fills the slot with the output stack filledSlots.add(outputSlots[i]); } }