Jump to content

[1.8.9] Metadata blocks are not able to find model for item rendering


Recommended Posts

Posted

Hi

 

I am having some problems with trying to render the item/hand model for my metadata blocks. It just appears as a black and purple blocks. I followed this tutorial and added a bit to my code. The only thing I added was some utility functions and the support for metadata blocks up to 16, like wool.

 

So when it comes to the item rendering of the blocks, I have no idea why it isn't working. I have a simple test block that works perfectly but still these metadata blocks don't work. Since that works it proves that there is nothing wrong with the path to the actual models.I've been sitting here for at least 5 hours to try and fix this. Endless Google searches and attempts to fix it have gotten me nowhere. This is my only chance, pretty much.

 

So this is the actual code that handles rendering.

 

  Reveal hidden contents

 

Now this is the "wood_colored" blockstate json or whatever you could call it.

 

  Reveal hidden contents

 

And the BlockProperties class.

 

  Reveal hidden contents

 

And lastly, just a JSON file from the item models. In this case, "wood_blue".

 

  Reveal hidden contents

 

 

I can't really see anything that I've missed in the code.

 

Any help is greatly appreciated! Even more appreciated if I can get it pretty quick. I need to do this for a school project that is quickly reaching it's deadline. :S

Posted

In the rendering class (BlockRenderRegister), I changed the line

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), meta, new ModelResourceLocation(modid + ":" + file, "inventory"));

to

ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), meta, new ModelResourceLocation(modid + ":" + file));

but it didn't seem to do much, except saying it couldn't find wood_<color>.json. So I created a json file in blockstates for each color but that did nothing either.

 

I also removed this part from the preInit in the BlockRenderRegister

 

  Reveal hidden contents

 

 

And lastly, I am not sure how I can use the blockstate file for the items.

Posted

The "registerBlockRenderer()" function was called in the init in my ClientProxy. I changed it to preInit and that just seem to have made it worse since now the test block doesn't get it's item model either.

And as for the blockstate file, I honestly have no idea on how to do anything like it so if it isn't "super duper important", we can skip that.

 

EDIT: Every time I forgot to add that I keep getting "Model definition for location hertzole:wood_colored#inventory not found" in the console.

Posted

Yes.

 

"wood_colored

 

  Reveal hidden contents

 

Posted

But since my blocks only appear as black and purple blocks in the inventory, something must be wrong, right?

 

I'm sorry if I am missing some super obvious detail here but I don't have much knowledge about Minecraft's "new" way of handling blocks and such.

Posted

The code

 

  Reveal hidden contents

 

 

JSON structure

 

  Reveal hidden contents

 

Posted

Woops, my bad. Here is the actual json structure.

 

  Reveal hidden contents

 

 

With the variant, do you mean like this? "new ModelResourceLocation(modid + ":" + file, modid + ":" + "wood_colored"));" or am I just being stupid?

I am also not sure what you mean with the second thing.

Posted

The reason I have so many was because some error messages said it couldn't find these blockstates so I created them to try and fix it and then I never got around to delete them.

 

But anyways, I tried this "new ModelResourceLocation(modid + ":wood_colored#white")" and "new ModelResourceLocation(modid + ":wood#white")" but none worked. What am I missing?

Posted

I think I am starting to understand now. But let's see if I get this straight.

 

I should go into "wood_colored.json" and add ""white": { "model":"hertzole:wood_white" }," under variants.

Then in the render register add this to the ModelLoader function "new ModelResourceLocation("hertzole:wood_colored#white")".

Then make sure I have two json files called "wood_white". One located in models/block and one in models/item.

 

If that is the case, I must have done something wrong. The white block turned into a purple and black block in both the inventory and in the world.

Posted

I'm quite confused by this stage.

 

What I can understand, I need to remove "{ "model":"hertzole:wood_white" } from ""type=white": { "model":"hertzole:wood_white" }".

 

I also changed the end of the ModelLoader function to "new ModelResourceLocation("hertzole:wood_colored#type=white")" and now I've got the world model but not the inventory model.

Posted

Ok, I think I understand that part now.

But back to square one, how do I make it work in the inventory? Every block is still a black and purple block in the inventory.

Posted

I think D7 said that if no item is explicitly defined, then Forge will look for an inventory variant within the blockstates json. That means that your blockstates json can do item work for you.

 

