Java 类org.bukkit.entity.Wolf 实例源码

项目:ExilePearl    文件:EntityCombustEventWrapper.java   
/**
 * Gets the damager or indirect damager from any projectile.
 * @return The damager player
 */
public Player getPlayerDamager() {
    Player damager = null;
    if (event.getCombuster() instanceof Player) {
        damager = (Player) event.getCombuster();
    } else if (event.getCombuster() instanceof Wolf) {
        Wolf wolf = (Wolf) event.getCombuster();
        if (wolf.getOwner() instanceof Player) {
            damager = (Player) wolf.getOwner();
        }
    } else if (event.getCombuster() instanceof Projectile) {
        Projectile projectile = (Projectile) event.getCombuster();
        if (projectile.getShooter() instanceof Player) {
            damager = (Player) projectile.getShooter();
        }
    }
    return damager;
}
项目:ExilePearl    文件:EntityDamageEventWrapper.java   
/**
 * Gets the damager or indirect damager from any projectile.
 * @return The damager player
 */
public Player getPlayerDamager() {
    Player damager = null;
    if (event.getDamager() instanceof Player) {
        damager = (Player) event.getDamager();
    } else if (event.getDamager() instanceof Wolf) {
        Wolf wolf = (Wolf) event.getDamager();
        if (wolf.getOwner() instanceof Player) {
            damager = (Player) wolf.getOwner();
        }
    } else if (event.getDamager() instanceof Projectile) {
        Projectile projectile = (Projectile) event.getDamager();
        if (projectile.getShooter() instanceof Player) {
            damager = (Player) projectile.getShooter();
        }
    }
    return damager;
}
项目:ExilePearl    文件:CoreDamageLoggerTest.java   
@SuppressWarnings("deprecation")
@Test
public void testWolfDamage() {
    dut.start();

    List<Player> damagers = dut.getSortedDamagers(player);
    assertEquals(0, damagers.size());

    Wolf wolf = mock(Wolf.class);

    EntityDamageByEntityEvent damageEvent = new EntityDamageByEntityEvent(wolf, player, null, 5);
    dut.onEntityDamageByEntity(damageEvent);
    damagers = dut.getSortedDamagers(player);
    assertEquals(0, damagers.size());

    when(wolf.getOwner()).thenReturn(d1);
    dut.onEntityDamageByEntity(damageEvent);
    damagers = dut.getSortedDamagers(player);
    assertEquals(1, damagers.size());
    assertEquals(d1, damagers.get(0));
}
项目:buildinggame    文件:ColorSelectionMenu.java   
/**
 * Constructs a new Gui
 *
 * @param entity the entity to change the color of
 */
public ColorSelectionMenu(Creature entity) {
    super(null, 18, ChatColor.GREEN + "Select a color", 1);

    for (DyeColor dyeColor : DyeColor.values())
        addItem(new Wool(dyeColor).toItemStack(1), event -> {
            if (entity instanceof Colorable)
                ((Colorable) entity).setColor(dyeColor);
            else if (entity instanceof Wolf) {
                Wolf wolf = (Wolf) entity;

                wolf.setTamed(true);
                wolf.setCollarColor(dyeColor);
            }

            event.setCancelled(true);
        });
}
项目:PetMaster    文件:PlayerInteractListener.java   
/**
 * Frees a pet; it will no longer be tamed.
 * 
 * @param event
 * @param oldOwner
 */
