private static float getCheckingAngle(EntityLivingBase player, float base) { float yaw = MathHelper.wrapDegrees(player.rotationYaw) + 90F; int angles = 360; int segAngles = angles / SEGMENTS; float shift = segAngles / 2; if(yaw < 0) yaw = 180F + (180F + yaw); yaw -= 360F - base; float angle = 360F - yaw + shift; if(angle < 0) angle = 360F + angle; return angle; }
private float updateRotation(float float1, float float2, float float3) { float f = MathHelper.wrapDegrees(float2 - float1); if (f > float3) { f = float3; } if (f < -float3) { f = -float3; } return float1 + f; } }
public static float updateRotation(float angle, float targetAngle, float maxIncrease) { float f = MathHelper.wrapDegrees(targetAngle - angle); if (f > maxIncrease) { f = maxIncrease; } if (f < -maxIncrease) { f = -maxIncrease; } return angle + f; } @SubscribeEvent
@Override protected float evaluate(float arg) { return MathHelper.wrapDegrees(arg); } });
private float updateRotation(float angle, float targetAngle, float maxIncrease) { float f = MathHelper.wrapDegrees(targetAngle - angle); if (f > maxIncrease) { f = maxIncrease; } if (f < -maxIncrease) { f = -maxIncrease; } return angle + f; }
private float updateRotation(float current, float desired, float range) { float offset = MathHelper.wrapDegrees(desired - current); if (offset > range) { offset = range; } if (offset < -range) { offset = -range; } return MathHelper.wrapDegrees(current + offset); }
private float approach(float target, float current, float limit) { float delta = MathHelper.wrapDegrees(target - current); if (delta < -limit) { delta = -limit; } else if (delta >= limit) { delta = limit; } return target - delta * 0.67F; }
weapon.setVariety(rand.nextInt(WEAPON_TYPES)); weapon.setDelay(spawned); weapon.setRotation(MathHelper.wrapDegrees(-living.rotationYaw + 180));
@Override public void faceTarget(float yaw, float pitch, float rotationDivisor, AdvancedModelRenderer... boxes) { float actualRotationDivisor = rotationDivisor * boxes.length; float yawAmount = MathHelper.clamp(MathHelper.wrapDegrees(yaw), -45.0F, 45.0F) / (180.0F / (float) Math.PI) / actualRotationDivisor; float pitchAmount = MathHelper.wrapDegrees(pitch) / (180.0F / (float) Math.PI) / actualRotationDivisor; for (AdvancedModelRenderer box : boxes) { box.rotateAngleY += yawAmount; box.rotateAngleX += pitchAmount; } } }
public void flyToTarget() { if (currentFlightTarget != null) { double targetX = currentFlightTarget.getX() + 0.5D - posX; double targetY = currentFlightTarget.getY() + 1D - posY; double targetZ = currentFlightTarget.getZ() + 0.5D - posZ; motionX += (Math.signum(targetX) * 0.5D - motionX) * 0.10000000149011612D; motionY += (Math.signum(targetY) * 0.699999988079071D - motionY) * 0.10000000149011612D; motionZ += (Math.signum(targetZ) * 0.5D - motionZ) * 0.10000000149011612D; float angle = (float) (Math.atan2(motionZ, motionX) * 180.0D / Math.PI) - 90.0F; float rotation = MathHelper.wrapDegrees(angle - rotationYaw); moveForward = 0.5F; rotationYaw += rotation; } }
@SideOnly(Side.CLIENT) private double getFrameRotation(EntityItemFrame frame) { return MathHelper.wrapDegrees(180 + frame.facingDirection.getHorizontalIndex() * 90); }
@SideOnly(Side.CLIENT) private double getFrameRotation(EntityItemFrame frame) { return MathHelper.wrapDegrees(180 + frame.facingDirection.getHorizontalIndex() * 90); }
@SideOnly(Side.CLIENT) private double getFrameRotation(EntityItemFrame entityItemFrame) { return (double) MathHelper.wrapDegrees(180 + entityItemFrame.facingDirection.getHorizontalIndex() * 90); }
@SideOnly(Side.CLIENT) private double getFrameRotation(EntityItemFrame entityItemFrame) { return (double) MathHelper.wrapDegrees(180 + entityItemFrame.facingDirection.getHorizontalIndex() * 90); }
@SideOnly(Side.CLIENT) private double getFrameRotation(EntityItemFrame entityItemFrame) { return (double) MathHelper.wrapDegrees(180 + entityItemFrame.facingDirection.getHorizontalIndex() * 90); }
@Override protected void updateAITasks() { super.updateAITasks(); if (getState().doesMovement && flightTarget != null) { double diffX = flightTarget.x + 0.5d - posX; double diffY = flightTarget.y + 0.1d - posY; double diffZ = flightTarget.z + 0.5d - posZ; motionX += (Math.signum(diffX) * 0.5d - motionX) * 0.10000000149011612d; motionY += (Math.signum(diffY) * 0.699999988079071d - motionY) * 0.10000000149011612d; motionZ += (Math.signum(diffZ) * 0.5d - motionZ) * 0.10000000149011612d; float horizontal = (float) (Math.atan2(motionZ, motionX) * 180d / Math.PI) - 90f; rotationYaw += MathHelper.wrapDegrees(horizontal - rotationYaw); setMoveForward(contained.getGenome().getSpeed()); } }
private void tickInterp() { if (this.interpProgress > 0 && !this.canPassengerSteer()) { double interpolatedX = this.posX + (this.interpTargetX - this.posX) / (double) this.interpProgress; double interpolatedY = this.posY + (this.interpTargetY - this.posY) / (double) this.interpProgress; double interpolatedZ = this.posZ + (this.interpTargetZ - this.posZ) / (double) this.interpProgress; double deltaYaw = MathHelper.wrapDegrees(this.interpTargetYaw - (double) this.rotationYaw); this.rotationYaw = (float) ((double) this.rotationYaw + deltaYaw / (double) this.interpProgress); this.interpProgress--; this.setPosition(interpolatedX, interpolatedY, interpolatedZ); this.setRotation(this.rotationYaw, this.rotationPitch); } }
private void tickLerp() { if (this.lerpSteps > 0 && !this.canPassengerSteer()) { double d0 = this.posX + (this.boatPitch - this.posX) / (double) this.lerpSteps; double d1 = this.posY + (this.lerpY - this.posY) / (double) this.lerpSteps; double d2 = this.posZ + (this.lerpZ - this.posZ) / (double) this.lerpSteps; double d3 = MathHelper.wrapDegrees(this.boatYaw - (double) this.rotationYaw); this.rotationYaw = (float) ((double) this.rotationYaw + d3 / (double) this.lerpSteps); this.rotationPitch = (float) ((double) this.rotationPitch + (this.lerpXRot - (double) this.rotationPitch) / (double) this.lerpSteps); --this.lerpSteps; this.setPosition(d0, d1, d2); this.setRotation(this.rotationYaw, this.rotationPitch); } }
public void faceEntity(Entity entityIn) { double d0 = entityIn.posX - this.posX; double d2 = entityIn.posZ - this.posZ; double d1; if (entityIn instanceof EntityLivingBase) { EntityLivingBase entitylivingbase = (EntityLivingBase) entityIn; d1 = entitylivingbase.posY + entitylivingbase.getEyeHeight() - (this.posY + this.getEyeHeight()); } else { d1 = (entityIn.getEntityBoundingBox().minY + entityIn.getEntityBoundingBox().maxY) / 2.0D - (this.posY + this.getEyeHeight()); } double d3 = MathHelper.sqrt(d0 * d0 + d2 * d2); rotationPitch = MathHelper.wrapDegrees((float) (-(MathHelper.atan2(d1, d3) * (180D / Math.PI)))); rotationYaw = MathHelper.wrapDegrees((float) (MathHelper.atan2(d2, d0) * (180D / Math.PI)) - 90.0F); }
public static <E extends EntityLiving> E spawnEntity(World world, E living, double x, double y, double z) { living.setLocationAndAngles(x, y, z, MathHelper.wrapDegrees(world.rand.nextFloat() * 360.0f), 0.0f); living.rotationYawHead = living.rotationYaw; living.renderYawOffset = living.rotationYaw; living.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(x, y, z)), null); world.spawnEntity(living); living.playLivingSound(); return living; }