Solved 1.11 horse inventory not accessible from variants

Discussion in 'Spigot Plugin Development' started by PappaProntaTeam, Nov 21, 2016.

  1. Hi, I want to try my plugin that manage horses to 1.11, but I can't find a way to put saddle and armor on all of the implementations of AbstractHorse. Only the Horse class has a method to access the HorseInventory for the entity, for all other variants I can't figure it out.
  2. Choco


    Well AbstractHorse implements InventoryHolder, and it even overrides the #getInventory() method. There's no reason to not be able to get the inventory from any of the variants. Call the #getInventory() method and cast it to HorseInventory
  3. Nope, #getInventory() method returns an Inventory with InventoryType Chest. Even with a normal Horse you can't access his saddle and armor inventory trough InventoryHolder getInventory(), you must use the getInventory() override in Horse class...
    • Informative Informative x 1
  4. For everyone who is interested, right now you can't cast #getInventory() Inventory to HorseInventory. So to give AbstractHorse implementations that are not an instance of Horse saddle and armor you might simply set items in inventory slot 0 (saddle) and 1 (armor), or you can try to cast to CraftAbstractHorse.
    • Like Like x 1
    • Informative Informative x 1
  5. This is very helpful, and if they don't want to have AbstractHorse extend HorseInventory, they should add your documentation to the javadocs.

    Not sure why they did not make getInventory return a HorseInventory in AbstractHorse...
    #5 RoboMWM, Mar 1, 2017
    Last edited: Mar 2, 2017