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)
|
if(tile instanceof TileController)
|
||||||
{
|
{
|
||||||
TileController controller = (TileController)tile;
|
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));
|
ItemStack stack = new ItemStack(RefinedStorageBlocks.CONTROLLER, 1, RefinedStorageBlocks.CONTROLLER.getMetaFromState(state));
|
||||||
|
|
||||||
NBTTagCompound tag = new NBTTagCompound();
|
NBTTagCompound tag = new NBTTagCompound();
|
||||||
((TileController) world.getTileEntity(pos)).writeItemToNBT(tag);
|
((TileController) world.getTileEntity(pos)).writeNBT(tag);
|
||||||
stack.setTagCompound(tag);
|
stack.setTagCompound(tag);
|
||||||
|
|
||||||
drops.add(stack);
|
drops.add(stack);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import refinedstorage.RefinedStorageBlocks;
|
import refinedstorage.RefinedStorageBlocks;
|
||||||
|
import refinedstorage.block.EnumControllerType;
|
||||||
import refinedstorage.block.EnumStorageType;
|
import refinedstorage.block.EnumStorageType;
|
||||||
import refinedstorage.tile.TileController;
|
import refinedstorage.tile.TileController;
|
||||||
|
|
||||||
@@ -20,17 +21,25 @@ 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 = 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();
|
NBTTagCompound tag = stack.getTagCompound();
|
||||||
|
|
||||||
int energyStored = tag.getInteger(TileController.NBT_ENERGY);
|
energyStored = tag.getInteger(TileController.NBT_ENERGY);
|
||||||
int capacity = TileController.ENERGY_CAPACITY;
|
percent = (int)((float)energyStored / (capacity) * 100);
|
||||||
int percent = (int)((float)energyStored / (capacity) * 100);
|
|
||||||
|
|
||||||
//TODO: Format numbers ?
|
|
||||||
list.add("RF: " + energyStored + "/" + capacity + "(" + percent + "%)");
|
|
||||||
}
|
}
|
||||||
|
//TODO: Format numbers ?
|
||||||
|
list.add("RF: " + energyStored + "/" + capacity + " (" + percent + "%)");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -41,6 +50,12 @@ public class ItemBlockController extends ItemBlockBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack initNBT(ItemStack stack) {
|
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;
|
return stack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -368,12 +368,7 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
|||||||
readNBT(nbt);
|
readNBT(nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readItemFromNBT(NBTTagCompound nbt) {
|
public void readNBT(NBTTagCompound nbt) {
|
||||||
readNBT(nbt);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void readNBT(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
energy.readFromNBT(nbt);
|
energy.readFromNBT(nbt);
|
||||||
|
|
||||||
if (nbt.hasKey(RedstoneMode.NBT)) {
|
if (nbt.hasKey(RedstoneMode.NBT)) {
|
||||||
@@ -387,12 +382,7 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
|||||||
writeNBT(nbt);
|
writeNBT(nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeItemToNBT(NBTTagCompound nbt) {
|
public void writeNBT(NBTTagCompound nbt) {
|
||||||
writeNBT(nbt);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void writeNBT(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
energy.writeToNBT(nbt);
|
energy.writeToNBT(nbt);
|
||||||
nbt.setInteger(RedstoneMode.NBT, redstoneMode.id);
|
nbt.setInteger(RedstoneMode.NBT, redstoneMode.id);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user