private void freePet(PlayerInteractEntityEvent event, AnimalTamer oldOwner) {
    if (chargePrice(event.getPlayer(), freePetPrice)) {
        Tameable tameableAnimal = (Tameable) event.getRightClicked();
        // Free pet.
        tameableAnimal.setTamed(false);
        // Make freed pet stand up.
        if (version >= 12 && tameableAnimal instanceof Sittable) {
            ((Sittable) tameableAnimal).setSitting(false);
        } else if (tameableAnimal instanceof Wolf) {
            ((Wolf) tameableAnimal).setSitting(false);
        } else if (tameableAnimal instanceof Ocelot) {
            ((Ocelot) tameableAnimal).setSitting(false);
        }

        event.getPlayer().sendMessage(plugin.getChatHeader()
                + plugin.getPluginLang().getString("pet-freed", "Say goodbye: this pet returned to the wild!"));

        // Create new event to allow other plugins to be aware of the freeing.
        PlayerChangeAnimalOwnershipEvent playerChangeAnimalOwnershipEvent = new PlayerChangeAnimalOwnershipEvent(
                oldOwner, null, tameableAnimal);
        Bukkit.getServer().getPluginManager().callEvent(playerChangeAnimalOwnershipEvent);
    }
}
项目:McMMOPlus    文件:CombatUtils.java   
private static void processTamingCombat(LivingEntity target, Player master, Wolf wolf, EntityDamageByEntityEvent event) {
    double initialDamage = event.getDamage();
    double finalDamage = initialDamage;

    McMMOPlayer mcMMOPlayer = UserManager.getPlayer(master);
    TamingManager tamingManager = mcMMOPlayer.getTamingManager();

    if (tamingManager.canUseFastFoodService()) {
        tamingManager.fastFoodService(wolf, event.getDamage());
    }

    if (tamingManager.canUseSharpenedClaws()) {
        finalDamage += tamingManager.sharpenedClaws();
    }

    if (tamingManager.canUseGore()) {
        finalDamage += tamingManager.gore(target, initialDamage);
    }

    applyScaledModifiers(initialDamage, finalDamage, event);
    startGainXp(mcMMOPlayer, target, SkillType.TAMING);
}
项目:Skript    文件:WolfData.java   
@Override
    public void set(final Wolf entity) {
        if (angry != 0)
            entity.setAngry(angry == 1);
        if (tamed != 0)
            entity.setTamed(tamed == 1);
//      if (owner != null) {
//          if (owner.isEmpty())
//              entity.setOwner(null);
//          else
//              entity.setOwner(Bukkit.getOfflinePlayer(owner));
//      }
    }
项目:world-of-icerealm    文件:MansBestFriendPerk.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onTamedWolfDamage(EntityDamageEvent evt) {
    if (evt.getEntity() instanceof Wolf) {
        Wolf wolf = (Wolf)evt.getEntity();

        if (wolf.isTamed()) {
            evt.setDamage(evt.getDamage() / 2);
        }
    }
}
项目:world-of-icerealm    文件:MansBestFriendPerk.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onTamedWolfAttack(EntityDamageByEntityEvent evt) {
    if (evt.getDamager() instanceof Wolf) {
        Wolf wolf = (Wolf)evt.getDamager();

        if (wolf.isTamed()) {
            evt.setDamage(evt.getDamage() * 2);
        }
    }
}
项目:WolfCommand    文件:WolfPlayer.java   
/**
 * Commands player's wolves to sit down
 * @return
 */
public int sitWolves() {
    int count = 0;
    for (Wolf w : this.getWolves()) {
        if (!w.isSitting()) {
            w.setSitting(true);
            count++;
        }
    }
    return count;
}
项目:WolfCommand    文件:WolfPlayer.java   
/**
 * Commands player's wolves to stand up
 * @return
 */
public int standWolves() {
    int count = 0;
    for (Wolf w : this.getWolves()) {
        if (w.isSitting()) {
            w.setSitting(false);
            count++;
        }
    }
    return count;
}
项目:WolfCommand    文件:WolfPlayer.java   
/**
 * Gets player's tamed wolves
 * @return
 */
public List<Wolf> getWolves() {
    List<Wolf> entities = new ArrayList<Wolf>();
    for (Entity e : player.getNearbyEntities(ATTACK_RANGE, ATTACK_RANGE, ATTACK_RANGE)) {
        if (e instanceof Wolf && e instanceof Tameable) {
            Tameable t = (Tameable) e;
            if (t.isTamed() && t.getOwner() == this.player) {
                entities.add((Wolf) e);
            }
        }
    }
    return entities;
}
项目:WolfCommand    文件:WolfPlayer.java   
/**
 * Sets player's wolves target
 * @param target 
 */
public void setTarget(LivingEntity target) {
    for (Wolf w : this.getWolves()) {
        if (!w.isSitting()) {
            w.setTarget(target);
        }
    }
}
项目:BukkitLib    文件:Utilities.java   
/**
 * Play heart particles at the given location.
 * <p>
 * <i>Implementation note:</i> This method accomplishes the desired behavior by spawning a wolf, playing the {@linkplain EntityEffect#WOLF_HEARTS wolf heart} effect, and removing the wolf.
 * Event handlers at the highest priority level are registered that will uncancel the spawn of this wolf.
 * </p>
 * @param location The location at which to play the heart effect.
 */
