Posted August 11, 201510 yr I have a a tile entity called mimic block. It mimics other blocks textures from it's state, and it seemed to be working great until I tried it on grass. It gives me a strange texture. The strange texture I'm getting https://gyazo.com/05e6d28803f8ec71565c578aad6f97e2 TileEntityMimicBlock http://pastebin.com/QvZi553P MimicBlock http://pastebin.com/uGUKsVYM MimicBlockISmartBlockModelFactory http://pastebin.com/J1w1EEVx Any ideas as to what would cause that?
August 11, 201510 yr That's the actual grass texture, but BlockGrass overrides getBlockColor , getRenderColor and colorMultiplier to colour it depending on the position in the world. You should override these methods in MimicBlock to call the corresponding methods of the mimicked Block . Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
August 11, 201510 yr Author Thanks a bunch! I copied this over from the grass block and I've tested it and it seems to work. @SideOnly(Side.CLIENT) public int getBlockColor(){ return ColorizerGrass.getGrassColor(0.5D, 1.0D); } @SideOnly(Side.CLIENT) public int getRenderColor(IBlockState state){ return this.getBlockColor(); } @SideOnly(Side.CLIENT) public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) { return BiomeColorHelper.getGrassColorAtPos(worldIn, pos); } out of curiosity, would you know whether or not I should copy the block's Model In my TileEntity?
August 11, 201510 yr Thanks a bunch! I copied this over from the grass block and I've tested it and it seems to work. @SideOnly(Side.CLIENT) public int getBlockColor(){ return ColorizerGrass.getGrassColor(0.5D, 1.0D); } @SideOnly(Side.CLIENT) public int getRenderColor(IBlockState state){ return this.getBlockColor(); } @SideOnly(Side.CLIENT) public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) { return BiomeColorHelper.getGrassColorAtPos(worldIn, pos); } out of curiosity, would you know whether or not I should copy the block's Model In my TileEntity? Note, that you can't jusy copy these methods from grass block, otherwise all mimiced blocks will be recolored... And you will get green planks... Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
August 11, 201510 yr Author @SideOnly(Side.CLIENT) public int getBlockColor(){ return ColorizerGrass.getGrassColor(0.5D, 1.0D); } @SideOnly(Side.CLIENT) public int getRenderColor(IBlockState state){ return this.getBlockColor(); } @SideOnly(Side.CLIENT) public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) { return BiomeColorHelper.getGrassColorAtPos(worldIn, pos); } Note, that you can't jusy copy these methods from grass block, otherwise all mimiced blocks will be recolored... And you will get green planks... Thanks for telling me that. I had a feeling, but wasn't sure. However, I did test the wood and it comes out fine, but then I tested tall grass and redstone. The tall grass was gray and the redstone was green:p So I looked at the code from both classes and came up with something that seemed to have worked. It takes the only blocks that actually use this color coding stuff, or atleast the ones I currently know about... So I will be patching it as I see others that need it @SideOnly(Side.CLIENT) public int getRenderColor(IBlockState state){ if(state == Blocks.redstone_wire.getDefaultState()){//This will make the mimiced redstone line look like it's off (red) float f1 = 0.3F; float f2 = 0.0F; float f3 = 0.0F; int j = MathHelper.clamp_int((int)(f1 * 255.0F), 0, 255); int k = MathHelper.clamp_int((int)(f2 * 255.0F), 0, 255); int l = MathHelper.clamp_int((int)(f3 * 255.0F), 0, 255); return -16777216 | j << 16 | k << 8 | l; } return this.getBlockColor(); } @SideOnly(Side.CLIENT) public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) { TileEntity tile_entity; IBlockState state = worldIn.getBlockState(pos); if(worldIn.getTileEntity(pos) instanceof TileEntityMimicBlock){ tile_entity = (TileEntityMimicBlock)worldIn.getTileEntity(pos); state = ((TileEntityMimicBlock) tile_entity).getState(); if(state == Blocks.grass.getDefaultState() || state.getBlock() == Blocks.tallgrass) return BiomeColorHelper.getGrassColorAtPos(worldIn, pos); return getRenderColor(state); } return getRenderColor(state); }
August 12, 201510 yr @SideOnly(Side.CLIENT) public int getBlockColor(){ return ColorizerGrass.getGrassColor(0.5D, 1.0D); } @SideOnly(Side.CLIENT) public int getRenderColor(IBlockState state){ return this.getBlockColor(); } @SideOnly(Side.CLIENT) public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) { return BiomeColorHelper.getGrassColorAtPos(worldIn, pos); } Note, that you can't jusy copy these methods from grass block, otherwise all mimiced blocks will be recolored... And you will get green planks... Thanks for telling me that. I had a feeling, but wasn't sure. However, I did test the wood and it comes out fine, but then I tested tall grass and redstone. The tall grass was gray and the redstone was green:p So I looked at the code from both classes and came up with something that seemed to have worked. It takes the only blocks that actually use this color coding stuff, or atleast the ones I currently know about... So I will be patching it as I see others that need it @SideOnly(Side.CLIENT) public int getRenderColor(IBlockState state){ if(state == Blocks.redstone_wire.getDefaultState()){//This will make the mimiced redstone line look like it's off (red) float f1 = 0.3F; float f2 = 0.0F; float f3 = 0.0F; int j = MathHelper.clamp_int((int)(f1 * 255.0F), 0, 255); int k = MathHelper.clamp_int((int)(f2 * 255.0F), 0, 255); int l = MathHelper.clamp_int((int)(f3 * 255.0F), 0, 255); return -16777216 | j << 16 | k << 8 | l; } return this.getBlockColor(); } @SideOnly(Side.CLIENT) public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) { TileEntity tile_entity; IBlockState state = worldIn.getBlockState(pos); if(worldIn.getTileEntity(pos) instanceof TileEntityMimicBlock){ tile_entity = (TileEntityMimicBlock)worldIn.getTileEntity(pos); state = ((TileEntityMimicBlock) tile_entity).getState(); if(state == Blocks.grass.getDefaultState() || state.getBlock() == Blocks.tallgrass) return BiomeColorHelper.getGrassColorAtPos(worldIn, pos); return getRenderColor(state); } return getRenderColor(state); } I would still recomend you to use mimicedBlock.colorMultiplier instead, because you already missed some customly colored blocks: leaves, vines, grass block, double tall grass block, flowers... Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
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.