Jump to content

Recommended Posts

Posted

I want to ignore a blockstate TYPE from all my BRPedestal blocks for the model loader.

So I loop through pedestal blocks in client-side pre-init with setCustomStateMapper to have the model loader ignore this specific blockstate.

 

@Override
public void preInit(FMLPreInitializationEvent event) throws IOException {
    super.preInit(event);
    pedestalList.forEach((pedestal) -> {
        logger.printf(Level.INFO, "Setting a CustomStateMapper for %s.", pedestal.getUnlocalizedName());
        ModelLoader.setCustomStateMapper(pedestal, new StateMap.Builder().ignore(BRPedestal.TYPE).build());
    });
}

 

My issue is that it works perfectly for the first block ID pedestal0, but only for it.

All other blocks pedestal1 and above are claiming model variants on type=.

 

My logger report:

Setting a CustomStateMapper for tile.beyondreality:pedestal0
Setting a CustomStateMapper for tile.beyondreality:pedestal1

 

But after that I have pedestal1 erroring with:

[main/ERROR] [FML]: Exception loading model for variant beyondreality:pedestal1#down=true,type=0,up=false for blockstate "beyondreality:pedestal1[down=true,type=0,up=false]"
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model beyondreality:pedestal1#down=true,type=0,up=false with loader VariantLoader.INSTANCE, skipping

 

See: https://github.com/leagris/BeyondRealityCore/blob/patch-1/src/main/java/com/beyondrealitygaming/core/proxy/ClientProxy.java#L36

Posted
2 minutes ago, diesieben07 said:

You should not create a variable amount of blocks/items/etc. based on config. The set of items/blocks/etc. you register should always be the same.

If you want N pedestals, use metadata and/or a TileEntity.

1. I already use meta that is exactly mapped to the TYPE blockstate. This is the reason I need to ignore this Block State to have same model used for all the different META.

2. I don't want or need Tile Entities here. I already have all the blockstates I need.

TYPE is mapped to block Meta so one block ID provides me with 16 different pedestals (one per meta)

UP and DOWN are dynamic computed blockstates that only serve to differentiate block connection with same block (like fence).
 

Posted

I am not sure how it cause issues with the CustomStateMapper working only for the first Block ID pedestal0.

It is common pre-init where a dynamic amount of pedestal blocks are created:

for (int i = 0; i < configuration.getInt("amountOfPedestals", Configuration.CATEGORY_GENERAL, 1, 0, Integer.MAX_VALUE, "The amount of pedestal multiplied by 16 that will be generated"); ++i) {
    BRPedestal pedestal = new BRPedestal("pedestal" + i , buildingBlocks){
        @Override
        public void registerItem(IForgeRegistry<Item> itemIForgeRegistry) {
            itemIForgeRegistry.register(new ItemBlock(this) {
                @Override
                public String getUnlocalizedName(ItemStack stack) {
                    return getUnlocalizedName() + "." + stack.getItemDamage();
                }
            }.setCreativeTab(buildingBlocks).setRegistryName(this.getRegistryName()).setHasSubtypes(true));
        }
    };
    logger.printf(Level.INFO, "adding %s to pedestalList.", pedestal.getUnlocalizedName());
    pedestalList.add(pedestal);
}

 

It is not like the configuration is supposed to change, between launches. It is intended for mod-pack/map making with specific purpose, creative blocks interacting with other mods about progression and, stuffs like that.

The number of pedestal blocks needed may var,y depending on: map or mod-pack rules. It indeed will not change between different runs of a game or map.

 

So I have a list containing all pedestal blocks pedestalList created during global pre-init:

BRPedestal pedestal = new BRPedestal("pedestal" + i , buildingBlocks)
...
pedestalList.add(pedestal);

 

It iterates this list in client-side pre-init after calling the global pre-init that is registering said blocks.

pedestalList.forEach((pedestal) -> {

 

To set a CustomStateMapper

ModelLoader.setCustomStateMapper(pedestal, new StateMap.Builder().ignore(BRPedestal.TYPE).build());

 

And my logger reports it is setting it for all pedestal block id pedestal0 and pedestal1 here.

 

But as it turns-out, the CustomStateMapper is not working for pedestal1.

 

I am fairly new to modding with Forge, I read through your comment about:

Quote

You cannot just register 5 blocks on one game start and then 10 blocks on another.

But really could not get it why, or how it causes CustomStateMapper not working for pedestal1 and above.

Posted

This.

Do not do this.

this.png

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.