From fe59e5379b0751ce8915118459be0aed9c9ede3c Mon Sep 17 00:00:00 2001 From: Alexander B Date: Tue, 5 Jan 2021 20:54:23 +0100 Subject: [PATCH] Added NMT-Data to spawner to keep mob-type --- .../ruakij/spawnerDrops/listener/OnBlockBreak.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/eu/railduction/ruakij/spawnerDrops/listener/OnBlockBreak.java b/eu/railduction/ruakij/spawnerDrops/listener/OnBlockBreak.java index 0a368f2..893e687 100644 --- a/eu/railduction/ruakij/spawnerDrops/listener/OnBlockBreak.java +++ b/eu/railduction/ruakij/spawnerDrops/listener/OnBlockBreak.java @@ -5,6 +5,7 @@ import eu.railduction.ruakij.spawnerDrops.Main; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.block.CreatureSpawner; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.enchantments.Enchantment; @@ -13,6 +14,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BlockStateMeta; import java.io.IOException; @@ -88,6 +90,13 @@ public class OnBlockBreak implements Listener { // Set drop if(success){ ItemStack item = new ItemStack(Material.MOB_SPAWNER); + + CreatureSpawner cs = (CreatureSpawner)e.getBlock().getState(); + + BlockStateMeta bsm = (BlockStateMeta)item.getItemMeta(); + bsm.setBlockState(cs); + item.setItemMeta(bsm); + loc.getWorld().dropItem(loc, item); }