I have a block with some blockstates, and when the block gets broken, the current state is saved in the item as nbt data ("charges"), and the proper blockstate is restored when the item is placed.
My issue is that I can't really figure out how to get the item to render properly with the texture of the related blockstate, Can anyone help me? (relevant jsons below)
#Issue with proper rendering of block item in relation to blockState
36 messages · Page 1 of 1 (latest)
{
"parent": "arcanistsparagon:item/entropy_cell",
"overrides": [
{"predicate": {"charges": 0}, "model": "arcanistsparagon:item/entropy_cell_0"},
{"predicate": {"charges": 1}, "model": "arcanistsparagon:item/entropy_cell_1"},
{"predicate": {"charges": 2}, "model": "arcanistsparagon:item/entropy_cell_2"},
{"predicate": {"charges": 3}, "model": "arcanistsparagon:item/entropy_cell_3"},
{"predicate": {"charges": 4}, "model": "arcanistsparagon:item/entropy_cell_4"},
{"predicate": {"charges": 5}, "model": "arcanistsparagon:item/entropy_cell_5"},
{"predicate": {"charges": 6}, "model": "arcanistsparagon:item/entropy_cell_6"},
{"predicate": {"charges": 7}, "model": "arcanistsparagon:item/entropy_cell_7"},
{"predicate": {"charges": 8}, "model": "arcanistsparagon:item/entropy_cell_8"}
]
}```
this is entropy_cell.json
{
"parent": "arcanistsparagon:block/entropy_cell_stage0"
}```
all of the other models are like this
predicates must be from 0 to 1 correct?
oops, idrk, I just tried to copy that from the clock item model, and figured it was just an nbt tag
idk either, it could have changed since i last touched it.
Also I'm doing this by hand, I can't figure out how to do this with datagen and figured it would just be easier
Also I'm using moremcmeta, maybe there's something there that can help?
hmmm, how would I get the item here? it just says EXAMPLE_BOW, but my issue is with an item from a block
yep yep forgot about that hold on
and since it has to be a float, it appears, I could just get number/10? (to avoid rounding errors)
probably
ModelPredicateProviderRegistry.register(ModBlocks.ENTROPY_CELL.asItem(), new Identifier(ArcanistsParagon.MOD_ID, "charges"), (itemStack, clientWorld, livingEntity, seed) -> {
if (livingEntity == null) {
return 0.0F;
}
return livingEntity.getActiveItem() != itemStack ? 0.0F : (itemStack.getNbt().getInt("charges")) / 10.0F;
});```
something like this?
ah no the return is wrong, I need the item to be rendered always
and you want it to render even when living entity is null right
ModelPredicateProviderRegistry.register(ModBlocks.ENTROPY_CELL.asItem(), new Identifier(ArcanistsParagon.MOD_ID, "charges"), (itemStack, clientWorld, livingEntity, seed) -> {
return (itemStack.getNbt().getInt("charges")) / 10.0F;
});```
?
looks like it, try it
do I leave the json as is?
idk.
oops
of course it won't work, I left the old values
{
"parent": "arcanistsparagon:item/entropy_cell_0",
"overrides": [
{"predicate": {"charges": 0.0}, "model": "arcanistsparagon:item/entropy_cell_0"},
{"predicate": {"charges": 0.1}, "model": "arcanistsparagon:item/entropy_cell_1"},
{"predicate": {"charges": 0.2}, "model": "arcanistsparagon:item/entropy_cell_2"},
{"predicate": {"charges": 0.3}, "model": "arcanistsparagon:item/entropy_cell_3"},
{"predicate": {"charges": 0.4}, "model": "arcanistsparagon:item/entropy_cell_4"},
{"predicate": {"charges": 0.5}, "model": "arcanistsparagon:item/entropy_cell_5"},
{"predicate": {"charges": 0.6}, "model": "arcanistsparagon:item/entropy_cell_6"},
{"predicate": {"charges": 0.7}, "model": "arcanistsparagon:item/entropy_cell_7"},
{"predicate": {"charges": 0.8}, "model": "arcanistsparagon:item/entropy_cell_8"}
]
}```
nope, still won't work
hmmmm. it seems like the whole function isn't running. Like. at all.
ModelPredicateProviderRegistry.register(ModBlocks.ENTROPY_CELL.asItem(), new Identifier(ArcanistsParagon.MOD_ID, "charges"), (itemStack, clientWorld, livingEntity, seed) -> {
int charges = 0;
if (itemStack.getNbt() != null){
charges = itemStack.getNbt().getInt("charges");
}
float charges_10 = charges / 10.0f;
ArcanistsParagon.LOGGER.info(charges_10 + " = charges_10");
return charges_10;
});
``` this never seems to run
You're sure the code is referenced in your client initializer?
public class ArcanistsParagonClient implements ClientModInitializer {
public static void registerModelPredicateProviders() {
ModelPredicateProviderRegistry.register(ModBlocks.ENTROPY_CELL.asItem(), new Identifier("custom_model_data"), (itemStack, clientWorld, livingEntity, seed) -> {
int charges = 0;
NbtCompound nbtData = itemStack.getNbt();
if (nbtData != null) {
charges = Integer.parseInt(nbtData.getCompound("BlockStateTag").getString("charges"));
}
float charges_10 = (float)Math.round((charges / 10.0f) * 10.0f) / 10.0f;
ArcanistsParagon.LOGGER.info(charges_10 + " = charges_10");
return charges_10;
});
}
@Override
public void onInitializeClient() {
registerModelPredicateProviders();
HandledScreens.register(ModScreenHandlers.RITUAL_TABLE_SCREEN_HANDLER, RitualTableScreen::new);
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.RISINGBULB_CROP, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.SCIONBLOOM_BLOSSOM, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.POTTED_SCIONBLOOM_BLOSSOM, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.WEANING_IMPATIENS, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.POTTED_WEANING_IMPATIENS, RenderLayer.getCutout());
BlockEntityRendererFactories.register(ModBlockEntities.RITUAL_PEDESTAL_BLOCK_ENTITY, PedestalBlockEntityRenderer::new);
BlockEntityRendererFactories.register(ModBlockEntities.RITUAL_CORE_BLOCK_ENTITY, RitualCoreEntityRenderer::new);
EntityRendererRegistry.register(ModEntities.INKY_CORE_PROJECTILE, FlyingItemEntityRenderer::new);
ArcanistsParagonParticleDecoder decoder = new ArcanistsParagonParticleDecoder();
``` I can't really be more sure than this... (also the nbt ws a string, lol)
still not working though...
{
"parent" : "arcanistsparagon:block/entropy_cell_stage0",
"overrides": [
{"predicate": {
"custom_model_data": 0.0}, "model": "arcanistsparagon:item/entropy_cell_0"},
{"predicate": {
"custom_model_data": 0.1}, "model": "arcanistsparagon:item/entropy_cell_1"},
{"predicate": {
"custom_model_data": 0.2}, "model": "arcanistsparagon:item/entropy_cell_2"},
{"predicate": {
"custom_model_data": 0.3}, "model": "arcanistsparagon:item/entropy_cell_3"},
{"predicate": {
"custom_model_data": 0.4}, "model": "arcanistsparagon:item/entropy_cell_4"},
{"predicate": {
"custom_model_data": 0.5}, "model": "arcanistsparagon:item/entropy_cell_5"},
{"predicate": {
"custom_model_data": 0.6}, "model": "arcanistsparagon:item/entropy_cell_6"},
{"predicate": {
"custom_model_data": 0.7}, "model": "arcanistsparagon:item/entropy_cell_7"},
{"predicate": {
"custom_model_data": 0.8}, "model": "arcanistsparagon:item/entropy_cell_8"}
]
}```
I'm starting to think the issue is with parent...
Why do you have custom_model_data
I'm not sure, but it looks to me like a reread of the predicate page may be nessesary
I looked up on the minecraft wiki and a list of predicates showed that they are pretty much hard-coded if I understood that correctly, and this one has the specific purpose of setting generic model data
Also I think another issue is that I put a logger in the first function, and it just never came up