use of stevekung.mods.moreplanets.utils.IDescription 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 IDescription) {
if (ClientUtils.isShiftKeyDown()) {
((IDescription) this.block).getDescription().addDescription(itemStack, list);
} else {
if (this.getBlock() instanceof BlockTileMP) {
TileEntity tile = ((BlockTileMP) this.getBlock()).createNewTileEntity(null, 0);
if (tile instanceof TileBaseUniversalElectrical) {
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("EnergyStored")) {
int power = (int) itemStack.getTagCompound().getFloat("EnergyStored");
list.add(TextFormatting.GREEN + LangUtils.translate("desc.energy_stored.name", EnergyDisplayHelper.getEnergyDisplayS(power)));
}
}
if (tile instanceof TileEntityDarkEnergyGenerator) {
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("DarkEnergyFuel") && itemStack.getTagCompound().hasKey("Items")) {
int fuelValue = 0;
NBTTagList listTag = itemStack.getTagCompound().getTagList("Items", NBT.TAG_COMPOUND);
for (int i = 0; i < listTag.tagCount(); ++i) {
NBTTagCompound compound = listTag.getCompoundTagAt(i);
int slot = compound.getByte("Slot") & 255;
ItemStack darkEnergyFuel = new ItemStack(compound);
if (slot == 2 && darkEnergyFuel.getItem() instanceof IDarkEnergyFuel) {
IDarkEnergyFuel fuel = (IDarkEnergyFuel) darkEnergyFuel.getItem();
fuelValue = fuel.getDarkEnergyFuel();
}
}
int power = itemStack.getTagCompound().getInteger("DarkEnergyFuel");
power = power * 100 / fuelValue;
list.add(TextFormatting.GREEN + LangUtils.translate("desc.dark_energy_fuel.name", power) + "%");
}
}
}
list.add(LangUtils.translate("desc.shift_info.name"));
}
}
}
use of stevekung.mods.moreplanets.utils.IDescription in project MorePlanets by SteveKunG.
the class ItemBlockDescriptionTESR method addInformation.
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemStack, @Nullable World world, List<String> list, ITooltipFlag flag) {
if (this.getBlock() instanceof IDescription) {
if (ClientUtils.isShiftKeyDown()) {
((IDescription) this.block).getDescription().addDescription(itemStack, list);
} else {
if (this.getBlock() instanceof BlockTileMP) {
TileEntity tile = ((BlockTileMP) this.getBlock()).createNewTileEntity(null, 0);
if (tile instanceof TileBaseElectricBlock) {
float powerDrawn = ((TileBaseElectricBlock) tile).storage.getMaxExtract();
if (powerDrawn > 0) {
list.add(TextFormatting.GREEN + LangUtils.translate("item_desc.powerdraw.name", EnergyDisplayHelper.getEnergyDisplayS(powerDrawn * 20)));
}
}
if (tile instanceof TileBaseUniversalElectrical) {
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("EnergyStored")) {
int power = (int) itemStack.getTagCompound().getFloat("EnergyStored");
list.add(TextFormatting.GREEN + LangUtils.translate("desc.energy_stored.name", EnergyDisplayHelper.getEnergyDisplayS(power)));
}
}
} else if (this.getBlock() instanceof BlockAdvancedTileMP) {
TileEntity tile = ((BlockAdvancedTileMP) this.getBlock()).createNewTileEntity(null, 0);
if (tile instanceof TileBaseElectricBlock) {
float powerDrawn = ((TileBaseElectricBlock) tile).storage.getMaxExtract();
if (powerDrawn > 0) {
list.add(TextFormatting.GREEN + LangUtils.translate("item_desc.powerdraw.name", EnergyDisplayHelper.getEnergyDisplayS(powerDrawn * 20)));
}
}
}
list.add(LangUtils.translate("desc.shift_info.name"));
}
}
}
use of stevekung.mods.moreplanets.utils.IDescription 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.moreplanets_other.enableDescriptionInWaila) {
if (block instanceof IDescription) {
IDescription desc = (IDescription) block;
if (ClientUtils.isShiftKeyDown()) {
desc.getDescription().addDescription(itemStack, tooltip);
} else {
tooltip.add(LangUtils.translate("desc.shift_info.name"));
}
}
// block
if (block.getClass().equals(BlockDummy.class)) {
TileEntityDummy dummy = (TileEntityDummy) tile;
if (accessor.getWorld().getBlockState(dummy.mainBlockPosition).getBlock() instanceof IDescription) {
IDescription desc = (IDescription) accessor.getWorld().getBlockState(dummy.mainBlockPosition).getBlock();
if (ClientUtils.isShiftKeyDown()) {
desc.getDescription().addDescription(itemStack, tooltip);
} else {
tooltip.add(LangUtils.translate("desc.shift_info.name"));
}
}
}
}
return tooltip;
}
use of stevekung.mods.moreplanets.utils.IDescription 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 IDescription) {
if (ClientUtils.isShiftKeyDown()) {
((IDescription) this.block).getDescription().addDescription(itemStack, list);
} else {
if (this.getBlock() instanceof BlockTileMP) {
TileEntity tile = ((BlockTileMP) this.getBlock()).createNewTileEntity(null, 0);
if (tile instanceof TileBaseElectricBlock) {
float powerDrawn = ((TileBaseElectricBlock) tile).storage.getMaxExtract();
if (powerDrawn > 0) {
list.add(TextFormatting.GREEN + LangUtils.translate("item_desc.powerdraw.name", EnergyDisplayHelper.getEnergyDisplayS(powerDrawn * 20)));
}
}
if (tile instanceof TileBaseUniversalElectrical) {
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("EnergyStored")) {
int power = (int) itemStack.getTagCompound().getFloat("EnergyStored");
list.add(TextFormatting.GREEN + LangUtils.translate("desc.energy_stored.name", EnergyDisplayHelper.getEnergyDisplayS(power)));
}
}
} else if (this.getBlock() instanceof BlockAdvancedTileMP) {
TileEntity tile = ((BlockAdvancedTileMP) this.getBlock()).createNewTileEntity(null, 0);
if (tile instanceof TileBaseElectricBlock) {
float powerDrawn = ((TileBaseElectricBlock) tile).storage.getMaxExtract();
if (powerDrawn > 0) {
list.add(TextFormatting.GREEN + LangUtils.translate("item_desc.powerdraw.name", EnergyDisplayHelper.getEnergyDisplayS(powerDrawn * 20)));
}
}
}
list.add(LangUtils.translate("desc.shift_info.name"));
}
}
}
Aggregations