feat: rework dynamic item colors

This commit is contained in:
Martin Prokoph
2025-01-26 01:46:16 +01:00
parent 3307ba337e
commit d95a18b28b
11 changed files with 103 additions and 80 deletions

View File

@@ -74,12 +74,6 @@ public class VisualOverhaulClientFabric implements ClientModInitializer {
// PhonosCompatInit.init();
//}
// Registries.ITEM.forEach((item) -> {
// ModelPredicateProviderRegistry.register(item, Identifier.ofVanilla("round"), (stack, world, entity, seed) ->
// stack.getComponents().contains(DataComponentTypes.JUKEBOX_PLAYABLE) && stack.getComponents().contains(DataComponentTypes.CUSTOM_MODEL_DATA) &&
// stack.getComponents().get(DataComponentTypes.CUSTOM_MODEL_DATA).value() == 710 ? 1.0F : 0.0F);
// });
ClientPlayNetworking.registerGlobalReceiver(UpdateItemsPacket.PACKET_ID,
(payload, context) -> context.client().execute(() -> {
if (payload.blockTypeID().equals(UPDATE_TYPE_RECORD)) jukeboxItems.put(payload.pos(), payload.inv().getFirst());
@@ -101,7 +95,6 @@ public class VisualOverhaulClientFabric implements ClientModInitializer {
ResourceManagerHelper.registerBuiltinResourcePack(id("nobrewingbottles"), modContainer, ResourcePackActivationType.DEFAULT_ENABLED);
ResourceManagerHelper.registerBuiltinResourcePack(id("fancyfurnace"), modContainer, ResourcePackActivationType.DEFAULT_ENABLED);
ResourceManagerHelper.registerBuiltinResourcePack(id("coloredwaterbucket"), modContainer, ResourcePackActivationType.DEFAULT_ENABLED);
ResourceManagerHelper.registerBuiltinResourcePack(id("rounddiscs"), modContainer, ResourcePackActivationType.ALWAYS_ENABLED);
});
ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> {
if (client.player != null) {
@@ -116,7 +109,7 @@ public class VisualOverhaulClientFabric implements ClientModInitializer {
waterColor = BiomeColors.getWaterColor(client.world, client.player.getBlockPos());
foliageColor = BiomeColors.getFoliageColor(client.world, client.player.getBlockPos());
grassColor = BiomeColors.getGrassColor(client.world, client.player.getBlockPos());
potionColor = VOColorUtil.convertRgbToArgb(waterColor);
potionColor = VOColorUtil.convertRgbToArgb(waterColor, 200);
} else {
waterColor = 4159204;
foliageColor = -8934609;
@@ -124,21 +117,6 @@ public class VisualOverhaulClientFabric implements ClientModInitializer {
potionColor = -13083194;
}
});
// ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex == 0 ? -1 : waterColor, Items.WATER_BUCKET, Items.AXOLOTL_BUCKET, Items.COD_BUCKET, Items.PUFFERFISH_BUCKET, Items.TROPICAL_FISH_BUCKET, Items.SALMON_BUCKET);
// ColorProviderRegistry.ITEM.register((stack, tintIndex) -> grassColor, Items.GRASS_BLOCK, Items.SHORT_GRASS, Items.TALL_GRASS, Items.FERN, Items.LARGE_FERN);
// ColorProviderRegistry.ITEM.register((stack, tintIndex) -> foliageColor, Items.OAK_LEAVES, Items.DARK_OAK_LEAVES, Items.JUNGLE_LEAVES, Items.ACACIA_LEAVES, Items.VINE, Items.SUGAR_CANE);
// if (VOConfig.coloredLilypad) ColorProviderRegistry.ITEM.register((stack, tintIndex) -> foliageColor, Items.LILY_PAD);
//
// ColorProviderRegistry.ITEM.register((stack, tintIndex) -> {
// var contents = stack.getComponents().get(DataComponentTypes.POTION_CONTENTS);
// if (contents == null || contents.potion().isEmpty()) return tintIndex > 0 ? -1 : potionColor;
// var potion = contents.potion().get();
// if ((potion == Potions.WATER || potion == Potions.MUNDANE || potion == Potions.THICK || potion == Potions.AWKWARD) && tintIndex == 0) {
// return potionColor;
// }
// return tintIndex > 0 ? -1 : contents.getColor();
// }, Items.POTION, Items.SPLASH_POTION, Items.LINGERING_POTION);
}
if (VOConfig.coloredLilypad) {
ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> world != null ? world.getColor(pos, BiomeColors.FOLIAGE_COLOR) : 0, Blocks.LILY_PAD);