entity.setHealth(entity.getMaxHealth()); horse.setColor(Horse.Color.values()[Misc.getRandom().nextInt(Horse.Color.values().length)]); horse.setStyle(Horse.Style.values()[Misc.getRandom().nextInt(Horse.Style.values().length)]); horse.setJumpStrength(Math.max(AdvancedConfig.getInstance().getMinHorseJumpStrength(), Math.min(Math.min(Misc.getRandom().nextDouble(), Misc.getRandom().nextDouble()) * 2, AdvancedConfig.getInstance().getMaxHorseJumpStrength())));
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); } } } }
style = Horse.Style.valueOf(specialType.toUpperCase()); } catch (IllegalArgumentException e) {} if (style != null) {
try { String styleString = parameters.getString("mount_style"); mountHorseStyle = Horse.Style.valueOf(styleString.toUpperCase()); } catch (Exception ex) { ex.printStackTrace();
} else if (myPet instanceof MyHorse) { Horse.Variant type = Horse.Variant.values()[((MyHorse) myPet).getHorseType()]; Horse.Style style = Horse.Style.values()[(((MyHorse) myPet).getVariant() >>> 8)]; Horse.Color color = Horse.Color.values()[(((MyHorse) myPet).getVariant() & 0xFF)];
en.set("style", horse.getStyle().name());
ConfigurationSection inv = ent.getConfigurationSection(INVENTORY); inv.getKeys(false).forEach(i -> horse.getInventory().setItem(Integer.valueOf(i), (ItemStack)inv.get(i))); horse.setStyle(Horse.Style.valueOf(ent.getString("style", "NONE")));
public EntityHorseData(ConfigurationSection parameters, MageController controller) { Logger log = controller.getLogger(); if (parameters.contains("horse_color")) { try { String colorString = parameters.getString("horse_color"); color = Horse.Color.valueOf(colorString.toUpperCase()); } catch (Exception ex) { log.log(Level.WARNING, "Invalid horse_color: " + parameters.getString("horse_color"), ex); } } if (parameters.contains("horse_style")) { try { String styleString = parameters.getString("horse_style"); style = Horse.Style.valueOf(styleString.toUpperCase()); } catch (Exception ex) { log.log(Level.WARNING, "Invalid horse_style: " + parameters.getString("horse_style"), ex); } } if (parameters.contains("horse_jump_strength")) { jumpStrength = parameters.getDouble("horse_jump_strength"); } if (parameters.contains("tamed")) { tamed = parameters.getBoolean("tamed"); } saddle = controller.getOrCreateItemOrWand(parameters.getString("saddle")); armor = controller.getOrCreateItemOrWand(parameters.getString("armor")); }
public void setColor(Color color) { setData(MetaIndex.HORSE_COLOR, color.ordinal() & 0xFF | getStyle().ordinal() << 8); sendData(MetaIndex.HORSE_COLOR); }
public Style getStyle() { return Style.values()[(getData(MetaIndex.HORSE_COLOR) >>> 8)]; }
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; }
@Override public void load(GlowHorse entity, CompoundTag compound) { super.load(entity, compound); compound.readBoolean("EatingHaystack", entity::setEatingHay); compound.readInt("Variant", variant -> { entity.setStyle(Horse.Style.values()[variant >>> 8]); entity.setColor(Horse.Color.values()[variant & 0xFF]); }); compound.readInt("Temper", entity::setTemper); compound.readItem("ArmorItem", entity.getInventory()::setArmor); compound.readItem("SaddleItem", entity.getInventory()::setSaddle); }