Jump to content

How to connect new block to texture.


Jontom Xire

Recommended Posts

I thought I posted this last night, but it was late and I was tired, so it may be in the wrong forum, or maybe I just didn't click the post button. If there is a duplicate, my apologies.

 

In my main class I have this, as per the example code:

    public static final DeferredRegister<Block> BLOCKS          = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
    public static final DeferredRegister<Item>  ITEMS              = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
    public static final RegistryObject<Block>   BONE_ALTAR   = BLOCKS.register("bone_altar", () -> new Block(BlockBehaviour.Properties.copy(Material.STONE).requiresCorrectToolForDrops()));
    public static final RegistryObject<Item>    BONE_ALTAR_ITEM = ITEMS.register("bone_altar", () -> new BlockItem(BONE_ALTAR.get(), new Item.Properties()));

 

I figured out how to add it to a creative mode tab, and placed one, and the texture is just a magenta and black check.

The texture I want to use is at src/main/resources/assets/stats_and_skills/textures/blocks/bone_altar.png.

The model file is at src/main/resources/assets/stats_and_skills/models/blocks/bone_altar.json and looks like:

    {
        "parent": "block/cube",
        "textures": {
            "particle": "block/bone_altar",
            "all": "block/bone_altar"
        },
        "elements": [
            {
               "from": [ 0, 0, 0 ],
                "to": [ 16, 16, 16 ],
                "faces": {
                    "down":  { "texture": "#all", "cullface": "down" },
                    "up":    { "texture": "#all", "cullface": "up" },
                    "north": { "texture": "#all", "cullface": "north" },
                    "south": { "texture": "#all", "cullface": "south" },
                    "west":  { "texture": "#all", "cullface": "west" },
                    "east":  { "texture": "#all", "cullface": "east" }
                }
            }
        ]
    }

I am guessing that a file is in the wrong location, or the model file is using the wrong path to the texture. Or something. I have no idea, and the documentation really needs a bit more in the way of examples.

 

 

 

Link to comment
Share on other sites

I have added a few more files and modified the JSON one I had. I now have:

assets/stats_and_skills/blockstates/bone_altar.json:

{
    "variants": {
        "": { "model": "stats_and_skills:block/bone_altar" }
    }
}

assets/stats_and_skills/models/item/bone_altar.json:

{
  "parent": "item/generated",
  "textures": {
    "layer0": "stats_and_skills:block/bone_altar"
  }
}

assets/stats_and_skills/models/block/bone_altar.json:

{
    "parent": "block/cube",
    "textures": {
        "": "stats_and_skills:block/bone_altar",
        "inventory": "stats_and_skills:block/bone_altar",
        "all": "stats_and_skills:block/bone_altar"
    },
    "elements": [
        {
           "from": [ 0, 0, 0 ],
            "to": [ 16, 16, 16 ],
            "faces": {
                "down":  { "texture": "#all", "cullface": "down" },
                "up":    { "texture": "#all", "cullface": "up" },
                "north": { "texture": "#all", "cullface": "north" },
                "south": { "texture": "#all", "cullface": "south" },
                "west":  { "texture": "#all", "cullface": "west" },
                "east":  { "texture": "#all", "cullface": "east" }
            }
        }
    ]
}

 

I also renamed the directory from "blocks" to "block" for the textures. The documentation that is available is very inconsistent here. It all seems to work now.

 

Link to comment
Share on other sites

2 hours ago, Jontom Xire said:

The documentation that is available is very inconsistent here. It all seems to work now.

Again...if you want to complain about the documentation, please provide an issue. I can't know there are issues unless somebody mentions them. Additionally, as this is vanilla related stuff, all of this is documented on the Minecraft wiki which is linked on the Forge docs.

Link to comment
Share on other sites

You are right, it was the community wiki:

 

https://forge.gemwire.uk/wiki/Model_JSONs

    examplemod:blocks/test → assets/examplemod/textures/blocks/test.png

    ...

    minecraft:block/cube_all, not minecraft:block/cube_all.json

 

And this is a doozy at https://forge.gemwire.uk/wiki/Item_Properties:

 

{
  "parent": "item/generated",
  "textures": {
    "__comment": "Default",
    "layer0": "examplemod:items/example_partial"
  },
  "overrides": [
    {
      "__comment": "power >= .75",
      "predicate": {
        "examplemod:power": 0.75
      },
      "model": "examplemod:item/example_powered"
    }
  ]
}

The "layer0" definition uses "items" and the "model" in the overrides uses "item".

 

I think there were more using the plural, but it was a while ago and I don't have time to search them all out right now.

 

Link to comment
Share on other sites

6 hours ago, Jontom Xire said:

You are right, it was the community wiki:

Like I said, we have issue trackers for all that stuff which need to be reported to rather than saying it's wrong and either not informing us or fixing it (since the wiki can be contributed to by anyone); however, I don't believe the wiki was ever updated to 1.19.3, so that still would've been fine in 1.19.2 where that convention was still used often.

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.