public static void playHeartEffect(@Nonnull Location location){
    Validate.notNull(location, "The location of the effect must not be null.");
    Validate.notNull(location.getWorld(), "The location must not have a null world.");

    _eventListener.getWolfSpawnLocSet().add(location);
    Wolf o = location.getWorld().spawn(location, Wolf.class);
    o.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, (int) Constants.TICKS_PER_MINUTE, 0));
    o.playEffect(EntityEffect.WOLF_HEARTS);
    o.remove();
}
项目:DDCustomPlugin    文件:Chat.java   
public void playWolfHearts(Location loc) {
    World world = loc.getWorld();
    Wolf wo = (Wolf) world.spawn(loc, Wolf.class);
    wo.remove();
    net.minecraft.server.v1_6_R3.World nmsWorld = ((CraftWorld) world).getHandle();
    net.minecraft.server.v1_6_R3.EntityWolf nmsWolf = (EntityWolf) ((CraftEntity) wo).getHandle();
    nmsWorld.broadcastEntityEffect(nmsWolf, (byte) 7);
}
项目:McMMOPlus    文件:TamingManager.java   
/**
 * Apply the Fast Food Service ability.
 *
 * @param wolf The wolf using the ability
 * @param damage The damage being absorbed by the wolf
 */
public void fastFoodService(Wolf wolf, double damage) {
    if (!SkillUtils.activationSuccessful(SecondaryAbility.FAST_FOOD, getPlayer(), Taming.fastFoodServiceActivationChance, activationChance)) {
        return;
    }

    double health = wolf.getHealth();
    double maxHealth = wolf.getMaxHealth();

    if (health < maxHealth) {
        double newHealth = health + damage;
        wolf.setHealth(Math.min(newHealth, maxHealth));
    }
}
项目:McMMOPlus    文件:TamingManager.java   
public void processEnvironmentallyAware(Wolf wolf, double damage) {
    if (damage > wolf.getHealth()) {
        return;
    }

    Player owner = getPlayer();

    wolf.teleport(owner);
    owner.sendMessage(LocaleLoader.getString("Taming.Listener.Wolf"));
}
项目:modules-extra    文件:ListenerPlayerEntity.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event)
{
    if (!(event.getRightClicked() instanceof LivingEntity))
    {
        return;
    }
    Player player = event.getPlayer();
    Entity entity = event.getRightClicked();
    ActionPlayerEntity action;
    if (player.getItemInHand().getType() == COAL && entity instanceof PoweredMinecart)
    {
        action = this.newAction(UseFurnaceMinecart.class, entity.getWorld());
    }
    else if (player.getItemInHand().getType() == INK_SACK && entity instanceof Sheep || entity instanceof Wolf)
    {
        action = this.newAction(EntityDye.class, entity.getWorld());
        if (action != null)
        {
            ((EntityDye)action).setColor(((Dye)player.getItemInHand().getData()).getColor());
        }
    }
    else if (player.getItemInHand().getType().equals(BOWL) && entity instanceof MushroomCow)
    {
        action = this.newAction(EntityFillSoup.class, entity.getWorld());
    }
    else
    {
        return;
    }
    if (action != null)
    {
        action.setEntity(entity);
        action.setPlayer(player);
        action.setLocation(entity.getLocation());
        this.logAction(action);
    }
}
项目:sensibletoolbox    文件:PaintBrush.java   
@Override
public void onInteractEntity(PlayerInteractEntityEvent event) {
    event.setCancelled(true);
    if (getPaintLevel() <= 0) {
        return;
    }
    Entity e = event.getRightClicked();
    int paintUsed = 0;
    if (e instanceof Colorable) {
        ((Colorable) e).setColor(getColour());
        paintUsed = 1;
    } else if (e instanceof Painting) {
        Art a = ((Painting) e).getArt();
        if (getPaintLevel() >= a.getBlockHeight() * a.getBlockWidth()) {
            IconMenu menu = buildMenu((Painting) e);
            menu.open(event.getPlayer());
        } else {
            Location loc = e.getLocation().add(0, -a.getBlockHeight() / 2.0, 0);
            PopupMessage.quickMessage(event.getPlayer(), loc, ChatColor.RED + "Not enough paint!");
        }
    } else if (e instanceof Wolf) {
        Wolf wolf = (Wolf) e;
        wolf.setCollarColor(getColour());
        paintUsed = 1;
    }

    if (paintUsed > 0) {
        setPaintLevel(getPaintLevel() - paintUsed);
        event.getPlayer().setItemInHand(toItemStack());
        event.getPlayer().playSound(e.getLocation(), Sound.WATER, 1.0f, 1.5f);
    }
}
项目:ce    文件:BeastmastersBow.java   
@Override
    public boolean effect(Event event, Player player) {
//        List<String> lore = e.getBow().getItemMeta().getLore();
//        if(!lore.contains(placeHolder)) {
//            for(int i = descriptionSize; i != 0; i--)
//                lore.remove(i);
//            e.getProjectile().setMetadata("ce." + this.getOriginalName(), new FixedMetadataValue(main, writeType(lore)));
//            player.setMetadata("ce.CanUnleashBeasts", null);
//        } else
//            e.getProjectile().setMetadata("ce." + this.getOriginalName(), null);
          if(event instanceof EntityDamageByEntityEvent) {
          EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
          if(e.getDamager() != player)
              return false;
          Entity ent = e.getEntity();
          Location loc = ent.getLocation();
          World w = ent.getWorld();
            if(ent instanceof Silverfish || ent instanceof EnderDragon || ent instanceof Spider || ent instanceof Slime || ent instanceof Ghast || ent instanceof MagmaCube || ent instanceof CaveSpider || (ent instanceof Wolf && ((Wolf) ent).isAngry()) || ent instanceof PigZombie) {
                    e.setDamage(e.getDamage()*DamageMultiplication);
                    w.playEffect(loc, Effect.SMOKE, 50);
                    w.playEffect(loc, Effect.MOBSPAWNER_FLAMES, 50);
                    EffectManager.playSound(loc, "BLOCK_PISTON_RETRACT", 1.3f, 3f);
                return true;
            } else if (ent instanceof Player) {
                for(int i = 0; i < MaximumMobs; i++) {
                    if(rand.nextInt(100) < MobAppearanceChance) {
                        w.spawnEntity(loc, rand.nextInt(2) == 1 ? EntityType.SPIDER : EntityType.SLIME);
                        w.playEffect(loc, Effect.MOBSPAWNER_FLAMES, 30);
                        w.playEffect(loc, Effect.SMOKE, 30);
                        EffectManager.playSound(loc, "BLOCK_ANVIL_BREAK", 0.3f, 0.1f);
                    }
                }
            }
        }
          return false;
    }
