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

Implement texture handling for BlockItemBuilder texture overrides #868

Open
wants to merge 1 commit into
base: 2001
Choose a base branch
from

Conversation

tiduslaugh
Copy link

Description

BlockItemBuilders ignore texture overrides provided via the .texture method, preventing scripters from changing a block item's texture without a workaround. See https://discord.com/channels/303440391124942858/1098748984572518440 . This fix attempts to mimic the behavior of ItemBuilder which handles this data correctly, but its generateAssetJsons method is overridden by BlockItemBuilder.

Example Script

// kubejs/startup/example.js
StartupEvents.registry('block', event => {
    event.create('dirt_pile')
        .model("kubejs:block/dirt_pile")
        .item(builder => {
            builder
                .displayName("Pile o' Dirt")
                // This workaround works because the modelJson attribute is processed in `generateItemModelJson`
                // .modelJson({
                //     parent: 'minecraft:item/generated',
                //     textures: {
                //       layer0: 'kubejs:item/dirt_pile',
                //     },
                // })
                // ...but this doesn't, because the textureJson attribute is not, and this item will have the parent model texture
                .texture("kubejs:item/dirt_pile")
        })
})

Other details

I'm very new to this codebase and MC modding in general so there is probably something I've overlooked :)

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

Successfully merging this pull request may close these issues.

1 participant