public virtual void applyEntityCollision(Entity entity) { if (entity.riddenByEntity == this || entity.ridingEntity == this) { return; } double d = entity.posX - posX; double d1 = entity.posZ - posZ; double d2 = MathHelper.abs_max(d, d1); if (d2 >= 0.0099999997764825821D) { 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.05000000074505806D; d1 *= 0.05000000074505806D; d *= 1.0F - entityCollisionReduction; d1 *= 1.0F - entityCollisionReduction; addVelocity(-d, 0.0D, -d1); entity.addVelocity(d, 0.0D, d1); } }
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); } } }
public virtual void applyEntityCollision(Entity entity) { if (entity.riddenByEntity == this || entity.ridingEntity == this) { return; } double d = entity.posX - posX; double d1 = entity.posZ - posZ; double d2 = MathHelper.abs_max(d, d1); if (d2 >= 0.0099999997764825821D) { 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.05000000074505806D; d1 *= 0.05000000074505806D; d *= 1.0F - entityCollisionReduction; d1 *= 1.0F - entityCollisionReduction; addVelocity(-d, 0.0D, -d1); entity.addVelocity(d, 0.0D, d1); } }
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); } } }