public void convertHorse(Horse horse, TagCompound properties) { byte type = (byte) horse.getVariant().ordinal(); int style = horse.getStyle().ordinal(); int color = horse.getColor().ordinal(); int variant = color & 255 | style << 8; if (horse.getInventory().getArmor() != null) { TagCompound armor = MyPetApi.getPlatformHelper().itemStackToCompund(horse.getInventory().getArmor()); properties.getCompoundData().put("Armor", armor); } if (horse.getInventory().getSaddle() != null) { TagCompound saddle = MyPetApi.getPlatformHelper().itemStackToCompund(horse.getInventory().getSaddle()); properties.getCompoundData().put("Saddle", saddle); } properties.getCompoundData().put("Type", new TagByte(type)); properties.getCompoundData().put("Variant", new TagInt(variant)); properties.getCompoundData().put("Chest", new TagByte(horse.isCarryingChest())); properties.getCompoundData().put("Age", new TagInt(horse.getAge())); if (horse.isCarryingChest()) { ItemStack[] contents = horse.getInventory().getContents(); for (int i = 2; i < contents.length; i++) { ItemStack item = contents[i]; if (item != null) { horse.getWorld().dropItem(horse.getLocation(), item); } } } }
horseStyle = styleValues[(horseStyle.ordinal() + 1) % styleValues.length];
horseStyle = styleValues[(horseStyle.ordinal() + 1) % styleValues.length];
public void setColor(Color color) { setData(MetaIndex.HORSE_COLOR, color.ordinal() & 0xFF | getStyle().ordinal() << 8); sendData(MetaIndex.HORSE_COLOR); }
public void setStyle(Style style) { setData(MetaIndex.HORSE_COLOR, getColor().ordinal() & 0xFF | style.ordinal() << 8); sendData(MetaIndex.HORSE_COLOR); }
@Override public void save(GlowHorse entity, CompoundTag tag) { super.save(entity, tag); tag.putBool("EatingHaystack", entity.isEatingHay()); tag.putInt("Variant", entity.getStyle().ordinal() << 8 | entity.getColor().ordinal() & 0xFF); tag.putInt("Temper", entity.getTemper()); if (entity.getInventory().getArmor() != null) { tag.putCompound("ArmorItem", NbtSerialization.writeItem(entity.getInventory().getArmor(), -1)); } if (entity.getInventory().getSaddle() != null) { tag.putCompound("SaddleItem", NbtSerialization.writeItem(entity.getInventory().getSaddle(), -1)); } } }
private int getHorseStyleData() { return color.ordinal() & 0xFF | style.ordinal() << 8; }