Jump to content

Recommended Posts

Posted

I am currently trying to make my item use an obj file as the model. I found https://github.com/MinecraftForge/MinecraftForge/blob/d1b220f6a375c64c0172137b8e08b4827450298d/src/test/java/net/minecraftforge/debug/ModelLoaderRegistryDebug.java and https://github.com/MinecraftForge/MinecraftForge/tree/d1b220f6a375c64c0172137b8e08b4827450298d/src/test/resources/assets/forgedebugmodelloaderregistry, but I can't seem to get it to work for items.

 

At first I thought it was ModelLoader.setCustomModelResourceLocation(etc), but that ended up being only for blocks(unless I am mistaken).

I have been searching since a few days ago trying to find what will work for just items.

Again, this is based on the fact that the setCustomModelResourceLocation takes in a ModelResourceLocation, which goes to the blockstates folder, which doesn't seem right or I'm doing something wrong with the json file.

 

Does anyone have a link to a repository or some documentation on what the json files/code has to be in order to make the item use the obj file?

Posted

ModelLoader.setCustomModelResourceLocation

only affects item models (including but not limited to the

Item

forms of

Block

s). It has nothing to do with the in-world model for blocks.

 

The

ModelResourceLocation

passed to

ModelLoader.setCustomModelResourceLocation

can point to a regular item model (the first priority) or to a variant of a blockstates file (only used if the item model doesn't exist). The

ModelResourceLocation

<modid>:<name>#<variant>

can either point to assets/<modid>/models/item/<name> (an item model in JSON, OBJ or B3D format) or the

<variant>

variant of assets/<modid>/blockstates/<name>.json (a blockstates file). For an item model, the variant should be

inventory

.

 

If you want to load an item model other than the default (the one with the item's registry name), call

ModelBakery.registerItemVariants

. To load an OBJ model directly, include the .obj extension in the

ResourceLocation

/

ModelResourceLocation

's resource path. To load a model specified by a blockstates file, don't include the extension.

 

Minecraft used the name blockstates because it was only designed for blocks, but Forge adds the ability to use it for items as well.

 

Edit: Added a missing closing tag.

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

Thank you! I've got it to stop using the missing model. However, now it is invisible. Is it a problem with my json?

 

{
    "parent": "builtin/generated",
    "model": "testmod:items/Crystal.obj",
    "textures": {
        "default": "testmod:Red_Crystal"
    },
    "display": {
        "thirdperson": {
            "rotation": [ -90, 0, 0 ],
            "translation": [ 0, 1, -2.5 ],
            "scale": [ 0.55, 0.55, 0.55 ]
        },
        "firstperson": {
            "rotation": [ 0, -135, 25 ],
            "translation": [ 0, 4, 2 ],
            "scale": [ 1.7, 1.7, 1.7 ]
        }
    }
}

 

The game isn't giving me a missing texture error so I know it is picking up the correct texture. Also, do you know where any kind of documentation on all of the terms the json can have?

 

I doubt it is a problem with my obj file. I added mtllib Crystal.mtl to the obj as I read that it is required.

 

Would the problem be my .mtl file?

newmtl default
Ns 98.039216
Ka 0.000000 0.000000 0.000000
Kd 0.800000 0.800000 0.800000
Ks 1.000000 1.000000 1.000000
Ni 1.000000
d 1.000000
illum 2

Thanks for your help.

 

 

edit: http://www.minecraftforge.net/forum/index.php?topic=34936.0

That thread helped me solve my issue.

Posted

You're confusing the blockstates format and the item model format. You can also use Forge's blockstates format instead of the vanilla format.

 

Either use a blockstates file and move your model to models/block instead of models/item or set your OBJ model as the parent of your JSON item 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

Thanks for your help! I ended up using blockstates and putting the model in the blocks folder. It is now working great! Except for one thing.

 

When I drop the item in the world, or put it in an item frame, it is gigantic and the orientation is wrong (in the item frame).

 

I have "firstperson", "thirdperson", and "gui" all set to how I want it. However, I can't seem to figure out how to change it for dropped items/item frames.

 

Posted

The

ItemCameraTransforms.TransformType

enum describes the valid transform types for items.

HEAD

is used to render the item on entity heads,

GROUND

is used to render the item as an

EntityItem

and

FIXED

is used to render the item in item frames.

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

Ah that's what Fixed is for. I thought is was a fall back or something, so I ignored it. :-[

Due to thinking itemframes used the Ground(entity) transforms, I never tested them out. And now I need to go back and adjust several models for the frames.

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.