public void collide(Entity var1) {
    if (!this.world.isClientSide) {
      if (!var1.noclip && !this.noclip) {
        if (var1 != this.passenger) {
          if (var1 instanceof EntityLiving
              && !(var1 instanceof EntityHuman)
              && !(var1 instanceof EntityIronGolem)
              && this.s() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE
              && this.motX * this.motX + this.motZ * this.motZ > 0.01D
              && this.passenger == null
              && var1.vehicle == null) {
            var1.mount(this);
          }

          double var2 = var1.locX - this.locX;
          double var4 = var1.locZ - this.locZ;
          double var6 = var2 * var2 + var4 * var4;
          if (var6 >= 9.999999747378752E-5D) {
            var6 = (double) MathHelper.sqrt(var6);
            var2 /= var6;
            var4 /= var6;
            double var8 = 1.0D / var6;
            if (var8 > 1.0D) {
              var8 = 1.0D;
            }

            var2 *= var8;
            var4 *= var8;
            var2 *= 0.10000000149011612D;
            var4 *= 0.10000000149011612D;
            var2 *= (double) (1.0F - this.U);
            var4 *= (double) (1.0F - this.U);
            var2 *= 0.5D;
            var4 *= 0.5D;
            if (var1 instanceof EntityMinecartAbstract) {
              double var10 = var1.locX - this.locX;
              double var12 = var1.locZ - this.locZ;
              Vec3D var14 = (new Vec3D(var10, 0.0D, var12)).a();
              Vec3D var15 =
                  (new Vec3D(
                          (double) MathHelper.cos(this.yaw * 3.1415927F / 180.0F),
                          0.0D,
                          (double) MathHelper.sin(this.yaw * 3.1415927F / 180.0F)))
                      .a();
              double var16 = Math.abs(var14.b(var15));
              if (var16 < 0.800000011920929D) {
                return;
              }

              double var18 = var1.motX + this.motX;
              double var20 = var1.motZ + this.motZ;
              if (((EntityMinecartAbstract) var1).s()
                      == EntityMinecartAbstract.EnumMinecartType.FURNACE
                  && this.s() != EntityMinecartAbstract.EnumMinecartType.FURNACE) {
                this.motX *= 0.20000000298023224D;
                this.motZ *= 0.20000000298023224D;
                this.g(var1.motX - var2, 0.0D, var1.motZ - var4);
                var1.motX *= 0.949999988079071D;
                var1.motZ *= 0.949999988079071D;
              } else if (((EntityMinecartAbstract) var1).s()
                      != EntityMinecartAbstract.EnumMinecartType.FURNACE
                  && this.s() == EntityMinecartAbstract.EnumMinecartType.FURNACE) {
                var1.motX *= 0.20000000298023224D;
                var1.motZ *= 0.20000000298023224D;
                var1.g(this.motX + var2, 0.0D, this.motZ + var4);
                this.motX *= 0.949999988079071D;
                this.motZ *= 0.949999988079071D;
              } else {
                var18 /= 2.0D;
                var20 /= 2.0D;
                this.motX *= 0.20000000298023224D;
                this.motZ *= 0.20000000298023224D;
                this.g(var18 - var2, 0.0D, var20 - var4);
                var1.motX *= 0.20000000298023224D;
                var1.motZ *= 0.20000000298023224D;
                var1.g(var18 + var2, 0.0D, var20 + var4);
              }
            } else {
              this.g(-var2, 0.0D, -var4);
              var1.g(var2 / 4.0D, 0.0D, var4 / 4.0D);
            }
          }
        }
      }
    }
  }
Esempio n. 2
0
  public void collide(Entity entity) {
    if (!this.world.isStatic) {
      if (entity != this.passenger) {
        if (entity instanceof EntityLiving
            && !(entity instanceof EntityHuman)
            && !(entity instanceof EntityIronGolem)
            && this.type == 0
            && this.motX * this.motX + this.motZ * this.motZ > 0.01D
            && this.passenger == null
            && entity.vehicle == null) {
          entity.mount(this);
        }

        double d0 = entity.locX - this.locX;
        double d1 = entity.locZ - this.locZ;
        double d2 = d0 * d0 + d1 * d1;

        if (d2 >= 9.999999747378752E-5D) {
          d2 = (double) MathHelper.sqrt(d2);
          d0 /= d2;
          d1 /= d2;
          double d3 = 1.0D / d2;

          if (d3 > 1.0D) {
            d3 = 1.0D;
          }

          d0 *= d3;
          d1 *= d3;
          d0 *= 0.10000000149011612D;
          d1 *= 0.10000000149011612D;
          d0 *= (double) (1.0F - this.Z);
          d1 *= (double) (1.0F - this.Z);
          d0 *= 0.5D;
          d1 *= 0.5D;
          if (entity instanceof EntityMinecart) {
            double d4 = entity.locX - this.locX;
            double d5 = entity.locZ - this.locZ;
            Vec3D vec3d = this.world.getVec3DPool().create(d4, 0.0D, d5).a();
            Vec3D vec3d1 =
                this.world
                    .getVec3DPool()
                    .create(
                        (double) MathHelper.cos(this.yaw * 3.1415927F / 180.0F),
                        0.0D,
                        (double) MathHelper.sin(this.yaw * 3.1415927F / 180.0F))
                    .a();
            double d6 = Math.abs(vec3d.b(vec3d1));

            if (d6 < 0.800000011920929D) {
              return;
            }

            double d7 = entity.motX + this.motX;
            double d8 = entity.motZ + this.motZ;

            if (((EntityMinecart) entity).type == 2 && this.type != 2) {
              this.motX *= 0.20000000298023224D;
              this.motZ *= 0.20000000298023224D;
              this.g(entity.motX - d0, 0.0D, entity.motZ - d1);
              entity.motX *= 0.949999988079071D;
              entity.motZ *= 0.949999988079071D;
            } else if (((EntityMinecart) entity).type != 2 && this.type == 2) {
              entity.motX *= 0.20000000298023224D;
              entity.motZ *= 0.20000000298023224D;
              entity.g(this.motX + d0, 0.0D, this.motZ + d1);
              this.motX *= 0.949999988079071D;
              this.motZ *= 0.949999988079071D;
            } else {
              d7 /= 2.0D;
              d8 /= 2.0D;
              this.motX *= 0.20000000298023224D;
              this.motZ *= 0.20000000298023224D;
              this.g(d7 - d0, 0.0D, d8 - d1);
              entity.motX *= 0.20000000298023224D;
              entity.motZ *= 0.20000000298023224D;
              entity.g(d7 + d0, 0.0D, d8 + d1);
            }
          } else {
            this.g(-d0, 0.0D, -d1);
            entity.g(d0 / 4.0D, 0.0D, d1 / 4.0D);
          }
        }
      }
    }
  }