Jump to content

Recommended Posts

Posted

I've been attempting to make an obsidian pressure plate (implementation #57,480, I know) and am having an issue getting the texture to render both in-game and in the GUI. I get a MissingVariantException and I cannot find anything online that spells out what's going wrong in plain English.

 

The fml-client-latest:

 

  Reveal hidden contents

 

 

Block rendering method:

 

  Reveal hidden contents

 

 

BlockObsidianPressurePlate.class:

 

  Reveal hidden contents

 

 

Blockstate:

 

  Reveal hidden contents

 

 

The variant models:

 

  Reveal hidden contents

 

 

As you can see, this is a bog-standard vanilla implementation of a pressure plate. I haven't even added all the fun stuff to make it a tile entity yet! I just want it to render before I go off doing more. Am I missing something ridiculously simple? Because I've wasted days on single lines of code before. Thank you in advance.

Posted

Caused by: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Expected ':' at line 3 column 96

 

Minecraft is complaining that your json files aren't valid, and they're not.

Double-check your blockstate.json file

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.

Posted

Thanks for pointing that out; I fixed it and edited the post above to what the blockstate.json is supposed to be. However, the error is exactly the same. The malformed JSON was a different problem, but not the cause of my main one, it seems.

Posted

If it's "doing the same thing" after making a change, post the updated log too.  Because you obviously fixed on error, but now there's a new error being thrown which you did not include.

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.

Posted

Here ye go:

 

 

  Reveal hidden contents

 

 

Okay, the thing that is standing out to me here is a FileNotFoundException: fsrandomstuff:models/item/obsidian_pressure_plate.json, which causes me to wonder: what does the item model for a pressure plate look like, then? I've scoured the repos of any mod I could find that implemented custom pressure plates in 1.10.2 (which is not many) and also vanilla Minecraft's resource folder.

 

I've not found anything that I can base my next steps off of; the other mods I've seen seem to implement the pressure plates the same way from what I've seen, and it presumably works for them.

 

Then there's the ModelBlockDefinition$MissingVariantException which is probably related.

Posted

You mean the file stone_pressure_plate.json in assets.minecraft.models.item?

{
    "parent": "block/stone_pressure_plate_up"
}

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.

Posted

I'm making progress. No more exceptions, except I'm still holding onto a magenta and black cube in my hand, and the inventory slot shows up as a majenta and black square! I can't see a bloody thing in the log that points to an error!

 

Here's the log:

 

  Reveal hidden contents

 

 

The changes I made:

 

  Reveal hidden contents

 

 

Apparently due to the way my mod loads item model renderers, every single thing that could potentially be an item has to have an "inventory" element. I'm not sure if there's a way around that, or if it's even worth it to try. Anyway, I digress.

 

This is the new item model:

{
    "parent": "fsrandomstuff:block/obsidian_pressure_plate/obsidian_pressure_plate_up"
}

 

This thing 114% points to a file that exists, and should be inheriting the right data from the parent Minecraft blockstates.

 

I don't know if I'm stupid or just getting too frustrated to think properly, but this is just getting obscene!

Posted

Well now that's going to depend on what metadata you passed to registerItemRenderers and what metadata your item's itemstack is.

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.

Posted

I'm afraid you lost me. The pressure plate doesn't have any metadata. As far as I know, the method to render its model was just passed 0, like all the other stuff in my mod that doesn't have metadata associated with it. Was there something special regarding metadata I was supposed to do to make it work? If so, can you link me to some documentation on pressure plates, please?

Posted

No, just checking.

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.

Posted

Then I am at a loss. The item model is "extending" (for lack of a better word) the block model, which means I should be holding onto a little mini obsidian pressure plate. Instead, I've got this absurd thing!

 

9L2gOfm.png

Posted

Yes, that's the MISSING_MODEL

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.

Posted

The model is right here:

 

{
    "parent": "block/pressure_plate_up",
    "textures": {
        "texture": "blocks/obsidian"
    }
}

 

The parent is the minecraft pressure plate parent model, located at assets.minecraft.models.block.pressure_plate_up.json.

 

This thing:

{   "parent": "block/thin_block",
    "textures": {
        "particle": "#texture"
    },
    "elements": [
        {   "from": [ 1, 0, 1 ],
            "to": [ 15, 1, 15 ],
            "faces": {
                "down":  { "uv": [ 1,  1, 15, 15 ], "texture": "#texture", "cullface": "down" },
                "up":    { "uv": [ 1,  1, 15, 15 ], "texture": "#texture" },
                "north": { "uv": [ 1, 15, 15, 16 ], "texture": "#texture" },
                "south": { "uv": [ 1, 15, 15, 16 ], "texture": "#texture" },
                "west":  { "uv": [ 1, 15, 15, 16 ], "texture": "#texture" },
                "east":  { "uv": [ 1, 15, 15, 16 ], "texture": "#texture" }
            }
        }
    ]
}

 

