Skip to content

Commit

Permalink
Enchanted books
Browse files Browse the repository at this point in the history
  • Loading branch information
PetteriM1 committed Feb 19, 2022
1 parent d9c1940 commit 5e7f229
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>cn.wode490390.nukkit</groupId>
<artifactId>vipop</artifactId>
<packaging>jar</packaging>
<version>1.0.2</version>
<version>1.0.2-IGN.1</version>
<name>Classic Village Populator</name>
<description>This is a plugin that implements the old village feature for Nukkit servers</description>
<url>http://wode490390.cn/</url>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cn.wode490390.nukkit.vipop.loot;

import cn.nukkit.item.Item;
import cn.nukkit.item.enchantment.Enchantment;
import cn.nukkit.math.NukkitRandom;
import cn.nukkit.nbt.NBTIO;
import cn.nukkit.nbt.tag.CompoundTag;
Expand All @@ -10,6 +11,7 @@

import java.util.List;
import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;

public class RandomizableContainer {

Expand All @@ -32,7 +34,11 @@ public void create(ListTag<CompoundTag> list, NukkitRandom random) {
result -= entry.getWeight();
if (result < 0) {
int index = random.nextBoundedInt(tags.length);
tags[index] = NBTIO.putItemHelper(Item.get(entry.getId(), entry.getMeta(), random.nextRange(entry.getMinCount(), entry.getMaxCount())), index);
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)));
}
tags[index] = NBTIO.putItemHelper(item, index);
break;
}
}
Expand Down

0 comments on commit 5e7f229

Please sign in to comment.