Java Code Examples for net.minecraft.util.math.MathHelper#wrapDegrees()

The following examples show how to use net.minecraft.util.math.MathHelper#wrapDegrees() . 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: Nuker.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
public boolean canSeeBlock(BlockPos pos) {
	double diffX = pos.getX() + 0.5 - mc.player.getCameraPosVec(mc.getTickDelta()).x;
	double diffY = pos.getY() + 0.5 - mc.player.getCameraPosVec(mc.getTickDelta()).y;
	double diffZ = pos.getZ() + 0.5 - mc.player.getCameraPosVec(mc.getTickDelta()).z;
		
	double diffXZ = Math.sqrt(diffX * diffX + diffZ * diffZ);
		
	float yaw = mc.player.yaw + MathHelper.wrapDegrees((float)Math.toDegrees(Math.atan2(diffZ, diffX)) - 90 - mc.player.yaw);
	float pitch = mc.player.pitch + MathHelper.wrapDegrees((float)-Math.toDegrees(Math.atan2(diffY, diffXZ)) - mc.player.pitch);
	
	Vec3d rotation = new Vec3d(
			(double)(MathHelper.sin(-yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F)),
			(double)(-MathHelper.sin(pitch * 0.017453292F)),
			(double)(MathHelper.cos(-yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F)));
	
	Vec3d rayVec = mc.player.getCameraPosVec(mc.getTickDelta()).add(rotation.x * 6, rotation.y * 6, rotation.z * 6);
	return mc.world.rayTrace(new RayTraceContext(mc.player.getCameraPosVec(mc.getTickDelta()),
			rayVec, RayTraceContext.ShapeType.OUTLINE, RayTraceContext.FluidHandling.NONE, mc.player))
			.getBlockPos().equals(pos);
}
 
Example 2
Source File: EntityVampireBat.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
protected void batAiEdit() {

		Entity target = getAttackTarget();

		if (target == null || rand.nextInt(100) > 50) {
			this.spawnPosition = nonAttackLocation();
		} else {
			spawnPosition = target.getPosition().up();
		}

		double d0 = (double) this.spawnPosition.getX() + 0.5D - this.posX;
		double d1 = (double) this.spawnPosition.getY() + 0.1D - this.posY;
		double d2 = (double) this.spawnPosition.getZ() + 0.5D - this.posZ;
		this.motionX += (Math.signum(d0) * 0.5D - this.motionX) * 0.10000000149011612D;
		this.motionY += (Math.signum(d1) * 0.699999988079071D - this.motionY) * 0.10000000149011612D;
		this.motionZ += (Math.signum(d2) * 0.5D - this.motionZ) * 0.10000000149011612D;
		float f = (float) (MathHelper.atan2(this.motionZ, this.motionX) * (180D / Math.PI)) - 90.0F;
		float f1 = MathHelper.wrapDegrees(f - this.rotationYaw);
		this.moveForward = 0.5F;
		this.rotationYaw += f1;
	}
 
Example 3
Source File: Nuker.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
public boolean canSeeBlock(BlockPos pos) {
	double diffX = pos.getX() + 0.5 - mc.player.getCameraPosVec(mc.getTickDelta()).x;
	double diffY = pos.getY() + 0.5 - mc.player.getCameraPosVec(mc.getTickDelta()).y;
	double diffZ = pos.getZ() + 0.5 - mc.player.getCameraPosVec(mc.getTickDelta()).z;
		
	double diffXZ = Math.sqrt(diffX * diffX + diffZ * diffZ);
		
	float yaw = mc.player.yaw + MathHelper.wrapDegrees((float)Math.toDegrees(Math.atan2(diffZ, diffX)) - 90 - mc.player.yaw);
	float pitch = mc.player.pitch + MathHelper.wrapDegrees((float)-Math.toDegrees(Math.atan2(diffY, diffXZ)) - mc.player.pitch);
	
	Vec3d rotation = new Vec3d(
			(double)(MathHelper.sin(-yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F)),
			(double)(-MathHelper.sin(pitch * 0.017453292F)),
			(double)(MathHelper.cos(-yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F)));
	
	Vec3d rayVec = mc.player.getCameraPosVec(mc.getTickDelta()).add(rotation.x * 6, rotation.y * 6, rotation.z * 6);
	return mc.world.rayTrace(new RayTraceContext(mc.player.getCameraPosVec(mc.getTickDelta()),
			rayVec, RayTraceContext.ShapeType.OUTLINE, RayTraceContext.FluidHandling.NONE, mc.player))
			.getBlockPos().equals(pos);
}
 
