Beispiel #1
0
        public override void applyEntityCollision(Entity entity)
        {
            if (worldObj.singleplayerWorld)
            {
                return;
            }
            if (entity == riddenByEntity)
            {
                return;
            }
            if ((entity is EntityLiving) && !(entity is EntityPlayer) && minecartType == 0 &&
                motionX * motionX + motionZ * motionZ > 0.01D && riddenByEntity == null && entity.ridingEntity == null)
            {
                entity.mountEntity(this);
            }
            double d  = entity.posX - posX;
            double d1 = entity.posZ - posZ;
            double d2 = d * d + d1 * d1;

            if (d2 >= 9.9999997473787516E-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.10000000149011612D;
                d1 *= 0.10000000149011612D;
                d  *= 1.0F - entityCollisionReduction;
                d1 *= 1.0F - entityCollisionReduction;
                d  *= 0.5D;
                d1 *= 0.5D;
                if (entity is EntityMinecart)
                {
                    double d4 = entity.motionX + motionX;
                    double d5 = entity.motionZ + motionZ;
                    if (((EntityMinecart)entity).minecartType == 2 && minecartType != 2)
                    {
                        motionX *= 0.20000000298023224D;
                        motionZ *= 0.20000000298023224D;
                        addVelocity(entity.motionX - d, 0.0D, entity.motionZ - d1);
                        entity.motionX *= 0.69999998807907104D;
                        entity.motionZ *= 0.69999998807907104D;
                    }
                    else if (((EntityMinecart)entity).minecartType != 2 && minecartType == 2)
                    {
                        entity.motionX *= 0.20000000298023224D;
                        entity.motionZ *= 0.20000000298023224D;
                        entity.addVelocity(motionX + d, 0.0D, motionZ + d1);
                        motionX *= 0.69999998807907104D;
                        motionZ *= 0.69999998807907104D;
                    }
                    else
                    {
                        d4      /= 2D;
                        d5      /= 2D;
                        motionX *= 0.20000000298023224D;
                        motionZ *= 0.20000000298023224D;
                        addVelocity(d4 - d, 0.0D, d5 - d1);
                        entity.motionX *= 0.20000000298023224D;
                        entity.motionZ *= 0.20000000298023224D;
                        entity.addVelocity(d4 + d, 0.0D, d5 + d1);
                    }
                }
                else
                {
                    addVelocity(-d, 0.0D, -d1);
                    entity.addVelocity(d / 4D, 0.0D, d1 / 4D);
                }
            }
        }
Beispiel #2
0
 public override void applyEntityCollision(Entity entity)
 {
     if (worldObj.singleplayerWorld)
     {
         return;
     }
     if (entity == riddenByEntity)
     {
         return;
     }
     if ((entity is EntityLiving) && !(entity is EntityPlayer) && minecartType == 0 &&
         motionX*motionX + motionZ*motionZ > 0.01D && riddenByEntity == null && entity.ridingEntity == null)
     {
         entity.mountEntity(this);
     }
     double d = entity.posX - posX;
     double d1 = entity.posZ - posZ;
     double d2 = d*d + d1*d1;
     if (d2 >= 9.9999997473787516E-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.10000000149011612D;
         d1 *= 0.10000000149011612D;
         d *= 1.0F - entityCollisionReduction;
         d1 *= 1.0F - entityCollisionReduction;
         d *= 0.5D;
         d1 *= 0.5D;
         if (entity is EntityMinecart)
         {
             double d4 = entity.motionX + motionX;
             double d5 = entity.motionZ + motionZ;
             if (((EntityMinecart) entity).minecartType == 2 && minecartType != 2)
             {
                 motionX *= 0.20000000298023224D;
                 motionZ *= 0.20000000298023224D;
                 addVelocity(entity.motionX - d, 0.0D, entity.motionZ - d1);
                 entity.motionX *= 0.69999998807907104D;
                 entity.motionZ *= 0.69999998807907104D;
             }
             else if (((EntityMinecart) entity).minecartType != 2 && minecartType == 2)
             {
                 entity.motionX *= 0.20000000298023224D;
                 entity.motionZ *= 0.20000000298023224D;
                 entity.addVelocity(motionX + d, 0.0D, motionZ + d1);
                 motionX *= 0.69999998807907104D;
                 motionZ *= 0.69999998807907104D;
             }
             else
             {
                 d4 /= 2D;
                 d5 /= 2D;
                 motionX *= 0.20000000298023224D;
                 motionZ *= 0.20000000298023224D;
                 addVelocity(d4 - d, 0.0D, d5 - d1);
                 entity.motionX *= 0.20000000298023224D;
                 entity.motionZ *= 0.20000000298023224D;
                 entity.addVelocity(d4 + d, 0.0D, d5 + d1);
             }
         }
         else
         {
             addVelocity(-d, 0.0D, -d1);
             entity.addVelocity(d/4D, 0.0D, d1/4D);
         }
     }
 }
Beispiel #3
0
 public virtual void func_22085_d(Entity entity)
 {
     if (entity.riddenByEntity != null)
     {
         entity.riddenByEntity.mountEntity(null);
     }
     if (entity.ridingEntity != null)
     {
         entity.mountEntity(null);
     }
     entity.setEntityDead();
     if (entity is EntityPlayer)
     {
         playerEntities.remove(entity);
         updateAllPlayersSleepingFlag();
     }
 }