@Override
  public boolean c(EntityLiving entity) {
    if (this.getRemoteEntity() == null) return super.c(entity);

    if (!(entity.getBukkitEntity() instanceof Player)) return super.c(entity);

    return ((RemoteBaseEntity) this.m_remoteEntity)
            .onInteract((Player) entity.getBukkitEntity(), false)
        && super.c(entity);
  }
Exemplo n.º 2
0
  public static void setHeadYaw(Entity en, float yaw) {
    if (!(en instanceof EntityLiving)) return;
    EntityLiving handle = (EntityLiving) en;
    while (yaw < -180.0F) {
      yaw += 360.0F;
    }

    while (yaw >= 180.0F) {
      yaw -= 360.0F;
    }
    handle.aP = yaw;
    if (!(handle instanceof EntityHuman)) handle.aN = yaw;
    handle.aQ = yaw;
  }
Exemplo n.º 3
0
  public static void attack(EntityLiving handle, Entity target) {
    AttributeInstance attribute = handle.getAttributeInstance(GenericAttributes.e);
    float damage = (float) (attribute == null ? 1D : attribute.getValue());

    if (handle.hasEffect(MobEffectList.INCREASE_DAMAGE)) {
      damage += 3 << handle.getEffect(MobEffectList.INCREASE_DAMAGE).getAmplifier();
    }

    if (handle.hasEffect(MobEffectList.WEAKNESS)) {
      damage -= 2 << handle.getEffect(MobEffectList.WEAKNESS).getAmplifier();
    }

    int knockbackLevel = 0;

    if (target instanceof EntityLiving) {
      damage += EnchantmentManager.a(handle, (EntityLiving) target);
      knockbackLevel +=
          EnchantmentManager.getKnockbackEnchantmentLevel(handle, (EntityLiving) target);
    }

    boolean success = target.damageEntity(DamageSource.mobAttack(handle), damage);
    if (!success) return;

    if (knockbackLevel > 0) {
      target.g(
          -Math.sin(handle.yaw * Math.PI / 180.0F) * knockbackLevel * 0.5F,
          0.1D,
          Math.cos(handle.yaw * Math.PI / 180.0F) * knockbackLevel * 0.5F);
      handle.motX *= 0.6D;
      handle.motZ *= 0.6D;
    }

    int fireAspectLevel = EnchantmentManager.getFireAspectEnchantmentLevel(handle);

    if (fireAspectLevel > 0) {
      target.setOnFire(fireAspectLevel * 4);
    }
  }
  @Override
  public boolean update() {
    EntityHuman passenger = (EntityHuman) this.getEntityHandle().passenger;
    EntityLiving entity = this.getEntityHandle();
    float f = MathHelper.g(passenger.yaw - entity.yaw) * 0.5f;

    if (f > 5) f = 5;

    if (f < -5) f = -5;

    entity.yaw = MathHelper.g(entity.yaw + f);
    if (this.m_currentSpeed < this.m_maxSpeed)
      this.m_currentSpeed += (this.m_maxSpeed - this.m_currentSpeed) * 0.01;

    if (this.m_currentSpeed > this.m_maxSpeed) this.m_currentSpeed = this.m_maxSpeed;

    int x = MathHelper.floor(entity.locX);
    int y = MathHelper.floor(entity.locY);
    int z = MathHelper.floor(entity.locZ);
    float speed = this.m_currentSpeed;

    if (this.m_speedBoosted) {
      if (this.m_speedBoostTime++ > this.m_maxSpeedBoostTime) this.m_speedBoosted = false;

      speed +=
          speed
              * 1.15
              * MathHelper.sin(
                  (float) (this.m_speedBoostTime / this.m_maxSpeedBoostTime * Math.PI));
    }

    float f2 = 0.91f;
    if (entity.onGround) {
      f2 = 0.54600006F;
      Block block = entity.world.getType(MathHelper.d(x), MathHelper.d(y) - 1, MathHelper.d(z));
      if (block.getMaterial() != Material.AIR) f2 = block.frictionFactor * 0.91f;
    }

    float f3 = 0.16277136F / (f2 * f2 * f2);
    float f4 = MathHelper.sin(entity.yaw * 3.1415927F / 180.0F);
    float f5 = MathHelper.cos(entity.yaw * 3.1415927F / 180.0F);
    float f6 = entity.bl() * f3;
    float f7 = Math.max(speed, 1.0F);

    f7 = f6 / f7;
    float f8 = speed * f7;
    float f9 = -(f8 * f4);
    float f10 = f8 * f5;

    if (MathHelper.abs(f9) > MathHelper.abs(f10)) {
      if (f9 < 0.0F) {
        f9 -= entity.width / 2.0F;
      }

      if (f9 > 0.0F) {
        f9 += entity.width / 2.0F;
      }

      f10 = 0.0F;
    } else {
      f9 = 0.0F;
      if (f10 < 0.0F) {
        f10 -= entity.width / 2.0F;
      }

      if (f10 > 0.0F) {
        f10 += entity.width / 2.0F;
      }
    }

    int nextX = MathHelper.floor(entity.locX + f9);
    int nextZ = MathHelper.floor(entity.locZ + f10);
    PathPoint point =
        new PathPoint(
            MathHelper.d(entity.width + 1),
            MathHelper.d(entity.length + passenger.length + 1),
            MathHelper.d(entity.width + 1));
    if (x != nextX || z != nextZ) {
      Block type1 = entity.world.getType(x, y, z);
      Block type2 = entity.world.getType(x, y - 1, z);
      boolean isStep = this.isStep(type1) || type1 == null && this.isStep(type2);

      if (!isStep
          && Pathfinder.a(entity, nextX, y, nextZ, point, false, false, true) == 0
          && Pathfinder.a(entity, x, y + 1, z, point, false, false, true) == 1
          && Pathfinder.a(entity, nextX, y + 1, nextZ, point, false, false, true) == 1)
        NMSUtil.getControllerLook(entity).a();
    }

    if (!passenger.abilities.canInstantlyBuild
        && this.m_currentSpeed >= this.m_maxSpeed * 0.5
        && entity.aI().nextFloat() < 0.006f
        && !this.m_speedBoosted) {
      ItemStack item = passenger.be();

      if (item != null && item.getItem() == Items.CARROT_STICK) {
        item.damage(1, passenger);
        if (item.count == 0) {
          ItemStack newItem = new ItemStack(Items.FISHING_ROD);
          newItem.setTag(item.tag);
          passenger.inventory.items[passenger.inventory.itemInHandIndex] = newItem;
        }
      }
    }

    entity.e(0, speed);
    return true;
  }