项目:NucleusFramework    文件:WolfAnimal.java   
public WolfAnimal(Entity entity) {
    PreCon.notNull(entity);
    PreCon.isValid(entity instanceof Wolf, "org.bukkit.entity.Wolf expected.");

    Wolf wolf = (Wolf)entity;

    _isAngry = wolf.isAngry();
    _collar = wolf.getCollarColor();
    _isSitting = wolf.isSitting();
}
项目:NucleusFramework    文件:WolfAnimal.java   
@Override
public boolean apply(Entity entity) {
    PreCon.notNull(entity);
    PreCon.isValid(entity instanceof Wolf, "org.bukkit.entity.Wolf expected.");

    Wolf wolf = (Wolf)entity;

    wolf.setSitting(_isSitting);
    wolf.setAngry(_isAngry);
    wolf.setCollarColor(_collar);

    return true;
}
项目:RodsTwo    文件:Companion.java   
@Override
public boolean run(Player player, ConfigurationSection config) {
    for (int i = 0; i < config.getInt("number_to_spawn"); i++) {
        Wolf wolf = player.getWorld().spawn(player.getLocation(), Wolf.class);
        wolf.setTamed(true);
        wolf.setHealth(config.getInt("health_per_companion"));
        wolf.setOwner(player);
        wolf.setCustomName(player.getName());
        wolf.setCustomNameVisible(true);
    }
    return true;
}
项目:Skript    文件:WolfData.java   
@Override
protected boolean init(final @Nullable Class<? extends Wolf> c, final @Nullable Wolf e) {
    angry = e == null ? 0 : e.isAngry() ? 1 : -1;
    tamed = e == null ? 0 : e.isTamed() ? 1 : -1;
    return true;
}
项目:Skript    文件:WolfData.java   
@Override
    public boolean match(final Wolf entity) {
        return (angry == 0 || entity.isAngry() == (angry == 1)) && (tamed == 0 || entity.isTamed() == (tamed == 1));
//              && (owner == null || owner.isEmpty() && entity.getOwner() == null || entity.getOwner() != null && entity.getOwner().getName().equalsIgnoreCase(owner));
    }
