mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 14:52:58 +00:00
51 lines
1.2 KiB
Java
51 lines
1.2 KiB
Java
package mekanism.common.item;
|
|
|
|
import mekanism.api.EnumColor;
|
|
import mekanism.common.util.LangUtils;
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.item.EnumDyeColor;
|
|
import net.minecraft.item.ItemBlock;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.util.text.translation.I18n;
|
|
|
|
public class ItemBlockPlastic extends ItemBlock
|
|
{
|
|
public Block metaBlock;
|
|
|
|
public ItemBlockPlastic(Block block)
|
|
{
|
|
super(block);
|
|
metaBlock = block;
|
|
setHasSubtypes(true);
|
|
}
|
|
|
|
@Override
|
|
public int getMetadata(int i)
|
|
{
|
|
return i;
|
|
}
|
|
|
|
@Override
|
|
public String getItemStackDisplayName(ItemStack stack)
|
|
{
|
|
EnumDyeColor dyeColour = EnumDyeColor.byDyeDamage(stack.getItemDamage()&15);
|
|
EnumColor colour = EnumColor.DYES[dyeColour.getDyeDamage()];
|
|
String colourName;
|
|
|
|
if(I18n.canTranslate(getUnlocalizedName(stack) + "." + colour.dyeName))
|
|
{
|
|
return LangUtils.localize(getUnlocalizedName(stack) + "." + colour.dyeName);
|
|
}
|
|
|
|
if(colour == EnumColor.BLACK)
|
|
{
|
|
colourName = EnumColor.DARK_GREY + colour.getDyeName();
|
|
}
|
|
else {
|
|
colourName = colour.getDyedName();
|
|
}
|
|
|
|
return colourName + " " + super.getItemStackDisplayName(stack);
|
|
}
|
|
}
|