Skip to content

Commit

Permalink
feat: added ability to combine enchanted books through assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
Yarden-zamir committed Jan 20, 2024
1 parent 52786ef commit 1dd94f1
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions kubejs/server_scripts/base/featrues/enchantments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
if (feature("Combining enchanted books")) {
var $Registry = Java.loadClass("net.minecraft.core.Registry");

$Registry.ENCHANTMENT.entrySet().forEach((enchant) => {
var enchant_id = String(enchant.getKey().location());
var enchant_max_level = parseInt(
enchant.getValue().getMaxLevel().toFixed(0)
);
let enchant_level = 2;
while (enchant_level <= enchant_max_level) {
addAssembly(
Item.of("minecraft:enchanted_book", 1).enchant(
enchant_id,
enchant_level
),
Item.of("minecraft:enchanted_book", 1)
.enchant(enchant_id, enchant_level - 1)
.strongNBT(),
[
addFilling(
"stick",
"stick",
"1x create_enchantment_industry:experience"
),
addDeploying(
"stick",
"stick",
Item.of("minecraft:enchanted_book", 1)
.enchant(enchant_id, enchant_level - 1)
.strongNBT()
),
]
);
enchant_level++;
}
});
}

0 comments on commit 1dd94f1

Please sign in to comment.