#Issue with proper rendering of block item in relation to blockState

36 messages · Page 1 of 1 (latest)

runic quartz
#

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)

#
{
  "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
lean coyote
#

predicates must be from 0 to 1 correct?

runic quartz
lean coyote
runic quartz
#

Also I'm using moremcmeta, maybe there's something there that can help?

runic quartz
lean coyote
runic quartz
#

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)

runic quartz
# lean coyote 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

lean coyote
runic quartz
# lean coyote that
ModelPredicateProviderRegistry.register(ModBlocks.ENTROPY_CELL.asItem(), new Identifier(ArcanistsParagon.MOD_ID, "charges"), (itemStack, clientWorld, livingEntity, seed) -> {
            return (itemStack.getNbt().getInt("charges")) / 10.0F;
        });```
#

?

lean coyote
#

looks like it, try it

runic quartz
lean coyote
runic quartz
#

of course it won't work, I left the old values

runic quartz
# lean coyote .
{
  "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
runic quartz
# lean coyote .

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
lean coyote
runic quartz
#
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)
runic quartz
#
{
  "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...
lean coyote
#

I'm not sure, but it looks to me like a reread of the predicate page may be nessesary

runic quartz
# lean coyote Why do you have custom_model_data

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