net.minecraft.util.math.MathHelper#wrapDegrees ( )源码实例Demo

下面列出了net.minecraft.util.math.MathHelper#wrapDegrees ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: bleachhack-1.14   文件: Nuker.java
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);
}
 
源代码2 项目: ToroQuest   文件: EntityVampireBat.java
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;
	}
 
源代码3 项目: bleachhack-1.14   文件: Nuker.java
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);
}
 
源代码4 项目: bleachhack-1.14   文件: Nuker.java
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);
}
 
源代码5 项目: ForgeWurst   文件: RotationUtils.java
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)};
}
 
源代码6 项目: litematica   文件: PositionUtils.java
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;
}
 
源代码7 项目: seppuku   文件: MathUtil.java
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)))};
}
 
源代码8 项目: Wurst7   文件: KillauraLegitHack.java
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);
}
 
源代码9 项目: bleachhack-1.14   文件: EntityUtils.java
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);
}
 
源代码10 项目: AdvancedRocketry   文件: ItemBeaconFinder.java
@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();
			
		}
	}
}
 
源代码11 项目: bleachhack-1.14   文件: EntityUtils.java
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);
}
 
源代码12 项目: bleachhack-1.14   文件: EntityUtils.java
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);
}
 
源代码13 项目: ForgeWurst   文件: RotationUtils.java
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);
}
 
源代码14 项目: ForgeWurst   文件: RotationUtils.java
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);
}
 
源代码15 项目: Wurst7   文件: RotationUtils.java
public Rotation(float yaw, float pitch)
{
	this.yaw = MathHelper.wrapDegrees(yaw);
	this.pitch = MathHelper.wrapDegrees(pitch);
}
 
源代码16 项目: bleachhack-1.14   文件: BlockParty.java
@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;
			}
		}
	}
}
 
源代码17 项目: bleachhack-1.14   文件: BlockParty.java
@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;
			}
		}
	}
}
 
@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;
    }
}
 
源代码19 项目: ForgeHax   文件: AngleHelper.java
public static double normalizeInDegrees(double ang) {
  return MathHelper.wrapDegrees(ang);
}
 
源代码20 项目: OpenModsLib   文件: EvaluatorFactory.java
@Override
protected float evaluate(float arg) {
	return MathHelper.wrapDegrees(arg);
}