Search in sources :

Example 1 with ITieredMetaTileEntity

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()));
    }
}
Also used : MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) ITieredMetaTileEntity(gregtech.api.metatileentity.ITieredMetaTileEntity) ITieredMetaTileEntity(gregtech.api.metatileentity.ITieredMetaTileEntity) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

ITieredMetaTileEntity (gregtech.api.metatileentity.ITieredMetaTileEntity)1 MetaTileEntity (gregtech.api.metatileentity.MetaTileEntity)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1