2

Here are my predicate overrides, inside of weather_cycle_device.json:

{
  "parent": "minecraft:item/generated",
  "textures": {
    "layer0": "rafaels-weather-cycle-device:item/weather_cycle_device"
  },
  "overrides": [
    {
      "predicate": {
        "rafaels-weather-cycle-device:weather_state": 2.0
      },
      "model": "rafaels-weather-cycle-device:item/weather_cycle_device_rainy"
    },
    {
      "predicate": {
        "rafaels-weather-cycle-device:weather_state": 3.0
      },
      "model": "rafaels-weather-cycle-device:item/weather_cycle_device_thunder"
    }
  ]
}

Here is how I am setting the model states for items in the Java code:

package net.rafael.weathercycledevice.util;

import net.minecraft.client.item.ModelPredicateProviderRegistry;
import net.minecraft.util.Identifier;
import net.rafael.weathercycledevice.RafaelsWeatherCycleDevice;
import net.rafael.weathercycledevice.components.ModComponentDataTypes;
import net.rafael.weathercycledevice.item.ModItems;

public class ModModelPredicates {
    public static void registerModelPredicates() {

        ModelPredicateProviderRegistry.register(ModItems.WEATHER_CYCLE_DEVICE, Identifier.of(RafaelsWeatherCycleDevice.MOD_ID, "weather_state"),
                (stack, world, entity, seed) -> {
                    Integer weatherState = stack.get(ModComponentDataTypes.WeatherState);
                    return weatherState != null ? weatherState : 1;
                });
    }
}

In the beginning, my logs reported that the state was 1, and it changes after using the item appropriately to state 3. So, predicate values are changing but not the textures.

How can I affect the predicate overrides accordingly?

2
  • Thank you for making the edits to add the full code so quickly! I'll be taking a stab at drawing up a solution shortly, as I have worked with model predicates for Minecraft before (using damage states specifically), but anyone else who wants to help should very much post an answer. :) Commented Nov 13, 2024 at 15:57
  • In weather_cycle_device.json, can you first try removing rafaels-weather-cycle-device: from layer0 and the two model overrides? If that doesn't work, also try removing minecraft: from parent. I initially did the same thing but for my old plugin, I ended up just using values like "item/generated" or "item/custom_item". Let me know how it goes and if it doesn't fix the problem, I'll see if I can't find some other issue. Commented Nov 19, 2024 at 10:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.