From f8e6b891b2b17133edd2ea9ff827d86ad6de6e79 Mon Sep 17 00:00:00 2001
From: Petteri <26197131+PetteriM1@users.noreply.github.com>
Date: Wed, 5 Apr 2023 20:14:02 +0300
Subject: [PATCH] Ench
---
pom.xml | 2 +-
.../wode490390/nukkit/vipop/loot/RandomizableContainer.java | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index d3d3350..31d0837 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
cn.wode490390.nukkit
vipop
jar
- 1.0.2-IGN.1
+ 1.0.2-IGN.2
Classic Village Populator
This is a plugin that implements the old village feature for Nukkit servers
http://wode490390.cn/
diff --git a/src/main/java/cn/wode490390/nukkit/vipop/loot/RandomizableContainer.java b/src/main/java/cn/wode490390/nukkit/vipop/loot/RandomizableContainer.java
index ac46a7f..c89831a 100644
--- a/src/main/java/cn/wode490390/nukkit/vipop/loot/RandomizableContainer.java
+++ b/src/main/java/cn/wode490390/nukkit/vipop/loot/RandomizableContainer.java
@@ -36,7 +36,11 @@ public void create(ListTag list, NukkitRandom random) {
int index = random.nextBoundedInt(tags.length);
Item item = Item.get(entry.getId(), entry.getMeta(), random.nextRange(entry.getMinCount(), entry.getMaxCount()));
if (item.getId() == Item.ENCHANT_BOOK) {
- item.addEnchantment(Enchantment.getEnchantment(ThreadLocalRandom.current().nextInt(37)));
+ Enchantment enchantment = Enchantment.getEnchantment(ThreadLocalRandom.current().nextInt(36));
+ if (ThreadLocalRandom.current().nextDouble() < 0.3) {
+ enchantment.setLevel(ThreadLocalRandom.current().nextInt(enchantment.getMaxLevel() + 1));
+ }
+ item.addEnchantment(enchantment);
}
tags[index] = NBTIO.putItemHelper(item, index);
break;