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.item.ItemBlockController; | ||||
| import refinedstorage.tile.TileController; | ||||
| import refinedstorage.tile.TileMachine; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| @@ -114,11 +115,11 @@ public class BlockController extends BlockBase { | ||||
|  | ||||
|         NBTTagCompound tag = itemStack.getTagCompound(); | ||||
|  | ||||
|         if (tag != null) { | ||||
|         if (tag != null && tag.hasKey(TileMachine.NBT_ENERGY)) { | ||||
|             TileEntity tile = world.getTileEntity(pos); | ||||
|  | ||||
|             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)); | ||||
|  | ||||
|         NBTTagCompound tag = new NBTTagCompound(); | ||||
|         ((TileController) world.getTileEntity(pos)).writeItemOrBlockNBT(tag); | ||||
|         tag.setInteger(TileMachine.NBT_ENERGY, ((TileController) world.getTileEntity(pos)).getEnergyStored(null)); | ||||
|         stack.setTagCompound(tag); | ||||
|  | ||||
|         drops.add(stack); | ||||
| @@ -138,7 +139,6 @@ public class BlockController extends BlockBase { | ||||
|         return drops; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     @Override | ||||
|     public boolean hasComparatorInputOverride(IBlockState state) { | ||||
|         return true; | ||||
|   | ||||
| @@ -18,18 +18,15 @@ public class ItemBlockController extends ItemBlockBase { | ||||
|  | ||||
|     @Override | ||||
|     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 capacity = TileController.ENERGY_CAPACITY; | ||||
|  | ||||
|         if (type == EnumControllerType.CREATIVE) { | ||||
|             energyStored = capacity; | ||||
|         } else if (stack.getTagCompound() != null && stack.getTagCompound().hasKey(TileController.NBT_ENERGY)) { | ||||
|             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)); | ||||
|             list.add(I18n.format("misc.refinedstorage:energy_stored", energyStored, TileController.ENERGY_CAPACITY)); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
| @@ -40,15 +37,13 @@ public class ItemBlockController extends ItemBlockBase { | ||||
|     } | ||||
|  | ||||
|     public static ItemStack initNBT(ItemStack stack) { | ||||
|         EnumControllerType type = stack.getMetadata() == EnumControllerType.CREATIVE.getId() ? EnumControllerType.CREATIVE : EnumControllerType.NORMAL; | ||||
|  | ||||
|         NBTTagCompound tag = stack.getTagCompound(); | ||||
|  | ||||
|         if (tag == null) { | ||||
|             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; | ||||
|     } | ||||
|   | ||||
| @@ -36,7 +36,6 @@ import refinedstorage.util.InventoryUtils; | ||||
| import java.util.*; | ||||
|  | ||||
| public class TileController extends TileBase implements IEnergyReceiver, INetworkTile, IRedstoneModeConfig { | ||||
|  | ||||
|     public class ClientSideMachine { | ||||
|         public ItemStack stack; | ||||
|         public int energyUsage; | ||||
| @@ -196,10 +195,6 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor | ||||
|         machines.clear(); | ||||
|     } | ||||
|  | ||||
|     public List<TileMachine> getMachines() { | ||||
|         return machines; | ||||
|     } | ||||
|  | ||||
|     public List<ItemGroup> getItemGroups() { | ||||
|         return itemGroups; | ||||
|     } | ||||
| @@ -366,12 +361,6 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor | ||||
|     public void readFromNBT(NBTTagCompound nbt) { | ||||
|         super.readFromNBT(nbt); | ||||
|  | ||||
|         readItemOrBlockNBT(nbt); | ||||
|     } | ||||
|  | ||||
|     public void readItemOrBlockNBT(NBTTagCompound nbt) { | ||||
|         energy.readFromNBT(nbt); | ||||
|  | ||||
|         if (nbt.hasKey(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) { | ||||
|         super.writeToNBT(nbt); | ||||
|  | ||||
|         writeItemOrBlockNBT(nbt); | ||||
|     } | ||||
|  | ||||
|     public void writeItemOrBlockNBT(NBTTagCompound nbt) { | ||||
|         energy.writeToNBT(nbt); | ||||
|         nbt.setInteger(RedstoneMode.NBT, redstoneMode.id); | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Raoul Van den Berge
					Raoul Van den Berge