Ваш первый скрипт

В папке KubeJS откройте файл server_script, а затем - script.js. Вы увидите следующий код, который мы рассмотрим далее:

// priority: 0
settings.logAddedRecipes = true
settings.logRemovedRecipes = true
settings.logSkippedRecipes = false
settings.logErroringRecipes = true
console.info('Hello, World! (You will see this line every time server resources reload)')
onEvent('recipes', event => {
 // Change recipes here
})
onEvent('item.tags', event => {
 // Get the #forge:cobblestone tag collection and add Diamond Ore to it
 // event.get('forge:cobblestone').add('minecraft:diamond_ore')
 // Get the #forge:cobblestone tag collection and remove Mossy Cobblestone from it
 // event.get('forge:cobblestone').remove('minecraft:mossy_cobblestone')
})

//priority - устанавливает приоритет скрипта 0-∞.

За отображение информации в логах отвечают следующие параметры:

  • settings.logAddedRecipes - Добавление рецепта.

  • settings.logRemovedRecipes - Удаление рецепта.

  • settings.logSkippedRecipes - Пропуск рецепта.

  • settings.logErroringRecipes - Ошибки в рецепте.

console.info - выводит сообщение в logs. onEvent('recipes', event => { - регистрация Event. 'recipes', - имя Event.

Теперь создадим первый скрипт. Мы добавим рецепт для кремня из 3-х гравия.

У нас для таких целей есть 2 способа:

  1. Форменный рецепт (shaped)

  2. Бесформенный рецепт (shapeless)

Мы воспользуемся 2 способом, так как нам не нужна строгая последовательность.

// priority: 0
settings.logAddedRecipes = true
settings.logRemovedRecipes = true
settings.logSkippedRecipes = false
settings.logErroringRecipes = true
console.info('Hello, World! (You will see this line every time server resources reload)')
onEvent('recipes', event => {
 // Change recipes here
 event.shapeless("flint", ["gravel", "gravel", "gravel"])
})
onEvent('item.tags', event => {
 // Get the #forge:cobblestone tag collection and add Diamond Ore to it
 // event.get('forge:cobblestone').add('minecraft:diamond_ore')
 // Get the #forge:cobblestone tag collection and remove Mossy Cobblestone from it
 // event.get('forge:cobblestone').remove('minecraft:mossy_cobblestone')
})

Теперь сохраним и напишем в чате игры /reload для запуска изменений.

Last updated