net.minecraft.entity.ai.EntityMoveHelper Java Examples
The following examples show how to use
net.minecraft.entity.ai.EntityMoveHelper.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityTofuFish.java From TofuCraftReload with MIT License | 6 votes |
public void onUpdateMoveHelper() { if (this.fish.isInWater()) { this.fish.motionY += 0.005D; } if (this.action == EntityMoveHelper.Action.MOVE_TO && !this.fish.getNavigator().noPath()) { double d0 = this.posX - this.fish.posX; double d1 = this.posY - this.fish.posY; double d2 = this.posZ - this.fish.posZ; double d3 = (double) MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2); d1 = d1 / d3; float f = (float)(MathHelper.atan2(d2, d0) * (double)(180F / (float)Math.PI)) - 90.0F; this.fish.rotationYaw = this.limitAngle(this.fish.rotationYaw, f, 90.0F); this.fish.renderYawOffset = this.fish.rotationYaw; float f1 = (float)(this.speed * this.fish.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getBaseValue()); this.fish.setAIMoveSpeed(this.fish.getAIMoveSpeed() + (f1 - this.fish.getAIMoveSpeed()) * 0.125F); this.fish.motionY += (double)this.fish.getAIMoveSpeed() * d1 * 0.1D; } else { this.fish.setAIMoveSpeed(0.0F); } }
Example #2
Source File: FairyMoveHelper.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onUpdateMoveHelper() { if (this.action == EntityMoveHelper.Action.MOVE_TO) { double x = this.posX - this.entity.posX; double y = this.posY - this.entity.posY; double z = this.posZ - this.entity.posZ; double distance = x * x + y * y + z * z; distance = (double) MathHelper.sqrt(distance); if (distance < this.entity.getEntityBoundingBox().getAverageEdgeLength()) { this.action = EntityMoveHelper.Action.WAIT; // this.entity.motionX *= 0.9D; // this.entity.motionY *= 0.9D; // this.entity.motionZ *= 0.9D; } else { this.entity.motionX += x / distance * 0.05D * this.speed; this.entity.motionY += y / distance * 0.05D * this.speed; this.entity.motionZ += z / distance * 0.05D * this.speed; if (this.entity.getAttackTarget() == null) { this.entity.rotationYaw = -((float) MathHelper.atan2(this.entity.motionX, this.entity.motionZ)) * (180F / (float) Math.PI); this.entity.renderYawOffset = this.entity.rotationYaw; } else { double d4 = this.entity.getAttackTarget().posX - this.entity.posX; double d5 = this.entity.getAttackTarget().posZ - this.entity.posZ; this.entity.rotationYaw = -((float) MathHelper.atan2(d4, d5)) * (180F / (float) Math.PI); this.entity.renderYawOffset = this.entity.rotationYaw; } } } }
Example #3
Source File: UnicornMoveHelper.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onUpdateMoveHelper() { if (this.action == EntityMoveHelper.Action.MOVE_TO) { this.action = EntityMoveHelper.Action.WAIT; this.entity.setNoGravity(true); double d0 = this.posX - this.entity.posX; double d1 = this.posY - this.entity.posY; double d2 = this.posZ - this.entity.posZ; double d3 = d0 * d0 + d1 * d1 + d2 * d2; if (d3 < 2.500000277905201E-7D) { this.entity.setMoveVertical(0.0F); this.entity.setMoveForward(0.0F); return; } float f = (float) (MathHelper.atan2(d2, d0) * (180D / Math.PI)) - 90.0F; this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw, f, 10.0F); float f1; if (this.entity.onGround) { f1 = (float) (this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue()); } else { f1 = (float) (this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.FLYING_SPEED).getAttributeValue()); } this.entity.setAIMoveSpeed((float) speed); double d4 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2); float f2 = (float) (-(MathHelper.atan2(d1, d4) * (180D / Math.PI))); this.entity.rotationPitch = this.limitAngle(this.entity.rotationPitch, f2, 10.0F); this.entity.setMoveVertical(d1 > 0.0D ? f1 : -f1); } else { this.entity.setNoGravity(true); this.entity.setMoveVertical(0.0F); this.entity.setMoveForward(0.0F); } }
Example #4
Source File: FairyMoveHelper.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void read(EntityMoveHelper that) { super.read(that); this.speed = that.getSpeed(); }