#Create Block Error

28 messages · Page 1 of 1 (latest)

tranquil bay
#

im creating the block, when run the game, it show an error. How to fix that

quick oasisBOT
#

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

tranquil bay
#

this is the code

#
    global.substrate_mapping[id] = {
        category: category_index,
        index: substrate_index,
        name: name.replace(" Reagent", "").replace(" Catalyst", "")
    }
    current_category.push({
        id: `kubejs:substrate_${id}`,
        ingredient: ingredient,
        outputItem: outputItem
    })
    event.create(`substrate_${id}`)
        .material('glass')
        .color(0, color)
        .color(1, color)
        .hardness(0.1)
        .box(.25, 0, .25, .75, 14.0 / 16.0, .75, false)
        .model("kubejs:block/jar/" + model)
        .displayName(name)
        .renderType("cutout")
        .item(e => e.rarity(model == "catalyst" ? RARITY_UNCOMMON : RARITY_COMMON)
                    .color(0, c1))
    substrate_index++
}

let createReagent = (color, id, prefix, ingredient, outputItem) => substrate_base(color, id, `${prefix} Reagent`, "substrate", ingredient, outputItem)
let catalyst = (color, id, prefix, ingredient) => substrate_base(color, id, `${prefix} Catalyst`, "catalyst", ingredient)

let reagent = (id, prefix, item, color) => ({id, prefix, item, color})
let IGNEOUS = {
    c1: 0x6C8191,
    reagents: [
        reagent("andesite", "Andesite", "minecraft:andesite", 0x868887)
    ]}
    IGNEOUS.reagents.forEach(builder => {
        createReagent(builder.color, builder.id, builder.prefix, builder.item)
    })
})```
#

this is the log

warm merlinBOT
#

Paste version of startup.txt from @tranquil bay

#

This is a list of all the events. Choose your version.

little path
#

which line is 85?

#

also can you add some syntax highlighting to that codeblock, its hard to read with it all being white

tranquil bay
#

this one

#

let reagent = (id, prefix, item, color) => ({id, prefix, item, color})

little path
#

what are you trying to do with that line?

#

i cant make any sense of it

tranquil bay
#

im making the function add properties to an object and put the object in the IGNEOUS array. Then im making the loop to create the object

little path
#

im not even sure if that would be valid code in normal JS, ive never seen that before
but either way with Rhino you need to provide a key, it cannot default it

#
let reagent = (id, prefix, item, color) => ({id: id, prefix: prefix, item: item, color: color})
tender summit
#

however, this isn't normal js heh

tranquil bay
#

I have another question. Can I add the color with no index ?

little path
#

should be able to

tranquil bay
#

How to write that ?

little path
#

just remove the first param

tranquil bay
#

It showing the error texture

#

the log show this [01:39:58] [ERR ] Error occurred while handling event 'block.registry': Can't find method dev.latvian.mods.kubejs.block.BlockBuilder.color(number). (startup_scripts:launch/blockRegistry.js#76)

little path
#
public BlockBuilder color(int index, Color c) {
    color.put(index, c.getArgbJS());
    return this;
}

ye nevermind, you need an index

tranquil bay
#

Ok. Thanks for the help