Posted February 27, 20241 yr So i wanna make several items that use at most 5 textures, all of them are white but i wanna make it so that a specific layer has a custom tint. Im trying to make a milkshake that has different flavors, each flavor having a different colored liquid without making 50 textures that are just recolors, to lower clutter. I couldn't find anything on the internet, but i might have missed something, so sorry if i did. Just now, Viler_of_cool said: So i wanna make several items that use at most 5 textures, all of them are white but i wanna make it so that a specific layer has a custom tint. Im trying to make a milkshake that has different flavors, each flavor having a different colored liquid without making 50 textures that are just recolors, to lower clutter. I couldn't find anything on the internet, but i might have missed something, so sorry if i did. Btw im using 1.20
February 27, 20241 yr 47 minutes ago, Viler_of_cool said: specific layer has a custom tint. You can register an 'ItemColor' in the 'ColorHandlerEvent.Item' event.
February 27, 20241 yr can we have a example of that for item inever could make it work for item for blocks i got this Spoiler //########## ########## ########## ########## ########## ########## ########## ########## //########## ########## ########## ########## ########## ########## ########## ########## @Mod.EventBusSubscriber(modid = MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD) public final class ColorHandler { @SubscribeEvent public static void registerBlockColors(RegisterColorHandlersEvent.Block event) { //System.out.println("\n#RegisterColorHandlersEvent#\n"); event.register((state, getter, pos, tintIndex) -> { if (tintIndex > 15) return 0xFFFFFF; if (getter == null || pos == null) { //return FoliageColor.getDefaultColor(); return GrassColor.get(0.5D, 1.0D); } int red = 0; int grn = 0; int blu = 0; for (int dz = -1; dz <= 1; ++dz) { for (int dx = -1; dx <= 1; ++dx) { int i2 = BiomeColors.getAverageGrassColor(getter, pos.offset(dx, 0, dz)); red += (i2 & 16711680) >> 16; grn += (i2 & 65280) >> 8; blu += i2 & 255; } } return (red / 9 & 255) << 16 | (grn / 9 & 255) << 8 | blu / 9 & 255; }, BlockInit.GRASS_SLAB.get()); event.register((state, getter, pos, tintIndex) -> { if (tintIndex > 15) return 0xFFFFFF; if (getter == null || pos == null) { //return FoliageColor.getDefaultColor(); return GrassColor.get(0.5D, 1.0D); } int red = 9215;//8192;//16383; int grn = 128; int blu = 128; return (red / 9 & 255) << 16 | (grn / 9 & 255) << 8 | blu / 9 & 255; }, BlockInit.MREDSTONE_WIRE.get()); event.register((state, getter, pos, tintIndex) -> { if (tintIndex > 15) return 0xFFFFFF; if (getter == null || pos == null) { //return FoliageColor.getDefaultColor(); return GrassColor.get(0.5D, 1.0D); } int red = 0; int grn = 0; int blu = 0; for (int dz = -1; dz <= 1; ++dz) { for (int dx = -1; dx <= 1; ++dx) { int i2 = BiomeColors.getAverageWaterColor(getter, pos.offset(dx, 0, dz)); red += (i2 & 16711680) >> 16; grn += (i2 & 65280) >> 8; blu += i2 & 255; } } return (red / 9 & 255) << 16 | (grn / 9 & 255) << 8 | blu / 9 & 255; }, //BlockInit.RUNNING_WATER.get(), //BlockInit.WATER_PIPE_.get(), //BlockInit.CAULDRUM_FAUCET.get(), //BlockInit.FALLING_WATER.get(), BlockInit.COBBLESTONE_TOILET.get(), BlockInit.STONE_TOILET.get(), BlockInit.IRON_TOILET.get(), BlockInit.EMERALD_TOILET.get(), BlockInit.DIAMOND_TOILET .get(), BlockInit.GOLD_TOILET.get(), BlockInit.POLISHED_DIORITE_TOILET .get(), BlockInit.POLISHED_ANDESITE_TOILET.get(), BlockInit.POLISHED_GRANITE_TOILET .get(), BlockInit.GLASS_BOTTLE_BLOCK.get(), BlockInit.QUARTZ_TOILET.get() ); } } //########## ########## ########## ########## ########## ########## ########## ##########
February 28, 20241 yr Author On 2/27/2024 at 4:43 PM, vemerion said: You can register an 'ItemColor' in the 'ColorHandlerEvent.Item' event. So because i just simply dont know, where do i put this? In what file? If you have an example file you can send me that would be great.
February 28, 20241 yr i have it as a class in the main mod folder but dont seems to matter whats is the location /home/usuario/workspace/1.20.4/mercmod/src/main/java/mercmod/ColorHandler.java "src/main/java/mercmod/ColorHandler.java" Spoiler package mercmod; import mercmod.blocks.BlockInit; import net.minecraft.client.renderer.BiomeColors; import net.minecraft.world.level.GrassColor; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.RegisterColorHandlersEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; //########## ########## ########## ########## ########## ########## ########## ########## //########## ########## ########## ########## ########## ########## ########## ########## @Mod.EventBusSubscriber(modid = mercmod.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD) public final class ColorHandler { @SubscribeEvent public static void registerBlockColors(RegisterColorHandlersEvent.Block event) { //System.out.println("\n#RegisterColorHandlersEvent#\n"); event.register((state, getter, pos, tintIndex) -> { if (tintIndex > 15) return 0xFFFFFF; if (getter == null || pos == null) { //return FoliageColor.getDefaultColor(); return GrassColor.get(0.5D, 1.0D); } int red = 0; int grn = 0; int blu = 0; for (int dz = -1; dz <= 1; ++dz) { for (int dx = -1; dx <= 1; ++dx) { int i2 = BiomeColors.getAverageGrassColor(getter, pos.offset(dx, 0, dz)); red += (i2 & 16711680) >> 16; grn += (i2 & 65280) >> 8; blu += i2 & 255; } } return (red / 9 & 255) << 16 | (grn / 9 & 255) << 8 | blu / 9 & 255; }, BlockInit.GRASS_SLAB.get()); event.register((state, getter, pos, tintIndex) -> { if (tintIndex > 15) return 0xFFFFFF; if (getter == null || pos == null) { //return FoliageColor.getDefaultColor(); return GrassColor.get(0.5D, 1.0D); } int red = 9215;//8192;//16383; int grn = 128; int blu = 128; return (red / 9 & 255) << 16 | (grn / 9 & 255) << 8 | blu / 9 & 255; }, BlockInit.MREDSTONE_WIRE.get()); event.register((state, getter, pos, tintIndex) -> { if (tintIndex > 15) return 0xFFFFFF; if (getter == null || pos == null) { //return FoliageColor.getDefaultColor(); return GrassColor.get(0.5D, 1.0D); } int red = 0; int grn = 0; int blu = 0; for (int dz = -1; dz <= 1; ++dz) { for (int dx = -1; dx <= 1; ++dx) { int i2 = BiomeColors.getAverageWaterColor(getter, pos.offset(dx, 0, dz)); red += (i2 & 16711680) >> 16; grn += (i2 & 65280) >> 8; blu += i2 & 255; } } return (red / 9 & 255) << 16 | (grn / 9 & 255) << 8 | blu / 9 & 255; }, //BlockInit.RUNNING_WATER.get(), //BlockInit.WATER_PIPE_.get(), //BlockInit.CAULDRUM_FAUCET.get(), //BlockInit.FALLING_WATER.get(), BlockInit.COBBLESTONE_TOILET.get(), BlockInit.STONE_TOILET.get(), BlockInit.IRON_TOILET.get(), BlockInit.EMERALD_TOILET.get(), BlockInit.DIAMOND_TOILET .get(), BlockInit.GOLD_TOILET.get(), BlockInit.POLISHED_DIORITE_TOILET .get(), BlockInit.POLISHED_ANDESITE_TOILET.get(), BlockInit.POLISHED_GRANITE_TOILET .get(), BlockInit.GLASS_BOTTLE_BLOCK.get(), BlockInit.QUARTZ_TOILET.get() ); } } //########## ########## ########## ########## ########## ########## ########## ########## i can not get the item color part to work this is mi grass slab As block when placed it takes the corresponding bioma grass color its fine as item in the inventory or the hotbar and as entityItem dont takes the color is just gray
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.