Adding A Table (KubeJS) - TeamAOF/Artis GitHub Wiki

Adding a table with KubeJS

Adding an Artis table to the game with KubeJS is easy. Adding a table is done with a startup script in the kubejs/startup folder. In it, you simply listen to the artis.registry event.

events.listen('artis.registry', function (event) {
  // Register table here
})

There are three methods for creating an Artis table with KubeJS:

  • event.create(name) - used for creating a brand new Artis table.
  • event.createExistingBlock(modid, name) - used for adding an Artis table to an existing block.
  • event.createExistingItem(modid, name) - used for adding an Artis table to an existing block.

You can call, for example, event.create('machining_table') in order to start creating a new table. This isn't enough for a table to be registered, however. A table requires dimensions in order to be registered. In order to do this, you simply append .dimensions(width, height) onto the create function.

This would look like event.create('machining_table').dimensions(3, 3) for a 3x3 table.

Here are some more examples of various optional functions that you can use:

  • .generateAssets() - automatically generates assets for the table. Only works for event.create.
  • .color("#FFFFFF") - you provide a color as a hex string which gets applied as the GUI color. Also changes the color of the default asset for the table.
  • .blockEntity() - sets the table to have a block entity, meaning its contents do not drop when closed. Only works for event.create.
  • .catalystSlots(1) - allows you to set the number of catalyst slots in the table. Only 0 and 1 are valid currently.
  • .normalRecipes() - allows the table to craft vanilla recipes, and not just tables made for this table.
  • .bypassCheck() - uncommonly needed, but bypasses the check for an existing block or item, if you are sure it will exist. Only works for event.createExistingBlock and event.createExistingItem.

These can all be appended after .dimensions in order to change the various properties of a table.

Additionally, there are also more methods that are used for modifying the settings of the block that will be created. These are optional, and the table will default to copying the crafting table's block settings if none are included. This entire section only applies to event.create:

  • .copy("minecraft:stone") - copies the block settings of an existing block. Can still change further settings.
  • .material("stone") - sets the material of the block. For a more comprehensive list check here.
  • .materialColor("gray") - sets the material color of the block. For a more comprehensive list check here.
  • .sounds("stone") - sets the sound group of the block. For a more comprehensive list check here.
  • .collidable(true) - sets whether or not the block collides with the player.
  • .breakByHand(true) - sets whether or not a player can break the table with his bare hands.
  • .nonOpaque() - sets the block to not be opaque, which means it isn't a full block or is transparent.
  • .lightLevel(15) - sets the block's light level.
  • .hardness(1.5) - sets the hardness of the block.
  • .resistance(1.5) - sets the resistance of the block.
  • .slipperiness(0) - sets the slipperiness of the block.
  • .breakInstantly() - makes the block be broken instantly.
  • .dropsNothing() - makes the block drop nothing. If not set, will drop the block itself.
  • .dropsLike("minecraft:stone") - makes the block copy the drops of a targeted block. If not set, will drop the block itself.
  • .drops("minecraft:stone") - makes the block drop the targeted block/item. If not set, will drop the block itself.
  • .dynamicBounds() - I'm honestly not sure exactly what this does.

After you've got your table customized how you like, just launch your game and your table should show up in game.

Example KubeJS Table

Code:

events.listen('artis.registry', function (event) {
  event.create('skibby').dimensions(4, 3).generateAssets().color('#7FD176').catalystSlots(1).blockEntity().material('wood').nonOpaque()
})

Pictures: