From fe9d41ac7667d07c1be6f100c3c9554d8bd15958 Mon Sep 17 00:00:00 2001 From: Modmuss50 Date: Mon, 23 Nov 2015 20:27:06 +0000 Subject: [PATCH] 50 --- .../powerSystem/TilePowerAcceptor.java | 22 +++++ .../techreborn/tiles/TileAlloyFurnace.java | 72 ++++++++++---- .../techreborn/tiles/TileAlloySmelter.java | 95 ++++++++++--------- .../tiles/TileAssemblingMachine.java | 95 ++++++++++--------- .../techreborn/tiles/TileBlastFurnace.java | 4 +- .../java/techreborn/tiles/TileCentrifuge.java | 89 +++++++++-------- .../techreborn/tiles/TileChargeBench.java | 88 ++++++++++------- .../techreborn/tiles/TileChemicalReactor.java | 85 ++++++++++------- .../techreborn/tiles/TileChunkLoader.java | 68 +++++++++---- .../techreborn/tiles/TileDieselGenerator.java | 73 +++++++++----- .../techreborn/tiles/TileDigitalChest.java | 75 ++++++++++----- .../tiles/TileDragonEggSiphoner.java | 54 ++++++++--- .../java/techreborn/tiles/TileGasTurbine.java | 61 ++++++++---- .../java/techreborn/tiles/TileGrinder.java | 68 +++++++++---- .../tiles/TileImplosionCompressor.java | 67 +++++++++---- .../tiles/TileIndustrialElectrolyzer.java | 74 +++++++++------ .../tiles/TileIndustrialSawmill.java | 68 +++++++++---- .../techreborn/tiles/TileMachineCasing.java | 8 +- .../tiles/TileMatterFabricator.java | 61 ++++++++---- .../techreborn/tiles/TileQuantumChest.java | 65 +++++++++---- .../techreborn/tiles/TileQuantumTank.java | 64 +++++++++---- .../techreborn/tiles/TileRollingMachine.java | 74 ++++++++------- .../tiles/TileSemifluidGenerator.java | 61 ++++++++---- .../tiles/TileThermalGenerator.java | 68 +++++++++---- .../techreborn/tiles/TileVacuumFreezer.java | 73 +++++++++----- 25 files changed, 1076 insertions(+), 556 deletions(-) diff --git a/src/main/java/techreborn/powerSystem/TilePowerAcceptor.java b/src/main/java/techreborn/powerSystem/TilePowerAcceptor.java index 9a46efed7..cdfa826b8 100644 --- a/src/main/java/techreborn/powerSystem/TilePowerAcceptor.java +++ b/src/main/java/techreborn/powerSystem/TilePowerAcceptor.java @@ -297,6 +297,28 @@ public abstract class TilePowerAcceptor extends RFProviderTile implements // } + public void charge(int slot) + { + //TODO rewrite to use built in power system +// if(getStackInSlot(slot) != null) +// { +// if(getStackInSlot(slot).getItem() instanceof IElectricItem) +// { +// if(getEnergy() != getMaxPower()) +// { +// ItemStack stack = inventory.getStackInSlot(slot); +// double MaxCharge = ((IElectricItem) stack.getItem()).getMaxCharge(stack); +// double CurrentCharge = ElectricItem.manager.getCharge(stack); +// if (CurrentCharge != 0) +// { +// ElectricItem.manager.discharge(stack, 5, 4, false, false, false); +// addEnergy(5); +// } +// } +// } +// } + } + public int getEnergyScaled(int scale) { return (int) ((energy * scale / getMaxPower())); } diff --git a/src/main/java/techreborn/tiles/TileAlloyFurnace.java b/src/main/java/techreborn/tiles/TileAlloyFurnace.java index 083ace8c8..3dc99eb06 100644 --- a/src/main/java/techreborn/tiles/TileAlloyFurnace.java +++ b/src/main/java/techreborn/tiles/TileAlloyFurnace.java @@ -9,6 +9,7 @@ import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.item.*; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IChatComponent; import net.minecraftforge.fml.common.registry.GameRegistry; import reborncore.common.util.Inventory; import reborncore.common.util.ItemUtils; @@ -20,7 +21,7 @@ import techreborn.lib.Reference; public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, IInventory { public int tickTime; - public Inventory inventory = new Inventory(4, "TileAlloyFurnace", 64); + public Inventory inventory = new Inventory(4, "TileAlloyFurnace", 64, this); int input1 = 0; int input2 = 1; @@ -214,7 +215,7 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD")) return 200; if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD")) return 200; - if (item instanceof ItemHoe && ((ItemHoe) item).getToolMaterialName().equals("WOOD")) return 200; + //if (item instanceof ItemHoe && ((ItemHoe) item).getToolMaterialName().equals("WOOD")) return 200; if (item == Items.stick) return 100; if (item == Items.coal) return 1600; if (item == Items.lava_bucket) return 20000; @@ -299,15 +300,6 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II inventory.setInventorySlotContents(slot, stack); } - @Override - public String getInventoryName() { - return inventory.getInventoryName(); - } - - @Override - public boolean hasCustomInventoryName() { - return inventory.hasCustomInventoryName(); - } @Override public int getInventoryStackLimit() { @@ -319,18 +311,56 @@ public class TileAlloyFurnace extends TileMachineBase implements IWrenchable, II 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 void openInventory(EntityPlayer player) { + inventory.openInventory(player); + } + + @Override + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); + } + + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); + } } diff --git a/src/main/java/techreborn/tiles/TileAlloySmelter.java b/src/main/java/techreborn/tiles/TileAlloySmelter.java index 1a39a86df..eb9b1a329 100644 --- a/src/main/java/techreborn/tiles/TileAlloySmelter.java +++ b/src/main/java/techreborn/tiles/TileAlloySmelter.java @@ -1,7 +1,5 @@ package techreborn.tiles; -import ic2.api.item.ElectricItem; -import ic2.api.item.IElectricItem; import ic2.api.tile.IWrenchable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -9,6 +7,7 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; +import net.minecraft.util.IChatComponent; import reborncore.common.util.Inventory; import techreborn.api.recipe.RecipeCrafter; import techreborn.api.upgrade.UpgradeHandler; @@ -19,7 +18,7 @@ import techreborn.powerSystem.TilePowerAcceptor; public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable, IInventory, ISidedInventory { public int tickTime; - public Inventory inventory = new Inventory(8, "TileAlloySmelter", 64); + public Inventory inventory = new Inventory(8, "TileAlloySmelter", 64, this); public RecipeCrafter crafter; public int capacity = 1000; UpgradeHandler upgrades; @@ -43,27 +42,7 @@ public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable, upgrades.tick(); charge(3); } - - public void charge(int slot) - { - if(getStackInSlot(slot) != null) - { - if(getStackInSlot(slot).getItem() instanceof IElectricItem) - { - if(getEnergy() != capacity) - { - ItemStack stack = inventory.getStackInSlot(slot); - double MaxCharge = ((IElectricItem) stack.getItem()).getMaxCharge(stack); - double CurrentCharge = ElectricItem.manager.getCharge(stack); - if (CurrentCharge != 0) - { - ElectricItem.manager.discharge(stack, 5, 4, false, false, false); - addEnergy(5); - } - } - } - } - } + @Override public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { @@ -149,15 +128,6 @@ public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable, inventory.setInventorySlotContents(slot, stack); } - @Override - public String getInventoryName() { - return inventory.getInventoryName(); - } - - @Override - public boolean hasCustomInventoryName() { - return inventory.hasCustomInventoryName(); - } @Override public int getInventoryStackLimit() { @@ -169,15 +139,6 @@ public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable, return inventory.isUseableByPlayer(player); } - @Override - public void openInventory() { - inventory.openInventory(); - } - - @Override - public void closeInventory() { - inventory.closeInventory(); - } @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { @@ -191,14 +152,14 @@ public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable, } @Override - public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) { + public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) { if (slotIndex == 2) return false; return isItemValidForSlot(slotIndex, itemStack); } @Override - public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) { + public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) { return slotIndex == 2; } @@ -233,4 +194,50 @@ public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable, public double getMaxInput() { return 32; } + + @Override + public void openInventory(EntityPlayer player) { + inventory.openInventory(player); + } + + @Override + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); + } + + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); + } } diff --git a/src/main/java/techreborn/tiles/TileAssemblingMachine.java b/src/main/java/techreborn/tiles/TileAssemblingMachine.java index 00fa16b0e..6720f2280 100644 --- a/src/main/java/techreborn/tiles/TileAssemblingMachine.java +++ b/src/main/java/techreborn/tiles/TileAssemblingMachine.java @@ -1,7 +1,5 @@ package techreborn.tiles; -import ic2.api.item.ElectricItem; -import ic2.api.item.IElectricItem; import ic2.api.tile.IWrenchable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -9,6 +7,7 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; +import net.minecraft.util.IChatComponent; import reborncore.common.util.Inventory; import techreborn.api.recipe.RecipeCrafter; import techreborn.init.ModBlocks; @@ -18,7 +17,7 @@ import techreborn.powerSystem.TilePowerAcceptor; public class TileAssemblingMachine extends TilePowerAcceptor implements IWrenchable, IInventory, ISidedInventory { public int tickTime; - public Inventory inventory = new Inventory(8, "TileAssemblingMachine", 64); + public Inventory inventory = new Inventory(8, "TileAssemblingMachine", 64, this); public RecipeCrafter crafter; public TileAssemblingMachine() { @@ -38,27 +37,6 @@ public class TileAssemblingMachine extends TilePowerAcceptor implements IWrencha crafter.updateEntity(); charge(3); } - - public void charge(int slot) - { - if(getStackInSlot(slot) != null) - { - if(getStackInSlot(slot).getItem() instanceof IElectricItem) - { - if(getEnergy() != getMaxPower()) - { - ItemStack stack = inventory.getStackInSlot(slot); - double MaxCharge = ((IElectricItem) stack.getItem()).getMaxCharge(stack); - double CurrentCharge = ElectricItem.manager.getCharge(stack); - if (CurrentCharge != 0) - { - ElectricItem.manager.discharge(stack, 5, 4, false, false, false); - addEnergy(5); - } - } - } - } - } @Override public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { @@ -136,16 +114,6 @@ public class TileAssemblingMachine extends TilePowerAcceptor implements IWrencha 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(); @@ -156,15 +124,6 @@ public class TileAssemblingMachine extends TilePowerAcceptor implements IWrencha return inventory.isUseableByPlayer(player); } - @Override - public void openInventory() { - inventory.openInventory(); - } - - @Override - public void closeInventory() { - inventory.closeInventory(); - } @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { @@ -178,14 +137,14 @@ public class TileAssemblingMachine extends TilePowerAcceptor implements IWrencha } @Override - public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) { + public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) { if (slotIndex == 2) return false; return isItemValidForSlot(slotIndex, itemStack); } @Override - public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) { + public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) { return slotIndex == 2; } @@ -230,4 +189,50 @@ public class TileAssemblingMachine extends TilePowerAcceptor implements IWrencha public double getMaxInput() { return 128; } + + @Override + public void openInventory(EntityPlayer player) { + inventory.openInventory(player); + } + + @Override + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); + } + + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); + } } diff --git a/src/main/java/techreborn/tiles/TileBlastFurnace.java b/src/main/java/techreborn/tiles/TileBlastFurnace.java index 2cb8e02e9..fc30d6907 100644 --- a/src/main/java/techreborn/tiles/TileBlastFurnace.java +++ b/src/main/java/techreborn/tiles/TileBlastFurnace.java @@ -218,14 +218,14 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable, } @Override - public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) { + public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) { if (slotIndex >= 1) return false; return isItemValidForSlot(slotIndex, itemStack); } @Override - public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) { + public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) { return slotIndex == 2 || slotIndex == 3; } diff --git a/src/main/java/techreborn/tiles/TileCentrifuge.java b/src/main/java/techreborn/tiles/TileCentrifuge.java index 2aa2e3d03..556ae8c47 100644 --- a/src/main/java/techreborn/tiles/TileCentrifuge.java +++ b/src/main/java/techreborn/tiles/TileCentrifuge.java @@ -1,7 +1,5 @@ package techreborn.tiles; -import ic2.api.item.ElectricItem; -import ic2.api.item.IElectricItem; import ic2.api.tile.IWrenchable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -9,6 +7,7 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; +import net.minecraft.util.IChatComponent; import reborncore.api.IListInfoProvider; import reborncore.common.util.Inventory; import techreborn.api.recipe.RecipeCrafter; @@ -22,7 +21,7 @@ import java.util.List; public class TileCentrifuge extends TilePowerAcceptor implements IWrenchable, IInventory, ISidedInventory, IListInfoProvider { public int tickTime; - public Inventory inventory = new Inventory(11, "TileCentrifuge", 64); + public Inventory inventory = new Inventory(11, "TileCentrifuge", 64, this); public RecipeCrafter crafter; public int euTick = ConfigTechReborn.CentrifugeInputTick; @@ -48,27 +47,7 @@ public class TileCentrifuge extends TilePowerAcceptor implements IWrenchable, II crafter.updateEntity(); charge(6); } - - public void charge(int slot) - { - if(getStackInSlot(slot) != null) - { - if(getStackInSlot(slot).getItem() instanceof IElectricItem) - { - if(getEnergy() != getMaxPower()) - { - ItemStack stack = inventory.getStackInSlot(slot); - double MaxCharge = ((IElectricItem) stack.getItem()).getMaxCharge(stack); - double CurrentCharge = ElectricItem.manager.getCharge(stack); - if (CurrentCharge != 0) - { - ElectricItem.manager.discharge(stack, 5, 4, false, false, false); - addEnergy(5); - } - } - } - } - } + @Override public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { @@ -151,16 +130,6 @@ public class TileCentrifuge extends TilePowerAcceptor implements IWrenchable, II 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(); @@ -188,19 +157,19 @@ public class TileCentrifuge extends TilePowerAcceptor implements IWrenchable, II // ISidedInventory @Override - public int[] getAccessibleSlotsFromSide(int side) { + public int[] getAccessibleSlotsFromSide(EnumFacing side) { return side == EnumFacing.DOWN.ordinal() ? new int[]{0, 1, 2, 3, 4, 5} : new int[]{0, 1, 2, 3, 4, 5}; } @Override - public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) { + public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) { if (slotIndex >= 2) return false; return isItemValidForSlot(slotIndex, itemStack); } @Override - public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) { + public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) { return slotIndex == 2 || slotIndex == 3 || slotIndex == 4 || slotIndex == 5; } @@ -235,4 +204,50 @@ public class TileCentrifuge extends TilePowerAcceptor implements IWrenchable, II public double getMaxInput() { return 32; } + + @Override + public void openInventory(EntityPlayer player) { + inventory.openInventory(player); + } + + @Override + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); + } + + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); + } } \ No newline at end of file diff --git a/src/main/java/techreborn/tiles/TileChargeBench.java b/src/main/java/techreborn/tiles/TileChargeBench.java index 9a5222caa..ed9917e37 100644 --- a/src/main/java/techreborn/tiles/TileChargeBench.java +++ b/src/main/java/techreborn/tiles/TileChargeBench.java @@ -1,7 +1,5 @@ package techreborn.tiles; -import ic2.api.item.ElectricItem; -import ic2.api.item.IElectricItem; import ic2.api.tile.IWrenchable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -9,6 +7,7 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; +import net.minecraft.util.IChatComponent; import reborncore.common.util.Inventory; import techreborn.api.power.IEnergyInterfaceItem; import techreborn.init.ModBlocks; @@ -16,7 +15,7 @@ import techreborn.powerSystem.TilePowerAcceptor; public class TileChargeBench extends TilePowerAcceptor implements IWrenchable, IInventory, ISidedInventory { - public Inventory inventory = new Inventory(6, "TileChargeBench", 64); + public Inventory inventory = new Inventory(6, "TileChargeBench", 64, this); public int capacity = 100000; public TileChargeBench() { @@ -36,8 +35,6 @@ public class TileChargeBench extends TilePowerAcceptor implements IWrenchable, I double trans = Math.min(interfaceItem.getMaxPower(stack) - interfaceItem.getEnergy(stack), Math.min(interfaceItem.getMaxTransfer(stack), getEnergy())); interfaceItem.setEnergy(trans + interfaceItem.getEnergy(stack), stack); useEnergy(trans); - } else if (stack.getItem() instanceof IElectricItem) { - useEnergy(ElectricItem.manager.charge(stack, getEnergy(), 4, false, false)); } } } @@ -118,16 +115,6 @@ public class TileChargeBench extends TilePowerAcceptor implements IWrenchable, I 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(); @@ -138,15 +125,6 @@ public class TileChargeBench extends TilePowerAcceptor implements IWrenchable, I return inventory.isUseableByPlayer(player); } - @Override - public void openInventory() { - inventory.openInventory(); - } - - @Override - public void closeInventory() { - inventory.closeInventory(); - } @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { @@ -160,18 +138,18 @@ public class TileChargeBench extends TilePowerAcceptor implements IWrenchable, I } @Override - public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) { + public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) { return isItemValidForSlot(slotIndex, itemStack); } @Override - public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) { - if (itemStack.getItem() instanceof IElectricItem) { - double CurrentCharge = ElectricItem.manager.getCharge(itemStack); - double MaxCharge = ((IElectricItem) itemStack.getItem()).getMaxCharge(itemStack); - if (CurrentCharge == MaxCharge) - return true; - } + public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) { +// if (itemStack.getItem() instanceof IElectricItem) { +// double CurrentCharge = ElectricItem.manager.getCharge(itemStack); +// double MaxCharge = ((IElectricItem) itemStack.getItem()).getMaxCharge(itemStack); +// if (CurrentCharge == MaxCharge) +// return true; +// } return false; } @@ -199,4 +177,50 @@ public class TileChargeBench extends TilePowerAcceptor implements IWrenchable, I public double getMaxInput() { return 512; } + + @Override + public void openInventory(EntityPlayer player) { + inventory.openInventory(player); + } + + @Override + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); + } + + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); + } } diff --git a/src/main/java/techreborn/tiles/TileChemicalReactor.java b/src/main/java/techreborn/tiles/TileChemicalReactor.java index 494cb5138..634d65619 100644 --- a/src/main/java/techreborn/tiles/TileChemicalReactor.java +++ b/src/main/java/techreborn/tiles/TileChemicalReactor.java @@ -1,7 +1,5 @@ package techreborn.tiles; -import ic2.api.item.ElectricItem; -import ic2.api.item.IElectricItem; import ic2.api.tile.IWrenchable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -9,6 +7,7 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; +import net.minecraft.util.IChatComponent; import reborncore.common.util.Inventory; import techreborn.api.recipe.RecipeCrafter; import techreborn.init.ModBlocks; @@ -18,7 +17,7 @@ import techreborn.powerSystem.TilePowerAcceptor; public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchable, IInventory, ISidedInventory { public int tickTime; - public Inventory inventory = new Inventory(8, "TileChemicalReactor", 64); + public Inventory inventory = new Inventory(8, "TileChemicalReactor", 64, this); public RecipeCrafter crafter; public TileChemicalReactor() { @@ -38,27 +37,6 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl crafter.updateEntity(); charge(3); } - - public void charge(int slot) - { - if(getStackInSlot(slot) != null) - { - if(getStackInSlot(slot).getItem() instanceof IElectricItem) - { - if(getEnergy() != getMaxPower()) - { - ItemStack stack = inventory.getStackInSlot(slot); - double MaxCharge = ((IElectricItem) stack.getItem()).getMaxCharge(stack); - double CurrentCharge = ElectricItem.manager.getCharge(stack); - if (CurrentCharge != 0) - { - ElectricItem.manager.discharge(stack, 5, 4, false, false, false); - addEnergy(5); - } - } - } - } - } @Override public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { @@ -135,15 +113,6 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl inventory.setInventorySlotContents(slot, stack); } - @Override - public String getInventoryName() { - return inventory.getInventoryName(); - } - - @Override - public boolean hasCustomInventoryName() { - return inventory.hasCustomInventoryName(); - } @Override public int getInventoryStackLimit() { @@ -177,14 +146,14 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl } @Override - public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) { + public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) { if (slotIndex == 2) return false; return isItemValidForSlot(slotIndex, itemStack); } @Override - public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) { + public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) { return slotIndex == 2; } @@ -229,4 +198,50 @@ public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchabl public double getMaxInput() { return 128; } + + @Override + public void openInventory(EntityPlayer player) { + inventory.openInventory(player); + } + + @Override + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); + } + + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); + } } diff --git a/src/main/java/techreborn/tiles/TileChunkLoader.java b/src/main/java/techreborn/tiles/TileChunkLoader.java index 82d899e92..23bcca809 100644 --- a/src/main/java/techreborn/tiles/TileChunkLoader.java +++ b/src/main/java/techreborn/tiles/TileChunkLoader.java @@ -5,13 +5,14 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; +import net.minecraft.util.IChatComponent; import reborncore.common.util.Inventory; import techreborn.init.ModBlocks; import techreborn.powerSystem.TilePowerAcceptor; public class TileChunkLoader extends TilePowerAcceptor implements IWrenchable, IInventory { - public Inventory inventory = new Inventory(1, "TileChunkLoader", 64); + public Inventory inventory = new Inventory(1, "TileChunkLoader", 64, this); public boolean isRunning; public int tickTime; @@ -83,16 +84,6 @@ public class TileChunkLoader extends TilePowerAcceptor implements IWrenchable, I 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(); @@ -103,15 +94,6 @@ public class TileChunkLoader extends TilePowerAcceptor implements IWrenchable, I return inventory.isUseableByPlayer(player); } - @Override - public void openInventory() { - inventory.openInventory(); - } - - @Override - public void closeInventory() { - inventory.closeInventory(); - } @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { @@ -142,4 +124,50 @@ public class TileChunkLoader extends TilePowerAcceptor implements IWrenchable, I public double getMaxInput() { return 32; } + + @Override + public void openInventory(EntityPlayer player) { + inventory.openInventory(player); + } + + @Override + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); + } + + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); + } } diff --git a/src/main/java/techreborn/tiles/TileDieselGenerator.java b/src/main/java/techreborn/tiles/TileDieselGenerator.java index ca5501991..f3e055649 100644 --- a/src/main/java/techreborn/tiles/TileDieselGenerator.java +++ b/src/main/java/techreborn/tiles/TileDieselGenerator.java @@ -9,6 +9,7 @@ import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.util.EnumFacing; +import net.minecraft.util.IChatComponent; import net.minecraftforge.fluids.*; import reborncore.api.fuel.FluidPowerManager; import reborncore.common.util.FluidUtils; @@ -23,7 +24,7 @@ public class TileDieselGenerator extends TilePowerAcceptor implements IWrenchabl public Tank tank = new Tank("TileDieselGenerator", FluidContainerRegistry.BUCKET_VOLUME * 10, this); - public Inventory inventory = new Inventory(3, "TileDieselGenerator", 64); + public Inventory inventory = new Inventory(3, "TileDieselGenerator", 64, this); public static final int euTick = ConfigTechReborn.ThermalGenertaorOutput; public TileDieselGenerator() { @@ -118,8 +119,7 @@ public class TileDieselGenerator extends TilePowerAcceptor implements IWrenchabl public Packet getDescriptionPacket() { NBTTagCompound nbtTag = new NBTTagCompound(); writeToNBT(nbtTag); - return new S35PacketUpdateTileEntity(this.getPos().getX(), this.getPos().getY(), - this.getPos().getZ(), 1, nbtTag); + return new S35PacketUpdateTileEntity(this.getPos(), 1, nbtTag); } @Override @@ -127,7 +127,7 @@ public class TileDieselGenerator extends TilePowerAcceptor implements IWrenchabl S35PacketUpdateTileEntity packet) { worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(), getPos().getY(), getPos().getZ()); - readFromNBT(packet.func_148857_g()); + readFromNBT(packet.getNbtCompound()); } @Override @@ -181,16 +181,6 @@ public class TileDieselGenerator extends TilePowerAcceptor implements IWrenchabl inventory.setInventorySlotContents(p_70299_1_, p_70299_2_); } - @Override - public String getInventoryName() { - return inventory.getInventoryName(); - } - - @Override - public boolean hasCustomInventoryName() { - return inventory.hasCustomInventoryName(); - } - @Override public int getInventoryStackLimit() { return inventory.getInventoryStackLimit(); @@ -201,15 +191,6 @@ public class TileDieselGenerator extends TilePowerAcceptor implements IWrenchabl return inventory.isUseableByPlayer(p_70300_1_); } - @Override - public void openInventory() { - inventory.openInventory(); - } - - @Override - public void closeInventory() { - inventory.closeInventory(); - } @Override public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { @@ -240,4 +221,50 @@ public class TileDieselGenerator extends TilePowerAcceptor implements IWrenchabl public double getMaxInput() { return 0; } + + @Override + public void openInventory(EntityPlayer player) { + inventory.openInventory(player); + } + + @Override + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); + } + + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); + } } diff --git a/src/main/java/techreborn/tiles/TileDigitalChest.java b/src/main/java/techreborn/tiles/TileDigitalChest.java index fb255f649..cda7c7b03 100644 --- a/src/main/java/techreborn/tiles/TileDigitalChest.java +++ b/src/main/java/techreborn/tiles/TileDigitalChest.java @@ -8,6 +8,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.util.IChatComponent; import reborncore.api.IListInfoProvider; import reborncore.common.util.Inventory; import reborncore.common.util.ItemUtils; @@ -25,7 +26,7 @@ public class TileDigitalChest extends TileMachineBase implements IInventory, //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 Inventory inventory = new Inventory(3, "TileDigitalChest", storage, this); public ItemStack storedItem; @@ -95,8 +96,7 @@ public class TileDigitalChest extends TileMachineBase implements IInventory, public Packet getDescriptionPacket() { NBTTagCompound nbtTag = new NBTTagCompound(); writeToNBT(nbtTag); - return new S35PacketUpdateTileEntity(this.getPos().getX(), this.getPos().getY(), - this.getPos().getZ(), 1, nbtTag); + return new S35PacketUpdateTileEntity(this.getPos(), 1, nbtTag); } @Override @@ -104,7 +104,7 @@ public class TileDigitalChest extends TileMachineBase implements IInventory, S35PacketUpdateTileEntity packet) { worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(), getPos().getY(), getPos().getZ()); - readFromNBT(packet.func_148857_g()); + readFromNBT(packet.getNbtCompound()); } @Override @@ -170,16 +170,6 @@ public class TileDigitalChest extends TileMachineBase implements IInventory, 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(); @@ -190,15 +180,6 @@ public class TileDigitalChest extends TileMachineBase implements IInventory, return inventory.isUseableByPlayer(player); } - @Override - public void openInventory() { - inventory.openInventory(); - } - - @Override - public void closeInventory() { - inventory.closeInventory(); - } @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { @@ -242,7 +223,7 @@ public class TileDigitalChest extends TileMachineBase implements IInventory, ItemStack dropStack = new ItemStack(ModBlocks.digitalChest, 1); writeToNBTWithoutCoords(tileEntity); dropStack.setTagCompound(new NBTTagCompound()); - dropStack.stackTagCompound.setTag("tileEntity", tileEntity); + dropStack.getTagCompound().setTag("tileEntity", tileEntity); return dropStack; } @@ -262,4 +243,50 @@ public class TileDigitalChest extends TileMachineBase implements IInventory, } + @Override + public void openInventory(EntityPlayer player) { + inventory.openInventory(player); + } + + @Override + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); + } + + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); + } + } diff --git a/src/main/java/techreborn/tiles/TileDragonEggSiphoner.java b/src/main/java/techreborn/tiles/TileDragonEggSiphoner.java index e0b324e16..8e2aa9c63 100644 --- a/src/main/java/techreborn/tiles/TileDragonEggSiphoner.java +++ b/src/main/java/techreborn/tiles/TileDragonEggSiphoner.java @@ -7,6 +7,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; +import net.minecraft.util.IChatComponent; import reborncore.common.util.Inventory; import techreborn.config.ConfigTechReborn; import techreborn.init.ModBlocks; @@ -106,13 +107,49 @@ public class TileDragonEggSiphoner extends TilePowerAcceptor implements IWrencha } @Override - public String getInventoryName() { - return inventory.getInventoryName(); + public void openInventory(EntityPlayer player) { + inventory.openInventory(player); } @Override - public boolean hasCustomInventoryName() { - return inventory.hasCustomInventoryName(); + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); + } + + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); } @Override @@ -125,15 +162,6 @@ public class TileDragonEggSiphoner extends TilePowerAcceptor implements IWrencha return inventory.isUseableByPlayer(player); } - @Override - public void openInventory() { - inventory.openInventory(); - } - - @Override - public void closeInventory() { - inventory.closeInventory(); - } @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { diff --git a/src/main/java/techreborn/tiles/TileGasTurbine.java b/src/main/java/techreborn/tiles/TileGasTurbine.java index 94499d07b..24a945a25 100644 --- a/src/main/java/techreborn/tiles/TileGasTurbine.java +++ b/src/main/java/techreborn/tiles/TileGasTurbine.java @@ -9,6 +9,7 @@ import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.util.EnumFacing; +import net.minecraft.util.IChatComponent; import net.minecraftforge.fluids.*; import reborncore.common.util.FluidUtils; import reborncore.common.util.Inventory; @@ -25,7 +26,7 @@ public class TileGasTurbine extends TilePowerAcceptor implements IWrenchable, public Tank tank = new Tank("TileGasTurbine", FluidContainerRegistry.BUCKET_VOLUME * 10, this); - public Inventory inventory = new Inventory(3, "TileGasTurbine", 64); + public Inventory inventory = new Inventory(3, "TileGasTurbine", 64, this); //TODO: run this off config public static final int euTick = 16; @@ -132,8 +133,7 @@ public class TileGasTurbine extends TilePowerAcceptor implements IWrenchable, public Packet getDescriptionPacket() { NBTTagCompound nbtTag = new NBTTagCompound(); writeToNBT(nbtTag); - return new S35PacketUpdateTileEntity(this.getPos().getX(), this.getPos().getY(), - this.getPos().getZ(), 1, nbtTag); + return new S35PacketUpdateTileEntity(this.getPos(), 1, nbtTag); } @Override @@ -141,7 +141,7 @@ public class TileGasTurbine extends TilePowerAcceptor implements IWrenchable, S35PacketUpdateTileEntity packet) { worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(), getPos().getY(), getPos().getZ()); - readFromNBT(packet.func_148857_g()); + readFromNBT(packet.getNbtCompound()); } @Override @@ -200,15 +200,50 @@ public class TileGasTurbine extends TilePowerAcceptor implements IWrenchable, } @Override - public String getInventoryName() { - return inventory.getInventoryName(); + public void openInventory(EntityPlayer player) { + inventory.openInventory(player); } @Override - public boolean hasCustomInventoryName() { - return inventory.hasCustomInventoryName(); + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); } + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); + } @Override public int getInventoryStackLimit() { return inventory.getInventoryStackLimit(); @@ -219,16 +254,6 @@ public class TileGasTurbine extends TilePowerAcceptor implements IWrenchable, return inventory.isUseableByPlayer(p_70300_1_); } - @Override - public void openInventory() { - inventory.openInventory(); - } - - @Override - public void closeInventory() { - inventory.closeInventory(); - } - @Override public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { return inventory.isItemValidForSlot(p_94041_1_, p_94041_2_); diff --git a/src/main/java/techreborn/tiles/TileGrinder.java b/src/main/java/techreborn/tiles/TileGrinder.java index d8ce95aae..742b181ff 100644 --- a/src/main/java/techreborn/tiles/TileGrinder.java +++ b/src/main/java/techreborn/tiles/TileGrinder.java @@ -7,7 +7,9 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.IChatComponent; import net.minecraftforge.fluids.*; import reborncore.common.misc.Location; import reborncore.common.util.FluidUtils; @@ -24,7 +26,7 @@ import techreborn.powerSystem.TilePowerAcceptor; public class TileGrinder extends TilePowerAcceptor implements IWrenchable, IFluidHandler, IInventory, ISidedInventory { public int tickTime; - public Inventory inventory = new Inventory(6, "TileGrinder", 64); + public Inventory inventory = new Inventory(6, "TileGrinder", 64, this); public Tank tank = new Tank("TileGrinder", 16000, this); public RecipeCrafter crafter; @@ -80,15 +82,15 @@ public class TileGrinder extends TilePowerAcceptor implements IWrenchable, IFlui } public boolean getMutliBlock() { - for (EnumFacing direction : EnumFacing.VALID_DIRECTIONS) { - TileEntity tileEntity = worldObj.getTileEntity(getPos().getX() + direction.offsetX, getPos().getY() + direction.offsetY, getPos().getZ() + direction.offsetZ); + for (EnumFacing direction : EnumFacing.values()) { + TileEntity tileEntity = worldObj.getTileEntity(new BlockPos(getPos().getX() + direction.getFrontOffsetX(), getPos().getY() + direction.getFrontOffsetY(), getPos().getZ() + direction.getFrontOffsetZ())); if (tileEntity instanceof TileMachineCasing) { if ((tileEntity.getBlockType() instanceof BlockMachineCasing)) { int heat; heat = BlockMachineCasing.getHeatFromMeta(tileEntity.getBlockMetadata()); Location location = new Location(getPos().getX(), getPos().getY(), getPos().getZ(), direction); location.modifyPositionFromSide(direction, 1); - if (worldObj.getBlock(location.getX(), location.getY(), location.getZ()).getUnlocalizedName().equals("tile.lava")) { + if (worldObj.getBlockState(new BlockPos(location.getX(), location.getY(), location.getZ())).getBlock().getUnlocalizedName().equals("tile.lava")) { heat += 500; } return true; @@ -206,13 +208,49 @@ public class TileGrinder extends TilePowerAcceptor implements IWrenchable, IFlui } @Override - public String getInventoryName() { - return inventory.getInventoryName(); + public void openInventory(EntityPlayer player) { + inventory.openInventory(player); } @Override - public boolean hasCustomInventoryName() { - return inventory.hasCustomInventoryName(); + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); + } + + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); } @Override @@ -225,16 +263,6 @@ public class TileGrinder extends TilePowerAcceptor implements IWrenchable, IFlui 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); @@ -247,14 +275,14 @@ public class TileGrinder extends TilePowerAcceptor implements IWrenchable, IFlui } @Override - public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) { + public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) { if (slotIndex >= 2) return false; return isItemValidForSlot(slotIndex, itemStack); } @Override - public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) { + public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) { return slotIndex == 2 || slotIndex == 3 || slotIndex == 4 || slotIndex == 5; } diff --git a/src/main/java/techreborn/tiles/TileImplosionCompressor.java b/src/main/java/techreborn/tiles/TileImplosionCompressor.java index 2743b380c..2034c800f 100644 --- a/src/main/java/techreborn/tiles/TileImplosionCompressor.java +++ b/src/main/java/techreborn/tiles/TileImplosionCompressor.java @@ -7,7 +7,9 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.IChatComponent; import reborncore.common.misc.Location; import reborncore.common.util.Inventory; import techreborn.api.recipe.RecipeCrafter; @@ -19,7 +21,7 @@ import techreborn.powerSystem.TilePowerAcceptor; public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenchable, IInventory, ISidedInventory { public int tickTime; - public Inventory inventory = new Inventory(4, "TileImplosionCompressor", 64); + public Inventory inventory = new Inventory(4, "TileImplosionCompressor", 64,this); public RecipeCrafter crafter; public TileImplosionCompressor() { @@ -67,15 +69,15 @@ public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenc } public boolean getMutliBlock() { - for (EnumFacing direction : EnumFacing.VALID_DIRECTIONS) { - TileEntity tileEntity = worldObj.getTileEntity(getPos().getX() + direction.offsetX, getPos().getY() + direction.offsetY, getPos().getZ() + direction.offsetZ); + for (EnumFacing direction : EnumFacing.values()) { + TileEntity tileEntity = worldObj.getTileEntity(new BlockPos(getPos().getX() + direction.getFrontOffsetX(), getPos().getY() + direction.getFrontOffsetY(), getPos().getZ() + direction.getFrontOffsetZ())); if (tileEntity instanceof TileMachineCasing) { if ((tileEntity.getBlockType() instanceof BlockMachineCasing)) { int heat; heat = BlockMachineCasing.getHeatFromMeta(tileEntity.getBlockMetadata()); Location location = new Location(getPos().getX(), getPos().getY(), getPos().getZ(), direction); location.modifyPositionFromSide(direction, 1); - if (worldObj.getBlock(location.getX(), location.getY(), location.getZ()).getUnlocalizedName().equals("tile.lava")) { + if (worldObj.getBlockState(new BlockPos(location.getX(), location.getY(), location.getZ())).getBlock().getUnlocalizedName().equals("tile.lava")) { heat += 500; } return true; @@ -144,15 +146,50 @@ public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenc } @Override - public String getInventoryName() { - return inventory.getInventoryName(); + public void openInventory(EntityPlayer player) { + inventory.openInventory(player); } @Override - public boolean hasCustomInventoryName() { - return inventory.hasCustomInventoryName(); + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); } + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); + } @Override public int getInventoryStackLimit() { return inventory.getInventoryStackLimit(); @@ -163,16 +200,6 @@ public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenc 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); @@ -185,14 +212,14 @@ public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenc } @Override - public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) { + public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) { if (slotIndex >= 2) return false; return isItemValidForSlot(slotIndex, itemStack); } @Override - public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) { + public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) { return slotIndex == 2 || slotIndex == 3; } diff --git a/src/main/java/techreborn/tiles/TileIndustrialElectrolyzer.java b/src/main/java/techreborn/tiles/TileIndustrialElectrolyzer.java index 2d851c9a0..fe246a376 100644 --- a/src/main/java/techreborn/tiles/TileIndustrialElectrolyzer.java +++ b/src/main/java/techreborn/tiles/TileIndustrialElectrolyzer.java @@ -1,7 +1,5 @@ package techreborn.tiles; -import ic2.api.item.ElectricItem; -import ic2.api.item.IElectricItem; import ic2.api.tile.IWrenchable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -9,6 +7,7 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; +import net.minecraft.util.IChatComponent; import reborncore.common.util.Inventory; import techreborn.api.recipe.RecipeCrafter; import techreborn.init.ModBlocks; @@ -18,7 +17,7 @@ import techreborn.powerSystem.TilePowerAcceptor; public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWrenchable, IInventory, ISidedInventory { public int tickTime; - public Inventory inventory = new Inventory(8, "TileIndustrialElectrolyzer", 64); + public Inventory inventory = new Inventory(8, "TileIndustrialElectrolyzer", 64, this); public RecipeCrafter crafter; public TileIndustrialElectrolyzer() { @@ -41,27 +40,6 @@ public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWr crafter.updateEntity(); charge(6); } - - public void charge(int slot) - { - if(getStackInSlot(slot) != null) - { - if(getStackInSlot(slot).getItem() instanceof IElectricItem) - { - if(getEnergy() != getMaxPower()) - { - ItemStack stack = inventory.getStackInSlot(slot); - double MaxCharge = ((IElectricItem) stack.getItem()).getMaxCharge(stack); - double CurrentCharge = ElectricItem.manager.getCharge(stack); - if (CurrentCharge != 0) - { - ElectricItem.manager.discharge(stack, 5, 4, false, false, false); - addEnergy(5); - } - } - } - } - } @Override public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { @@ -149,13 +127,49 @@ public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWr } @Override - public String getInventoryName() { - return inventory.getInventoryName(); + public void openInventory(EntityPlayer player) { + inventory.openInventory(player); } @Override - public boolean hasCustomInventoryName() { - return inventory.hasCustomInventoryName(); + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); + } + + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); } @Override @@ -190,14 +204,14 @@ public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWr } @Override - public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) { + public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) { if (slotIndex >= 1) return false; return isItemValidForSlot(slotIndex, itemStack); } @Override - public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) { + public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) { return slotIndex == 2 || slotIndex == 3 || slotIndex == 4 || slotIndex == 5; } diff --git a/src/main/java/techreborn/tiles/TileIndustrialSawmill.java b/src/main/java/techreborn/tiles/TileIndustrialSawmill.java index bd600d94f..902acd843 100644 --- a/src/main/java/techreborn/tiles/TileIndustrialSawmill.java +++ b/src/main/java/techreborn/tiles/TileIndustrialSawmill.java @@ -7,7 +7,9 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.IChatComponent; import net.minecraftforge.fluids.*; import reborncore.api.IListInfoProvider; import reborncore.common.misc.Location; @@ -24,7 +26,7 @@ import techreborn.powerSystem.TilePowerAcceptor; public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrenchable, IFluidHandler, IInventory, ISidedInventory, IListInfoProvider { public int tickTime; - public Inventory inventory = new Inventory(5, "TileIndustrialSawmill", 64); + public Inventory inventory = new Inventory(5, "TileIndustrialSawmill", 64, this); public Tank tank = new Tank("TileSawmill", 16000, this); public RecipeCrafter crafter; @@ -53,15 +55,15 @@ public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrencha } public boolean getMutliBlock() { - for (EnumFacing direction : EnumFacing.VALID_DIRECTIONS) { - TileEntity tileEntity = worldObj.getTileEntity(getPos().getX() + direction.offsetX, getPos().getY() + direction.offsetY, getPos().getZ() + direction.offsetZ); + for (EnumFacing direction : EnumFacing.values()) { + TileEntity tileEntity = worldObj.getTileEntity(new BlockPos(getPos().getX() + direction.getFrontOffsetX(), getPos().getY() + direction.getFrontOffsetY(), getPos().getZ() + direction.getFrontOffsetZ())); if (tileEntity instanceof TileMachineCasing) { if ((tileEntity.getBlockType() instanceof BlockMachineCasing)) { int heat; heat = BlockMachineCasing.getHeatFromMeta(tileEntity.getBlockMetadata()); Location location = new Location(getPos().getX(), getPos().getY(), getPos().getZ(), direction); location.modifyPositionFromSide(direction, 1); - if (worldObj.getBlock(location.getX(), location.getY(), location.getZ()).getUnlocalizedName().equals("tile.lava")) { + if (worldObj.getBlockState(location.getBlockPos()).getBlock().getUnlocalizedName().equals("tile.lava")) { heat += 500; } return true; @@ -196,13 +198,49 @@ public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrencha } @Override - public String getInventoryName() { - return inventory.getInventoryName(); + public void openInventory(EntityPlayer player) { + inventory.openInventory(player); } @Override - public boolean hasCustomInventoryName() { - return inventory.hasCustomInventoryName(); + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); + } + + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); } @Override @@ -215,16 +253,6 @@ public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrencha 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); @@ -237,14 +265,14 @@ public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrencha } @Override - public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) { + public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) { if (slotIndex >= 2) return false; return isItemValidForSlot(slotIndex, itemStack); } @Override - public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) { + public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) { return slotIndex == 2 || slotIndex == 3 || slotIndex == 4; } diff --git a/src/main/java/techreborn/tiles/TileMachineCasing.java b/src/main/java/techreborn/tiles/TileMachineCasing.java index 76c8541a2..015cfb041 100644 --- a/src/main/java/techreborn/tiles/TileMachineCasing.java +++ b/src/main/java/techreborn/tiles/TileMachineCasing.java @@ -7,10 +7,6 @@ import techreborn.multiblocks.MultiBlockCasing; public class TileMachineCasing extends RectangularMultiblockTileEntityBase { - @Override - public boolean canUpdate() { - return false; - } @Override public void onMachineActivated() { @@ -61,4 +57,8 @@ public class TileMachineCasing extends RectangularMultiblockTileEntityBase { return (MultiBlockCasing) super.getMultiblockController(); } + @Override + public void tick() { + + } } diff --git a/src/main/java/techreborn/tiles/TileMatterFabricator.java b/src/main/java/techreborn/tiles/TileMatterFabricator.java index 2a32a66f9..0875d0fda 100644 --- a/src/main/java/techreborn/tiles/TileMatterFabricator.java +++ b/src/main/java/techreborn/tiles/TileMatterFabricator.java @@ -9,6 +9,7 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; +import net.minecraft.util.IChatComponent; import reborncore.common.util.Inventory; import reborncore.common.util.ItemUtils; import techreborn.init.ModBlocks; @@ -19,7 +20,7 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab public static int fabricationRate = 2666656; public int tickTime; - public Inventory inventory = new Inventory(7, "TileMatterFabricator", 64); + public Inventory inventory = new Inventory(7, "TileMatterFabricator", 64, this); private int amplifier = 0; public int progresstime = 0; @@ -102,13 +103,49 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab } @Override - public String getInventoryName() { - return inventory.getInventoryName(); + public void openInventory(EntityPlayer player) { + inventory.openInventory(player); } @Override - public boolean hasCustomInventoryName() { - return inventory.hasCustomInventoryName(); + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); + } + + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); } @Override @@ -121,16 +158,6 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab 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); @@ -143,14 +170,14 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab } @Override - public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) { + public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) { if (slotIndex == 6) return false; return isItemValidForSlot(slotIndex, itemStack); } @Override - public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) { + public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) { return slotIndex == 6; } diff --git a/src/main/java/techreborn/tiles/TileQuantumChest.java b/src/main/java/techreborn/tiles/TileQuantumChest.java index e2aa9a9c3..bf4058b74 100644 --- a/src/main/java/techreborn/tiles/TileQuantumChest.java +++ b/src/main/java/techreborn/tiles/TileQuantumChest.java @@ -8,6 +8,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.util.IChatComponent; import powercrystals.minefactoryreloaded.api.IDeepStorageUnit; import reborncore.api.IListInfoProvider; import reborncore.common.util.Inventory; @@ -26,7 +27,7 @@ public class TileQuantumChest extends TileMachineBase implements IInventory, //TODO use long so we can have 9,223,372,036,854,775,807 items instead of 2,147,483,647 int storage = (int) Double.MAX_VALUE; - public Inventory inventory = new Inventory(3, "TileQuantumChest", storage); + public Inventory inventory = new Inventory(3, "TileQuantumChest", storage, this); public ItemStack storedItem; @@ -95,14 +96,13 @@ public class TileQuantumChest extends TileMachineBase implements IInventory, public Packet getDescriptionPacket() { NBTTagCompound nbtTag = new NBTTagCompound(); writeToNBT(nbtTag); - return new S35PacketUpdateTileEntity(this.getPos().getX(), this.getPos().getY(), - this.getPos().getZ(), 1, nbtTag); + return new S35PacketUpdateTileEntity(this.getPos(), 1, nbtTag); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(), getPos().getY(), getPos().getZ()); - readFromNBT(packet.func_148857_g()); + readFromNBT(packet.getNbtCompound()); } @Override @@ -167,15 +167,50 @@ public class TileQuantumChest extends TileMachineBase implements IInventory, public void setInventorySlotContents(int slot, ItemStack stack) { inventory.setInventorySlotContents(slot, stack); } - @Override - public String getInventoryName() { - return inventory.getInventoryName(); + public void openInventory(EntityPlayer player) { + inventory.openInventory(player); } @Override - public boolean hasCustomInventoryName() { - return inventory.hasCustomInventoryName(); + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); + } + + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); } @Override @@ -188,16 +223,6 @@ public class TileQuantumChest extends TileMachineBase implements IInventory, 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); @@ -240,7 +265,7 @@ public class TileQuantumChest extends TileMachineBase implements IInventory, ItemStack dropStack = new ItemStack(ModBlocks.quantumChest, 1); writeToNBTWithoutCoords(tileEntity); dropStack.setTagCompound(new NBTTagCompound()); - dropStack.stackTagCompound.setTag("tileEntity", tileEntity); + dropStack.getTagCompound().setTag("tileEntity", tileEntity); return dropStack; } diff --git a/src/main/java/techreborn/tiles/TileQuantumTank.java b/src/main/java/techreborn/tiles/TileQuantumTank.java index 33b36d12b..b0969e0fd 100644 --- a/src/main/java/techreborn/tiles/TileQuantumTank.java +++ b/src/main/java/techreborn/tiles/TileQuantumTank.java @@ -9,6 +9,7 @@ import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.util.EnumFacing; +import net.minecraft.util.IChatComponent; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; @@ -25,7 +26,7 @@ public class TileQuantumTank extends TileMachineBase implements IFluidHandler, IInventory, IWrenchable, IListInfoProvider { public Tank tank = new Tank("TileQuantumTank", Integer.MAX_VALUE, this); - public Inventory inventory = new Inventory(3, "TileQuantumTank", 64); + public Inventory inventory = new Inventory(3, "TileQuantumTank", 64, this); @Override public void readFromNBT(NBTTagCompound tagCompound) { @@ -52,8 +53,7 @@ public class TileQuantumTank extends TileMachineBase implements IFluidHandler, public Packet getDescriptionPacket() { NBTTagCompound nbtTag = new NBTTagCompound(); writeToNBT(nbtTag); - return new S35PacketUpdateTileEntity(this.getPos().getX(), this.getPos().getY(), - this.getPos().getZ(), 1, nbtTag); + return new S35PacketUpdateTileEntity(this.getPos(), 1, nbtTag); } @Override @@ -61,7 +61,7 @@ public class TileQuantumTank extends TileMachineBase implements IFluidHandler, S35PacketUpdateTileEntity packet) { worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(), getPos().getY(), getPos().getZ()); - readFromNBT(packet.func_148857_g()); + readFromNBT(packet.getNbtCompound()); } @Override @@ -148,13 +148,49 @@ public class TileQuantumTank extends TileMachineBase implements IFluidHandler, } @Override - public String getInventoryName() { - return inventory.getInventoryName(); + public void openInventory(EntityPlayer player) { + inventory.openInventory(player); } @Override - public boolean hasCustomInventoryName() { - return inventory.hasCustomInventoryName(); + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); + } + + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); } @Override @@ -167,16 +203,6 @@ public class TileQuantumTank extends TileMachineBase implements IFluidHandler, 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); @@ -219,7 +245,7 @@ public class TileQuantumTank extends TileMachineBase implements IFluidHandler, ItemStack dropStack = new ItemStack(ModBlocks.quantumTank, 1); writeToNBTWithoutCoords(tileEntity); dropStack.setTagCompound(new NBTTagCompound()); - dropStack.stackTagCompound.setTag("tileEntity", tileEntity); + dropStack.getTagCompound().setTag("tileEntity", tileEntity); return dropStack; } diff --git a/src/main/java/techreborn/tiles/TileRollingMachine.java b/src/main/java/techreborn/tiles/TileRollingMachine.java index 76f5960f2..55ff41c93 100644 --- a/src/main/java/techreborn/tiles/TileRollingMachine.java +++ b/src/main/java/techreborn/tiles/TileRollingMachine.java @@ -1,7 +1,5 @@ package techreborn.tiles; -import ic2.api.item.ElectricItem; -import ic2.api.item.IElectricItem; import ic2.api.tile.IWrenchable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; @@ -10,6 +8,7 @@ import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; +import net.minecraft.util.IChatComponent; import reborncore.common.util.Inventory; import reborncore.common.util.ItemUtils; import techreborn.api.RollingMachineRecipe; @@ -19,7 +18,7 @@ import techreborn.powerSystem.TilePowerAcceptor; //TODO add tick and power bars. public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable, IInventory { - public Inventory inventory = new Inventory(3, "TileRollingMachine", 64); + public Inventory inventory = new Inventory(3, "TileRollingMachine", 64, this); public final InventoryCrafting craftMatrix = new InventoryCrafting( new RollingTileContainer(), 3, 3); @@ -35,21 +34,6 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable return 100000; } - public void charge(int slot) { - if (getStackInSlot(slot) != null) { - if (getStackInSlot(slot).getItem() instanceof IElectricItem) { - if (getEnergy() != getMaxPower()) { - ItemStack stack = inventory.getStackInSlot(slot); - double MaxCharge = ((IElectricItem) stack.getItem()).getMaxCharge(stack); - double CurrentCharge = ElectricItem.manager.getCharge(stack); - if (CurrentCharge != 0) { - ElectricItem.manager.discharge(stack, 5, 4, false, false, false); - addEnergy(5); - } - } - } - } - } @Override public boolean canAcceptEnergy(EnumFacing direction) { @@ -240,13 +224,49 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable } @Override - public String getInventoryName() { - return inventory.getInventoryName(); + public void openInventory(EntityPlayer player) { + inventory.openInventory(player); } @Override - public boolean hasCustomInventoryName() { - return inventory.hasCustomInventoryName(); + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); + } + + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); } @Override @@ -259,16 +279,6 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable 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/TileSemifluidGenerator.java b/src/main/java/techreborn/tiles/TileSemifluidGenerator.java index 467e0eaa5..0851cbb2d 100644 --- a/src/main/java/techreborn/tiles/TileSemifluidGenerator.java +++ b/src/main/java/techreborn/tiles/TileSemifluidGenerator.java @@ -9,6 +9,7 @@ import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.util.EnumFacing; +import net.minecraft.util.IChatComponent; import net.minecraftforge.fluids.*; import reborncore.common.util.FluidUtils; import reborncore.common.util.Inventory; @@ -25,7 +26,7 @@ public class TileSemifluidGenerator extends TilePowerAcceptor implements IWrench public Tank tank = new Tank("TileSemifluidGenerator", FluidContainerRegistry.BUCKET_VOLUME * 10, this); - public Inventory inventory = new Inventory(3, "TileSemifluidGenerator", 64); + public Inventory inventory = new Inventory(3, "TileSemifluidGenerator", 64, this); //TODO: run this off config public static final int euTick = 8; @@ -138,8 +139,7 @@ public class TileSemifluidGenerator extends TilePowerAcceptor implements IWrench public Packet getDescriptionPacket() { NBTTagCompound nbtTag = new NBTTagCompound(); writeToNBT(nbtTag); - return new S35PacketUpdateTileEntity(this.getPos().getX(), this.getPos().getY(), - this.getPos().getZ(), 1, nbtTag); + return new S35PacketUpdateTileEntity(this.getPos(), 1, nbtTag); } @Override @@ -147,7 +147,7 @@ public class TileSemifluidGenerator extends TilePowerAcceptor implements IWrench S35PacketUpdateTileEntity packet) { worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(), getPos().getY(), getPos().getZ()); - readFromNBT(packet.func_148857_g()); + readFromNBT(packet.getNbtCompound()); } @Override @@ -204,13 +204,49 @@ public class TileSemifluidGenerator extends TilePowerAcceptor implements IWrench } @Override - public String getInventoryName() { - return inventory.getInventoryName(); + public void openInventory(EntityPlayer player) { + inventory.openInventory(player); } @Override - public boolean hasCustomInventoryName() { - return inventory.hasCustomInventoryName(); + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); + } + + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); } @Override @@ -223,15 +259,6 @@ public class TileSemifluidGenerator extends TilePowerAcceptor implements IWrench return inventory.isUseableByPlayer(p_70300_1_); } - @Override - public void openInventory() { - inventory.openInventory(); - } - - @Override - public void closeInventory() { - inventory.closeInventory(); - } @Override public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { diff --git a/src/main/java/techreborn/tiles/TileThermalGenerator.java b/src/main/java/techreborn/tiles/TileThermalGenerator.java index 3c1011681..3b6bac202 100644 --- a/src/main/java/techreborn/tiles/TileThermalGenerator.java +++ b/src/main/java/techreborn/tiles/TileThermalGenerator.java @@ -9,7 +9,9 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.IChatComponent; import net.minecraftforge.fluids.*; import reborncore.common.util.FluidUtils; import reborncore.common.util.Inventory; @@ -23,7 +25,7 @@ public class TileThermalGenerator extends TilePowerAcceptor implements IWrenchab public Tank tank = new Tank("TileThermalGenerator", FluidContainerRegistry.BUCKET_VOLUME * 10, this); - public Inventory inventory = new Inventory(3, "TileThermalGenerator", 64); + public Inventory inventory = new Inventory(3, "TileThermalGenerator", 64, this); public static final int euTick = ConfigTechReborn.ThermalGenertaorOutput; public TileThermalGenerator() { @@ -121,8 +123,7 @@ public class TileThermalGenerator extends TilePowerAcceptor implements IWrenchab public Packet getDescriptionPacket() { NBTTagCompound nbtTag = new NBTTagCompound(); writeToNBT(nbtTag); - return new S35PacketUpdateTileEntity(this.getPos().getX(), this.getPos().getY(), - this.getPos().getZ(), 1, nbtTag); + return new S35PacketUpdateTileEntity(this.getPos(), 1, nbtTag); } @Override @@ -130,7 +131,7 @@ public class TileThermalGenerator extends TilePowerAcceptor implements IWrenchab S35PacketUpdateTileEntity packet) { worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(), getPos().getY(), getPos().getZ()); - readFromNBT(packet.func_148857_g()); + readFromNBT(packet.getNbtCompound()); } @Override @@ -138,8 +139,8 @@ public class TileThermalGenerator extends TilePowerAcceptor implements IWrenchab super.updateEntity(); if (!worldObj.isRemote) { FluidUtils.drainContainers(this, inventory, 0, 1); - for (EnumFacing direction : EnumFacing.VALID_DIRECTIONS) { - if (worldObj.getBlock(getPos().getX() + direction.offsetX, getPos().getY() + direction.offsetY, getPos().getZ() + direction.offsetZ) == Blocks.lava) { + for (EnumFacing direction : EnumFacing.values()) { + if (worldObj.getBlockState(new BlockPos(getPos().getX() + direction.getFrontOffsetX(), getPos().getY() + direction.getFrontOffsetY(), getPos().getZ() + direction.getFrontOffsetZ())).getBlock() == Blocks.lava) { addEnergy(1); } } @@ -182,15 +183,50 @@ public class TileThermalGenerator extends TilePowerAcceptor implements IWrenchab public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { inventory.setInventorySlotContents(p_70299_1_, p_70299_2_); } - @Override - public String getInventoryName() { - return inventory.getInventoryName(); + public void openInventory(EntityPlayer player) { + inventory.openInventory(player); } @Override - public boolean hasCustomInventoryName() { - return inventory.hasCustomInventoryName(); + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); + } + + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); } @Override @@ -203,16 +239,6 @@ public class TileThermalGenerator extends TilePowerAcceptor implements IWrenchab return inventory.isUseableByPlayer(p_70300_1_); } - @Override - public void openInventory() { - inventory.openInventory(); - } - - @Override - public void closeInventory() { - inventory.closeInventory(); - } - @Override public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { return inventory.isItemValidForSlot(p_94041_1_, p_94041_2_); diff --git a/src/main/java/techreborn/tiles/TileVacuumFreezer.java b/src/main/java/techreborn/tiles/TileVacuumFreezer.java index c9266bb82..30061f877 100644 --- a/src/main/java/techreborn/tiles/TileVacuumFreezer.java +++ b/src/main/java/techreborn/tiles/TileVacuumFreezer.java @@ -5,7 +5,9 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.IChatComponent; import reborncore.common.util.Inventory; import techreborn.api.recipe.RecipeCrafter; import techreborn.init.ModBlocks; @@ -15,7 +17,7 @@ import techreborn.powerSystem.TilePowerAcceptor; public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable, IInventory { public int tickTime; - public Inventory inventory = new Inventory(3, "TileVacuumFreezer", 64); + public Inventory inventory = new Inventory(3, "TileVacuumFreezer", 64, this); public RecipeCrafter crafter; public int multiBlockStatus = 0; @@ -141,13 +143,49 @@ public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable, } @Override - public String getInventoryName() { - return inventory.getInventoryName(); + public void openInventory(EntityPlayer player) { + inventory.openInventory(player); } @Override - public boolean hasCustomInventoryName() { - return inventory.hasCustomInventoryName(); + public void closeInventory(EntityPlayer player) { + inventory.closeInventory(player); + } + + + @Override + public int getField(int id) { + return inventory.getField(id); + } + + @Override + public void setField(int id, int value) { + inventory.setField(id, value); + } + + @Override + public int getFieldCount() { + return inventory.getFieldCount(); + } + + @Override + public void clear() { + inventory.clear(); + } + + @Override + public String getCommandSenderName() { + return inventory.getCommandSenderName(); + } + + @Override + public boolean hasCustomName() { + return inventory.hasCustomName(); + } + + @Override + public IChatComponent getDisplayName() { + return inventory.getDisplayName(); } @Override @@ -160,15 +198,6 @@ public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable, return inventory.isUseableByPlayer(player); } - @Override - public void openInventory() { - inventory.openInventory(); - } - - @Override - public void closeInventory() { - inventory.closeInventory(); - } @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { @@ -183,20 +212,20 @@ public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable, } public boolean checkMachine() { - int xDir = EnumFacing.UP.offsetX * 2; - int yDir = EnumFacing.UP.offsetY * 2; - int zDir = EnumFacing.UP.offsetZ * 2; + int xDir = EnumFacing.UP.getFrontOffsetX() * 2; + int yDir = EnumFacing.UP.getFrontOffsetY() * 2; + int zDir = EnumFacing.UP.getFrontOffsetZ() * 2; for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { for (int k = -1; k < 2; k++) { if ((i != 0) || (j != 0) || (k != 0)) { - if (worldObj.getBlock(getPos().getX() - xDir + i, getPos().getY() - yDir + j, getPos().getZ() - zDir + k) != ModBlocks.MachineCasing) { + if (worldObj.getBlockState(new BlockPos(getPos().getX() - xDir + i, getPos().getY() - yDir + j, getPos().getZ() - zDir + k)).getBlock() != ModBlocks.MachineCasing) { return false; } - if (worldObj.getBlockMetadata(getPos().getX() - xDir + i, getPos().getY() - yDir + j, getPos().getZ() - zDir + k) != (((i == 0) && (j == 0) && (k != 0)) || ((i == 0) && (j != 0) && (k == 0)) || ((i != 0) && (j == 0) && (k == 0)) ? 2 : 1)) { - return false; - } - } else if (!worldObj.isAirBlock(getPos().getX() - xDir + i, getPos().getY() - yDir + j, getPos().getZ() - zDir + k)) { +// if (worldObj.getBlockMetadata(getPos().getX() - xDir + i, getPos().getY() - yDir + j, getPos().getZ() - zDir + k) != (((i == 0) && (j == 0) && (k != 0)) || ((i == 0) && (j != 0) && (k == 0)) || ((i != 0) && (j == 0) && (k == 0)) ? 2 : 1)) { +// return false; +// }//TODO meta fix + } else if (!worldObj.isAirBlock(new BlockPos(getPos().getX() - xDir + i, getPos().getY() - yDir + j, getPos().getZ() - zDir + k))) { return false; } }