Do anyone know how I can convert a ItemStack MOB_SPAWNER to a specific mob spawner? How should I make the instances? If anyone have any examples then that would be great! Cheers!
Well that's the CreatureSpawner class, which is a blockstate and even has a method to set spawn types. Not sure what else you need.
Code: @EventHandler public void onPlace(BlockPlaceEvent e) { if ((e.getBlockPlaced().getType().equals(Material.MOB_SPAWNER)) && (e.getItemInHand().hasItemMeta()) && (e.getItemInHand().getItemMeta().hasDisplayName()) && (CreatureType.fromName(e.getItemInHand().getItemMeta() .getDisplayName().replace(" SPAWNER", "")) != null)) ((CreatureSpawner) e.getBlockPlaced().getState()) .setCreatureTypeByName(e.getItemInHand().getItemMeta() .getDisplayName().replace(" Spawner", "")); } @EventHandler public void onBreakez(BlockBreakEvent e) { if ((e.getBlock().getType().equals(Material.MOB_SPAWNER))){ ItemStack spawnerStack = new ItemStack(e.getBlock().getType()); ItemMeta im = spawnerStack.getItemMeta(); im.setDisplayName(((CreatureSpawner) e.getBlock().getState()) .getCreatureTypeName().toUpperCase() + " SPAWNER"); spawnerStack.setItemMeta(im); spawnerStack.setDurability(((CreatureSpawner) e.getBlock() .getState()).getSpawnedType().getTypeId()); } } I used these methods for do it ^^ I just give you general lines ^^
Yea, ItemStack xD @lilian58660 Thanks! But can you tell me how that works? EDIT by Moderator: merged posts, please use the edit button instead of double posting.