コード例 #1
0
  public EntityHuman findNearbyVulnerablePlayer(double d0, double d1, double d2) {
    if (world.players.size() > 0) {
      int i = r.nextInt(world.players.size());
      EntityHuman entityhuman1 = (EntityHuman) this.world.players.get(i);

      if (!entityhuman1.abilities.isInvulnerable && entityhuman1.isAlive()) {
        return entityhuman1;
      }
    }
    return null;
  }
コード例 #2
0
ファイル: EntityPet.java プロジェクト: NAT007/EchoPet
 // EntityInsentient
 @Override
 public boolean a(EntityHuman human) {
   if (human.getBukkitEntity() == this.getPlayerOwner().getPlayer()) {
     if (EchoPet.getConfig()
             .getBoolean(
                 "pets."
                     + this.getPet().getPetType().toString().toLowerCase().replace("_", " ")
                     + ".interactMenu",
                 true)
         && Perm.BASE_MENU.hasPerm(this.getPlayerOwner(), false, false)) {
       ArrayList<MenuOption> options = MenuUtil.createOptionList(getPet().getPetType());
       int size = this.getPet().getPetType() == PetType.HORSE ? 18 : 9;
       PetMenu menu = new PetMenu(getPet(), options, size);
       menu.open(true);
     }
     return true;
   }
   return false;
 }
コード例 #3
0
ファイル: EntityPet.java プロジェクト: NAT007/EchoPet
  // EntityInsentient
  @Override
  public void e(float sideMot, float forwMot) {
    if (this.passenger == null || !(this.passenger instanceof EntityHuman)) {
      super.e(sideMot, forwMot);
      // https://github.com/Bukkit/mc-dev/blob/master/net/minecraft/server/EntityHorse.java#L914
      this.W = 0.5F;
      return;
    }
    EntityHuman human = (EntityHuman) this.passenger;
    if (human.getBukkitEntity() != this.getPlayerOwner().getPlayer()) {
      super.e(sideMot, forwMot);
      this.W = 0.5F;
      return;
    }

    this.W = 1.0F;

    this.lastYaw = this.yaw = this.passenger.yaw;
    this.pitch = this.passenger.pitch * 0.5F;
    this.b(this.yaw, this.pitch);
    this.aO = this.aM = this.yaw;

    sideMot = ((EntityLiving) this.passenger).bd * 0.5F;
    forwMot = ((EntityLiving) this.passenger).be;

    if (forwMot <= 0.0F) {
      forwMot *= 0.25F;
    }
    sideMot *= 0.75F;

    PetRideMoveEvent moveEvent = new PetRideMoveEvent(this.getPet(), forwMot, sideMot);
    EchoPet.getPlugin().getServer().getPluginManager().callEvent(moveEvent);
    if (moveEvent.isCancelled()) {
      return;
    }

    this.i(this.rideSpeed);
    super.e(moveEvent.getSidewardMotionSpeed(), moveEvent.getForwardMotionSpeed());

    PetType pt = this.getPet().getPetType();
    if (FIELD_JUMP != null && this.passenger != null) {
      if (EchoPet.getOptions().canFly(pt)) {
        try {
          if (((Player) (human.getBukkitEntity())).isFlying()) {
            ((Player) (human.getBukkitEntity())).setFlying(false);
          }
          if (FIELD_JUMP.getBoolean(this.passenger)) {
            PetRideJumpEvent rideEvent = new PetRideJumpEvent(this.getPet(), this.jumpHeight);
            EchoPet.getPlugin().getServer().getPluginManager().callEvent(rideEvent);
            if (!rideEvent.isCancelled()) {
              this.motY = 0.5F;
            }
          }
        } catch (IllegalArgumentException e) {
          Logger.log(
              Logger.LogLevel.WARNING,
              "Failed to initiate Pet Flying Motion for "
                  + this.getPlayerOwner().getName()
                  + "'s Pet.",
              e,
              true);
        } catch (IllegalAccessException e) {
          Logger.log(
              Logger.LogLevel.WARNING,
              "Failed to initiate Pet Flying Motion for "
                  + this.getPlayerOwner().getName()
                  + "'s Pet.",
              e,
              true);
        } catch (IllegalStateException e) {
          Logger.log(
              Logger.LogLevel.WARNING,
              "Failed to initiate Pet Flying Motion for "
                  + this.getPlayerOwner().getName()
                  + "'s Pet.",
              e,
              true);
        }
      } else if (this.onGround) {
        try {
          if (FIELD_JUMP.getBoolean(this.passenger)) {
            PetRideJumpEvent rideEvent = new PetRideJumpEvent(this.getPet(), this.jumpHeight);
            EchoPet.getPlugin().getServer().getPluginManager().callEvent(rideEvent);
            if (!rideEvent.isCancelled()) {
              this.motY = rideEvent.getJumpHeight();
              doJumpAnimation();
            }
          }
        } catch (IllegalArgumentException e) {
          Logger.log(
              Logger.LogLevel.WARNING,
              "Failed to initiate Pet Jumping Motion for "
                  + this.getPlayerOwner().getName()
                  + "'s Pet.",
              e,
              true);
        } catch (IllegalAccessException e) {
          Logger.log(
              Logger.LogLevel.WARNING,
              "Failed to initiate Pet Jumping Motion for "
                  + this.getPlayerOwner().getName()
                  + "'s Pet.",
              e,
              true);
        } catch (IllegalStateException e) {
          Logger.log(
              Logger.LogLevel.WARNING,
              "Failed to initiate Pet Jumping Motion for "
                  + this.getPlayerOwner().getName()
                  + "'s Pet.",
              e,
              true);
        }
      }
    }
  }