Jump to content

Recommended Posts

Posted

Hello, I have problems rendering the itemblock with metadata client and server-side. 

Here's the error:

 
 
 
 
  Reveal hidden contents

This is the block class:

 
 
 
 
  Reveal hidden contents

IMetaBlockName class:

 
 
 
 
  Reveal hidden contents

 

ItemInfiniteBlock:

 
 
 
 
  Reveal hidden contents

RegistryHandler (to register all metadata renders)

 
 
 
 
 
 
 
 
  Reveal hidden contents

ClientProxy:

 
 
 
 
  Reveal hidden contents

Main class Init/PreInit ("proxy" point to CommonProxy class): 

 
 
 
 
  Reveal hidden contents

infinite_block.json (Blockstate):

{
	"variants": {
		"color=white": { "model": "testmod:infinite_block_white" },
		"color=orange": { "model": "testmod:infinite_block_orange" },
		"color=magenta": { "model": "testmod:infinite_block_magenta" },
		"color=light_blue": { "model": "testmod:infinite_block_light_blue" },
		"color=yellow": { "model": "testmod:infinite_block_yellow" },
		"color=lime": { "model": "testmod:infinite_block_lime" },
		"color=pink": { "model": "testmod:infinite_block_pink" },
		"color=gray": { "model": "testmod:infinite_block_gray" },
		"color=light_gray": { "model": "testmod:infinite_block_light_gray" },
		"color=cyan": { "model": "testmod:infinite_block_cyan" },
		"color=purple": { "model": "testmod:infinite_block_purple" },
		"color=blue": { "model": "testmod:infinite_block_blue" },
		"color=brown": { "model": "testmod:infinite_block_brown" },
		"color=green": { "model": "testmod:infinite_block_green" },
		"color=red": { "model": "testmod:infinite_block_red" },
		"color=black": { "model": "testmod:infinite_block_black" }
	}
}

 

The blocks are rendered when placed but not in my inventory, is displayed the missing texture. How can I render them to see the texture client and server side?

Posted (edited)

 

Models must be registered in ModelRegistryEvent.

@SubscribeEvent
	public static void onItemRegister(RegistryEvent.Register<Item> event) {
		event.getRegistry().registerAll(InitItems.ITEMS.toArray(new Item[0]));
	}

	@SubscribeEvent
	public static void onBlockRegister(RegistryEvent.Register<Block> event) {
		event.getRegistry().registerAll(InitBlocks.BLOCKS.toArray(new Block[0]));
	}

	@SubscribeEvent
	public static void onModelRegister(ModelRegistryEvent event) {
		for (Item item : InitItems.ITEMS) {
			if (item instanceof ModelManager) {
				((ModelManager) item).registerModels();
			}
		}

		for (Block block : InitBlocks.BLOCKS) {
			if (block instanceof ModelManager) {
				((ModelManager) block).registerModels();
			}
		}
	}
	
	public static void registerBlock(Block block, ItemBlock itemBlock) {
		block.setCreativeTab(Main.MISC_TAB);
		InitBlocks.BLOCKS.add(block);
		InitItems.ITEMS.add(itemBlock.setRegistryName(block.getRegistryName()));
	}
	
	public static void RegisterInfiniteBlockRender(Block block, int meta, String filename) {
		ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), meta, new ModelResourceLocation(new ResourceLocation(Main.MODID, filename), "inventory"));
		
	}
	
	public static void RenderInfiniteBlock(){
		for (int i = 0; i < InfiniteBlockTypes.values().length; i++) {	
			RegisterInfiniteBlockRender(InitBlocks.INFINITE_BLOCK, i, "infinite_block_" + InfiniteBlockTypes.values()[i].getName());
		}
	}

 

ModelBakery#registerItemVariants only tells Minecraft to load and bake these models, it does not bind them to a particular item. Use ModelLoader.setCustomModelResourceLocation.

 

Is it wrong?

public static void RegisterInfiniteBlockRender(Block block, int meta, String filename) {
		ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), meta, new ModelResourceLocation(new ResourceLocation(Main.MODID, filename), "inventory"));
		
	}
	
	public static void RenderInfiniteBlock(){
		for (int i = 0; i < InfiniteBlockTypes.values().length; i++) {	
			RegisterInfiniteBlockRender(InitBlocks.INFINITE_BLOCK, i, "infinite_block_" + InfiniteBlockTypes.values()[i].getName());
		}
	}

 

Off topic question: Why are my spoilers like this?

Edited by NoobMaster4000
Posted
  On 10/10/2019 at 2:28 AM, NoobMaster4000 said:

 Off topic question: Why are my spoilers like this?

Expand  

What are you talking about? Those aren't called spoilers. They ste code "areas".

 

  On 10/10/2019 at 2:28 AM, NoobMaster4000 said:

Is it wrong?

Expand  

Yes on many levels.

 

  On 10/10/2019 at 2:28 AM, NoobMaster4000 said:

RegisterInfiniteBlockRender(Block

Expand  

You never call this in your model registry event.

  On 10/10/2019 at 2:28 AM, NoobMaster4000 said:

ModelManager

Expand  

Is just another name for IHasModel which is down right incorrect to use. Just call ModelLoader.setCustomModelResourceLocation in the ModelRegistryEvent directly.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.