Jump to content

[1.10.2/1.9.4] Adding a sapling (texture only)


spazzmods

Recommended Posts

So, I have been collaborating on a mod for about a week now, and we are still working on simple resources. However, trying to add a textured sapling has been MURDERING our brains.

 

A.) The sapling block is implemented and initialized.

B.)it has no texture

C.) we have no idea how to get the 'vanilla' sapling look. (where the textures cross eachother like all other plants)

 

Blockstate .json:

{
    "variants": {
        "normal": { "model": "glorious:shinySapling" }
    }
}

 

 

Models Block .json:

{
    "parent": "block/cross",
    "textures": {
        "cross": "glorious:blocks/shinySapling"
    }
}

BlockShinySapling.java

http://pastebin.com/Qag6dWZz

 

Link to comment
Share on other sites

Using

block/cross

as the model's parent should display the texture in a cross like vanilla saplings.

 

Post your FML log (logs/fml-client-latest.log), it should say exactly what went wrong with the model/texture loading.

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.

Link to comment
Share on other sites

[06:11:10] [Client thread/ERROR] [FML/]: Exception loading model for variant glorious:BlockShinySapling#stage=0,type=dark_oak for blockstate "glorious:BlockShinySapling[stage=0,type=dark_oak]"

net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model glorious:BlockShinySapling#stage=0,type=dark_oak with loader VariantLoader.INSTANCE, skipping

...

Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException

 

...

 

[06:11:10] [Client thread/ERROR] [FML/]: Exception loading model for variant glorious:BlockShinySapling#stage=1,type=spruce for blockstate "glorious:BlockShinySapling[stage=1,type=spruce]"

net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model glorious:BlockShinySapling#stage=1,type=spruce with loader VariantLoader.INSTANCE, skipping

...

Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException

 

...

 

[06:11:10] [Client thread/ERROR] [FML/]: Exception loading model for variant glorious:BlockShinySapling#stage=1,type=acacia for blockstate "glorious:BlockShinySapling[stage=1,type=acacia]"

net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model glorious:BlockShinySapling#stage=1,type=acacia with loader VariantLoader.INSTANCE, skipping

...

Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException

 

...

 

[06:11:10] [Client thread/ERROR] [FML/]: Exception loading model for variant glorious:BlockShinySapling#stage=0,type=birch for blockstate "glorious:BlockShinySapling[stage=0,type=birch]"

net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model glorious:BlockShinySapling#stage=0,type=birch with loader VariantLoader.INSTANCE, skipping

...

Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException

 

...

 

[06:11:10] [Client thread/ERROR] [FML/]: Suppressed additional 7 model loading errors for domain glorious

 

Your block has two properties (

stage

and

type

), neither of which you've specified in your blockstates file. If these properties don't affect the model, you can register an

IStateMapper

with

ModelLoader.setCustomStateMapper

. The easiest way to create an

IStateMapper

is to use

StateMap.Builder

.

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.

Link to comment
Share on other sites

So I'd have to create the IStateMapper in the class file for the sapling it's self?

to be completely honest I don't understand any of that. Or where it should/could go.

 

Register the

IStateMapper

in the same class where you register your item models during preInit. I'd recommend doing this in a dedicated client-only class.

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.

Link to comment
Share on other sites

  • Create an instance of
    StateMap.Builder


  • Call
    StateMap.Builder#ignore

    to ignore the properties that don't affect your model

  • Call
    StateMap.Builder#build

    to create the

    IStateMapper


  • Call
    ModelLoader.setCustomStateMapper

    to register the

    IStateMapper

    for your

    Block

 

Side note: You should be using

ModelLoader.setCustomModelResourceLocation

/

setCustomMeshDefinition

in preInit rather than

ItemModelMesher#register

in init to register your item models.

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.

Link to comment
Share on other sites

So, as a beginner modder, I'm a little lost based on your explanation. Where would I call the StateMap.Builder?

 

Also, what's the difference between using ModelLoader.setCustomModelResourceLocation/setCustomMeshDefinition and using Minecraft.getMinecraft().getRenderItem().getItemModelMesher() ?

 

If you can't answer this specifically then is there somewhere I can get detailed documentation on these things without just peering at the forge source? Preferably somewhere with an example as to how these are used. It makes no difference to me if it's a video or written document as long as it's up to date with Minecraft 1.10.2. A lot of documentation seems to be out of date and a lot of things I have tried have failed due to changes in forge since the time of the written documentation being written.

 

Thanks for the help!

Link to comment
Share on other sites

If you haven't already, create a dedicated client-only class to register your block and item models.

 

In a method of this class called from your client proxy in preInit, create and register the

IStateMapper

.

 

ModelLoader.setCustomModelResourceLocation

will call

ModelBakery.registerItemVariants

for you (the corresponding

ItemModelMesher#register

overload doesn't), telling Minecraft to load the model. There's not really any difference between

ModelLoader.setCustomMeshDefinition

and the corresponding

ItemModelMesher#register

overload, but I'd still recommend using the Forge method rather than the vanilla one.

 

There's no documentation on this that I know of.

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.

Link to comment
Share on other sites

Okay, so I put the ModelLoader.setCustomStateMapper inside our ClientProxy. The issue I have is that we don't have more than one type of tree, and so I haven't created a "EnumType" for our wood.

 

...withName(BlockShinySapling.Type).withSuffix(_sapling).build();

 

This part is what I'm struggling with understanding what to do with. I can go in and create an enum for the wood type, but it seems like there would be a simpler way of doing this for only one wood type.

 

Also, should I also be using the ModelLoader for all of our other blocks that are just the decorative ones with no special rendering? I have yet to figure out how to do that just by reading BlockModelShapes.class and ModelLoader.class. This is honestly probably going to be something with a very simplistic answer and it's just going over my head.

Link to comment
Share on other sites

I didn't say anything about the

withName

or

withSuffix

methods, they're not needed in this case.

 

Only use

ModelLoader.setCustomStateMapper

when you need a custom

IStateMapper

for a

Block

.

 

Use

ModelLoader.setCustomModelResourceLocation

/

setCustomMeshDefinition

to register the model(s) for every

Item

(including

ItemBlock

s).

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.

Link to comment
Share on other sites

Sorry, I should have specified a bit more. Where do I get an IStateMapper from? I tried looking around but I can't seem to find where I create one.

public static Builder build;
build.build()

Above returns a StateMapper and I'm not sure how to get a StateMapper into an IStateMapper.

Link to comment
Share on other sites

Don't store the

StateMap.Builder

in a field, it's only a temporary object. You must actually create an instance of

StateMap.Builder

.

 

StateMap

implements

IStateMapper

.

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.

Link to comment
Share on other sites

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.