Jump to content

Custom block models [Easy to Implement]


Message added by TopicLocker3000

This topic was automatically locked after 6 months of inactivity. If you are the topic owner, please contact a moderator to have it unlocked.

Recommended Posts

So, in 1.8, they added 3D models in resource packs so that you can change the models of blocks. My idea is that when you open a resource pack, it will read the .json files of the models and use it. Luckily, the structure seems quite simple. Here is an example model (with comments):

{
    "__createdwith": "opl's Model Creator", //notneeded
    "ambientocclusion": false,              //ambient occlusion
    "textures": {                           //list of textures
        "tnt_side": "blocks/tnt_side",
        "tnt_top": "blocks/tnt_top",
        "tnt_bottom": "blocks/tnt_bottom",
        "particle": "blocks/tnt_side"
    },
    "elements": [                           //list of cubes
        {                                   //start of cube
            "from": [0,0,0],                //one corner
            "to": [16,16,16],               //opposite corner
            "faces": {                      //UV stuff
                "up": {
                    "uv": [0,0,16,16],
                    "texture": "#tnt_top"
                },
                "down": {
                    "texture": "#tnt_bottom"
                },
                "west": {
                    "texture": "#tnt_side"
                },
                "east": {
                    "texture": "#tnt_side"
                },
                "north": {
                    "texture": "#tnt_side"
                },
                "south": {
                    "texture": "#tnt_side"
                }
            }
        },
        {                                    //new cube
            "from": [-1,4,-1],               //one corner
            "to": [17,12,17],                //other corner
            "faces": {                       //UV stuff
                "up": {
                    "uv": [0,4,16,5],
                    "texture": "#tnt_side"
                },
                "down": {
                    "uv": [0,11,16,12],
                    "texture": "#tnt_side"
                },
                "west": {
                    "texture": "#tnt_side"
                },
                "east": {
                    "texture": "#tnt_side"
                },
                "north": {
                    "texture": "#tnt_side"
                },
                "south": {
                    "texture": "#tnt_side"
                }
            }
        }
    ]
}

 

The code is quite simple. It is some cubes with mapped textures. That is simply all it is. The 'from' and 'to' variables of each cube are the two opposite corners, and everything else is just saying what texture is mapped to which side.

 

 

HOW MINE-IMATOR WOULD DO IT:

 

CREATE FOLDER(BLOCK)

LOAD TEXTURES FROM FILE

CREATE CUBE("CUBE" + I)

I++

QUERY .JSON FILE FOR CORNERS

SCALE TO SIZE

MAP TEXTURE TO [CUBENAME]

PARENT TO [BLOCK]

 

In case you were interested, this code creates this block: 212caaf805.png

Edited by Willbl3pic
Link to post
Share on other sites

David will need to make a tutorial on how to do that. Not everyone knows what the heck that is :P

But I mean that code is very simple! I doubt anyone (except for a newbie) won't know how to do that.

Awesome suggestion!

Link to post
Share on other sites

David will need to make a tutorial on how to do that. Not everyone knows what the heck that is :P

But I mean that code is very simple! I doubt anyone (except for a newbie) won't know how to do that.

Awesome suggestion!

David doesn't need to make a tutorial, there are plenty already on the minecraftforums etc

Link to post
Share on other sites

The only thing I understand would be the part where the textures are loaded and aligned against the block. But now I know how Hypixel - Warlords is done! But what language is that? This is an interesting concept. But I do believe that not a lot of people know how to implement 3d textures into Minecraft, let alone code to actually do this. Perhaps David can simplify this...

Link to post
Share on other sites

The only thing I understand would be the part where the textures are loaded and aligned against the block. But now I know how Hypixel - Warlords is done! But what language is that? This is an interesting concept. But I do believe that not a lot of people know how to implement 3d textures into Minecraft, let alone code to actually do this. Perhaps David can simplify this...

There are plenty of programs made to make that code. I used opl's model creator.

 

Here is an annotated version of the code:

 

 

{

"__createdwith": "opl's Model Creator",  Just saying what it was made with. Not necessary.

"ambientocclusion": false,                        I guess this bit toggles ambient occlusion on the block.

"textures":                                              A list of textures and their paths in the resource pack.

"tnt_side": "blocks/tnt_side",

"tnt_top": "blocks/tnt_top",

"tnt_bottom": "blocks/tnt_bottom",

"particle": "blocks/tnt_side"

},

 

 

 

