use of stevekung.mods.moreplanets.util.blocks.IBlockDescription in project MorePlanets by SteveKunG.
the class ItemBlockDarkEnergyGenerator method addInformation.
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemStack, @Nullable World world, List<String> list, ITooltipFlag flag) {
if (this.getBlock() instanceof IBlockDescription) {
if (CommonRegisterHelper.isShiftKeyDown()) {
((IBlockDescription) this.block).getDescription().addDescription(itemStack, list);
} else {
if (this.getBlock() instanceof BlockTileGC) {
TileEntity te = ((BlockTileGC) this.getBlock()).createTileEntity(null, this.getBlock().getStateFromMeta(itemStack.getItemDamage() & 12));
if (te instanceof TileBaseElectricBlock) {
float powerDrawn = ((TileBaseElectricBlock) te).storage.getMaxExtract();
if (powerDrawn > 0) {
list.add(TextFormatting.GREEN + GCCoreUtil.translateWithFormat("item_desc.powerdraw.name", EnergyDisplayHelper.getEnergyDisplayS(powerDrawn * 20)));
}
}
if (te instanceof TileBaseUniversalElectrical) {
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("EnergyStored")) {
int power = (int) itemStack.getTagCompound().getFloat("EnergyStored");
list.add(TextFormatting.GREEN + GCCoreUtil.translateWithFormat("desc.energy_stored.name", EnergyDisplayHelper.getEnergyDisplayS(power)));
}
}
if (te instanceof TileEntityDarkEnergyGenerator) {
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("DarkEnergyFuel")) {
int power = itemStack.getTagCompound().getInteger("DarkEnergyFuel");
power = power * 100 / 1000;
list.add(TextFormatting.GREEN + GCCoreUtil.translateWithFormat("desc.dark_energy_fuel.name", power) + "%");
}
}
} else if (this.getBlock() instanceof BlockAdvancedTile) {
TileEntity te = ((BlockAdvancedTile) this.getBlock()).createTileEntity(world, this.getBlock().getStateFromMeta(itemStack.getItemDamage() & 12));
if (te instanceof TileBaseElectricBlock) {
float powerDrawn = ((TileBaseElectricBlock) te).storage.getMaxExtract();
if (powerDrawn > 0) {
list.add(TextFormatting.GREEN + GCCoreUtil.translateWithFormat("item_desc.powerdraw.name", EnergyDisplayHelper.getEnergyDisplayS(powerDrawn * 20)));
}
}
}
list.add(GCCoreUtil.translate("desc.shift_info.name"));
}
}
}
use of stevekung.mods.moreplanets.util.blocks.IBlockDescription in project MorePlanets by SteveKunG.
the class WailaTileEntityProviderMP method getWailaBody.
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> tooltip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
TileEntity tile = accessor.getTileEntity();
Block block = accessor.getBlock();
if (ConfigManagerMP.enableDescriptionInWaila) {
if (block instanceof IBlockDescription) {
IBlockDescription desc = (IBlockDescription) block;
if (CommonRegisterHelper.isShiftKeyDown()) {
desc.getDescription().addDescription(itemStack, tooltip);
} else {
tooltip.add(GCCoreUtil.translate("desc.shift_info.name"));
}
}
// block
if (block == MPBlocks.DUMMY_BLOCK) {
TileEntityDummy dummy = (TileEntityDummy) tile;
if (accessor.getWorld().getBlockState(dummy.mainBlockPosition).getBlock() instanceof IBlockDescription) {
IBlockDescription desc = (IBlockDescription) accessor.getWorld().getBlockState(dummy.mainBlockPosition).getBlock();
if (CommonRegisterHelper.isShiftKeyDown()) {
desc.getDescription().addDescription(itemStack, tooltip);
} else {
tooltip.add(GCCoreUtil.translate("desc.shift_info.name"));
}
}
}
}
return tooltip;
}
use of stevekung.mods.moreplanets.util.blocks.IBlockDescription in project MorePlanets by SteveKunG.
the class ItemBlockDescription method addInformation.
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemStack, @Nullable World world, List<String> list, ITooltipFlag flag) {
if (this.getBlock() instanceof IBlockDescription) {
if (CommonRegisterHelper.isShiftKeyDown()) {
((IBlockDescription) this.block).getDescription().addDescription(itemStack, list);
} else {
if (this.getBlock() instanceof BlockTileGC) {
TileEntity te = ((BlockTileGC) this.getBlock()).createTileEntity(null, this.getBlock().getStateFromMeta(itemStack.getItemDamage() & 12));
if (te instanceof TileBaseElectricBlock) {
float powerDrawn = ((TileBaseElectricBlock) te).storage.getMaxExtract();
if (powerDrawn > 0) {
list.add(TextFormatting.GREEN + GCCoreUtil.translateWithFormat("item_desc.powerdraw.name", EnergyDisplayHelper.getEnergyDisplayS(powerDrawn * 20)));
}
}
if (te instanceof TileBaseUniversalElectrical) {
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("EnergyStored")) {
int power = (int) itemStack.getTagCompound().getFloat("EnergyStored");
list.add(TextFormatting.GREEN + GCCoreUtil.translateWithFormat("desc.energy_stored.name", EnergyDisplayHelper.getEnergyDisplayS(power)));
}
}
} else if (this.getBlock() instanceof BlockAdvancedTile) {
TileEntity te = ((BlockAdvancedTile) this.getBlock()).createTileEntity(world, this.getBlock().getStateFromMeta(itemStack.getItemDamage() & 12));
if (te instanceof TileBaseElectricBlock) {
float powerDrawn = ((TileBaseElectricBlock) te).storage.getMaxExtract();
if (powerDrawn > 0) {
list.add(TextFormatting.GREEN + GCCoreUtil.translateWithFormat("item_desc.powerdraw.name", EnergyDisplayHelper.getEnergyDisplayS(powerDrawn * 20)));
}
}
}
list.add(GCCoreUtil.translate("desc.shift_info.name"));
}
}
}
Aggregations