Removed wrietItemNBT and readItemNBT, always show energy stored.
modified: src/main/java/refinedstorage/block/BlockController.java modified: src/main/java/refinedstorage/item/ItemBlockController.java modified: src/main/java/refinedstorage/tile/TileController.java
This commit is contained in:
@@ -129,7 +129,7 @@ public class BlockController extends BlockBase {
|
||||
if(tile instanceof TileController)
|
||||
{
|
||||
TileController controller = (TileController)tile;
|
||||
controller.readItemFromNBT(tag);
|
||||
controller.readNBT(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,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)).writeItemToNBT(tag);
|
||||
((TileController) world.getTileEntity(pos)).writeNBT(tag);
|
||||
stack.setTagCompound(tag);
|
||||
|
||||
drops.add(stack);
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import refinedstorage.RefinedStorageBlocks;
|
||||
import refinedstorage.block.EnumControllerType;
|
||||
import refinedstorage.block.EnumStorageType;
|
||||
import refinedstorage.tile.TileController;
|
||||
|
||||
@@ -20,17 +21,25 @@ public class ItemBlockController extends ItemBlockBase {
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean b) {
|
||||
EnumControllerType type = EnumControllerType.values()[stack.getMetadata()];
|
||||
|
||||
if (stack.getTagCompound() != null && stack.getTagCompound().hasKey(TileController.NBT_ENERGY)) {
|
||||
int energyStored = 0;
|
||||
int capacity = TileController.ENERGY_CAPACITY;
|
||||
int percent = 0;
|
||||
|
||||
if(type == EnumControllerType.CREATIVE) {
|
||||
energyStored = capacity;
|
||||
percent = 100;
|
||||
}
|
||||
else if (stack.getTagCompound() != null && stack.getTagCompound().hasKey(TileController.NBT_ENERGY)) {
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
int energyStored = tag.getInteger(TileController.NBT_ENERGY);
|
||||
int capacity = TileController.ENERGY_CAPACITY;
|
||||
int percent = (int)((float)energyStored / (capacity) * 100);
|
||||
|
||||
//TODO: Format numbers ?
|
||||
list.add("RF: " + energyStored + "/" + capacity + "(" + percent + "%)");
|
||||
energyStored = tag.getInteger(TileController.NBT_ENERGY);
|
||||
percent = (int)((float)energyStored / (capacity) * 100);
|
||||
}
|
||||
//TODO: Format numbers ?
|
||||
list.add("RF: " + energyStored + "/" + capacity + " (" + percent + "%)");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,6 +50,12 @@ public class ItemBlockController extends ItemBlockBase {
|
||||
}
|
||||
|
||||
public static ItemStack initNBT(ItemStack stack) {
|
||||
EnumControllerType type = EnumControllerType.values()[stack.getMetadata()];
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
if(tag == null) tag = new NBTTagCompound();
|
||||
|
||||
tag.setInteger(TileController.NBT_ENERGY, type == EnumControllerType.CREATIVE ? TileController.ENERGY_CAPACITY : 0);
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,12 +368,7 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
readNBT(nbt);
|
||||
}
|
||||
|
||||
public void readItemFromNBT(NBTTagCompound nbt) {
|
||||
readNBT(nbt);
|
||||
}
|
||||
|
||||
private void readNBT(NBTTagCompound nbt)
|
||||
{
|
||||
public void readNBT(NBTTagCompound nbt) {
|
||||
energy.readFromNBT(nbt);
|
||||
|
||||
if (nbt.hasKey(RedstoneMode.NBT)) {
|
||||
@@ -387,12 +382,7 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
writeNBT(nbt);
|
||||
}
|
||||
|
||||
public void writeItemToNBT(NBTTagCompound nbt) {
|
||||
writeNBT(nbt);
|
||||
}
|
||||
|
||||
private void writeNBT(NBTTagCompound nbt)
|
||||
{
|
||||
public void writeNBT(NBTTagCompound nbt) {
|
||||
energy.writeToNBT(nbt);
|
||||
nbt.setInteger(RedstoneMode.NBT, redstoneMode.id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user