"elements": [       A list of cubes:

{

"from": [0,0,0],      One corner of the cube

"to": [16,16,16],    Second corner of the cube

"faces": {              List of faces and texture mappings. I'll skip this part as you said you know.

"up": {

"uv": [0,0,16,16],

"texture": "#tnt_top"

},

"down": {

"texture": "#tnt_bottom"

},

"west": {

"texture": "#tnt_side"

},

"east": {

"texture": "#tnt_side"

},

"north": {

"texture": "#tnt_side"

},

"south": {

"texture": "#tnt_side"

}

}

},

{                        Second cube

"from": [-1,4,-1],    One corner

"to": [17,12,17],     Other corner

"faces": {

"up": {

"uv": [0,4,16,5],

"texture": "#tnt_side"

},

"down": {

"uv": [0,11,16,12],

"texture": "#tnt_side"

},

"west": {

"texture": "#tnt_side"

},

"east": {

"texture": "#tnt_side"

},

"north": {

"texture": "#tnt_side"

},

"south": {

"texture": "#tnt_side"

}

}

}

]

}

Link to post
Share on other sites

The only thing I understand would be the part where the textures are loaded and aligned against the block. But now I know how Hypixel - Warlords is done! But what language is that? This is an interesting concept. But I do believe that not a lot of people know how to implement 3d textures into Minecraft, let alone code to actually do this. Perhaps David can simplify this...

 

It's called JSON - and it's not a programming language

Edited by myluki2000
Link to post
Share on other sites

Then what is it?

 

If you look at the JSON posted in the startpost:

{
    "__createdwith": "opl's Model Creator",
    "ambientocclusion": false,
    "textures": {
        "tnt_side": "blocks/tnt_side",
        "tnt_top": "blocks/tnt_top",
        "tnt_bottom": "blocks/tnt_bottom",
        "particle": "blocks/tnt_side"
    },
    "elements": [
        {
            "from": [0,0,0],
            "to": [16,16,16],
            "faces": {
                "up": {
                    "uv": [0,0,16,16],
                    "texture": "#tnt_top"
                },
                "down": {
                    "texture": "#tnt_bottom"
                },
                "west": {
                    "texture": "#tnt_side"
                },
                "east": {
                    "texture": "#tnt_side"
                },
                "north": {
                    "texture": "#tnt_side"
                },
                "south": {
                    "texture": "#tnt_side"
                }
            }
        },
        {
            "from": [-1,4,-1],
            "to": [17,12,17],
            "faces": {
                "up": {
                    "uv": [0,4,16,5],
                    "texture": "#tnt_side"
                },
                "down": {
                    "uv": [0,11,16,12],
                    "texture": "#tnt_side"
                },
                "west": {
                    "texture": "#tnt_side"
                },
                "east": {
                    "texture": "#tnt_side"
                },
                "north": {
                    "texture": "#tnt_side"
                },
                "south": {
                    "texture": "#tnt_side"
                }
            }
        }
    ]
}

you can see that you don't "tell" Minecraft what to do, for example this line:

"tnt_bottom": "blocks/tnt_bottom"

It tells Minecraft where the file for the bottom block texture is located, it's not code that makes Minecraft do something with the texture. It's not "executing" something, it just gives information to Minecraft so Minecraft can process it.

 

I hope you understand now, I suck at explaining and normally I would use a generic example for my explanations but I can't think of one right now

Link to post
Share on other sites

If you look at the JSON posted in the startpost:

{
    "__createdwith": "opl's Model Creator",
    "ambientocclusion": false,
    "textures": {
        "tnt_side": "blocks/tnt_side",
        "tnt_top": "blocks/tnt_top",
        "tnt_bottom": "blocks/tnt_bottom",
        "particle": "blocks/tnt_side"
    },
    "elements": [
        {
            "from": [0,0,0],
            "to": [16,16,16],
            "faces": {
                "up": {
                    "uv": [0,0,16,16],
                    "texture": "#tnt_top"
                },
                "down": {
                    "texture": "#tnt_bottom"
                },
                "west": {
                    "texture": "#tnt_side"
                },
                "east": {
                    "texture": "#tnt_side"
                },
                "north": {
                    "texture": "#tnt_side"
                },
                "south": {
                    "texture": "#tnt_side"
                }
            }
        },
        {
            "from": [-1,4,-1],
            "to": [17,12,17],
            "faces": {
                "up": {
                    "uv": [0,4,16,5],
                    "texture": "#tnt_side"
                },
                "down": {
                    "uv": [0,11,16,12],
                    "texture": "#tnt_side"
                },
                "west": {
                    "texture": "#tnt_side"
                },
                "east": {
                    "texture": "#tnt_side"
                },
                "north": {
                    "texture": "#tnt_side"
                },
                "south": {
                    "texture": "#tnt_side"
                }
            }
        }
    ]
}

you can see that you don't "tell" Minecraft what to do, for example this line:

"tnt_bottom": "blocks/tnt_bottom"

It tells Minecraft where the file for the bottom block texture is located, it's not code that makes Minecraft do something with the texture. It's not "executing" something, it just gives information to Minecraft so Minecraft can process it.

 

I hope you understand now, I suck at explaining and normally I would use a generic example for my explanations but I can't think of one right now

I can say, that was very detailed. Thank you for your explanation.

Link to post
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...