Disable player pushing a villager

Discussion in 'Plugin Development' started by FireBuster12, Nov 28, 2017.

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

    FireBuster12

    Hello Bukkit,

    I have looked at a lot of websites but can not find out how I can stop a player pushing a villager. I have tried several things from the internet but nothing works. My question is whether you can help me to make this work? My minecraft development framework: PaperSpigot 1.11.2.

    My code:

    Code:java
    1.  
    2. //Spawn a villager
    3. Villager villager = (Villager)chestLoc.getWorld().spawnEntity(villagerLoc, EntityType.VILLAGER);
    4. villager.setProfession(Villager.Profession.FARMER);
    5. villager.setCustomName(ChatColor.RED + "SkyBlock Assistant");
    6. villager.setCustomNameVisible(true);
    7. villager.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0);
    8. villager.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).setBaseValue(1);
    9. villager.setInvulnerable(true);
    10. villager.setCollidable(false);
    11.  
    12. //Onjoinevent
    13. p.spigot().setCollidesWithEntities(false);
    14.  
    15. p.setCollidable(false);
    16.  
    17.  


    I hope you can help me

    Kind regards,
    FireBuster12
    Minecraft Developer
     
  2. Offline

    Smegel

  3. Offline

    MightyOne

    theoretically you could use LivinigEntity#setCollidable(false) buuuut that doesnt work so well for Players.
    If you do not need the AI of this villager just set it to false and its fine. An other alternative I heard of is adding e.g. 2 players to a score board team to prevent collision but I could not figure out how that works
     
Thread Status:
Not open for further replies.

Share This Page