#Multiple items with same texture but different colors?

44 messages · Page 1 of 1 (latest)

final ferry
#

I have a texture of an item and I am looking to create a bunch of items using the same texture but with different colors. How would I go about overlaying a color over the image?

grim bisonBOT
#

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

crisp pine
#

using .color(0xFFFFFF)

#

it uses hex, but has 0x at the start instead of #

final ferry
#

Do I need to set a transparency somehow or will that set the transparency?

crisp pine
#

it will be set automatically

final ferry
# crisp pine 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?

grand oceanBOT
#

Please send your startup.txt log file.
You can find it here: minecraft/logs/kubejs/startup.txt

crisp pine
#

oh I see the issue

#

one sec

final ferry
#

[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

grand oceanBOT
#

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.

final ferry
#

Ah, I am missing a comma in the arr

crisp pine
#

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()
            })
    })
})
final ferry
#

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?

grand oceanBOT
#

Please send your startup.txt log file.
You can find it here: minecraft/logs/kubejs/startup.txt

final ferry
#

It was an issue with .color, the fix was .color(0, 0xffffff)

#

it was just missing the index

crisp pine
#

forgot about it 😅

#

sorry

final ferry
#

No worries! thanks for rubber ducking with me! 😄

crisp pine
#

:D

final ferry
#

While you are here, do you know if you can change tree drops with Kubejs?

crisp pine
#

what do you mean by tree drops?

#

the drops of leaves?

final ferry
#

Ah yeah I guess that would just be tied to the drops of the leaves haha

crisp pine
#

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

grand oceanBOT
# crisp pine ??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.

final ferry
#

awesome I will look into it now! thanks!

crisp pine
#

if you have any questions, @ me

final ferry
#

will do! thanks 🙂

crisp pine
#

also it looks like you can do .item(i => i.color(0, 0xFFFFFF))

final ferry
#

Thank you! I was just about to give that a try! haha

final ferry
#

@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

crisp pine
#

probably not...

#

you can register custom leaves, however I don't know about the saplings