Posted January 9, 20178 yr Hello again! So I am working on something and it came up that it would be a nice feature to change the color of a block based on...stuff (really anything). Specifically right now I am working with pathfinding algorithms such as A*, DFS, BFS, Dijkstra's etc. In the case of A* I would like to tint a block slightly to visually differentiate which blocks are in the open/closed lists, which blocks are being scanned, etc. I found the function in the block class: /** * Common way to recolor a block with an external tool * @param world The world * @param pos Block position in world * @param side The side hit with the coloring tool * @param color The color to change to * @return If the recoloring was successful */ @SuppressWarnings({ "unchecked", "rawtypes" }) public boolean recolorBlock(World world, BlockPos pos, EnumFacing side, net.minecraft.item.EnumDyeColor color) { IBlockState state = world.getBlockState(pos); for (IProperty prop : state.getProperties().keySet()) { if (prop.getName().equals("color") && prop.getValueClass() == net.minecraft.item.EnumDyeColor.class) { net.minecraft.item.EnumDyeColor current = (net.minecraft.item.EnumDyeColor)state.getValue(prop); if (current != color) { world.setBlockState(pos, state.withProperty(prop, color)); return true; } } } return false; } This function doesn't seem to change the color of a block as expected though and always returns false for me. What should I do differently here? P.S. I have seen positions marked in classes that used WorldRenderer. But that doesn't seem to exist anymore.
January 9, 20178 yr What that does is when a Blocks block state has the EnumDyeColor as a PropertyEnum on it, changes the color/state of the block. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
January 9, 20178 yr Author What that does is when a Blocks block state has the EnumDyeColor as a PropertyEnum on it, changes the color/state of the block. Ah so if the blocks were dyed wool then color should update. I can make a test world using wool blocks for what I'm doing then and the recolorBlock function should be fine. For adding a transparent tint layer over the block faces should I be looking in the Render package? It seems like I should be using VertexBuffer in place of WorldRenderer but meh it is all very confusing.
January 9, 20178 yr When you say you want to add a transparent tint over the block, when do you want to do this? Is there any example you could give? VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
January 9, 20178 yr Author When you say you want to add a transparent tint over the block, when do you want to do this? Is there any example you could give? An example would be the case where I have set two position markers (BlockPos or Double X,Y,Z's idc) A and B and I want to do something like make A look Red and B look Green. When I say transparent I mean only that it isn't necessary to replace the texture of the native block. Or perhaps changing the color of an array of blocks such as the surface area of the rectangle given by two BlockPos. (If you've ever used the factions mod it could be that we highlight the blocks slightly when a chunk is claimed and remove the color if that chunk is unclaimed). sorry If I am aimlessly wandering here. I have been hittin' the coffee hard. Basically I would have the function in a ticker and have it update a block color/tint if some condition is true.
January 9, 20178 yr I think you would need to use the RenderWorldLastEvent VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
January 9, 20178 yr Author I think you would need to use the RenderWorldLastEvent Thanks I am looking at it now. Lot's going on in RenderGlobal but I will work around in it. For now though I think I can use recolorBlock on wool and glass to produce the effect I want for my testing.
January 10, 20178 yr You should use an IBlockColor implementation for the block via Minecraft.getMinecraft.getBlockColors.registerColorHandler(...). In the IBlockColor implementation you can set a tint based on the block state or value in the tile entity.
January 10, 20178 yr You should use an IBlockColor implementation for the block via Minecraft.getMinecraft.getBlockColors.registerColorHandler(...). In the IBlockColor implementation you can set a tint based on the block state or value in the tile entity. He isn't doing it to just his own Blocks. Edit: Also I do not believe that IBlockColor can add a "tint", or transparent layer. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
January 10, 20178 yr This doesn't matter as long as he knows the blocks. As the method from IBlockColor gives you a BlockPos you could even access a collection (beware that it must be thread safe!).
January 10, 20178 yr This doesn't matter as long as he knows the blocks. As the method from IBlockColor gives you a BlockPos you could even access a collection (beware that it must be thread safe!). It does. If the models of other blocks don't have the tintindex set, it won't call IBlockColor#colorMultiplier , thus not be able to handle every block in Minecraft and other mods without resource packs. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
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.