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?










share|improve this question



























    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?










    share|improve this question

























      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?










      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 10 at 18:21









      Squiddie

      9671821




      9671821










      asked Nov 10 at 15:53









      Ben Parkes

      84




      84






















          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);





          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            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

























            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);





            share|improve this answer


























              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);





              share|improve this answer
























                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);





                share|improve this answer














                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);






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 11 at 0:56

























                answered Nov 10 at 16:31









                Squiddie

                9671821




                9671821



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Top Tejano songwriter Luis Silva dead of heart attack at 64

                    政党

                    天津地下鉄3号線