Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block state data #18

Open
rom1504 opened this issue May 1, 2015 · 6 comments
Open

Block state data #18

rom1504 opened this issue May 1, 2015 · 6 comments

Comments

@rom1504
Copy link
Member

rom1504 commented May 1, 2015

There are block state files available by doing this :

mkdir /tmp/dminecraft
cp ~/.minecraft/versions/1.8.4/1.8.4.jar  /tmp/dminecraft
cd /tmp/dminecraft && unzip 1.8.4.jar
cd /tmp/dminecraft/assets/minecraft/blockstates

Example : birch_fence_gate.json :

{
    "variants": {
        "facing=south,in_wall=false,open=false": { "model": "birch_fence_gate_closed" },
        "facing=west,in_wall=false,open=false":  { "model": "birch_fence_gate_closed", "y": 90, "uvlock": true },
        "facing=north,in_wall=false,open=false": { "model": "birch_fence_gate_closed", "y": 180, "uvlock": true },
        "facing=east,in_wall=false,open=false":  { "model": "birch_fence_gate_closed", "y": 270, "uvlock": true },
        "facing=south,in_wall=false,open=true": { "model": "birch_fence_gate_open" },
        "facing=west,in_wall=false,open=true":  { "model": "birch_fence_gate_open", "y": 90, "uvlock": true },
        "facing=north,in_wall=false,open=true": { "model": "birch_fence_gate_open", "y": 180, "uvlock": true },
        "facing=east,in_wall=false,open=true":  { "model": "birch_fence_gate_open", "y": 270, "uvlock": true },
        "facing=south,in_wall=true,open=false": { "model": "birch_wall_gate_closed" },
        "facing=west,in_wall=true,open=false":  { "model": "birch_wall_gate_closed", "y": 90, "uvlock": true },
        "facing=north,in_wall=true,open=false": { "model": "birch_wall_gate_closed", "y": 180, "uvlock": true },
        "facing=east,in_wall=true,open=false":  { "model": "birch_wall_gate_closed", "y": 270, "uvlock": true },
        "facing=south,in_wall=true,open=true": { "model": "birch_wall_gate_open" },
        "facing=west,in_wall=true,open=true":  { "model": "birch_wall_gate_open", "y": 90, "uvlock": true },
        "facing=north,in_wall=true,open=true": { "model": "birch_wall_gate_open", "y": 180, "uvlock": true },
        "facing=east,in_wall=true,open=true":  { "model": "birch_wall_gate_open", "y": 270, "uvlock": true }
    }
}

Might be interesting for handling metadata/blockstate (and placing that kind of blocks)

@rom1504
Copy link
Member Author

rom1504 commented May 2, 2015

Interesting data but it doesn't make the link between block/item id and block state, for example :

That means it's needed to extract that information from the wiki in a first step.

@rom1504
Copy link
Member Author

rom1504 commented May 4, 2015

Might be interesting :
flower_pot.json

{
    "variants": {
        "contents=empty":            { "model": "flower_pot" },
        "contents=rose":             { "model": "flower_pot_rose" },
        "contents=blue_orchid":      { "model": "flower_pot_orchid" },
        "contents=allium":           { "model": "flower_pot_allium" },
        "contents=houstonia":        { "model": "flower_pot_houstonia" },
        "contents=red_tulip":        { "model": "flower_pot_tulip_red" },
        "contents=orange_tulip":     { "model": "flower_pot_tulip_orange" },
        "contents=white_tulip":      { "model": "flower_pot_tulip_white" },
        "contents=pink_tulip":       { "model": "flower_pot_tulip_pink" },
        "contents=oxeye_daisy":      { "model": "flower_pot_daisy" },
        "contents=dandelion":        { "model": "flower_pot_dandelion" },
        "contents=oak_sapling":      { "model": "flower_pot_oak" },
        "contents=spruce_sapling":   { "model": "flower_pot_spruce" },
        "contents=birch_sapling":    { "model": "flower_pot_birch" },
        "contents=jungle_sapling":   { "model": "flower_pot_jungle" },
        "contents=acacia_sapling":   { "model": "flower_pot_acacia" },
        "contents=dark_oak_sapling": { "model": "flower_pot_dark_oak" },
        "contents=mushroom_red":     { "model": "flower_pot_mushroom_red" },
        "contents=mushroom_brown":   { "model": "flower_pot_mushroom_brown" },
        "contents=dead_bush":        { "model": "flower_pot_dead_bush" },
        "contents=fern":             { "model": "flower_pot_fern" },
        "contents=cactus":           { "model": "flower_pot_cactus" }
    }
}

@Yogu
Copy link

Yogu commented Dec 31, 2016

Any new ideas on this issue? I need a mapping from the 16-bit metadata to the model, i.e. the blockstate and its variant. Of course, this is not completely possible because not all block state is persisted in the metadata, it should be possible to get a close-enough mapping for many blocks.

Do you think we could use an automatic import from a data source? The wiki does not seem like the best source, it can be informal, e.g. for Fence Gate.

Thus I think these information need to be added manually, or does someone have a better idea?

Edit: I got an idea: Maybe we can just execute the getStateFromMeta methods of all block classes with 0..15 as parameter. They should not depend on the game status, so it should be pretty easy to execute them from a script.

A bit more info: Block.registerBlocks populates Block.BLOCK_STATE_IDS with a mapping of block IDs, textual ids (probably a canonical minecraft:... name, though there might be multiple for one ID as far as I understand) and Block instances. So we can just loop over this map to get all the Block instances with their ids, and then call getStateFromMeta to map block state ids (block id + meta combined, as stored in the world and sent over network) to Block-IBlockState combinations which in turn can be mapped to the blockstate entries in the JSON file via the BlockStateMapper.

@rom1504
Copy link
Member Author

rom1504 commented Dec 31, 2016

@Yogu I'm open to any way to extract that data, using the minecraft jar would definitely be a good way to do it.
If you feel like doing it please go ahead, I'll accept a PR with the resulting data, and would be interested by the extractor code !

@Yogu
Copy link

Yogu commented Jan 1, 2017

I made a small mod: forge-data-extractor that produces these files (whole list of files which is too large so the interesting file is not displayed).

What do you think would be helpful here? I think, the blockstate-ids.json would fit nicely in the variants part of blocks, and the blockstates-without-models could also be a good fit. However, we should first look into what these flags stand for, I just put in everything that was available.

@rom1504
Copy link
Member Author

rom1504 commented Jun 23, 2017

related https://github.com/PrismarineJS/minecraft-jar-extractor/blob/master/image_names.js and https://github.com/rom1504/minecraft-assets

@Yogu yes it could be useful, I'm not sure exactly where to put that in mcdata

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants