From 52d41f5626c25fc8744193ae7539ff3d42e20a87 Mon Sep 17 00:00:00 2001 From: Dragon2488 Date: Sat, 6 Jan 2018 01:57:26 +0700 Subject: [PATCH] item colors --- .../api/items/materialitem/MaterialMetaItem.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/gregtech/api/items/materialitem/MaterialMetaItem.java b/src/main/java/gregtech/api/items/materialitem/MaterialMetaItem.java index 123c9cf6..1c598f1a 100644 --- a/src/main/java/gregtech/api/items/materialitem/MaterialMetaItem.java +++ b/src/main/java/gregtech/api/items/materialitem/MaterialMetaItem.java @@ -9,8 +9,10 @@ import gregtech.api.unification.material.type.MarkerMaterial; import gregtech.api.unification.material.type.Material; import gregtech.api.unification.ore.OrePrefix; import gregtech.api.util.GTUtility; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ModelBakery; import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; @@ -79,6 +81,17 @@ public class MaterialMetaItem extends StandardMetaItem { } return new ModelResourceLocation("builtin/missing", "missing"); }); + + Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new IItemColor() { + @Override + public int colorMultiplier(ItemStack stack, int tintIndex) { + if (tintIndex == 0 && stack.getMetadata() < orePrefixAmount * 1000) { + Material material = Material.MATERIAL_REGISTRY.getObjectById(stack.getMetadata() % 1000); + return material.materialRGB; + } + return 0xFFFFFF; + } + }, this); } protected boolean canGenerate(OrePrefix orePrefix, Material material) {