Solved Summoning Mobs

Discussion in 'Spigot Plugin Development' started by MaxKrissigo, Jun 12, 2016.

  1. I'm trying to spawn a shulker and give it custom health etc, but I'm not exactly sure how I would go about summoning it. I've read about needing to use NMS, but I couldn't find anything for 1.9/1.10, I also haven't really used before. Just some links on where to go would be great. Thanks, Max.
     
  2. Is this what you mean:

    Code (Text):
    Shulker shulker = (Shulker) world.spawnEntity(location, EntityType.SHULKER);
            shulker.setMaxHealth(50.0);
    The spawnEntity method in the world interface returns the Entity Object that is spawned, in which you can use it to manipulate its Health, Max Health, and anything else that can be changed as an entity object.

    Example method spawning a shulker on the player with 50 Max Health when a command is run:
    Code (Text):
        @Override
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args){

            if(!(sender instanceof Player)) return true;

            Player p = (Player) sender;

            if(label.equalsIgnoreCase("shulker")) {
                Shulker shulker = (Shulker) p.getWorld().spawnEntity(p.getLocation(), EntityType.SHULKER);
                shulker.setMaxHealth(50.0);
                return true;
            }

            return false;
        }
     
    • Like Like x 1
    • Informative Informative x 1
  3. Thank you, this perfectly solves my question!