Example 4
Source File: PositionUtils.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static float getMirroredYaw(float yaw, Mirror mirror)
{
    yaw = MathHelper.wrapDegrees(yaw);

    switch (mirror)
    {
        case LEFT_RIGHT:
            yaw = 180.0F - yaw;
            break;
        case FRONT_BACK:
            yaw = -yaw;
            break;
        default:
    }

    return yaw;
}
 
Example 5
Source File: Nuker.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
public boolean canSeeBlock(BlockPos pos) {
	double diffX = pos.getX() + 0.5 - mc.player.getCameraPosVec(mc.getTickDelta()).x;
	double diffY = pos.getY() + 0.5 - mc.player.getCameraPosVec(mc.getTickDelta()).y;
	double diffZ = pos.getZ() + 0.5 - mc.player.getCameraPosVec(mc.getTickDelta()).z;
		
	double diffXZ = Math.sqrt(diffX * diffX + diffZ * diffZ);
		
	float yaw = mc.player.yaw + MathHelper.wrapDegrees((float)Math.toDegrees(Math.atan2(diffZ, diffX)) - 90 - mc.player.yaw);
	float pitch = mc.player.pitch + MathHelper.wrapDegrees((float)-Math.toDegrees(Math.atan2(diffY, diffXZ)) - mc.player.pitch);
	
	Vec3d rotation = new Vec3d(
			(double)(MathHelper.sin(-yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F)),
			(double)(-MathHelper.sin(pitch * 0.017453292F)),
			(double)(MathHelper.cos(-yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F)));
	
	Vec3d rayVec = mc.player.getCameraPosVec(mc.getTickDelta()).add(rotation.x * 6, rotation.y * 6, rotation.z * 6);
	return mc.world.rayTrace(new RayTraceContext(mc.player.getCameraPosVec(mc.getTickDelta()),
			rayVec, RayTraceContext.ShapeType.OUTLINE, RayTraceContext.FluidHandling.NONE, mc.player))
			.getBlockPos().equals(pos);
}
 
Example 6
Source File: RotationUtils.java    From ForgeWurst with GNU General Public License v3.0 6 votes vote down vote up
private static float[] getNeededRotations(Vec3d vec)
{
	Vec3d eyesPos = getEyesPos();
	
	double diffX = WVec3d.getX(vec) - WVec3d.getX(eyesPos);
	double diffY = WVec3d.getY(vec) - WVec3d.getY(eyesPos);
	double diffZ = WVec3d.getZ(vec) - WVec3d.getZ(eyesPos);
	
	double diffXZ = Math.sqrt(diffX * diffX + diffZ * diffZ);
	
	float yaw = (float)Math.toDegrees(Math.atan2(diffZ, diffX)) - 90F;
	float pitch = (float)-Math.toDegrees(Math.atan2(diffY, diffXZ));
	
	return new float[]{MathHelper.wrapDegrees(yaw),
		MathHelper.wrapDegrees(pitch)};
}
 
Example 7
Source File: KillauraLegitHack.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
private float limitAngleChange(float current, float intended,
	float maxChange)
{
	float change = MathHelper.wrapDegrees(intended - current);
	change = MathHelper.clamp(change, -maxChange, maxChange);
	return MathHelper.wrapDegrees(current + change);
}
 
Example 8
Source File: MathUtil.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
public static float[] calcAngle(Vec3d from, Vec3d to) {
    final double difX = to.x - from.x;
    final double difY = (to.y - from.y) * -1.0F;
    final double difZ = to.z - from.z;

    final double dist = MathHelper.sqrt(difX * difX + difZ * difZ);

    return new float[]{(float) MathHelper.wrapDegrees(Math.toDegrees(Math.atan2(difZ, difX)) - 90.0f), (float) MathHelper.wrapDegrees(Math.toDegrees(Math.atan2(difY, dist)))};
}
 
