Skip to content

Instantly share code, notes, and snippets.

@RingOfStorms
Created June 11, 2014 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RingOfStorms/02128db5066658a75876 to your computer and use it in GitHub Desktop.
Save RingOfStorms/02128db5066658a75876 to your computer and use it in GitHub Desktop.
public void moveEntityWithHeading(float par1, float par2)
{
double var8;
if (this.isInWater() && (!(this instanceof EntityPlayer) || !((EntityPlayer)this).capabilities.isFlying))
{
var8 = this.posY;
this.moveFlying(par1, par2, this.isAIEnabled() ? 0.04F : 0.02F);
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.800000011920929D;
this.motionY *= 0.800000011920929D;
this.motionZ *= 0.800000011920929D;
this.motionY -= 0.02D;
if (this.isCollidedHorizontally && this.isOffsetPositionInLiquid(this.motionX, this.motionY + 0.6000000238418579D - this.posY + var8, this.motionZ))
{
this.motionY = 0.30000001192092896D;
}
}
else if (this.handleLavaMovement() && (!(this instanceof EntityPlayer) || !((EntityPlayer)this).capabilities.isFlying))
{
var8 = this.posY;
this.moveFlying(par1, par2, 0.02F);
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.5D;
this.motionY *= 0.5D;
this.motionZ *= 0.5D;
this.motionY -= 0.02D;
if (this.isCollidedHorizontally && this.isOffsetPositionInLiquid(this.motionX, this.motionY + 0.6000000238418579D - this.posY + var8, this.motionZ))
{
this.motionY = 0.30000001192092896D;
}
}
else
{
float var3 = 0.91F;
if (this.onGround)
{
var3 = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ)).slipperiness * 0.91F;
}
float var4 = 0.16277136F / (var3 * var3 * var3);
float var5;
if (this.onGround)
{
var5 = this.getAIMoveSpeed() * var4;
}
else
{
var5 = this.jumpMovementFactor;
}
this.moveFlying(par1, par2, var5);
var3 = 0.91F;
if (this.onGround)
{
var3 = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ)).slipperiness * 0.91F;
}
if (this.isOnLadder())
{
float var6 = 0.15F;
if (this.motionX < (double)(-var6))
{
this.motionX = (double)(-var6);
}
if (this.motionX > (double)var6)
{
this.motionX = (double)var6;
}
if (this.motionZ < (double)(-var6))
{
this.motionZ = (double)(-var6);
}
if (this.motionZ > (double)var6)
{
this.motionZ = (double)var6;
}
this.fallDistance = 0.0F;
if (this.motionY < -0.15D)
{
this.motionY = -0.15D;
}
boolean var7 = this.isSneaking() && this instanceof EntityPlayer;
if (var7 && this.motionY < 0.0D)
{
this.motionY = 0.0D;
}
}
this.moveEntity(this.motionX, this.motionY, this.motionZ);
if (this.isCollidedHorizontally && this.isOnLadder())
{
this.motionY = 0.2D;
}
if (this.worldObj.isClient && (!this.worldObj.blockExists((int)this.posX, 0, (int)this.posZ) || !this.worldObj.getChunkFromBlockCoords((int)this.posX, (int)this.posZ).isChunkLoaded))
{
if (this.posY > 0.0D)
{
this.motionY = -0.1D;
}
else
{
this.motionY = 0.0D;
}
}
else
{
this.motionY -= 0.08D;
}
this.motionY *= 0.9800000190734863D;
this.motionX *= (double)var3;
this.motionZ *= (double)var3;
}
this.prevLimbSwingAmount = this.limbSwingAmount;
var8 = this.posX - this.prevPosX;
double var9 = this.posZ - this.prevPosZ;
float var10 = MathHelper.sqrt_double(var8 * var8 + var9 * var9) * 4.0F;
if (var10 > 1.0F)
{
var10 = 1.0F;
}
this.limbSwingAmount += (var10 - this.limbSwingAmount) * 0.4F;
this.limbSwing += this.limbSwingAmount;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment