@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)); } } }
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); } } } }
@Override public void apply(Entity entity) { if (!(entity instanceof Horse)) return; Horse horse = (Horse)entity; horse.getInventory().setSaddle(saddle == null ? null : saddle.getItemStack(1)); horse.getInventory().setArmor(armor == null ? null : armor.getItemStack(1)); if (color != null) { horse.setColor(color); } if (style != null) { horse.setStyle(style); } if (domestication != null) { horse.setDomestication(domestication); } if (maxDomestication != null) { horse.setMaxDomestication(maxDomestication); } if (jumpStrength != null) { horse.setJumpStrength(jumpStrength); } if (tamed != null) { horse.setTamed(tamed); } }
private int getHorseArmorData() { if (getInventory().getArmor() != null) { if (getInventory().getArmor().getType() == Material.DIAMOND_BARDING) { return 3; } else if (getInventory().getArmor().getType() == Material.GOLD_BARDING) { return 2; } else if (getInventory().getArmor().getType() == Material.IRON_BARDING) { return 1; } } return 0; }
@Override public void setArmor(MCItemStack stack) { h.getInventory().setArmor(((BukkitMCItemStack) stack).asItemStack()); }
horse.setCustomName(player.getDisplayName() + "'s Fire Horse"); horse.setTamed(true); horseinv.setSaddle(saddle); int id = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new HorseTimer(horse), 0l, 5l); tasks.put(horse.getUniqueId(), id);
horse.getInventory().clear();
@Override public MCItemStack getArmor() { return new BukkitMCItemStack(h.getInventory().getArmor()); }
Material barding = bardingFromAmount(amount); if (barding != null) { ((Horse) mount).getInventory().setArmor(new ItemStack(barding));
public EntityHorseData(Horse horse) { color = horse.getColor(); style = horse.getStyle(); saddle = getItem(horse.getInventory().getSaddle()); armor = getItem(horse.getInventory().getArmor()); domestication = horse.getDomestication(); maxDomestication = horse.getMaxDomestication(); jumpStrength = horse.getJumpStrength(); tamed = horse.isTamed(); }