Bukkit/CraftBukkit — pull request #1189 by lucasec (2013-07-06 17:48:23+00:00)
Title: Introduce comprehensive Horse API.  Adds BUKKIT-4426.

## Issue & Justification:
Minecraft 1.6.1 introduced the new Horse entity. We need to expose an API for this new entity.

## Breakdown
This PR provides an implementation for my related Bukkit PR.

Minimal NMS changes were required for this implementation:
- Variable bG (which exposes the Horse's inventory) on EntityHorse was changed to public.
- InventoryHorseChest is always initialized with an array size of 17. Normally, only Donkeys and Mules would get size 17, all others would have an array size of 2. Slots 0 and 1 represent saddle and armor. Since my API allows adding chests to any horse type, or just changing the type to a Donkey or Mule, we should always leave room for chest slots.
- ContainerHorse needed a small change to take advantage of CraftInventoryHorse

CraftBukkit implementation:
- Properly initializes horses as type CraftHorse. Allows spawning or CraftHorse through world.spawn().
- Fleshes out CraftHorse.
- Fleshes out CraftInventoryHorse.

About Horse inventories:
- Internally, the NMS class InventoryHorseChest has a deceiving name, as the inventory contains more than just the chest contents. Slot 0 is saddle, slot 1 is armor, and slots 2-16 are chest contents.
- CraftInventoryHorse exposes the chest slots as 0-14 and provides special methods to access saddle and armor.
- This keeps consistency with APIs such as PlayerInventory.
- So, calling CraftInventoryHorse.setItem(0, new ItemStack(Material.STONE)) would actually set the itemstack into slot ID 2 internally.

All those enums..:
- the Horse interface defines several enums, but to keep implementation details out of Bukkit, all the mapping of enum -> integer is done in CraftHorse. I use Guava Immutable BiDirectional maps in static members.
- Internally, a property titled "variant" exposes the Horse's appearance as an integer. http://www.minecraftwiki.net/wiki/Item_id#Horse_Variants has this covered. CraftHorse contains public members to work with this field, but these ARE NOT part of the Bukkit API. Rather, I expose access to variant through the CoatColor and CoatPattern enums.

## Testing
I've tested these additions locally using a cljminecraft (CmdrDats/clj-minecraft) REPL. A JAR containing the API can be downloaded for your testing pleasure off my Amazon S3:

### On the subject of Unit Tests:
- The CoatColor and CoatPattern enum -> int mapping really probably should have a unit test, but I'm not sure how to initialize a proper test environment necessary to create an instance of the entity. I'd be happy to work with someone to get the proper tests in place.

## Related
This PR happens to include the functionally in https://github.com/Bukkit/CraftBukkit/pull/1185, practically verbatim.

This is my first Bukkit/CraftBukkit contribution. I've taken multiple steps to ensure I've done this right. Please let me know if there is any way I can improve.