Example 9
Source File: EntityUtils.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public static void facePos(double x, double y, double z) {
	double diffX = x - mc.player.x;
	double diffY = y - (mc.player.y + mc.player.getEyeHeight(mc.player.getPose()));
	double diffZ = z - mc.player.z;
		
	double diffXZ = Math.sqrt(diffX * diffX + diffZ * diffZ);
		
	float yaw = (float)Math.toDegrees(Math.atan2(diffZ, diffX)) - 90F;
	float pitch = (float)-Math.toDegrees(Math.atan2(diffY, diffXZ));
		
	mc.player.yaw += MathHelper.wrapDegrees(yaw - mc.player.yaw);
	mc.player.pitch += MathHelper.wrapDegrees(pitch - mc.player.pitch);
}
 
Example 10
Source File: ItemBeaconFinder.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void renderScreen(ItemStack componentStack, List<ItemStack> modules,
		RenderGameOverlayEvent event, Gui gui) {
	
	int dimid = Minecraft.getMinecraft().world.provider.getDimension();
	
	if(DimensionManager.getInstance().isDimensionCreated(dimid)) {
		for(HashedBlockPosition pos : DimensionManager.getInstance().getDimensionProperties(dimid).getBeacons()) {
			
			GL11.glPushMatrix();
			
			double deltaX = Minecraft.getMinecraft().player.posX - pos.x;
			double deltaZ = Minecraft.getMinecraft().player.posZ - pos.z;
			
			double angle = MathHelper.wrapDegrees(MathHelper.atan2(deltaZ, deltaX)*180/Math.PI + 90 - Minecraft.getMinecraft().player.rotationYawHead);
			
			//GL11.glTranslatef(pos.x, pos.y, pos.z);
			GL11.glTranslated((event.getResolution().getScaledWidth_double()*angle/180f) + event.getResolution().getScaledWidth()/2,0,5);
			//GL11.glDepthMask(false);
			//GL11.glDisable(GL11.GL_TEXTURE_2D);
			Minecraft.getMinecraft().renderEngine.bindTexture(TextureResources.buttonDown[0]);
			
			GlStateManager.color(0.5f, 0.5f, 1, 1);
			
	        Tessellator tessellator = Tessellator.getInstance();
	        BufferBuilder vertexbuffer = tessellator.getBuffer();
	        
	        vertexbuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
	        RenderHelper.renderNorthFaceWithUV(vertexbuffer, -1000, -10, 0, 10, 20, 0, 1, 0, 1);
			tessellator.draw();
			
			//GL11.glDepthMask(true);
			//GL11.glEnable(GL11.GL_TEXTURE_2D);
			GlStateManager.color(1, 1, 1, 1);
			GL11.glPopMatrix();
			
		}
	}
}
 
Example 11
Source File: EntityUtils.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public static void facePos(double x, double y, double z) {
	double diffX = x - mc.player.getX();
	double diffY = y - (mc.player.getY() + mc.player.getEyeHeight(mc.player.getPose()));
	double diffZ = z - mc.player.getZ();
		
	double diffXZ = Math.sqrt(diffX * diffX + diffZ * diffZ);
		
	float yaw = (float)Math.toDegrees(Math.atan2(diffZ, diffX)) - 90F;
	float pitch = (float)-Math.toDegrees(Math.atan2(diffY, diffXZ));
		
	mc.player.yaw += MathHelper.wrapDegrees(yaw - mc.player.yaw);
	mc.player.pitch += MathHelper.wrapDegrees(pitch - mc.player.pitch);
}
 
Example 12
Source File: EntityUtils.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public static void facePos(double x, double y, double z) {
	double diffX = x - mc.player.getX();
	double diffY = y - (mc.player.getY() + mc.player.getEyeHeight(mc.player.getPose()));
	double diffZ = z - mc.player.getZ();
		
	double diffXZ = Math.sqrt(diffX * diffX + diffZ * diffZ);
		
	float yaw = (float)Math.toDegrees(Math.atan2(diffZ, diffX)) - 90F;
	float pitch = (float)-Math.toDegrees(Math.atan2(diffY, diffXZ));
		
	mc.player.yaw += MathHelper.wrapDegrees(yaw - mc.player.yaw);
	mc.player.pitch += MathHelper.wrapDegrees(pitch - mc.player.pitch);
}
 