项目:Skript    文件:WolfData.java   
@Override
public Class<Wolf> getType() {
    return Wolf.class;
}
项目:SonarPet    文件:EntityWolfPet.java   
@Override
public Wolf getBukkitEntity() {
    return (Wolf) super.getBukkitEntity();
}
项目:CanaryBukkit    文件:CanaryWolf.java   
public CanaryWolf(net.canarymod.api.entity.living.animal.Wolf entity) {
    super(entity);
}
项目:CanaryBukkit    文件:CanaryWolf.java   
@Override
protected net.canarymod.api.entity.living.animal.Wolf getHandle() {
    return (net.canarymod.api.entity.living.animal.Wolf) super.getHandle();
}
项目:SimpleEgg    文件:LorePacker.java   
/**
 * Assembles an ArrayList of the properties for the specified Entity that
 * is to be used for a spawn egg. All instanceof checks are done internally
 * by the LorePackager, so no type checking is required prior to calling
 * this method. Null Entities will throw an IllegalArgumentException. <b>The
 * actual ArrayList is returned by {@link #getLore() LorePacker.getLore()}.
 * </b>
 * @param livingEntity - The Entity to assemble a lore for.
 * @return An ArrayList of Strings
 * @throws IllegalArgumentException If entity parameter is null
 */
