示例#1
0
 @Override
 public void l_() {
   super.l_();
   if (this.particle == this.particleCounter) {
     this.particle = 0;
     this.particleCounter = this.random.nextInt(50);
   } else {
     this.particle++;
   }
 }
示例#2
0
  @Override
  public void e(float f, float f1) { // f = sidewards, f1 = forwards/backwards

    // Can only jump over half slabs if the rider is not the owner
    // I like this idea
    // https://github.com/Bukkit/mc-dev/blob/master/net/minecraft/server/EntityHorse.java#L914
    if (this.passenger == null || !(this.passenger instanceof EntityHuman)) {
      super.e(f, f1);
      this.Y = 0.5F;
      return;
    }
    EntityHuman human = (EntityHuman) this.passenger;
    if (human.getBukkitEntity() != this.getOwner().getPlayer()) {
      super.e(f, f1);
      this.Y = 0.5F;
      return;
    }

    this.Y = 1.0F;

    this.lastYaw = this.yaw = this.passenger.yaw;
    this.pitch = this.passenger.pitch * 0.5F;
    this.b(this.yaw, this.pitch);
    this.aP = this.aN = this.yaw;

    f = ((EntityLiving) this.passenger).be * 0.5F;
    f1 = ((EntityLiving) this.passenger).bf;

    if (f1 <= 0.0F) {
      f1 *= 0.25F;
    }
    f *= 0.75F;

    PetRideMoveEvent moveEvent = new PetRideMoveEvent(this.getPet(), f1, f);
    EchoPet.getPluginInstance().getServer().getPluginManager().callEvent(moveEvent);
    if (moveEvent.isCancelled()) {
      return;
    }

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

    // https://github.com/Bukkit/mc-dev/blob/master/net/minecraft/server/EntityLiving.java#L1322-L1334

    PetType pt = this.getPet().getPetType();
    if (jump != null) {
      if (EchoPet.getPluginInstance().DO.canFly(pt)) {
        try {
          if (jump.getBoolean(this.passenger)) {
            PetRideJumpEvent rideEvent = new PetRideJumpEvent(this.getPet(), this.jumpHeight);
            EchoPet.getPluginInstance().getServer().getPluginManager().callEvent(rideEvent);
            if (!rideEvent.isCancelled()) {
              this.motY = 0.5F;
            }
          }
        } catch (Exception e) {
          EchoPet.getPluginInstance()
              .severe(
                  e,
                  "Failed to initiate Pet Flying Motion for "
                      + this.getOwner().getName()
                      + "'s Pet.");
        }
      } else if (this.onGround) {
        try {
          if (jump.getBoolean(this.passenger)) {
            PetRideJumpEvent rideEvent = new PetRideJumpEvent(this.getPet(), this.jumpHeight);
            EchoPet.getPluginInstance().getServer().getPluginManager().callEvent(rideEvent);
            if (!rideEvent.isCancelled()) {
              this.motY = rideEvent.getJumpHeight();
            }
          }
        } catch (Exception e) {
          EchoPet.getPluginInstance()
              .severe(
                  e,
                  "Failed to initiate Pet Jumping Motion for "
                      + this.getOwner().getName()
                      + "'s Pet.");
        }
      }
    }
  }