Example 13
Source File: RotationUtils.java    From ForgeWurst with GNU General Public License v3.0 5 votes vote down vote up
public static double getAngleToLookVec(Vec3d vec)
{
	float[] needed = getNeededRotations(vec);
	
	EntityPlayerSP player = WMinecraft.getPlayer();
	float currentYaw = MathHelper.wrapDegrees(player.rotationYaw);
	float currentPitch = MathHelper.wrapDegrees(player.rotationPitch);
	
	float diffYaw = currentYaw - needed[0];
	float diffPitch = currentPitch - needed[1];
	
	return Math.sqrt(diffYaw * diffYaw + diffPitch * diffPitch);
}
 
Example 14
Source File: RotationUtils.java    From ForgeWurst with GNU General Public License v3.0 5 votes vote down vote up
public static double getAngleToLastReportedLookVec(Vec3d vec)
{
	float[] needed = getNeededRotations(vec);
	
	EntityPlayerSP player = WMinecraft.getPlayer();
	float lastReportedYaw;
	float lastReportedPitch;
	try
	{
		Field yawField = EntityPlayerSP.class
			.getDeclaredField(ForgeWurst.getForgeWurst().isObfuscated()
				? "field_175164_bL" : "lastReportedYaw");
		yawField.setAccessible(true);
		lastReportedYaw = MathHelper.wrapDegrees(yawField.getFloat(player));
		
		Field pitchField = EntityPlayerSP.class
			.getDeclaredField(ForgeWurst.getForgeWurst().isObfuscated()
				? "field_175165_bM" : "lastReportedPitch");
		pitchField.setAccessible(true);
		lastReportedPitch =
			MathHelper.wrapDegrees(pitchField.getFloat(player));
		
	}catch(ReflectiveOperationException e)
	{
		throw new RuntimeException(e);
	}
	
	float diffYaw = lastReportedYaw - needed[0];
	float diffPitch = lastReportedPitch - needed[1];
	
	return Math.sqrt(diffYaw * diffYaw + diffPitch * diffPitch);
}
 
Example 15
Source File: EvaluatorFactory.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
protected float evaluate(float arg) {
	return MathHelper.wrapDegrees(arg);
}
 
Example 16
Source File: AngleHelper.java    From ForgeHax with MIT License 4 votes vote down vote up
public static double normalizeInDegrees(double ang) {
  return MathHelper.wrapDegrees(ang);
}
 
Example 17
Source File: TileEntityGiantPropellerPart.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
public void update() {
    if (!this.getWorld().isRemote) {
        if (firstUpdate) {
            this.rotationNode.markInitialized();
            this.rotationNode.queueTask(() -> this.rotationNode.setAngularVelocityRatio(
                this.getMultiBlockSchematic().getPropellerFacing().getOpposite(),
                Optional.of(-1D)));
            firstUpdate = false;
        }

        if (this.isPartOfAssembledMultiblock()) {
            Optional<PhysicsObject> physicsObjectOptional = ValkyrienUtils
                .getPhysicsObject(getWorld(), getPos());
            if (this.isMaster()) {
                if (!rotationNode.hasBeenPlacedIntoNodeWorld()) {
                    IRotationNodeWorld nodeWorld;
                    if (physicsObjectOptional.isPresent()) {
                        nodeWorld = physicsObjectOptional.get()
                            .getPhysicsProcessor().getPhysicsRotationNodeWorld();
                    } else {
                        IRotationNodeWorldProvider provider = (IRotationNodeWorldProvider) getWorld();
                        nodeWorld = provider.getPhysicsRotationNodeWorld();
                    }

                    nodeWorld.enqueueTaskOntoWorld(
                        () -> nodeWorld.setNodeFromPos(getPos(), rotationNode));

                    final int propellerRadius = this.getMultiBlockSchematic()
                        .getPropellerRadius();
                    this.rotationNode.queueTask(() -> this.rotationNode
                        .setRotationalInertia(propellerRadius * propellerRadius));
                }
                this.prevPropellerAngle = this.propellerAngle;
                // May need to convert to degrees from radians.
                this.propellerAngle = Math
                    .toDegrees(rotationNode.getAngularRotationUnsynchronized());
            }
            VSNetwork.sendTileToAllNearby(this);
        }
    } else {
        this.prevPropellerAngle = this.propellerAngle;
        double increment = nextPropellerAngle - propellerAngle;
        if (increment < 0) {
            increment = MathHelper.wrapDegrees(increment);
        }
        this.propellerAngle = this.propellerAngle + increment * .75;
    }
}
 
