Stop animal from sitting when clicked.

Discussion in 'Plugin Development' started by AwesomelyToad, Dec 13, 2018.

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

    AwesomelyToad

    I would love some help stopping a tamed critter from sitting when right clicked! I have tried running:
    ((Sittable) MY ENTITY).setSitting(false);
    when the animal is clicked but it still sits down. Is there a way to cancel the vanilla event of sitting when clicked?

    I would also love some help with item durabilities + crafting.
     
  2. Offline

    torpkev

  3. Offline

    AwesomelyToad

    I have removed lots of stuff from the code just to trim it down to the part I need help with. Hope that's ok.
    Code:
    public class This extends JavaPlugin implements Listener{
      
        @Override
        public void onEnable(){
            getServer().getPluginManager().registerEvents(this, this);
    
        }
      
        @EventHandler
        public void onPlayerInteract(PlayerInteractAtEntityEvent event) {
            if (event.getRightClicked().getType().equals(EntityType.WOLF)){
              
                Entity wolf = event.getRightClicked();
                ((Sittable) wolf).setSitting(false);
                  
            }
    }
    }
    I think I've fixed it :) Solution being that instead of setting it to (Sittable), I needed to set it to (Wolf).
    Like :
    Entity wolf = event.getRightClicked();
    Wolf wolfsit = (Wolf)wolf;

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Dec 14, 2018
Thread Status:
Not open for further replies.

Share This Page