Varied Model
All scripts should be written in client_scripts.
MafuyuEvents.modifyVariedModel(event => {
if (event.getItemStack().is(Items.APPLE)) event.setModelPath("minecraft:stone");
});
This is the simplest example — it replaces the apple’s texture with that of stone.
If you want to use an idle model that doesn’t belong to any item, you can do so as well — just make sure to register it in the configuration file first.
[VariedModelConfig]
loadIdleModel = false
PresetModel = ["allthemafuyu:stalker_core"]
Finally, here’s a simple example of randomized textures: This makes a single redstone block randomly appear as bread, stone, or dirt. When the blocks are stacked together, they revert to the normal redstone block texture.
MafuyuEvents.modifyVariedModel(event => {
if (event.getItemStack().id === "minecraft:redstone_block") {
if (event.getItemStack().getCount() > 1) {
event.setVariedModelCache(null);
} else {
let models = [
"minecraft:bread",
"minecraft:stone",
"minecraft:dirt"
]
if (!event.getVariedModelCache()) {
event.setVariedModelCache(models[(Math.floor(Math.random() * models.length))]);
}
event.setModelPath(event.getVariedModelCache());
}
}
});