Example 18
Source File: BlockParty.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	Item item = mc.player.inventory.getMainHandStack().getItem();
	Block block = Block.getBlockFromItem(item);
	if (block == Blocks.AIR) return;
	
	if (mc.world.getBlockState(mc.player.getBlockPos().add(0, -1, 0)).getBlock() == block
			|| mc.world.getBlockState(mc.player.getBlockPos().add(0, -2, 0)).getBlock() == block) {
		mc.player.setVelocity(0, mc.player.getVelocity().y, 0);
		KeyBinding.setKeyPressed(mc.options.keyForward.getDefaultKeyCode(), false);
		return;
	}
	
	List<BlockPos> poses = new ArrayList<>();
	for (int x = -50; x < 50; x++) {
		for (int y = -2; y < 1; y++) {
			for (int z = -50; z < 50; z++) {
				if (mc.world.getBlockState(mc.player.getBlockPos().add(x, y, z)).getBlock() == block
						&& mc.world.getBlockState(mc.player.getBlockPos().add(x, y+1, z)).getBlock() == Blocks.AIR) poses.add(mc.player.getBlockPos().add(x, y, z));
			}
		}
	}
	
	if (poses.isEmpty()) return;
	
	poses.sort((a,b) -> Double.compare(a.getSquaredDistance(mc.player.getBlockPos()), b.getSquaredDistance(mc.player.getBlockPos())));
	
	double diffX = poses.get(0).getX() + 0.5 - mc.player.getX();
	double diffZ = poses.get(0).getZ() + 0.5 - mc.player.getZ();
		
	float yaw = (float)Math.toDegrees(Math.atan2(diffZ, diffX)) - 90F;
		
	mc.player.yaw += MathHelper.wrapDegrees(yaw - mc.player.yaw);
	
	KeyBinding.setKeyPressed(mc.options.keyForward.getDefaultKeyCode(), true);
	
	if (mc.player.getBlockPos().getSquaredDistance(poses.get(0)) < (mc.player.isSprinting() ? 25 : 8)
			&& Math.abs(mc.player.getVelocity().x) + Math.abs(mc.player.getVelocity().z) > 0.15
			&& mc.player.verticalCollision) {
		mc.player.jump();
		mc.player.verticalCollision = false;
		//mc.player.setPosition(mc.player.getX(), mc.player.y + 0.02, mc.player.getZ());
	}
	
	if (getSettings().get(1).toToggle().state && mc.player.fallDistance < 0.25) {
		if (jumping && mc.player.getY() >= mc.player.prevY + 0.399994D) {
			mc.player.setVelocity(mc.player.getVelocity().x, -0.9, mc.player.getVelocity().z);
			mc.player.setPos(mc.player.getX(), mc.player.prevY, mc.player.getZ());
			jumping = false;
		}
		
		if (mc.player.forwardSpeed != 0.0F && !mc.player.horizontalCollision) {
			if (mc.player.verticalCollision) {
				mc.player.setVelocity(mc.player.getVelocity().x * Math.min(1.3, 0.85 + mc.player.getBlockPos().getSquaredDistance(poses.get(0)) / 300),
						mc.player.getVelocity().y,
						mc.player.getVelocity().z * Math.min(1.3, 0.85 + mc.player.getBlockPos().getSquaredDistance(poses.get(0)) / 300));
				jumping = true;
				mc.player.jump();
			}
			
			if (jumping && mc.player.getY() >= mc.player.prevY + 0.399994D) {
				mc.player.setVelocity(mc.player.getVelocity().x, -100, mc.player.getVelocity().z);
				jumping = false;
			}
		}
	}
}
 
