Changing Horse Attributes
up vote
0
down vote
favorite
I have been making a plugin for a "portable horse" recently and I am very close to being done, my horses spawn in and despawn as I want them. However, the only thing that I am having a considerable amount of trouble with is changing Horse attributes like speed, color, jump height and Variant.
Here is my Code:
package io.github.bxnie.events;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Donkey;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.inventory.ItemStack;
public class HorseSpawn implements Listener
@SuppressWarnings( "deprecation" )
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e)
@EventHandler
public void onPLayerDismount(VehicleExitEvent e)
if(e.getExited() instanceof Player)
if(e.getVehicle() instanceof Donkey)
Donkey donkey = (Donkey) e.getVehicle();
if(donkey.getCustomName() != null)
if(donkey.getCustomName().equals(ChatColor.GRAY + "Donkey"))
donkey.remove();
if(e.getVehicle() instanceof Horse)
Horse horse = (Horse) e.getVehicle();
if(horse.getCustomName() != null)
if(horse.getCustomName().equals(ChatColor.RED + "Horse"))
horse.remove();
if(horse.getCustomName().equals(ChatColor.DARK_GRAY + "Horse"))
horse.remove();
if(horse.getCustomName().equals(ChatColor.WHITE + "Horse"))
horse.remove();
I've done a ton of research but nothing really seems to help my case, is there any way that any of you know of to spawn in a horse with the custom attributes I mentioned above?
java plugins minecraft bukkit
add a comment |
up vote
0
down vote
favorite
I have been making a plugin for a "portable horse" recently and I am very close to being done, my horses spawn in and despawn as I want them. However, the only thing that I am having a considerable amount of trouble with is changing Horse attributes like speed, color, jump height and Variant.
Here is my Code:
package io.github.bxnie.events;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Donkey;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.inventory.ItemStack;
public class HorseSpawn implements Listener
@SuppressWarnings( "deprecation" )
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e)
@EventHandler
public void onPLayerDismount(VehicleExitEvent e)
if(e.getExited() instanceof Player)
if(e.getVehicle() instanceof Donkey)
Donkey donkey = (Donkey) e.getVehicle();
if(donkey.getCustomName() != null)
if(donkey.getCustomName().equals(ChatColor.GRAY + "Donkey"))
donkey.remove();
if(e.getVehicle() instanceof Horse)
Horse horse = (Horse) e.getVehicle();
if(horse.getCustomName() != null)
if(horse.getCustomName().equals(ChatColor.RED + "Horse"))
horse.remove();
if(horse.getCustomName().equals(ChatColor.DARK_GRAY + "Horse"))
horse.remove();
if(horse.getCustomName().equals(ChatColor.WHITE + "Horse"))
horse.remove();
I've done a ton of research but nothing really seems to help my case, is there any way that any of you know of to spawn in a horse with the custom attributes I mentioned above?
java plugins minecraft bukkit
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have been making a plugin for a "portable horse" recently and I am very close to being done, my horses spawn in and despawn as I want them. However, the only thing that I am having a considerable amount of trouble with is changing Horse attributes like speed, color, jump height and Variant.
Here is my Code:
package io.github.bxnie.events;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Donkey;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.inventory.ItemStack;
public class HorseSpawn implements Listener
@SuppressWarnings( "deprecation" )
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e)
@EventHandler
public void onPLayerDismount(VehicleExitEvent e)
if(e.getExited() instanceof Player)
if(e.getVehicle() instanceof Donkey)
Donkey donkey = (Donkey) e.getVehicle();
if(donkey.getCustomName() != null)
if(donkey.getCustomName().equals(ChatColor.GRAY + "Donkey"))
donkey.remove();
if(e.getVehicle() instanceof Horse)
Horse horse = (Horse) e.getVehicle();
if(horse.getCustomName() != null)
if(horse.getCustomName().equals(ChatColor.RED + "Horse"))
horse.remove();
if(horse.getCustomName().equals(ChatColor.DARK_GRAY + "Horse"))
horse.remove();
if(horse.getCustomName().equals(ChatColor.WHITE + "Horse"))
horse.remove();
I've done a ton of research but nothing really seems to help my case, is there any way that any of you know of to spawn in a horse with the custom attributes I mentioned above?
java plugins minecraft bukkit
I have been making a plugin for a "portable horse" recently and I am very close to being done, my horses spawn in and despawn as I want them. However, the only thing that I am having a considerable amount of trouble with is changing Horse attributes like speed, color, jump height and Variant.
Here is my Code:
package io.github.bxnie.events;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Donkey;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.inventory.ItemStack;
public class HorseSpawn implements Listener
@SuppressWarnings( "deprecation" )
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e)
@EventHandler
public void onPLayerDismount(VehicleExitEvent e)
if(e.getExited() instanceof Player)
if(e.getVehicle() instanceof Donkey)
Donkey donkey = (Donkey) e.getVehicle();
if(donkey.getCustomName() != null)
if(donkey.getCustomName().equals(ChatColor.GRAY + "Donkey"))
donkey.remove();
if(e.getVehicle() instanceof Horse)
Horse horse = (Horse) e.getVehicle();
if(horse.getCustomName() != null)
if(horse.getCustomName().equals(ChatColor.RED + "Horse"))
horse.remove();
if(horse.getCustomName().equals(ChatColor.DARK_GRAY + "Horse"))
horse.remove();
if(horse.getCustomName().equals(ChatColor.WHITE + "Horse"))
horse.remove();
I've done a ton of research but nothing really seems to help my case, is there any way that any of you know of to spawn in a horse with the custom attributes I mentioned above?
java plugins minecraft bukkit
java plugins minecraft bukkit
edited Nov 10 at 18:21
Squiddie
9671821
9671821
asked Nov 10 at 15:53
Ben Parkes
84
84
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
When you believe you've researched enough, research a little more, I searched for "bukkit change horse speed"
and one of the top answers works perfectly. With that being said, let's try to solve your issue.
Everything you need is right in the horse API, more specifically #setColor(), #setStyle(), #setJumpStrength and #setVariant(). Changing variant may not work using that method due to deprecation, instead you need to create a different entity, such as a skeletonHorse
These methods are really straightforward:
Horse horseblack = (Horse) p.getWorld().spawn(p.getLocation(), Horse.class);
horseblack.setJumpStrength(2.0);
horseblack.setColor(Color.BLACK);
SkeletonHorse skeletonHorse = (SkeletonHorse) p.getWorld().spawn(p.getLocation(), SkeletonHorse.class);
Changing speed is a little different, but the method works for any mobs.
entity.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(yourValue);
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
When you believe you've researched enough, research a little more, I searched for "bukkit change horse speed"
and one of the top answers works perfectly. With that being said, let's try to solve your issue.
Everything you need is right in the horse API, more specifically #setColor(), #setStyle(), #setJumpStrength and #setVariant(). Changing variant may not work using that method due to deprecation, instead you need to create a different entity, such as a skeletonHorse
These methods are really straightforward:
Horse horseblack = (Horse) p.getWorld().spawn(p.getLocation(), Horse.class);
horseblack.setJumpStrength(2.0);
horseblack.setColor(Color.BLACK);
SkeletonHorse skeletonHorse = (SkeletonHorse) p.getWorld().spawn(p.getLocation(), SkeletonHorse.class);
Changing speed is a little different, but the method works for any mobs.
entity.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(yourValue);
add a comment |
up vote
0
down vote
When you believe you've researched enough, research a little more, I searched for "bukkit change horse speed"
and one of the top answers works perfectly. With that being said, let's try to solve your issue.
Everything you need is right in the horse API, more specifically #setColor(), #setStyle(), #setJumpStrength and #setVariant(). Changing variant may not work using that method due to deprecation, instead you need to create a different entity, such as a skeletonHorse
These methods are really straightforward:
Horse horseblack = (Horse) p.getWorld().spawn(p.getLocation(), Horse.class);
horseblack.setJumpStrength(2.0);
horseblack.setColor(Color.BLACK);
SkeletonHorse skeletonHorse = (SkeletonHorse) p.getWorld().spawn(p.getLocation(), SkeletonHorse.class);
Changing speed is a little different, but the method works for any mobs.
entity.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(yourValue);
add a comment |
up vote
0
down vote
up vote
0
down vote
When you believe you've researched enough, research a little more, I searched for "bukkit change horse speed"
and one of the top answers works perfectly. With that being said, let's try to solve your issue.
Everything you need is right in the horse API, more specifically #setColor(), #setStyle(), #setJumpStrength and #setVariant(). Changing variant may not work using that method due to deprecation, instead you need to create a different entity, such as a skeletonHorse
These methods are really straightforward:
Horse horseblack = (Horse) p.getWorld().spawn(p.getLocation(), Horse.class);
horseblack.setJumpStrength(2.0);
horseblack.setColor(Color.BLACK);
SkeletonHorse skeletonHorse = (SkeletonHorse) p.getWorld().spawn(p.getLocation(), SkeletonHorse.class);
Changing speed is a little different, but the method works for any mobs.
entity.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(yourValue);
When you believe you've researched enough, research a little more, I searched for "bukkit change horse speed"
and one of the top answers works perfectly. With that being said, let's try to solve your issue.
Everything you need is right in the horse API, more specifically #setColor(), #setStyle(), #setJumpStrength and #setVariant(). Changing variant may not work using that method due to deprecation, instead you need to create a different entity, such as a skeletonHorse
These methods are really straightforward:
Horse horseblack = (Horse) p.getWorld().spawn(p.getLocation(), Horse.class);
horseblack.setJumpStrength(2.0);
horseblack.setColor(Color.BLACK);
SkeletonHorse skeletonHorse = (SkeletonHorse) p.getWorld().spawn(p.getLocation(), SkeletonHorse.class);
Changing speed is a little different, but the method works for any mobs.
entity.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(yourValue);
edited Nov 11 at 0:56
answered Nov 10 at 16:31
Squiddie
9671821
9671821
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240655%2fchanging-horse-attributes%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown