#NBT and Tags
16 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
done several different things to make it work.
@wide sable I saw you helped out a few people with a similar issue. Have any thoughts?
idk. I only have experience using custom model data. I could try this, but I am kinda busy this weekend.
bumping this in case I forget.
https://lexxie.dev/forge/1.20.1/net/minecraft/client/renderer/item/ItemProperties.html
declaration: package: net.minecraft.client.renderer.item, class: ItemProperties
This should work. But I could not write example code right now.
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
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.
If you can access the source code of nirvana, you can check how they register the properties and copy the code into kubejs format.
This is mainly just an example to show how ItemProperties work