[UTIL] HorseModifier - Spawn and modify horses!

Discussion in 'Resources' started by DarkBladee12, Jul 3, 2013.

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

    DarkBladee12

    nkrecklow All values from 0 - Integer.MAX_VALUE, values below 0 would work too, but they will have the same effect as setting it to 0!
     
  2. Offline

    daylight95

    I know nothing about java. I don't know anything about plugin development either. I'm just looking for a way for me to spawn zombie and skeleton horses on my server. Your thread is what I've found but I have no idea how to use your utility.
     
  3. Offline

    kreashenz

    How about forcing players to ride a horse that gets spawned on their location? I want to add a part in my KitPvP plugin that forces them to spawn on a horse if the config says.
     
  4. Offline

    DarkBladee12

    daylight95 Well this thread only contains an util for developers which they can implement in their plugins to spawn and modify horses! If you're searching for a plugin then search for it at dev.bukkit.org!

    kreashenz You could simply spawn the horse with the util and then set the player as the passenger of the horse ("HorseModifier.spawn(LOCATION).getHorse().setPassenger(PLAYER);")

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 2, 2016
  5. Hey, this util has been very helpful for my plugin.

    I was wondering, what are the possible values for setArmorItem?
     
  6. Offline

    ShadowDog007

    AdamQpzm
    The only ones that makes sense are stacks with horse armour. 417, 418 and 419.

    Would be interesting to see what happened with other stacks though :eek:
     
  7. Offline

    DarkBladee12

    ShadowDog007 Well I tested this and came to the result that the item gets removed automatically, it isn't even showing up in the inventory of the horse! (Another thing that works is .setChested(true) on a normal horse, but the game will crash when you try to open the horse inventory :D)
     
  8. Offline

    kreashenz

    DarkBladee12 Ahh, so how are you going to be able fix that, or are we gunna have to wait?
     
  9. Offline

    DarkBladee12

    kreashenz Well you could try to fix it via InventoryOpenEvent, so you cancel it and modify it in order to prevent a crash ;) (Or did you mean that you can't used .setChested(true) on normal horses)
     
  10. Offline

    kreashenz

    DarkBladee12 Another thing I now have to fix before updating my Kreas-Kits plugin. I used your HorseModifer in it, but split up all the classes. I've tried cancelling the InventoryOpenEvent but it doesn't work (the inventory that opens when you click 'E'), any ideas?

    //Off Topic: Didn't you used to be an admin or something of the forums?
     
  11. Offline

    DarkBladee12

    kreashenz Mhh... maybe the inventory is handled client-side like a players' inventory.

    //Well no, I wasn't an admin or something like that, but I know an admin who has almost the same avatar :D
     
  12. Offline

    ShadowDog007

    No, if you check console a IndexOutOfRangeException occurs when you open the inventory of a normal horse.

    Minecraft probably has something which kicks the player, perhaps to prevent something bad from happening?
     
  13. Offline

    Ba7marker

    Well if you want to spawn the horses use my plugin i use his util @ http://dev.bukkit.org/bukkit-plugins/better-horses/
    DarkBladee12 i also gave credit: P
     
  14. I have some errors that you cant cast an object from a int , and you cant cast an object from a boolean?
     
  15. Offline

    DarkBladee12

    Datdenkikniet Hmm that should be possible normally... You can try to replace "int" with "Integer" and "boolean" with "Boolean" and see if that works, because kreashenz had a similar problem and this fixed it!
     
  16. Offline

    kreashenz

    Datdenkikniet it's because DarkBladee12 is using Java 7 or a Mac OSX version of Java. Just either upgrade it Java 7 or do what DarkBladee said.
     
  17. Offline

    Darkblader

    Hey, the Code doesn't work for me.
    I want to check, if a horse is tamed. And if it is, it cancels the event.
    Code:java
    1. @EventHandler
    2. public void HorseAttack(EntityDamageByEntityEvent e){
    3. if((e.getEntity() instanceof Horse) && (e.getDamager() instanceof Player)){
    4. HorseModifier hm = new HorseModifier(e.getEntity());
    5. if(hm.isTamed()){
    6. Bukkit.getServer().broadcastMessage("§4TAMED!");
    7. e.setCancelled(true);
    8. }else{
    9. Bukkit.getServer().broadcastMessage("§4NOT TAMED!");
    10. }
    11. }
    12. }

    If it is tamed, it should throw out a TAMED. But everytime it says NOT TAMED even if the horse is tamed. It's the same with isSattled.
    Any idea?
     
  18. Offline

    DarkBladee12

    Darkblader You can't check if an entity is a horse with "instanceof", because there's a bug which makes horses being handled as "UNKNOWN" entity type... Try to replace "e.getEntity() instanceof Horse" with "HorseModifier.isHorse(e.getEntity())"!
     
  19. Offline

    Darkblader

    I tried it, but it didn't solve the problem.
    And I think that wasn't the bug because it says that every horse is "NOT TAMED" when i hit one. Even if it is tamed. If you were right, it would say nothing.
     
  20. Offline

    Retherz_

  21. Offline

    kreashenz

    DarkBladee12 Now with the Horse API, is this still going be used? I'm casting HorseModifier to my horse so I can set better colours on it, is this going to cause errors or anything? I am hell keen to keep using this, but the horse API is out now :)
     
  22. Offline

    DarkBladee12

    kreashenz Well you can still use this, it uses nms code through reflection so it won't break ;) However this is useless now, since you can do everything that is in that class with the new Horse API!^^
     
  23. Offline

    kreashenz

    DarkBladee12 Almost everything, the colours are shit.. Only the main colours (black, white, creamy, chestnut, dark_brown, gray) and I wanted to do as I said, but instead, I ended up just commenting it out. I will nag Lolmewn to add in more colours when he gets off that damn LoL game.
     
  24. Offline

    DarkBladee12

    kreashenz Well I first thought that they only implemented the main colors, but they also implemented the special things like "White field", "Black dots" etc., you can set these with "HORSE.setStyle(Style.NAME);" ;)
     
  25. Offline

    kreashenz

    Oh, so you can .setColor and .setType and it'll set both of them..?
     
  26. Offline

    DarkBladee12

    kreashenz Yes, you do ".setColor(Color.BLACK);" and ".setStyle(Style.WHITE_DOTS);", which is the same as "BLACK_WHITE_DOTS" from HorseModifier.
     
  27. Offline

    Deleted user

    DarkBladee12
    Thanks for this...
    How do I set the owner to player?
    And it keeps coming up with errors on HorseModifier.spawn(loc);
     
  28. Offline

    DarkBladee12

    JHG0 Well this class is pretty outdated now, please use the official Horse API!
     
  29. Offline

    Deleted user

    DarkBladee12
    I am bug am seeming to have bugs...
    How do you call on the horse...edit it....then spawn it?
     
Thread Status:
Not open for further replies.

Share This Page