Solved Custom NMS Entities

Discussion in 'Spigot Plugin Development' started by RustyDesigns, May 29, 2016.

  1. Hey!

    Could anyone point me in the direction of a good way to find out how to make frozen entities, or a good API. I need them not to be able to move, or be pushed.

    Thanks!
     
    #1 RustyDesigns, May 29, 2016
    Last edited: May 29, 2016
  2. You mean LivingEntity#setAI(boolean)?
     
    • Agree Agree x 2
  3. This kindof goes with @Redrield s signature, but could you show me how I would implement that into a custom entity class?
     
  4. You shouldn't need to, if they're an implementation of the LivingEntity class, you should be able to call it.
     
  5. @Redrield Would that stop them from being pushed?
     
  6. Not being pushed, but they can't move naturally
     
  7. No it doesn't. I'm not sure if LivingEntity#setPushable works, but give it a shot :p

    Edit: mb, think they removed it.
     
  8. @Redrield Is there a simple way to stop them from being pushed? Other than constantly teleporting them of course :)
     
  9. I remember a while ago I extended EntityCreeper and wanted to keep his AI but not allow him to move around or be pushed. I believe what I did was override the collision and move methods and left them empty.

    If you don't want him to have AI at all just ignore the move method and set the AI off as previously mentioned.

    Code (Text):

        @Override
        public void collide(Entity entity) {
        }

        @Override
        public void move(double d0, double d1, double d2) {
        }
     
    EDIT: I'm sure there are other ways to accomplish this as well.
     
    • Like Like x 1
  10. If u are using spigot > 1.8 you can use

    Villager e = p.getWorld().spawn(p.getLocation(), Villager.class);
    CraftVillager v = (CraftVillager) e;
    EntityVillager handle = ((CraftVillager) e).getHandle();

    handle.getDataWatcher().watch(15, (byte) 1); // NoAI
     
    #10 DevLeeo, May 30, 2016
    Last edited: May 30, 2016
  11. The #setCollidable needs to be set from both sides. That means that you need to disable the collision on both the entity and the player. But this brings another problem since arrow and snowball knockback will also disable when you do this. But you can get around it by listening to the playerWorldChangeEvent or look if a player is near an entity. :)
     
  12. Thats what I did, and it works so thanks!