Horse Mount

Discussion in 'Plugin Development' started by Cypthon, Aug 13, 2015.

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

    Cypthon

    I made a horse mount and whenever I click the apple to spawn it, it doesn't do anything.
    Code:
    public class mount extends JavaPlugin implements Listener {
        public void onEnable() {
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
        }
        @EventHandler
        public void onPlayerUse(PlayerInteractEvent event) {
            Player player = event.getPlayer();
            if (player.isInsideVehicle())
            if (player.getItemInHand().getType().equals(Material.APPLE)) {
                Horse h = (Horse) player.getWorld().spawnEntity(player.getLocation(), EntityType.HORSE);
                h.setTamed(true);
                h.setAdult();
                h.setVariant(Horse.Variant.SKELETON_HORSE);
                h.getInventory().setSaddle(new ItemStack(Material.SADDLE, 1));
                h.setPassenger(player);
            }
        }
    }
     
  2. Offline

    CoolDude53

    Well, you are only executing your code to create the mount if the player is inside a vehicle...I'd reckon that's your problem.
     
  3. Offline

    Agentleader1

    Put a "return;" underneath your first Boolean. Also I'd recommend you check if the player's hand isn't null first before checking the item's material type, otherwise errors appear when you interact with air in your hand.
     
Thread Status:
Not open for further replies.

Share This Page