@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); } }
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(); }
HorseInventory horseinv = null; ItemStack saddle = new ItemStack(Material.SADDLE); horse.setVariant(Variant.SKELETON_HORSE); 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); }else{ player.sendMessage(ChatColor.RED + "Usage: /firehorse");
public void onVehicleEnter(VehicleEnterEvent event) { Entity entity = event.getEntered(); if (!(entity instanceof Player)) return; Player p = (Player) entity; if (!arena.inArena(p)) return; Vehicle vehicle = event.getVehicle(); if (!(vehicle instanceof Horse)) return; Horse horse = (Horse) vehicle; if (!monsters.hasMount(horse)) return; AnimalTamer tamer = horse.getOwner(); if (tamer.equals(p)) { horse.setAI(true); } else { event.setCancelled(true); } }
Horse horse = (Horse)entity; Color color = horse.getColor(); Color[] colorValues = Color.values(); color = colorValues[(color.ordinal() + 1) % colorValues.length]; Style horseStyle = horse.getStyle(); Style[] styleValues = Style.values(); horseStyle = styleValues[(horseStyle.ordinal() + 1) % styleValues.length]; horse.setStyle(horseStyle); horse.setColor(color); break; case OCELOT:
horse.setTamed(true); horse.setOwner(player); horse.setAdult(); horse.setStyle(mountHorseStyle); horse.setColor(mountHorseColor); horse.getInventory().setSaddle(new ItemStack(Material.SADDLE, 1)); if (mountItem != null) { horse.getInventory().setArmor(new ItemStack(mountItem, 1)); horse.setBaby();
Horse.Color color = Horse.Color.values()[(((MyHorse) myPet).getVariant() & 0xFF)]; ((Horse) normalEntity).setVariant(type); ((Horse) normalEntity).setColor(color); ((Horse) normalEntity).setStyle(style); ((Horse) normalEntity).setCarryingChest(((MyHorse) myPet).hasChest()); ((Horse) normalEntity).getInventory().setSaddle(((MyHorse) myPet).getSaddle().clone()); ((Horse) normalEntity).getInventory().setArmor(((MyHorse) myPet).getArmor().clone()); ((Horse) normalEntity).setOwner(myPet.getOwner().getPlayer());
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 MCItemStack getArmor() { return new BukkitMCItemStack(h.getInventory().getArmor()); }
horse.setDomestication(ent.getInt("domestication")); 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")));
} catch (IllegalArgumentException e) {} if (color != null) { ((Horse) creature).setColor(color); continue; } catch (IllegalArgumentException e) {} if (style != null) { ((Horse) creature).setStyle(style); continue; } catch (IllegalArgumentException e) {} if (variant != null) { ((Horse) creature).setVariant(variant); continue;
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())));
try { MCHorse.MCHorseColor hcolor = MCHorse.MCHorseColor.valueOf(type); h.setColor(BukkitMCHorse.BukkitMCHorseColor.getConvertor().getConcreteEnum(hcolor)); continue; } catch (IllegalArgumentException ex) { h.setStyle(BukkitMCHorse.BukkitMCHorsePattern.getConvertor().getConcreteEnum(hpattern)); } catch (IllegalArgumentException notAnything) { throw new CREFormatException("Type " + type + " did not match any horse variants,"
@Override public void setPattern(MCHorsePattern pattern) { h.setStyle(BukkitMCHorsePattern.getConvertor().getConcreteEnum(pattern)); }
@Override public void setColor(MCHorseColor color) { h.setColor(BukkitMCHorseColor.getConvertor().getConcreteEnum(color)); }
@Override public MCHorsePattern getPattern() { return BukkitMCHorsePattern.getConvertor().getAbstractedEnum(h.getStyle()); }
@Override public MCHorseColor getColor() { return BukkitMCHorseColor.getConvertor().getAbstractedEnum(h.getColor()); }
return; } else if (holder instanceof Horse) { if (event.getPlayer().equals(((Horse) holder).getOwner())) { return; } else { location = ((Horse) holder).getLocation();
Horse horse = (Horse)entity; Horse.Color color = horse.getColor(); Horse.Color[] colorValues = Horse.Color.values(); color = colorValues[(color.ordinal() + 1) % colorValues.length]; Horse.Style horseStyle = horse.getStyle(); Horse.Style[] styleValues = Horse.Style.values(); horseStyle = styleValues[(horseStyle.ordinal() + 1) % styleValues.length]; horse.setStyle(horseStyle); horse.setColor(color); break; case OCELOT:
@Override public void setArmor(MCItemStack stack) { h.getInventory().setArmor(((BukkitMCItemStack) stack).asItemStack()); }