public LorePacker(LivingEntity livingEntity) throws IllegalArgumentException {
    if (livingEntity == null) {
        throw new IllegalArgumentException("Can't assemble lore for a null entity!");
    }

    lore = new ArrayList<String>();
    // This needs to always be on top of an egg's lore
    lore.add("Identifier: SimpleEgg." + livingEntity.getType().getEntityClass().getSimpleName() + "." + Main.getSelf().getDescription().getVersion());
    lore.addAll(livingEntity(livingEntity));

    if (livingEntity instanceof Ageable) {
        lore.addAll(ageable((Ageable) livingEntity));

        if (livingEntity instanceof Sheep) {
            lore.addAll(sheep((Sheep) livingEntity));
        } else if (livingEntity instanceof Pig) {
            lore.addAll(pig((Pig) livingEntity));
        } else if (livingEntity instanceof Rabbit) {
            lore.addAll(rabbit((Rabbit) livingEntity));
        } else if (livingEntity instanceof Villager) {
            lore.addAll(villager((Villager) livingEntity));
        } else if (livingEntity instanceof Tameable) {
            lore.addAll(tameable((Tameable) livingEntity));

            if (livingEntity instanceof AbstractHorse) {
                lore.addAll(abstractHorse((AbstractHorse) livingEntity));

                if (livingEntity instanceof Horse) {
                    lore.addAll(horse((Horse) livingEntity));
                } else if (livingEntity instanceof ChestedHorse) {
                    lore.addAll(chestedHorse((ChestedHorse) livingEntity));

                    if (livingEntity instanceof Llama) {
                        lore.addAll(llama((Llama) livingEntity));
                    }
                }
            } else if (livingEntity instanceof Sittable) {
                lore.addAll(sittable((Sittable) livingEntity));

                if (livingEntity instanceof Wolf) {
                    lore.addAll(wolf((Wolf) livingEntity));
                } else if (livingEntity instanceof Ocelot) {
                    lore.addAll(ocelot((Ocelot) livingEntity));
                } else if (livingEntity instanceof Parrot) {
                    lore.addAll(parrot((Parrot) livingEntity));
                }
            }
        }
    } else if (livingEntity instanceof Slime) {
        lore.addAll(slime((Slime) livingEntity));
    } else if (livingEntity instanceof Creeper) {
        lore.addAll(creeper((Creeper) livingEntity));
    } else if (livingEntity instanceof Zombie) {
        lore.addAll(zombie((Zombie) livingEntity));

        if (livingEntity instanceof PigZombie) {
            lore.addAll(pigZombie((PigZombie) livingEntity));
        } else if (livingEntity instanceof ZombieVillager) {
            lore.addAll(zombieVillager((ZombieVillager) livingEntity));
        }
    } else if (livingEntity instanceof Spellcaster) {
        lore.addAll(spellCaster((Spellcaster) livingEntity));
    } else if (livingEntity instanceof IronGolem) {
        lore.addAll(ironGolem((IronGolem) livingEntity));
    } else if (livingEntity instanceof Snowman) {
        lore.addAll(snowman((Snowman) livingEntity));
    }
}
项目:AncientGates    文件:EntityUtil.java   
public static String getEntityTypeData(final Entity entity) {
    String data = "";

    if (entity instanceof LivingEntity) {
        data += String.valueOf(((LivingEntity) entity).getHealth()) + ",";
        data += String.valueOf(((LivingEntity) entity).getMaxHealth()) + ",";
        data += String.valueOf(((LivingEntity) entity).getCustomName()) + ",";
        if (entity instanceof Animals) {
            data += String.valueOf(((Animals) entity).getAge()) + ",";
            if (entity instanceof Sheep) {
                data += String.valueOf(((Sheep) entity).isSheared()) + ",";
                data += ((Sheep) entity).getColor().name() + ",";
            } else if (entity instanceof Wolf) {
                data += String.valueOf(((Wolf) entity).isAngry()) + ",";
                if (((Wolf) entity).isTamed()) {
                    data += ((Tameable) entity).getOwner().getName() + ",";
                    data += String.valueOf(((Wolf) entity).getCollarColor()) + ",";
                }
            } else if (entity instanceof Ocelot) {
                if (((Ocelot) entity).isTamed()) {
                    data += ((Tameable) entity).getOwner().getName() + ",";
                    data += String.valueOf(((Ocelot) entity).getCatType().name()) + ",";
                }
            } else if (entity instanceof Pig) {
                data += String.valueOf(((Pig) entity).hasSaddle()) + ",";
            } else if (entity instanceof Horse) {
                data += "deprecated" + ",";
                data += String.valueOf(((Horse) entity).getStyle().name()) + ",";
                data += String.valueOf(((Horse) entity).getColor().name()) + ",";
                data += String.valueOf(((Horse) entity).getDomestication()) + ",";
                data += String.valueOf(((Horse) entity).getMaxDomestication()) + ",";
                data += String.valueOf(((Horse) entity).getJumpStrength()) + ",";
                if (((Horse) entity).isTamed()) {
                    data += (((Tameable) entity).getOwner() != null ? ((Tameable) entity).getOwner().getName() : null) + ",";
                    data += ItemStackUtil.itemStackToString(((Horse) entity).getInventory().getSaddle()) + ",";
                    data += ItemStackUtil.itemStackToString(((Horse) entity).getInventory().getArmor()) + ",";
                    if (((Horse) entity).isCarryingChest()) {
                        data += ItemStackUtil.itemStackToString(((Horse) entity).getInventory().getContents()) + ",";
                    }
                }
            }
        } else if (entity instanceof Villager) {
            data += String.valueOf(((Villager) entity).getProfession().name()) + ",";
            data += String.valueOf(((Villager) entity).getAge()) + ",";
        } else if (entity instanceof Creeper) {
            data += String.valueOf(((Creeper) entity).isPowered()) + ",";
        } else if (entity instanceof Slime) {
            data += String.valueOf(((Slime) entity).getSize()) + ",";
        } else if (entity instanceof Skeleton) {
            data += String.valueOf(((Skeleton) entity).getSkeletonType().name()) + ",";
        }
    }

    return data;
}
项目:AncientGates    文件:EntityUtil.java   
public static void setEntityTypeData(final Entity entity, final String data) {
    if (data == "")
        return;

    final String parts[] = data.split(",");
    if (entity instanceof LivingEntity) {
        ((LivingEntity) entity).setMaxHealth(Double.parseDouble(parts[1]));
        ((LivingEntity) entity).setHealth(Double.parseDouble(parts[0]));
        if (!parts[2].equals("null"))
            ((LivingEntity) entity).setCustomName(parts[2]);
        if (entity instanceof Animals) {
            ((Animals) entity).setAge(Integer.parseInt(parts[3]));
            if (entity instanceof Sheep) {
                ((Sheep) entity).setSheared(Boolean.parseBoolean(parts[4]));
                ((Sheep) entity).setColor(sheepColors.get(parts[5]));
            } else if (entity instanceof Wolf) {
                if (Boolean.parseBoolean(parts[4])) {
                    ((Wolf) entity).setAngry(Boolean.parseBoolean(parts[4]));
                } else if (parts.length > 5) {
                    ((Tameable) entity).setTamed(true);
                    ((Tameable) entity).setOwner(getPlayer(parts[5]));
                    ((Wolf) entity).setCollarColor(DyeColor.valueOf(parts[6]));
                }
            } else if (entity instanceof Ocelot) {
                if (parts.length > 4) {
                    ((Tameable) entity).setTamed(true);
                    ((Tameable) entity).setOwner(getPlayer(parts[4]));
                    ((Ocelot) entity).setCatType(catTypes.get(parts[5]));
                }
            } else if (entity instanceof Pig) {
                ((Pig) entity).setSaddle(Boolean.parseBoolean(parts[4]));
            } else if (entity instanceof Horse) {
                // ((Horse) entity).setVariant(horseVariants.get(parts[4]));
                ((Horse) entity).setStyle(horseStyles.get(parts[5]));
                ((Horse) entity).setColor(horseColors.get(parts[6]));
                ((Horse) entity).setDomestication(Integer.parseInt(parts[7]));
                ((Horse) entity).setMaxDomestication(Integer.parseInt(parts[8]));
                ((Horse) entity).setJumpStrength(Double.parseDouble(parts[9]));
                if (parts.length > 10) {
                    ((Tameable) entity).setTamed(true);
                    if (!parts[10].equals("null"))
                        ((Tameable) entity).setOwner(getPlayer(parts[10]));
                    ((Horse) entity).getInventory().setSaddle(ItemStackUtil.stringToItemStack(parts[11])[0]);
                    ((Horse) entity).getInventory().setArmor(ItemStackUtil.stringToItemStack(parts[12])[0]);
                    if (parts.length > 13) {
                        ((Horse) entity).setCarryingChest(true);
                        ((Horse) entity).getInventory().setContents(ItemStackUtil.stringToItemStack(parts[13]));
                    }
                }
            }
        } else if (entity instanceof Villager) {
            ((Villager) entity).setProfession(villagerProfessions.get(parts[3]));
            ((Villager) entity).setAge(Integer.parseInt(parts[4]));
        } else if (entity instanceof Creeper) {
            ((Creeper) entity).setPowered(Boolean.parseBoolean(parts[3]));
        } else if (entity instanceof Slime) {
            ((Slime) entity).setSize(Integer.parseInt(parts[3]));
        } else if (entity instanceof Skeleton) {
            ((Skeleton) entity).setSkeletonType(skeletonTypes.get(parts[3]));
            if (parts[3].equals("0")) {
                ((Skeleton) entity).getEquipment().setItemInHand(new ItemStack(Material.BOW));
            } else {
                ((Skeleton) entity).getEquipment().setItemInHand(new ItemStack(Material.BOW));
            }
        } else if (entity instanceof PigZombie) {
            ((LivingEntity) entity).getEquipment().setItemInHand(new ItemStack(Material.GOLD_SWORD));
        }
    }
}
项目:PwnBreeding    文件:FeedListener.java   
@EventHandler(ignoreCancelled = true)
  public void onAnimalClick(PlayerInteractEntityEvent e)
  {
// THIS EVENT FIRES TOO FAST WE NEED A TIMER


World eworld = e.getPlayer().getLocation().getWorld();

// If plugin is not enabled in this world, return
if (!PwnBreeding.isEnabledIn(eworld.getName())) return; 

      Player player = e.getPlayer(); 
      String thisItem = player.getItemInHand().getType().toString();

      if(e.getRightClicked() instanceof Chicken)
      {          

        e.setCancelled(true);

          player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
          if (player.getItemInHand().getType() == Material.SEEDS) 
          {
              if(player.getItemInHand().getAmount() > 1) 
              {
                    player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
              } 
              else 
              {
                  player.getItemInHand().setAmount(0);
              }
          }
      }
      else if(e.getRightClicked() instanceof Cow)
      {
          player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
      }
      else if(e.getRightClicked() instanceof Sheep)
      {
          player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
      }
      else if(e.getRightClicked() instanceof Pig)
      {
          player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
      }
      else if(e.getRightClicked() instanceof Horse)
      {
          player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
      }
      else if(e.getRightClicked() instanceof Wolf)
      {
          player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
      }
      else if(e.getRightClicked() instanceof Ocelot)
      {
          player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
      }
      else if(e.getRightClicked() instanceof Rabbit)
      {
          player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
      }        
  }
