use of gregtech.api.metatileentity.ITieredMetaTileEntity in project GregTech by GregTechCE.
the class MachineItemBlock method addInformation.
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
MetaTileEntity metaTileEntity = getMetaTileEntity(stack);
if (metaTileEntity == null)
return;
// item specific tooltip like: gregtech.machine.lathe.lv.tooltip
String tooltipLocale = metaTileEntity.getMetaName() + ".tooltip";
if (I18n.hasKey(tooltipLocale)) {
String[] lines = I18n.format(tooltipLocale).split("/n");
tooltip.addAll(Arrays.asList(lines));
}
// tier less tooltip for a electric machine like: gregtech.machine.lathe.tooltip
if (metaTileEntity instanceof ITieredMetaTileEntity) {
String tierlessTooltipLocale = ((ITieredMetaTileEntity) metaTileEntity).getTierlessTooltipKey();
// case when it's not true would be any machine extending from TieredMetaTileEntity but having only one tier
if (!tooltipLocale.equals(tierlessTooltipLocale) && I18n.hasKey(tierlessTooltipLocale)) {
String[] lines = I18n.format(tierlessTooltipLocale).split("/n");
tooltip.addAll(Arrays.asList(lines));
}
}
metaTileEntity.addInformation(stack, worldIn, tooltip, flagIn.isAdvanced());
if (flagIn.isAdvanced()) {
tooltip.add(String.format("MetaTileEntity Id: %s", metaTileEntity.metaTileEntityId.toString()));
}
}
Aggregations