Exemplo n.º 5
0
 public static void setVerticalMovement(org.bukkit.entity.Entity bukkitEntity, double d) {
   if (!bukkitEntity.getType().isAlive()) return;
   EntityLiving handle = NMS.getHandle((LivingEntity) bukkitEntity);
   handle.bf = (float) d;
 }
Exemplo n.º 6
0
 public static void setStepHeight(EntityLiving entity, float height) {
   entity.X = height;
 }
Exemplo n.º 7
0
  public static void flyingMoveLogic(EntityLiving entity, float f, float f1) {
    if (entity.M()) {
      entity.a(f, f1, 0.02F);
      entity.move(entity.motX, entity.motY, entity.motZ);
      entity.motX *= 0.800000011920929D;
      entity.motY *= 0.800000011920929D;
      entity.motZ *= 0.800000011920929D;
    } else if (entity.P()) {
      entity.a(f, f1, 0.02F);
      entity.move(entity.motX, entity.motY, entity.motZ);
      entity.motX *= 0.5D;
      entity.motY *= 0.5D;
      entity.motZ *= 0.5D;
    } else {
      float f2 = 0.91F;

      if (entity.onGround) {
        f2 =
            entity.world.getType(
                        MathHelper.floor(entity.locX),
                        MathHelper.floor(entity.boundingBox.b) - 1,
                        MathHelper.floor(entity.locZ))
                    .frictionFactor
                * 0.91F;
      }

      float f3 = 0.16277136F / (f2 * f2 * f2);

      entity.a(f, f1, entity.onGround ? 0.1F * f3 : 0.02F);
      f2 = 0.91F;
      if (entity.onGround) {
        f2 =
            entity.world.getType(
                        MathHelper.floor(entity.locX),
                        MathHelper.floor(entity.boundingBox.b) - 1,
                        MathHelper.floor(entity.locZ))
                    .frictionFactor
                * 0.91F;
      }

      entity.move(entity.motX, entity.motY, entity.motZ);
      entity.motX *= f2;
      entity.motY *= f2;
      entity.motZ *= f2;
    }

    entity.aF = entity.aG;
    double d0 = entity.locX - entity.lastX;
    double d1 = entity.locZ - entity.lastZ;
    float f4 = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F;

    if (f4 > 1.0F) {
      f4 = 1.0F;
    }

    entity.aG += (f4 - entity.aG) * 0.4F;
    entity.aH += entity.aG;
  }