Invincible/Immobile mobs?

Discussion in 'Plugin Development' started by PotatoLol12321, Sep 30, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    PotatoLol12321

    package max333221.mobs;

    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.IronGolem;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDamageEvent;
    import org.bukkit.plugin.java.JavaPlugin;

    public class mobs extends JavaPlugin implements Listener {

    public void onEnable() {

    }

    public void spawnMOB(Player player)
    {

    IronGolem IGM = (IronGolem) player.getLocation().getWorld().spawn(player.getLocation(), IronGolem.class);
    IGM.setCustomName(ChatColor.AQUA + "Info");
    IGM.setCustomNameVisible(true);
    }

    @EventHandler
    public void onDamage(EntityDamageEvent e){
    e.setCancelled(true);
    }

    public boolean onCommand(CommandSender sender, Command cmd, String label,
    String[] a) {
    if (cmd.getName().equalsIgnoreCase("Golem")) {
    Player p = (Player) sender;
    spawnMOB(p);


    }
    return false;
    }
    }
    How would i make it stationary and invincibile?
     
  2. Offline

    Jaaakee224

    PotatoLol12321
    Did you check the Resources? You probably will find something on this.
     
  3. Offline

    Skionz

    PotatoLol12321
    Invincible: setNoDamageTicks() <---something like that
    Stationary: Invisible wither skulls
     
  4. Offline

    RingOfStorms

  5. Offline

    97WaterPolo

    PotatoLol12321
    Code:
    @EventHandler
    public void onDamage(EntityDamageEvent e){
    e.setCancelled(true);
    }
    Wouldn't this prevent any entities from being damaged?
     
  6. Offline

    AlphaRLee

    97WaterPolo Quick fix: add the spawned iron golems to an array list. Check to see if the hit entity belongs to the array list. Cancel depending on result.

    Yeah, to make it immobile, I'd probably spawn a wither skeleton skull and set the iron golem as a passenger...if possible.
     
    97WaterPolo likes this.
  7. Offline

    MCCoding

    Your not registering the events.....
     
  8. Offline

    RingOfStorms

    Using wither skulls is not the best option and it is a very non future proof method. I'm not sure why people seem to think it is the normal or best way to make immobile entities nowadays. Instead you should be clearing their AI pathfinders or overriding their base tick function with an empty function. Wither skulls is esspecially not a good recommendation because if the person ever wants to make the entity move in any way (like an NPC or other similar situation) they won't be able to.
     
  9. Offline

    AlphaRLee

    RingOfStorms Yeah, you make a lot of sense! Editing their pathfinders in the NMS is a near fail-safe way of doing things. However, remember, there is a lot of set up involved with NMS that most people won't want to go through (unless if they are fans of the copy-paste techniques). I am currently writing a plugin that heavily relies on NMS editing, so I would much rather use NMS, but I try to stay away from that when trying to work on other plugins or help others.

    For now, wither skulls show some promise, I'm sure fire charges and a few other projectiles also work (right?). They might not work tomorrow, but for today, they'll be ok...but I challenge all experience Bukkit programmers to think of a more reliable method that does not use NMS, as NMS is messy and complex for beginner users.
     
  10. Offline

    RingOfStorms

    In that case wither skull would still be my last option, a better solution that is even more friendly than a wither skull would be a slowness potion with a high amplifier making it so the entity can't move.
     
  11. Offline

    AlphaRLee

    Hmm...I think I heard of that before. A slowness 7 potion should suffice in complete immobility...However, would the entity still be able to turn on the spot? This might or might not be optimal.
     
  12. Offline

    PotatoLol12321

    Skionz Thanks for that, and thanks every one else! :D

    But is there also any way to make it so it can not be pushed by players?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
  13. Offline

    fireblast709

  14. Offline

    RingOfStorms

    The only way to do that without a custom entity would be teleporting them every few ticks back to their original spot.
     
  15. Offline

    PotatoLol12321

Thread Status:
Not open for further replies.

Share This Page