Don't store redstone status for controller for consistency sake
This commit is contained in:
		| @@ -22,6 +22,7 @@ import refinedstorage.RefinedStorageBlocks; | |||||||
| import refinedstorage.RefinedStorageGui; | import refinedstorage.RefinedStorageGui; | ||||||
| import refinedstorage.item.ItemBlockController; | import refinedstorage.item.ItemBlockController; | ||||||
| import refinedstorage.tile.TileController; | import refinedstorage.tile.TileController; | ||||||
|  | import refinedstorage.tile.TileMachine; | ||||||
|  |  | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| @@ -114,11 +115,11 @@ public class BlockController extends BlockBase { | |||||||
|  |  | ||||||
|         NBTTagCompound tag = itemStack.getTagCompound(); |         NBTTagCompound tag = itemStack.getTagCompound(); | ||||||
|  |  | ||||||
|         if (tag != null) { |         if (tag != null && tag.hasKey(TileMachine.NBT_ENERGY)) { | ||||||
|             TileEntity tile = world.getTileEntity(pos); |             TileEntity tile = world.getTileEntity(pos); | ||||||
|  |  | ||||||
|             if (tile instanceof TileController) { |             if (tile instanceof TileController) { | ||||||
|                 ((TileController) tile).readItemOrBlockNBT(tag); |                 ((TileController) tile).receiveEnergy(null, tag.getInteger(TileMachine.NBT_ENERGY), false); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -130,7 +131,7 @@ public class BlockController extends BlockBase { | |||||||
|         ItemStack stack = new ItemStack(RefinedStorageBlocks.CONTROLLER, 1, RefinedStorageBlocks.CONTROLLER.getMetaFromState(state)); |         ItemStack stack = new ItemStack(RefinedStorageBlocks.CONTROLLER, 1, RefinedStorageBlocks.CONTROLLER.getMetaFromState(state)); | ||||||
|  |  | ||||||
|         NBTTagCompound tag = new NBTTagCompound(); |         NBTTagCompound tag = new NBTTagCompound(); | ||||||
|         ((TileController) world.getTileEntity(pos)).writeItemOrBlockNBT(tag); |         tag.setInteger(TileMachine.NBT_ENERGY, ((TileController) world.getTileEntity(pos)).getEnergyStored(null)); | ||||||
|         stack.setTagCompound(tag); |         stack.setTagCompound(tag); | ||||||
|  |  | ||||||
|         drops.add(stack); |         drops.add(stack); | ||||||
| @@ -138,7 +139,6 @@ public class BlockController extends BlockBase { | |||||||
|         return drops; |         return drops; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean hasComparatorInputOverride(IBlockState state) { |     public boolean hasComparatorInputOverride(IBlockState state) { | ||||||
|         return true; |         return true; | ||||||
|   | |||||||
| @@ -18,18 +18,15 @@ public class ItemBlockController extends ItemBlockBase { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean b) { |     public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean b) { | ||||||
|         EnumControllerType type = stack.getMetadata() == EnumControllerType.CREATIVE.getId() ? EnumControllerType.CREATIVE : EnumControllerType.NORMAL; |         if (stack.getMetadata() != EnumControllerType.CREATIVE.getId()) { | ||||||
|  |             int energyStored = 0; | ||||||
|  |  | ||||||
|         int energyStored = 0; |             if (stack.getTagCompound() != null && stack.getTagCompound().hasKey(TileController.NBT_ENERGY)) { | ||||||
|         int capacity = TileController.ENERGY_CAPACITY; |                 energyStored = stack.getTagCompound().getInteger(TileController.NBT_ENERGY); | ||||||
|  |             } | ||||||
|  |  | ||||||
|         if (type == EnumControllerType.CREATIVE) { |             list.add(I18n.format("misc.refinedstorage:energy_stored", energyStored, TileController.ENERGY_CAPACITY)); | ||||||
|             energyStored = capacity; |  | ||||||
|         } else if (stack.getTagCompound() != null && stack.getTagCompound().hasKey(TileController.NBT_ENERGY)) { |  | ||||||
|             energyStored = stack.getTagCompound().getInteger(TileController.NBT_ENERGY); |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         list.add(I18n.format("misc.refinedstorage:energy_stored", energyStored, capacity)); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -40,15 +37,13 @@ public class ItemBlockController extends ItemBlockBase { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static ItemStack initNBT(ItemStack stack) { |     public static ItemStack initNBT(ItemStack stack) { | ||||||
|         EnumControllerType type = stack.getMetadata() == EnumControllerType.CREATIVE.getId() ? EnumControllerType.CREATIVE : EnumControllerType.NORMAL; |  | ||||||
|  |  | ||||||
|         NBTTagCompound tag = stack.getTagCompound(); |         NBTTagCompound tag = stack.getTagCompound(); | ||||||
|  |  | ||||||
|         if (tag == null) { |         if (tag == null) { | ||||||
|             tag = new NBTTagCompound(); |             tag = new NBTTagCompound(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         tag.setInteger(TileController.NBT_ENERGY, type == EnumControllerType.CREATIVE ? TileController.ENERGY_CAPACITY : 0); |         tag.setInteger(TileController.NBT_ENERGY, stack.getMetadata() == EnumControllerType.CREATIVE.getId() ? TileController.ENERGY_CAPACITY : 0); | ||||||
|  |  | ||||||
|         return stack; |         return stack; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -36,7 +36,6 @@ import refinedstorage.util.InventoryUtils; | |||||||
| import java.util.*; | import java.util.*; | ||||||
|  |  | ||||||
| public class TileController extends TileBase implements IEnergyReceiver, INetworkTile, IRedstoneModeConfig { | public class TileController extends TileBase implements IEnergyReceiver, INetworkTile, IRedstoneModeConfig { | ||||||
|  |  | ||||||
|     public class ClientSideMachine { |     public class ClientSideMachine { | ||||||
|         public ItemStack stack; |         public ItemStack stack; | ||||||
|         public int energyUsage; |         public int energyUsage; | ||||||
| @@ -196,10 +195,6 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor | |||||||
|         machines.clear(); |         machines.clear(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public List<TileMachine> getMachines() { |  | ||||||
|         return machines; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public List<ItemGroup> getItemGroups() { |     public List<ItemGroup> getItemGroups() { | ||||||
|         return itemGroups; |         return itemGroups; | ||||||
|     } |     } | ||||||
| @@ -366,12 +361,6 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor | |||||||
|     public void readFromNBT(NBTTagCompound nbt) { |     public void readFromNBT(NBTTagCompound nbt) { | ||||||
|         super.readFromNBT(nbt); |         super.readFromNBT(nbt); | ||||||
|  |  | ||||||
|         readItemOrBlockNBT(nbt); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public void readItemOrBlockNBT(NBTTagCompound nbt) { |  | ||||||
|         energy.readFromNBT(nbt); |  | ||||||
|  |  | ||||||
|         if (nbt.hasKey(RedstoneMode.NBT)) { |         if (nbt.hasKey(RedstoneMode.NBT)) { | ||||||
|             redstoneMode = RedstoneMode.getById(nbt.getInteger(RedstoneMode.NBT)); |             redstoneMode = RedstoneMode.getById(nbt.getInteger(RedstoneMode.NBT)); | ||||||
|         } |         } | ||||||
| @@ -381,11 +370,6 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor | |||||||
|     public void writeToNBT(NBTTagCompound nbt) { |     public void writeToNBT(NBTTagCompound nbt) { | ||||||
|         super.writeToNBT(nbt); |         super.writeToNBT(nbt); | ||||||
|  |  | ||||||
|         writeItemOrBlockNBT(nbt); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public void writeItemOrBlockNBT(NBTTagCompound nbt) { |  | ||||||
|         energy.writeToNBT(nbt); |  | ||||||
|         nbt.setInteger(RedstoneMode.NBT, redstoneMode.id); |         nbt.setInteger(RedstoneMode.NBT, redstoneMode.id); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Raoul Van den Berge
					Raoul Van den Berge