Exemplo n.º 1
0
 public void attemptMount(Entity var1) {
   if (var1 != null
       && !(var1 instanceof EntityElevator)
       && !this.collideEntity(var1)
       && var1.ridingEntity == null) {
     var1.mountEntity(this);
     this.mountedEntities.add(var1);
   }
 }
Exemplo n.º 2
0
  public void handleAttachEntity(Packet39AttachEntity var1) {
    Object var2 = this.getEntityByID(var1.entityId);
    Entity var3 = this.getEntityByID(var1.vehicleEntityId);
    if (var1.entityId == this.mc.thePlayer.entityId) {
      var2 = this.mc.thePlayer;
    }

    if (var2 != null) {
      ((Entity) var2).mountEntity(var3);
    }
  }
Exemplo n.º 3
0
  private void ejectRiders() {
    Iterator var1 = this.mountedEntities.iterator();

    while (var1.hasNext()) {
      Entity var2 = (Entity) var1.next();
      this.riddenByEntity = var2;
      var2.mountEntity((Entity) null);
    }

    this.mountedEntities.clear();
  }
Exemplo n.º 4
0
  /** Applies a velocity to each of the entities pushing them away from each other. Args: entity */
  public void applyEntityCollision(Entity par1Entity) {
    if (worldObj.isRemote) {
      return;
    }

    if (par1Entity == riddenByEntity) {
      return;
    }

    if ((par1Entity instanceof EntityLiving)
        && !(par1Entity instanceof EntityPlayer)
        && !(par1Entity instanceof EntityIronGolem)
        && minecartType == 0
        && motionX * motionX + motionZ * motionZ > 0.01D
        && riddenByEntity == null
        && par1Entity.ridingEntity == null) {
      par1Entity.mountEntity(this);
    }

    double d = par1Entity.posX - posX;
    double d1 = par1Entity.posZ - posZ;
    double d2 = d * d + d1 * d1;

    if (d2 >= 10.0E-005D) {
      d2 = MathHelper.sqrt_double(d2);
      d /= d2;
      d1 /= d2;
      double d3 = 1.0D / d2;

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

      d *= d3;
      d1 *= d3;
      d *= 0.1D;
      d1 *= 0.1D;
      d *= 1.0F - entityCollisionReduction;
      d1 *= 1.0F - entityCollisionReduction;
      d *= 0.5D;
      d1 *= 0.5D;

      if (par1Entity instanceof EntityMinecart) {
        double d4 = par1Entity.motionX + motionX;
        double d5 = par1Entity.motionZ + motionZ;

        if (((EntityMinecart) par1Entity).minecartType == 2 && minecartType != 2) {
          motionX *= 0.2D;
          motionZ *= 0.2D;
          addVelocity(par1Entity.motionX - d, 0.0D, par1Entity.motionZ - d1);
          par1Entity.motionX *= 0.95D;
          par1Entity.motionZ *= 0.95D;
        } else if (((EntityMinecart) par1Entity).minecartType != 2 && minecartType == 2) {
          par1Entity.motionX *= 0.2D;
          par1Entity.motionZ *= 0.2D;
          par1Entity.addVelocity(motionX + d, 0.0D, motionZ + d1);
          motionX *= 0.95D;
          motionZ *= 0.95D;
        } else {
          d4 /= 2D;
          d5 /= 2D;
          motionX *= 0.2D;
          motionZ *= 0.2D;
          addVelocity(d4 - d, 0.0D, d5 - d1);
          par1Entity.motionX *= 0.2D;
          par1Entity.motionZ *= 0.2D;
          par1Entity.addVelocity(d4 + d, 0.0D, d5 + d1);
        }
      } else {
        addVelocity(-d, 0.0D, -d1);
        par1Entity.addVelocity(d / 4D, 0.0D, d1 / 4D);
      }
    }
  }
Exemplo n.º 5
0
  /** Applies a velocity to each of the entities pushing them away from each other. Args: entity */
  public void applyEntityCollision(Entity par1Entity) {
    if (!this.worldObj.isRemote) {
      if (par1Entity != this.riddenByEntity) {
        if (par1Entity instanceof EntityLiving
            && !(par1Entity instanceof EntityPlayer)
            && !(par1Entity instanceof EntityIronGolem)
            && this.minecartType == 0
            && this.motionX * this.motionX + this.motionZ * this.motionZ > 0.01D
            && this.riddenByEntity == null
            && par1Entity.ridingEntity == null) {
          par1Entity.mountEntity(this);
        }

        double var2 = par1Entity.posX - this.posX;
        double var4 = par1Entity.posZ - this.posZ;
        double var6 = var2 * var2 + var4 * var4;

        if (var6 >= 9.999999747378752E-5D) {
          var6 = (double) MathHelper.sqrt_double(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.entityCollisionReduction);
          var4 *= (double) (1.0F - this.entityCollisionReduction);
          var2 *= 0.5D;
          var4 *= 0.5D;

          if (par1Entity instanceof EntityMinecart) {
            double var10 = par1Entity.posX - this.posX;
            double var12 = par1Entity.posZ - this.posZ;
            Vec3 var14 =
                this.worldObj.getWorldVec3Pool().getVecFromPool(var10, 0.0D, var12).normalize();
            Vec3 var15 =
                this.worldObj
                    .getWorldVec3Pool()
                    .getVecFromPool(
                        (double) MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F),
                        0.0D,
                        (double) MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F))
                    .normalize();
            double var16 = Math.abs(var14.dotProduct(var15));

            if (var16 < 0.800000011920929D) {
              return;
            }

            double var18 = par1Entity.motionX + this.motionX;
            double var20 = par1Entity.motionZ + this.motionZ;

            if (((EntityMinecart) par1Entity).minecartType == 2 && this.minecartType != 2) {
              this.motionX *= 0.20000000298023224D;
              this.motionZ *= 0.20000000298023224D;
              this.addVelocity(par1Entity.motionX - var2, 0.0D, par1Entity.motionZ - var4);
              par1Entity.motionX *= 0.949999988079071D;
              par1Entity.motionZ *= 0.949999988079071D;
            } else if (((EntityMinecart) par1Entity).minecartType != 2 && this.minecartType == 2) {
              par1Entity.motionX *= 0.20000000298023224D;
              par1Entity.motionZ *= 0.20000000298023224D;
              par1Entity.addVelocity(this.motionX + var2, 0.0D, this.motionZ + var4);
              this.motionX *= 0.949999988079071D;
              this.motionZ *= 0.949999988079071D;
            } else {
              var18 /= 2.0D;
              var20 /= 2.0D;
              this.motionX *= 0.20000000298023224D;
              this.motionZ *= 0.20000000298023224D;
              this.addVelocity(var18 - var2, 0.0D, var20 - var4);
              par1Entity.motionX *= 0.20000000298023224D;
              par1Entity.motionZ *= 0.20000000298023224D;
              par1Entity.addVelocity(var18 + var2, 0.0D, var20 + var4);
            }
          } else {
            this.addVelocity(-var2, 0.0D, -var4);
            par1Entity.addVelocity(var2 / 4.0D, 0.0D, var4 / 4.0D);
          }
        }
      }
    }
  }