Jump to content

Recommended Posts

Posted

Hi everybody,

 

I am updating my mods to 1.8, and I have a few questions as to how I can do so:

 

  • What are the blockstate, block model, and item model files you need for textures/names of blocks/items?
  • The "setBlock(x, y, z, block)" method in the "World" class doesn't exist, what is the alternative?
  • I noticed that stairs use "IBlockState"s in the superconstructor, but there is no way to set the name, so do I need a blockstate file or something for that?

 

 

Posted

1.BlockState is just a wrapped block with meta, there is not much to say here.

Everything you should know about rendering and json: http://www.minecraftforge.net/forum/index.php/topic,26267.0.html

 

2. World#setBlockState(...)

 

3. I don't quite get you, IBlockState is something that holds wrapped info about block (meta and stuff):

Have look at vanilla:

Block block1 = (new BlockPlanks()).setHardness(2.0F).setResistance(5.0F).setStepSound(soundTypeWood).setUnlocalizedName("wood");

registerBlock(53, "oak_stairs", (new BlockStairs(block1.getDefaultState().withProperty(BlockPlanks.VARIANT, BlockPlanks.EnumType.OAK))).setUnlocalizedName("stairsWood"));

1.7.10 is no longer supported by forge, you are on your own.

Posted

The "setBlockState()" method worked really well, thanks for that tip.

 

The link you gave me on the first bullet looks interesting, but I don't see how it makes a block model/texture. Do I just make a file with that code or something similar, or do I need to make a class like that one to get the block to render?

 

Also, for the last one, my question is how do I change the in-game name of my stairs, do I need to do it in the IBlockState implemented by its superconstructor's parameter, or do I have to do it somewhere else?

Posted

I REALLY don't want to rewrite whole page here. :)

 

http://greyminecraftcoder.blogspot.co.at/p/list-of-topics.html

 

Have a look at "Block" topic-list. It contains probably best explanation on this stuff you will ever find.

 

As to my comment - every block MUST have:

blockstates/blockname.json

This file contains link to model and variants for it.

Then there are models:

models/block/some_model.json

Here you can define how model looks like.

And finally, since Block is block only in world, and if not it is ItemBlock, you need to add renderer for block as item (totorial on github in previous post's link explains how).

That happens in models/items/blockname.json - hre you define how ItemBlock will render as item.

 

My additional note: models/items/blockname.json MUST HAVE SAME FILENAME as blockstates/blockname.json (unless you do something tricky in code).

 

-----

 

 

In-game names are not defined by code. They are all in lang files.

I sadly have no knowledge about variant-block lang names.

It will probably look like:

tile.stairsWood.name=Oak Wood Stairs
tile.stairsWoodSpruce.name=Spruce Wood Stairs
tile.stairsWoodBirch.name=Birch Wood Stairs
tile.stairsWoodJungle.name=Jungle Wood Stairs
tile.stairsWoodAcacia.name=Acacia Wood Stairs
tile.stairsWoodDarkOak.name=Dark Oak Wood Stairs

 

Again - look at vanilla stairs and naming :)

1.7.10 is no longer supported by forge, you are on your own.

Posted

Thanks! It all worked except for the ItemBlock texture. I got the placed block texture and model to work, but the ItemBlock doesn't work.

 

Blockstate file:

{
    "variants": {
        "normal": { "model": "mymods:enderBlock" }
    }
}

 

Block model file:

{
    "ambientocclusion": false,
    "textures": {
        "particle": "blocks/stone",
        "base": "blocks/stone",
        "pole": "blocks/emerald_block"
    },

    "elements": [
        {   "from": [ 2, 0, 0 ],
            "to": [ 14, 1, 16 ],
            "shade": false,
            "faces": {
                "down": {
                    "uv": [
                        2,
                        0,
                        14,
                        16
                    ],
                    "texture": "#base"
                },
                "up": {
                    "uv": [
                        2,
                        0,
                        14,
                        16
                    ],
                    "texture": "#base"
                },
                "east": {
                    "uv": [
                        16,
                        0,
                        0,
                        1
                    ],
                    "texture": "#base"
                },
                "west": {
                    "uv": [
                        0,
                        0,
                        16,
                        1
                    ],
                    "texture": "#base"
                },
                "north": {
                    "uv": [
                        14,
                        0,
                        2,
                        1
                    ],
                    "texture": "#base"
                },
                "south": {
                    "uv": [
                        2,
                        0,
                        14,
                        1
                    ],
                    "texture": "#base"
                }
            }
        },
        {   "from": [ 7, 1, 6 ],
            "to": [ 9, 8, 10 ],
            "shade": false,
            "faces": {
                "up": {
                    "uv": [
                        7,
                        6,
                        9,
                        10
                    ],
                    "texture": "#pole"
                },
                "east": {
                    "uv": [
                        6,
                        1,
                        10,
                        8
                    ],
                    "texture": "#pole"
                },
                "west": {
                    "uv": [
                        6,
                        1,
                        10,
                        8
                    ],
                    "texture": "#pole"
                },
                "north": {
                    "uv": [
                        7,
                        1,
                        9,
                        8
                    ],
                    "texture": "#pole"
                },
                "south": {
                    "uv": [
                        7,
                        1,
                        9,
                        8
                    ],
                    "texture": "#pole"
                }
            }
        }
    ]
}

 

The block model file is long because I wanted it to have a cool shape.

 

Item model file:

{
  "parent": "mymods:block/enderBlock",
  "display": {
    "thirdperson": {
      "rotation": [ 10, -45, 170 ],
      "translation": [ 0, 1.5, -2.75 ],
      "scale": [ 0.375, 0.375, 0.375 ]
    }
  }
}

 

Can you tell me what I am doing wrong?

Posted

That's probably what I missed. What is the inventory block renderer and how do I register it? I'm guessing it renders the blocks in the inventory, but I don't know if that's right. I also don't know how to register it. Can you tell me what it is and how to register it?

Posted

From McByExample:

// This is currently necessary in order to make your block render properly when it is an item (i.e. in the inventory
// or in your hand or thrown on the ground).
// Minecraft knows to look for the item model based on the GameRegistry.registerBlock. However the registration of
// the model for each item is normally done by RenderItem.registerItems(), and this is not currently aware
// of any extra items you have created. Hence you have to do it manually. This will probably change in future.
// It must be done in the init phase, not preinit, and must be done on client only.
Item itemBlockSimple = GameRegistry.findItem("minecraftbyexample", "mbe01_block_simple");
ModelResourceLocation itemModelResourceLocation = new ModelResourceLocation("minecraftbyexample:mbe01_block_simple", "inventory");
final int DEFAULT_ITEM_SUBTYPE = 0;
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(itemBlockSimple, DEFAULT_ITEM_SUBTYPE, itemModelResourceLocation);

 

This happens ofc in client-proxy (registerRendering), MUST be in in init() (load). // Lol I noticed now that the posted code alredy said this xD

 

Now note (as I said before):

models/items/blockname.json MUST HAVE SAME FILENAME as blockstates/blockname.json.

 

1.7.10 is no longer supported by forge, you are on your own.

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.