How can i spawn and mount a player on a Horse in Java? I tried this but the player is not able to control the horse as if he mounted manualy ingame: Code: if (e.getPlayer().getName().equals("Esquilo_Azul")) { Horse h = (Horse) e.getPlayer().getLocation().getWorld().spawnEntity(e.getPlayer().getLocation(), EntityType.HORSE); h.setCustomName("§cCavalinho do Diego"); h.setCustomNameVisible(true); h.setTamed(true); h.getInventory().setSaddle(new ItemStack(Material.SADDLE)); h.setOwner(e.getPlayer()); h.setPassenger(e.getPlayer()); }
Code: Code: ~ Horse h = (Horse) e.getPlayer().getLocation().getWorld().spawnEntity(e.getPlayer().getLocation(), EntityType.HORSE); h.setCustomName("§cCavalinho do Diego"); h.setCustomNameVisible(true); h.setTamed(true); h.getInventory().setSaddle(new ItemStack(Material.SADDLE)); h.setOwner(e.getPlayer()); h.setPassenger(e.getPlayer()); e.getPlayer().sendMessage("Chegou seu cavalinho!"); } The player spawns but it it is not controlable like if it was right clicked
@Nuno_Facha Here are some basic tests you should do : When some command is sent (command "/test123"), the player will receive messages about the entity they are riding (casting that entity to a horse). Make this command and print out if A) it is tamed, B) registers that it has a saddle on, C) is owned and, D) has a passenger. Remove first the lines that are "unnecessary" (custom names, messages) and see if that fixes anything Re-Work your code. Move lines around. Maybe the saddle show be put on before the owner is set/ the player may have to be on the horse before owner/tamed is set.