From 4ff099ab450f9b98f090626e2116ebb2bad198b7 Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Thu, 20 Jan 2022 12:20:12 +0300 Subject: [PATCH] Added Items lookup system support to egg material, registered egg items in the Items lookup system --- .../main/java/com/willfp/ecobosses/bosses/EcoBoss.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java index 5bcff1d..b73bcc4 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/EcoBoss.java @@ -600,9 +600,7 @@ public class EcoBoss extends PluginDependent { // Spawn egg if (this.getConfig().getBool("spawn-egg.enabled")) { - Material material = Material.getMaterial(this.getConfig().getString("spawn-egg.material").toUpperCase()); - assert material != null; - ItemBuilder builder = new ItemStackBuilder(material) + ItemBuilder builder = new ItemStackBuilder(Items.lookup(this.getConfig().getString("spawn-egg.material")).getItem()) .setDisplayName(this.getConfig().getString("spawn-egg.name")) .addLoreLines(this.getConfig().getStrings("spawn-egg.lore")) .writeMetaKey(this.getPlugin().getNamespacedKeyFactory().create("spawn_egg"), PersistentDataType.STRING, this.getId()); @@ -614,6 +612,9 @@ public class EcoBoss extends PluginDependent { this.spawnEgg = builder.build(); + Items.registerCustomItem(this.getPlugin().getNamespacedKeyFactory().create(this.getId()+"_spawn_egg"), + Items.lookup(this.getConfig().getString("spawn-egg.material"))); + if (this.getConfig().getBool("spawn-egg.craftable")) { Recipes.createAndRegisterRecipe( this.getPlugin(), @@ -688,7 +689,7 @@ public class EcoBoss extends PluginDependent { continue; } - if (NumberUtils.randFloat(0, 100) <= chance) { + if (NumberUtils.randFloat(0, 100) < chance) { drops.add(itemStack); } }