Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

47 minutes ago, Viler_of_cool said:

specific layer has a custom tint.

You can register an 'ItemColor' in the 'ColorHandlerEvent.Item' event.

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()
		);
		}
		}
		
		
		//########## ########## ########## ########## ########## ########## ########## ##########				
			

 

  • 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.

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 

2024-02-28-12-28-02.png

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.