#Multiple items with same texture but different colors?
44 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
Do I need to set a transparency somehow or will that set the transparency?
it will be set automatically
let acornTypes = [
{
name: "dirt",
color: "9A5036"
}
{
name: "iron",
color: "9A5036"
}
]
onEvent("item.registry", (event) => {
for (const acorn in acornTypes) {
event.create(`treeblock:${acorn.name}`)
.displayName(`${acorn.name} acorn`)
.texture('treeblock:item/acorn_bw')
.food((food) => {
food
.hunger(1)
.saturation(1)
.effect("minecraft:hunger", 200, 0, 1)
.effect("minecraft:slowness", 200, 1, 1)
.effect("minecraft:resistance", 200, 1, 1)
.fastToEat();
});
}
});
This would not work, I was able to create a single custom item but when trying the loop and adding .texture, something is broke now, can you see what that is?
Please send your startup.txt log file.
You can find it here: minecraft/logs/kubejs/startup.txt
[10:54:50] [ERR ] Error loading KubeJS script: missing ] after element list (startup_scripts:registry.js#6)
[10:54:50] [INFO ] Hello, World! (You will only see this line once in console, during startup)
[10:54:50] [INFO ] Loaded script startup_scripts:script.js in 0.033 s
[10:54:50] [INFO ] Loaded 1/2 KubeJS startup scripts in 0.785 s
If you're working with KubeJS scripts, configuration files, or similar things, we generally recommend using an actual IDE rather than just Notepad and its various siblings. In a lot of cases, it can help you with finding errors in your code faster and also gives you neat features like syntax highlighting, automatic formatting, et cetera! We recommend Visual Studio Code, since it's lightweight(-ish) and works very well with JavaScript files out-of-the-box.
Ah, I am missing a comma in the arr
yea
let acornTypes = [{
name: "dirt",
color: "9A5036"
},
{
name: "iron",
color: "9A5036"
}
]
onEvent("item.registry", e => {
acornTypes.forEach(a => {
e.create(`treeblock:${a.name}`)
.displayName(`${a.name} acorn`)
.texture('treeblock:item/acorn_bw')
.food(f => {
f
.hunger(1)
.saturation(1)
.effect("minecraft:hunger", 200, 0, 1)
.effect("minecraft:slowness", 200, 1, 1)
.effect("minecraft:resistance", 200, 1, 1)
.fastToEat()
})
})
})
hmmmm....
let acornTypes = [
{
name: "dirt",
color: 0x9A5036
},
{
name: "iron",
color: 0x9A5036
}
];
onEvent("item.registry", (event) => {
acornTypes.forEach(acorn => {
event.create(`treeblock:${acorn.name}_acorn`)
.displayName(`${acorn.name} acorn`)
.texture('treeblock:item/acorn_bw')
.color(acorn.color)
.food((food) => {
food
.hunger(1)
.saturation(1)
.effect("minecraft:hunger", 200, 0, 1)
.effect("minecraft:slowness", 200, 1, 1)
.effect("minecraft:resistance", 200, 1, 1)
.fastToEat();
});
})
});
is only creating the first one and not adding color to it?
Please send your startup.txt log file.
You can find it here: minecraft/logs/kubejs/startup.txt
It was an issue with .color, the fix was .color(0, 0xffffff)
it was just missing the index
No worries! thanks for rubber ducking with me! 😄
:D
While you are here, do you know if you can change tree drops with Kubejs?
Ah yeah I guess that would just be tied to the drops of the leaves haha
you can use loot tables
in json
however that's a pain
or the default
however it's bad and not very documented
I recommend
??lootjs
LootJS is an addon for KubeJS that allows modifying loot from all sources dynamically (much nicer than loot tables)!
It also supports removing loot added by mods, unlike KubeJS' current loot table events.
awesome I will look into it now! thanks!
if you have any questions, @ me
will do! thanks 🙂
@final ferry https://github.com/KubeJS-Mods/KubeJS/issues/448
also it looks like you can do .item(i => i.color(0, 0xFFFFFF))
Thank you! I was just about to give that a try! haha
@crisp pine
I kind of asked before but wasnt entirely sure what I was looking for. can KubeJs make custom trees like I want to have more saplings that will grow similar to oak trees but different leaves on them