Provide default capacity for energy tooltip.
Don't store energy of computer in item.
This commit is contained in:
@@ -96,7 +96,6 @@ public final class ComputerBlock extends HorizontalBlock {
|
||||
public void addInformation(final ItemStack stack, @Nullable final IBlockReader world, final List<ITextComponent> tooltip, final ITooltipFlag advanced) {
|
||||
super.addInformation(stack, world, tooltip, advanced);
|
||||
TooltipUtils.addTileEntityInventoryInformation(stack, tooltip);
|
||||
TooltipUtils.addTileEntityEnergyInformation(stack, tooltip);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -40,7 +40,7 @@ public final class RobotItem extends ModItem {
|
||||
public void addInformation(final ItemStack stack, @Nullable final World world, final List<ITextComponent> tooltip, final ITooltipFlag flag) {
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
TooltipUtils.addEntityInventoryInformation(stack, tooltip);
|
||||
TooltipUtils.addEntityEnergyInformation(stack, tooltip);
|
||||
TooltipUtils.addEntityEnergyInformation(stack, tooltip, Config.robotEnergyStorage);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -203,7 +203,6 @@ public final class ComputerTileEntity extends AbstractTileEntity implements ITic
|
||||
tag.put(TERMINAL_TAG_NAME, NBTSerialization.serialize(terminal));
|
||||
tag.put(BUS_ELEMENT_TAG_NAME, NBTSerialization.serialize(busElement));
|
||||
tag.put(Constants.ITEMS_TAG_NAME, deviceItems.serialize());
|
||||
tag.put(Constants.ENERGY_TAG_NAME, energy.serializeNBT());
|
||||
|
||||
return tag;
|
||||
}
|
||||
@@ -220,7 +219,6 @@ public final class ComputerTileEntity extends AbstractTileEntity implements ITic
|
||||
}
|
||||
|
||||
deviceItems.deserialize(tag.getCompound(Constants.ITEMS_TAG_NAME));
|
||||
energy.deserializeNBT(tag.getCompound(Constants.ENERGY_TAG_NAME));
|
||||
}
|
||||
|
||||
public void exportToItemStack(final ItemStack stack) {
|
||||
|
||||
@@ -86,21 +86,23 @@ public final class TooltipUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void addTileEntityEnergyInformation(final ItemStack stack, final List<ITextComponent> tooltip) {
|
||||
addEnergyInformation(NBTUtils.getChildTag(stack.getTag(), BLOCK_ENTITY_TAG_NAME_IN_ITEM, ENERGY_TAG_NAME), tooltip);
|
||||
public static void addEntityEnergyInformation(final ItemStack stack, final List<ITextComponent> tooltip, final int defaultCapacity) {
|
||||
addEnergyInformation(NBTUtils.getChildTag(stack.getTag(), MOD_TAG_NAME, ENERGY_TAG_NAME), tooltip, defaultCapacity);
|
||||
}
|
||||
|
||||
public static void addEntityEnergyInformation(final ItemStack stack, final List<ITextComponent> tooltip) {
|
||||
addEnergyInformation(NBTUtils.getChildTag(stack.getTag(), MOD_TAG_NAME, ENERGY_TAG_NAME), tooltip);
|
||||
}
|
||||
|
||||
public static void addEnergyInformation(final CompoundNBT energyTag, final List<ITextComponent> tooltip) {
|
||||
public static void addEnergyInformation(final CompoundNBT energyTag, final List<ITextComponent> tooltip, final int defaultCapacity) {
|
||||
final int stored = energyTag.getInt(FixedEnergyStorage.STORED_TAG_NAME);
|
||||
if (stored == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int capacity = energyTag.getInt(FixedEnergyStorage.CAPACITY_TAG_NAME);
|
||||
final int capacity;
|
||||
if (energyTag.contains(FixedEnergyStorage.CAPACITY_TAG_NAME, NBTTagIds.TAG_INT)) {
|
||||
capacity = energyTag.getInt(FixedEnergyStorage.CAPACITY_TAG_NAME);
|
||||
} else {
|
||||
capacity = defaultCapacity;
|
||||
}
|
||||
|
||||
if (capacity > 0) {
|
||||
tooltip.add(new TranslationTextComponent(Constants.TOOLTIP_ENERGY, stored + "/" + capacity));
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user