项目:WolfCommand    文件:WolfPlayer.java   
/**
 * Gets the closest LivingEntity in player's crosshair
 * @return target
 */
public LivingEntity getTarget() {
    Location observerPos = this.player.getEyeLocation();
       Vector3D observerDir = new Vector3D(observerPos.getDirection());
       Vector3D observerStart = new Vector3D(observerPos);
       Vector3D observerEnd = observerStart.add(observerDir.multiply(ATTACK_RANGE));
       Entity targetEntity = null;

       // Loop through nearby entities (may be slow if too many around)
       for (Entity entity : this.player.getNearbyEntities(ATTACK_RANGE, ATTACK_RANGE, ATTACK_RANGE)) {
        // Skip not living entities
        if (!(entity instanceof LivingEntity)) {
            continue;
        }

        // Skip our own wolves
        if (entity instanceof Tameable && entity instanceof Wolf) {
            Tameable t = (Tameable) entity;
            if (t.isTamed() && t.getOwner() == this.player) {
                continue;
            }
        }

        // We can't attack what we can't see
        if (!this.player.hasLineOfSight(entity)) {
            continue;
        }

        // Bukkit API does not export an axis-aligned bounding box, so we'll settle for this
        // Bounding box is set to 1 block in width and 1.67 blocks high from entity's center
        Vector3D targetPos = new Vector3D(entity.getLocation());
           Vector3D minimum = targetPos.add(-0.5, 0, -0.5);
           Vector3D maximum = targetPos.add(0.5, 1.67, 0.5);

           if (entity != this.player && Vector3D.hasIntersection(observerStart, observerEnd, minimum, maximum)) {
            // Get closest living entity on vector
               if (targetEntity == null ||
                targetEntity.getLocation().distanceSquared(observerPos) > entity.getLocation().distanceSquared(observerPos)) {
                   targetEntity = entity;
               }
           }
       }
       return (LivingEntity) targetEntity;
}
项目:McMMOPlus    文件:Taming.java   
public static boolean canPreventDamage(Tameable pet, AnimalTamer owner) {
    return pet.isTamed() && owner instanceof Player && pet instanceof Wolf;
}
项目:McMMOPlus    文件:Taming.java   
public static double processThickFur(Wolf wolf, double damage) {
    wolf.playEffect(EntityEffect.WOLF_SHAKE);
    return damage / thickFurModifier;
}
项目:McMMOPlus    文件:Taming.java   
public static void processThickFurFire(Wolf wolf) {
    wolf.playEffect(EntityEffect.WOLF_SMOKE);
    wolf.setFireTicks(0);
}
项目:McMMOPlus    文件:Taming.java   
public static double processShockProof(Wolf wolf, double damage) {
    wolf.playEffect(EntityEffect.WOLF_SHAKE);
    return damage / shockProofModifier;
}
项目:McMMOPlus    文件:Taming.java   
public static void processHolyHound(Wolf wolf, double damage) {
    double modifiedHealth = Math.min(wolf.getHealth() + damage, wolf.getMaxHealth());

    wolf.setHealth(modifiedHealth);
    wolf.playEffect(EntityEffect.WOLF_HEARTS);
}
项目:EndHQ-Libraries    文件:RemoteWolf.java   
public RemoteWolf(int inID, RemoteWolfEntity inEntity, EntityManager inManager)
{
    super(inID, RemoteEntityType.Wolf, inManager);
    this.m_entity = inEntity;
}