Posted February 19, 20187 yr hey guys im trying to dynamically paint my blocks and items so i dont have to draw them for each type of metal i want to add to the game. this is the result i have so far, no issues on any of the items or itemblocks. but i have issues with the ore block. it has this wierd black layer over it at a certain distance and angle. but the color also applies to the whole block instead of only the ore vein like it does on the itemblock that im holding in my hand. Client proxy @Override public void init(FMLInitializationEvent e) { ModEntities.initModels(); Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new IMaterialColor(), ModItems.material); Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new IMetalColor(), ModItems.metal); Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new IItemBlockMetalColor(), ItemBlock.getItemFromBlock(ModBlocks.metalBlock)); Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new IItemBlockMetalColor(), ItemBlock.getItemFromBlock(ModBlocks.ore)); Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(new IBlockMetalColor(), ModBlocks.metalBlock); Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(new IBlockMetalColor(), ModBlocks.ore); super.init(e); } IBlockMetalColor public class IBlockMetalColor implements IBlockColor { @Override public int colorMultiplier(IBlockState state, IBlockAccess worldIn, BlockPos pos, int tintIndex) { if (tintIndex == 0) { EnumMetals m = (EnumMetals) state.getValue(BlockMetal.type); return m.getColor(); } else { return 0xffffff; } } } IItemMetalBlockColor public class IItemBlockMetalColor implements IItemColor { @Override public int colorMultiplier(ItemStack stack, int tintIndex) { return EnumMetals.values()[stack.getItemDamage()].getColor(); } } BlockOre public class BlockOre extends Block implements IMetaBlockName { public static final PropertyEnum type = PropertyEnum.create("type", EnumMetals.class); public BlockOre() { super(Material.ROCK); setUnlocalizedName(Reference.MOD_ID + ":" + "ore"); setRegistryName("ore"); setCreativeTab(ModItems.SteampunkItemsTab); setHardness(1.5F); setResistance(5F); setHarvestLevel("pickaxe", 1); setDefaultState(blockState.getBaseState().withProperty(type, EnumMetals.Copper)); } @Override public int getHarvestLevel(IBlockState state) { return ((EnumMetals) state.getValue(type)).getHarvestLevel(); } @Override public float getBlockHardness(IBlockState blockState, World worldIn, BlockPos pos) { return ((EnumMetals) blockState.getValue(type)).getHardness(); } @SideOnly(Side.CLIENT) public void initModel() { for (EnumMetals o : EnumMetals.values()) { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), o.getId() , new ModelResourceLocation(getRegistryName(), "type=" + o.getName())); } } @Override public int getMetaFromState(IBlockState state) { return ((EnumMetals) state.getValue(type)).getId(); } @Override public IBlockState getStateFromMeta(int meta) { return getDefaultState().withProperty(type, EnumMetals.values()[meta]); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, type); } @Override public String getSpecialName(ItemStack stack) { return EnumMetals.values()[stack.getItemDamage()].getName(); } @Override public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { return new ItemStack(Item.getItemFromBlock(this),1,getMetaFromState(world.getBlockState(pos))); } @Override public int damageDropped(IBlockState state) { return getMetaFromState(state); } public void initOreDict () { for (EnumMetals o : EnumMetals.values()) { OreDictionary.registerOre("ore" + o.name(), new ItemStack(Item.getItemFromBlock(this),1,o.getId())); } } @Override public void getSubBlocks(CreativeTabs itemIn, NonNullList<ItemStack> tab) { for (EnumMetals o : EnumMetals.values()) { if (o.hasOre()) { tab.add(new ItemStack(Item.getItemFromBlock(this),1, o.getId())); } } } EnumMetals public enum EnumMetals implements IStringSerializable{ Copper(0,0xe56b51,1,1.5F), Tin(1,0xcdcbc9,1,1.5F), Lead(2,0xa3a6c3,1,1.5F), Zinc(3,0xb8b3ad,1,1.5F), Silver(4,0xe8e8e8,2,1.5F), Titanium(5,0xb1c5c4,3,2F), Tungsten(6,0x07005d,3,2F), Brass(7,0xf9d352), Bronze(8,0xecb977), Steel(9,0x64635f), Electrum(10,0xfff182), Blacksteel(11,0x555970); int color = 0xffffff; boolean hasOre = false; float hardness = 1; int harvestLevel = 1; int id = 0; EnumMetals (int id) { this.id = id; }; EnumMetals (int id, int color) { this.color = color; this.id = id; } EnumMetals (int id, int color, int harvestLevel, float hardness) { this.color = color; this.harvestLevel = harvestLevel; this.hardness = hardness; this.hasOre = true; this.id = id; } @Override public String getName() { return this.toString().toLowerCase(Locale.ENGLISH); } public boolean hasOre () { return this.hasOre; } public float getHardness () { return this.hardness; } public int getHarvestLevel () { return this.harvestLevel; } public int getColor () { return this.color; } public int getId () { return this.id; } blockstate json for the ore block { "forge_marker": 1, "defaults": { "model": "steampunkrevolution:ore", "textures": { "all": "minecraft:blocks/stone", "colored": "steampunkrevolution:blocks/basevein" } }, "variants": { "normal": [{}], "inventory": [{}], "type": { "copper": { }, "tin": { }, "lead": { }, "silver": { }, "tungsten": { }, "titanium": { }, "zinc": { } } } } ore model json { "parent": "block/cube_all", "textures": { "all": "minecraft:blocks/stone", "colored": "steampunkrevolution:blocks/basevein" }, "elements": [ { "from": [ 0, 0, 0 ], "to": [ 16, 16, 16 ], "faces": { "down": { "texture": "#all", "cullface": "down" }, "up": { "texture": "#all", "cullface": "up" }, "north": { "texture": "#all", "cullface": "north" }, "south": { "texture": "#all", "cullface": "south" }, "west": { "texture": "#all", "cullface": "west" }, "east": { "texture": "#all", "cullface": "east" } } }, { "from": [ 0, 0, 0 ], "to": [ 16, 16, 16 ], "faces": { "down": { "tintindex": 0, "texture": "#colored", "cullface": "down" }, "up": { "tintindex": 0, "texture": "#colored", "cullface": "up" }, "north": { "tintindex": 0, "texture": "#colored", "cullface": "north" }, "south": { "tintindex": 0, "texture": "#colored", "cullface": "south" }, "west": { "tintindex": 0, "texture": "#colored", "cullface": "west" }, "east": { "tintindex": 0, "texture": "#colored", "cullface": "east" } } } ] } Edited February 19, 20187 yr by ghostwolf_ added version to title
February 19, 20187 yr Author On 7/1/2016 at 3:53 AM, Choonster said: You'll also need to override Block#getBlockLayer to return BlockRenderLayer.CUTOUT or BlockRenderLayer.CUTOUT_MIPPED ( BlockGrass uses the latter). This allows the block's textures to render with transparency. The Grey Ghost explains render layers in more detail here. this fixed it, didnt know this was a thing.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.