BTW, I am wondering why you have so many models. Are these different colored objects really different shapes? If not, then more simplifications are possible

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

Latest log:

 

  Reveal hidden contents

 

 

The current code. As of right now I am only trying to register the white block.

 

  Reveal hidden contents

 

 

Lastly, the stucture.

 

  Reveal hidden contents

 

Posted

The reason behind all those screwups was because I was getting tired, screwed around with the code and just left it there.

 

But I've now moved the BlockRenderRegister.registerBlockRenderer into preInit in the client proxy. The only change is that no modded blocks have inventory models.

Posted

So after I moved the registerBlockRenderer call to the main class it crashed. Turns out it was the test block. I will look into that. But the main metadata blocks worked! Finally!

Thank you so much for you patience and help! It is greatly appreciated! <3

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Managed to solve the issue myself. Solved by a fresh modpack instance.
    • Hello, so straight to the problem. Today i wanted to startup Enigmatica as usual and it just wont startup. Last night everything worked fine, i didnt even turn off my pc. Crash log: https://mclo.gs/GJ6Kcy1
    • Rubidium and Embeddium are versions of the same mod, you can only have one. I believe Embeddium is the one that's actively maintained.
    • Hello, New to modding, but have a solid CS foundation. I've created multiple custom BlockEntities that all have the same issue, which is that the inventory only updates on right click (overriding the useItemOn method). I've seen multiple posts on here outlining a similar issue to mine, but I've already implemented the solution of: overriding the correct methods in the BlockEntity class and calling setChanged(). I've tried every different place for setChanged() to no success. I'm wondering if I'm missing something else or if there was some change to sending data to the client in 1.21.5? Or will I have to use a custom packet sender? Here is the code for one of my BlockEntity classes with a single inventory slot: public class MyCustomBlockEntity extends BlockEntity { public final ItemStackHandler inventory = new ItemStackHandler(1) { @Override protected int getStackLimit(int slot, @NotNull ItemStack stack) { return 1; } @Override protected void onContentsChanged(int slot) { setChanged(); if (!level.isClientSide()) { level.setBlockAndUpdate(getBlockPos(), getBlockState()); } } }; public MyCustomBlockEntity(BlockPos pPos, BlockState pBlockState) { super(ModBlockEntities.MY_CUSTOM_BE.get(), pPos, pBlockState); } public void clearContents() { inventory.setStackInSlot(0, ItemStack.EMPTY); } public void dropItem() { SimpleContainer inv = new SimpleContainer(inventory.getSlots()); inv.setItem(0, inventory.getStackInSlot(0)); Containers.dropContents(this.level, this.worldPosition, inv); } @Override public void setRemoved() { dropItem(); super.setRemoved(); } @Override protected void saveAdditional(CompoundTag pTag, HolderLookup.Provider pRegistries) { super.saveAdditional(pTag, pRegistries); pTag.put("inventory", inventory.serializeNBT(pRegistries)); } @Override protected void loadAdditional(CompoundTag pTag, HolderLookup.Provider pRegistries) { super.loadAdditional(pTag, pRegistries); inventory.deserializeNBT(pRegistries, pTag.getCompound("inventory").get()); } @Override public Packet<ClientGamePacketListener> getUpdatePacket() { return ClientboundBlockEntityDataPacket.create(this); } @Override public CompoundTag getUpdateTag(HolderLookup.Provider pRegistries) { return saveWithoutMetadata(pRegistries); } } Mostly encountering the issue when calling the clearContents() method anywhere outside of useItemOn() in the Block class. I've also tried overriding both the handleUpdateTag() and onDataPacket() methods, calling their super along with loadAdditional(), but neither changed the outcome. Thanks in advance for any replies.
    • Hi all! I’m working on a Jurassic Park-themed mod for Minecraft 1.20.1, aiming to include dinosaurs, fossils, DNA extraction, and cool machines. This is a free project, mainly passion-driven, and I’ll give full credit to everyone involved. this is the perfect opportunity for beginners of modeling and coding. This project will give you experience and a creative freedom If you love dinosaurs and Minecraft modding, hit me up! Thanks! Add Me ogfrost. <--- Discord
  • Topics

×
×
  • Create New...

Important Information

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