#NBT and Tags

16 messages · Page 1 of 1 (latest)

graceful aspen
#

I have been trying forever to make NBT tags work with recipes and rn trying to make a specific NBT tag item have its own texture.

strong wigeonBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

graceful aspen
#

done several different things to make it work.

graceful aspen
#

@wide sable I saw you helped out a few people with a similar issue. Have any thoughts?

wide sable
#

idk. I only have experience using custom model data. I could try this, but I am kinda busy this weekend.

graceful aspen
#

Oh ok

#

appreciate it, lemme know if you need any more info

wide sable
#

This should work. But I could not write example code right now.

wide sable
# graceful aspen Oh ok
ClientEvents.highPriorityAssets(event => {
    const ITEM_GENERATED = "item/generated"
    const [TEXTURE_POTION_OVERLAY, TEXTURE_POTION] = ["minecraft:item/potion_overlay", "minecraft:item/potion"]
    const basicPotionModel = {
        parent: ITEM_GENERATED,
        textures: {layer0: TEXTURE_POTION_OVERLAY, layer1: TEXTURE_POTION},
        overrides:[]
    }
    const SPECIAL_POTION = "special_potion"

    Object.keys(specialPotions).forEach((key, i) => {
        basicPotionModel.overrides.push({
            predicate:{"special_potion": (i + 1)/(Object.keys(specialPotions).length + 1)},
            model: `kubejs:item/special_potion${i}`
        })
        event.addModel("item", `kubejs:special_potion${i}`, generator => {
            generator.parent(ITEM_GENERATED)
            const textures = specialPotions[key]
            textures.forEach((t, ti) => {
                generator.texture(`layer${ti}`, t)
            })
        })
    })
    const $ItemProperties = Java.loadClass("net.minecraft.client.renderer.item.ItemProperties")

    /**
     * 
     * @param {Internal.Item_} item 
     * @param {*} resourceLocation 
     * @param {Internal.ItemPropertyFunction_} itemPropertyFunction 
     * @returns 
     */
    const registerItemProperties = (item, resourceLocation, itemPropertyFunction) => $ItemProperties["register(net.minecraft.world.item.Item,net.minecraft.resources.ResourceLocation,net.minecraft.client.renderer.item.ItemPropertyFunction)"](item, resourceLocation, itemPropertyFunction)
    registerItemProperties("minecraft:potion", SPECIAL_POTION, (itemstack, level, livingEntity) => {
        if(!itemstack.nbt) return 0
        const potionName = itemstack.nbt.getString("Potion")
        const index = Object.keys(specialPotions).indexOf(potionName)
        if(index == -1) return 0
        return (index + 1)/(Object.keys(specialPotions).length + 1)
    })
    
    event.add("minecraft:models/item/potion", basicPotionModel)
})
#
    const specialPotions = {}
    specialPotions["minecraft:strength"] = ["minecraft:item/diamond_sword", "minecraft:item/iron_ingot"]
    specialPotions["alexsmobs:bug_pheromones"] = ["minecraft:item/cauldron", "minecraft:item/iron_axe", "minecraft:item/gold_nugget"]
    //specialPotions[PotionName] = array of texture resource location
graceful aspen
#

Just saw this. Gonna try it in a bit

#

Looks Farley complicated, also not sure if it's using the same properties as all the regular bongs in @nirvana. That is the main goal

#

Making it use the already built code in nirvana. But just adding a new item as an 'addon' for the new ones I made.

wide sable
#

This is mainly just an example to show how ItemProperties work