By using this model as a parent, and giving it the "texture": "blocks/obsidian", I am telling it to use the existing Minecraft model, but texture it with obsidian, instead of wood or stone. There is less than zero reason for me to reinvent the wheel.

Posted

Yes, I understand what you're doing and what you think is happening.

What I'm saying is: something isn't working right, I don't know what, and that's why you get a MISSING_MODEL.

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.

Posted

Then how do I find out what is going wrong when nothing throws an error or exception?

 

Again, the fml-client-latest.log:

 

  Reveal hidden contents

 

 

I need logs to tell me what's going wrong. I cannot read the computer's mind. If you're tired of banging your head against the wall with me here, believe me: I am ten times as tired. This is utter BS. There is zero effin' way it's this hard to render a freakin' pressure plate!

Posted

Yeah, I know, I get it.  I'm just scratching my head and hoping someone (cough, Choonster) can come along and say "have you tried..?"

 

Best I can offer is to attempt to debug the model loading code (but it's a right pain in the arse, especially trying to figure out where to put the first breakpoint, I've only managed it when I've had an error that I can jump-to-line for and place a breakpoint there).

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.

Posted

When are you registering the model for the

Item

?

 

ModelLoader

methods must be called in response to

ModelRegistryEvent

(if you're registering your

Block

s and

Item

s with

RegistryEvent.Register

) or in preInit (if you're registering your

Block

s and

Item

s in preInit).

 

If you call

ModelLoader.setCustomModelResourceLocation

in init or later, it will do nothing and your item will be rendered as the missing model.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

I think you also need to add a variant to your blockstates json. After adding a comma to the last block variant, add something like this:

 

"inventory": { "model": "pressure_plate_up" }

 

Here's a whole bs file from Uncle Jeff's sensors (which includes a raft of pressure plates):

 

{
  "forge_marker" : 1,
  "defaults": {
      "textures" : { "texture": "blocks/hay_block_side" }
  },
  "variants": {
      "power=0": { "model": "pressure_plate_up" },
      "power=1": { "model": "pressure_plate_down" },
      "power=2": { "model": "pressure_plate_down" },
      "power=3": { "model": "pressure_plate_down" },
      "power=4": { "model": "pressure_plate_down" },
      "power=5": { "model": "pressure_plate_down" },
      "power=6": { "model": "pressure_plate_down" },
      "power=7": { "model": "pressure_plate_down" },
      "power=8": { "model": "pressure_plate_down" },
      "power=9": { "model": "pressure_plate_down" },
      "power=10": { "model": "pressure_plate_down" },
      "power=11": { "model": "pressure_plate_down" },
      "power=12": { "model": "pressure_plate_down" },
      "power=13": { "model": "pressure_plate_down" },
      "power=14": { "model": "pressure_plate_down" },
      "power=15": { "model": "pressure_plate_down" },
      "inventory": { "model": "pressure_plate_up" }
  }
}

 

As you can see, I only use vanilla models, so I don't even have variant models. If you want p-plates shaped like vanilla's, then you can toss those.

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

The issue is fixed!

 

Choonster, to answer your question, the item models weren't being registered. The only objects in my mod that were having their models automatically registered as part of their creation were anything that extended my mod's BlockBase.

 

However, the pressure plate does not extend BlockBase. It's a BlockPressurePlate. It was as easy as adding the below to my block registrar:

 

if(block instanceof BlockObsidianPressurePlate) {
    ((BlockObsidianPressurePlate) block).registerItemModels(itemBlock);
}

 

So thank all of you for being patient! I hope this helps someone else who falls down the same rabbit hole I did.

Posted
  On 12/20/2016 at 3:17 AM, Flawedspirit said:
if(block instanceof BlockObsidianPressurePlate) {
    ((BlockObsidianPressurePlate) block).registerItemModels(itemBlock);
}

 

You'll probably want to genericize that at some point so you aren't casting all of your blocks to their class.  Either as an interface that supplies the registerItemModels method, or another way.

 

For example, I have this for simple blocks:

	private void _registerBlockResources(Block block) {
	Item item = Item.getItemFromBlock(block);
	ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(block.getRegistryName(),"normal"));
}

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.