Example 19
Source File: BlockParty.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	Item item = mc.player.inventory.getMainHandStack().getItem();
	Block block = Block.getBlockFromItem(item);
	if (block == Blocks.AIR) return;
	
	if (mc.world.getBlockState(mc.player.getBlockPos().add(0, -1, 0)).getBlock() == block
			|| mc.world.getBlockState(mc.player.getBlockPos().add(0, -2, 0)).getBlock() == block) {
		mc.player.setVelocity(0, mc.player.getVelocity().y, 0);
		KeyBinding.setKeyPressed(mc.options.keyForward.getDefaultKeyCode(), false);
		return;
	}
	
	List<BlockPos> poses = new ArrayList<>();
	for (int x = -50; x < 50; x++) {
		for (int y = -2; y < 1; y++) {
			for (int z = -50; z < 50; z++) {
				if (mc.world.getBlockState(mc.player.getBlockPos().add(x, y, z)).getBlock() == block
						&& mc.world.getBlockState(mc.player.getBlockPos().add(x, y+1, z)).getBlock() == Blocks.AIR) poses.add(mc.player.getBlockPos().add(x, y, z));
			}
		}
	}
	
	if (poses.isEmpty()) return;
	
	poses.sort((a,b) -> Double.compare(a.getSquaredDistance(mc.player.getBlockPos()), b.getSquaredDistance(mc.player.getBlockPos())));
	
	double diffX = poses.get(0).getX() + 0.5 - mc.player.x;
	double diffZ = poses.get(0).getZ() + 0.5 - mc.player.z;
		
	float yaw = (float)Math.toDegrees(Math.atan2(diffZ, diffX)) - 90F;
		
	mc.player.yaw += MathHelper.wrapDegrees(yaw - mc.player.yaw);
	
	KeyBinding.setKeyPressed(mc.options.keyForward.getDefaultKeyCode(), true);
	
	if (mc.player.getBlockPos().getSquaredDistance(poses.get(0)) < (mc.player.isSprinting() ? 25 : 8)
			&& Math.abs(mc.player.getVelocity().x) + Math.abs(mc.player.getVelocity().z) > 0.15
			&& mc.player.verticalCollision) {
		mc.player.jump();
		mc.player.verticalCollision = false;
		//mc.player.setPosition(mc.player.x, mc.player.y + 0.02, mc.player.z);
	}
	
	if (getSettings().get(1).toToggle().state && mc.player.fallDistance < 0.25) {
		if (jumping && mc.player.y >= mc.player.prevY + 0.399994D) {
			mc.player.setVelocity(mc.player.getVelocity().x, -0.9, mc.player.getVelocity().z);
			mc.player.y = mc.player.prevY;
			jumping = false;
		}
		
		if (mc.player.forwardSpeed != 0.0F && !mc.player.horizontalCollision) {
			if (mc.player.verticalCollision) {
				mc.player.setVelocity(mc.player.getVelocity().x * Math.min(1.3, 0.85 + mc.player.getBlockPos().getSquaredDistance(poses.get(0)) / 300),
						mc.player.getVelocity().y,
						mc.player.getVelocity().z * Math.min(1.3, 0.85 + mc.player.getBlockPos().getSquaredDistance(poses.get(0)) / 300));
				jumping = true;
				mc.player.jump();
			}
			
			if (jumping && mc.player.y >= mc.player.prevY + 0.399994D) {
				mc.player.setVelocity(mc.player.getVelocity().x, -100, mc.player.getVelocity().z);
				jumping = false;
			}
		}
	}
}
 
Example 20
Source File: RotationUtils.java    From Wurst7 with GNU General Public License v3.0 4 votes vote down vote up
public Rotation(float yaw, float pitch)
{
	this.yaw = MathHelper.wrapDegrees(yaw);
	this.pitch = MathHelper.wrapDegrees(pitch);
}