类net.minecraft.util.math.Vec3d源码实例Demo

下面列出了怎么用net.minecraft.util.math.Vec3d的API类实例代码及写法,或者点击链接到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 项目: Wizardry   文件: LibParticles.java
public static void MAGIC_DOT(World world, Vec3d pos, float scale) {
	ParticleBuilder glitter = new ParticleBuilder(3);
	glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
	glitter.setAlphaFunction(new InterpFloatInOut(1f, 1f));
	glitter.enableMotionCalculation();
	ParticleSpawner.spawn(glitter, world, new StaticInterp<>(pos), 1, 0, (aFloat, particleBuilder) -> {
		glitter.setColor(new Color(RandUtil.nextInt(0, 100), RandUtil.nextInt(0, 100), RandUtil.nextInt(50, 255)));
		if (scale == -1) glitter.setScale(RandUtil.nextFloat());
		else {
			glitter.setAlphaFunction(new InterpFloatInOut(1f, 1f));
			glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(0.3), 0));
			glitter.setLifetime(RandUtil.nextInt(30));
			glitter.setScale(scale);
		}
	});
}
 
源代码3 项目: Wurst7   文件: KaboomHack.java
private ArrayList<BlockPos> getBlocksByDistanceReversed(double range)
{
	Vec3d eyesVec = RotationUtils.getEyesPos().subtract(0.5, 0.5, 0.5);
	double rangeSq = Math.pow(range + 0.5, 2);
	int rangeI = (int)Math.ceil(range);
	
	BlockPos center = new BlockPos(RotationUtils.getEyesPos());
	BlockPos min = center.add(-rangeI, -rangeI, -rangeI);
	BlockPos max = center.add(rangeI, rangeI, rangeI);
	
	return BlockUtils.getAllInBox(min, max).stream()
		.filter(pos -> eyesVec.squaredDistanceTo(Vec3d.of(pos)) <= rangeSq)
		.sorted(Comparator.comparingDouble(
			pos -> -eyesVec.squaredDistanceTo(Vec3d.of(pos))))
		.collect(Collectors.toCollection(() -> new ArrayList<>()));
}
 
源代码4 项目: TFC2   文件: Helper.java
/**
 * Rotates a Vec3d around an arbitrary rotation point along an axis with a rotation in radians
 */
public static Vec3d rotateVertex(Vec3d origin, Vec3d src, Vec3d axis, double rotation)
{
	double q0 = 1;
	double q1 = 0;
	double q2 = 0;
	double q3 = 0;
	double norm = axis.lengthVector();
	if (norm == 0) {
		throw new ArithmeticException("zero norm for rotation axis");
	}

	double halfAngle = -0.5 * rotation;
	double coeff = Math.sin(halfAngle) / norm;

	q0 = Math.cos (halfAngle);
	q1 = coeff * axis.xCoord;
	q2 = coeff * axis.yCoord;
	q3 = coeff * axis.zCoord;

	return origin.add(applyTo(src.subtract(origin), q0, q1, q2, q3));

}
 
源代码5 项目: fabric-carpet   文件: MobAI.java
/**
 * Not a replacement for living entity jump() - this barely is to allow other entities that can't jump in vanilla to 'jump'
 * @param e
 */
public static void genericJump(Entity e)
{
    if (!e.onGround && !e.isInFluid(FluidTags.WATER) && !e.isInLava()) return;
    float m = e.world.getBlockState(new BlockPos(e)).getBlock().getJumpVelocityMultiplier();
    float g = e.world.getBlockState(new BlockPos(e.getX(), e.getBoundingBox().y1 - 0.5000001D, e.getZ())).getBlock().getJumpVelocityMultiplier();
    float jumpVelocityMultiplier = (double) m == 1.0D ? g : m;
    float jumpStrength = (0.42F * jumpVelocityMultiplier);
    Vec3d vec3d = e.getVelocity();
    e.setVelocity(vec3d.x, jumpStrength, vec3d.z);
    if (e.isSprinting())
    {
        float u = e.yaw * 0.017453292F;
        e.setVelocity(e.getVelocity().add((-MathHelper.sin(g) * 0.2F), 0.0D, (MathHelper.cos(u) * 0.2F)));
    }
    e.velocityDirty = true;
}
 
源代码6 项目: bleachhack-1.14   文件: RenderUtils.java
public static void drawFilledBox(AxisAlignedBB box, float r, float g, float b, float a) {
gl11Setup();

Vec3d ren = renderPos();

      /* Fill */
      Tessellator tessellator = Tessellator.getInstance();
      BufferBuilder buffer = tessellator.getBuffer();
      buffer.begin(5, DefaultVertexFormats.POSITION_COLOR);
      WorldRenderer.addChainedFilledBoxVertices(buffer,
      		box.minX - ren.x, box.minY - ren.y, box.minZ - ren.z,
      		box.maxX - ren.x, box.maxY - ren.y, box.maxZ - ren.z, r, g, b, a/2f);
      tessellator.draw();
      
      /* Outline */
      WorldRenderer.drawSelectionBoundingBox(new AxisAlignedBB(
      		box.minX - ren.x, box.minY - ren.y, box.minZ - ren.z,
      		box.maxX - ren.x, box.maxY - ren.y, box.maxZ - ren.z), r, g, b, a);

      gl11Cleanup();
  }
 
源代码7 项目: fabric-carpet   文件: CarpetEventServer.java
@Override
public void onBlockHit(ServerPlayerEntity player, Hand enumhand, BlockHitResult hitRes)//ItemStack itemstack, Hand enumhand, BlockPos blockpos, Direction enumfacing, Vec3d vec3d)
{
    handler.call( () ->
    {
        ItemStack itemstack = player.getStackInHand(enumhand);
        BlockPos blockpos = hitRes.getBlockPos();
        Direction enumfacing = hitRes.getSide();
        Vec3d vec3d = hitRes.getPos().subtract(blockpos.getX(), blockpos.getY(), blockpos.getZ());
        return Arrays.asList(
                ((c, t) -> new EntityValue(player)),
                ((c, t) -> ListValue.fromItemStack(itemstack)),
                ((c, t) -> new StringValue(enumhand == Hand.MAIN_HAND ? "mainhand" : "offhand")),
                ((c, t) -> new BlockValue(null, player.getServerWorld(), blockpos)),
                ((c, t) -> new StringValue(enumfacing.getName())),
                ((c, t) -> ListValue.of(
                        new NumericValue(vec3d.x),
                        new NumericValue(vec3d.y),
                        new NumericValue(vec3d.z)
                ))
        );
    }, player::getCommandSource);
}
 
源代码8 项目: Valkyrien-Skies   文件: BlockPassengerChair.java
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state,
    EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (!worldIn.isRemote) {
        Vec3d chairPos = getPlayerMountOffset(state, pos);

        TileEntity chairTile = worldIn.getTileEntity(pos);
        if (chairTile instanceof TileEntityPassengerChair) {
            // Try mounting the player onto the chair if possible.
            ((TileEntityPassengerChair) chairTile).tryToMountPlayerToChair(playerIn, chairPos);
        } else {
            new IllegalStateException(
                "world.getTileEntity() returned a tile that wasn't a chair at pos " + pos)
                .printStackTrace();
        }
    }
    return true;
}
 
源代码9 项目: Wizardry   文件: LibParticles.java
public static void SPIRIT_WIGHT_FLAME_FAR(World world, Vec3d pos) {
	ParticleBuilder glitter = new ParticleBuilder(30);
	glitter.setRender(new ResourceLocation(Wizardry.MODID, MISC.SPARKLE_BLURRED));
	glitter.setAlphaFunction(new InterpFloatInOut(0.3f, 0.3f));

	ParticleSpawner.spawn(glitter, world, new StaticInterp<>(pos), 5, 0, (i, build) -> {
		double radius = 0.15;
		double theta = 2.0f * (float) Math.PI * RandUtil.nextFloat();
		double r = radius * RandUtil.nextFloat();
		double x = r * MathHelper.cos((float) theta);
		double z = r * MathHelper.sin((float) theta);

		glitter.setColorFunction(new InterpColorHSV(Color.RED, 50, 20.0F));
		glitter.setPositionOffset(new Vec3d(x, RandUtil.nextDouble(0, 0.5), z));
		glitter.addMotion(new Vec3d(0, RandUtil.nextDouble(0, 0.02), 0));
	});
}
 
源代码10 项目: bleachhack-1.14   文件: Flight.java
public void onUpdate() {
	if (this.isToggled()) {
		float speed = (float) getSettings().get(1).toSlider().getValue();
		
		if (getSettings().get(0).toMode().mode == 0) {
			mc.player.abilities.setFlySpeed(speed / 10);
			mc.player.abilities.allowFlying = true;
			mc.player.abilities.isFlying = true;
		} else if (getSettings().get(0).toMode().mode == 1) {
			mc.player.setMotion(0, mc.player.ticksExisted % 20 == 0 ? -0.06 : 0, 0);
			Vec3d forward = new Vec3d(0, 0, speed).rotateYaw(-(float) Math.toRadians(mc.player.rotationYaw));
			Vec3d strafe = forward.rotateYaw((float) Math.toRadians(90));
			
			if (mc.gameSettings.keyBindJump.isKeyDown()) mc.player.setMotion(mc.player.getMotion().add(0, speed, 0));
			if (mc.gameSettings.keyBindSneak.isKeyDown()) mc.player.setMotion(mc.player.getMotion().add(0, -speed, 0));
			if (mc.gameSettings.keyBindForward.isKeyDown()) mc.player.setMotion(mc.player.getMotion().add(forward.x, 0, forward.z));
			if (mc.gameSettings.keyBindBack.isKeyDown()) mc.player.setMotion(mc.player.getMotion().add(-forward.x, 0, -forward.z));
			if (mc.gameSettings.keyBindLeft.isKeyDown()) mc.player.setMotion(mc.player.getMotion().add(strafe.x, 0, strafe.z));
			if (mc.gameSettings.keyBindRight.isKeyDown()) mc.player.setMotion(mc.player.getMotion().add(-strafe.x, 0, -strafe.z));

		} else if (getSettings().get(0).toMode().mode == 2) {
			if (!mc.gameSettings.keyBindJump.isKeyDown()) return;
			mc.player.setMotion(mc.player.getMotion().x, speed / 3, mc.player.getMotion().z);
		}
	}
}
 
源代码11 项目: Wurst7   文件: ExcavatorHack.java
private ArrayList<BlockPos> getValidBlocks(double range,
	Predicate<BlockPos> validator)
{
	Vec3d eyesVec = RotationUtils.getEyesPos().subtract(0.5, 0.5, 0.5);
	double rangeSq = Math.pow(range + 0.5, 2);
	int rangeI = (int)Math.ceil(range);
	
	BlockPos center = new BlockPos(RotationUtils.getEyesPos());
	BlockPos min = center.add(-rangeI, -rangeI, -rangeI);
	BlockPos max = center.add(rangeI, rangeI, rangeI);
	
	return BlockUtils.getAllInBox(min, max).stream()
		.filter(pos -> eyesVec.squaredDistanceTo(Vec3d.of(pos)) <= rangeSq)
		.filter(BlockUtils::canBeClicked).filter(validator)
		.sorted(Comparator.comparingDouble(
			pos -> eyesVec.squaredDistanceTo(Vec3d.of(pos))))
		.collect(Collectors.toCollection(() -> new ArrayList<>()));
}
 
源代码12 项目: Valkyrien-Skies   文件: EntityMountable.java
@Override
protected void writeEntityToNBT(NBTTagCompound compound) {
    // Try to prevent data race
    Vec3d mountPosLocal = mountPos;
    compound.setDouble("vs_mount_pos_x", mountPosLocal.x);
    compound.setDouble("vs_mount_pos_y", mountPosLocal.y);
    compound.setDouble("vs_mount_pos_z", mountPosLocal.z);

    compound.setInteger("vs_coord_type", mountPosSpace.ordinal());

    compound.setBoolean("vs_ref_pos_present", referencePos != null);
    if (referencePos != null) {
        compound.setInteger("vs_ref_pos_x", referencePos.getX());
        compound.setInteger("vs_ref_pos_y", referencePos.getY());
        compound.setInteger("vs_ref_pos_z", referencePos.getZ());
    }
}
 
源代码13 项目: Wizardry   文件: LibParticles.java
public static void SPIRIT_WIGHT_HURT(World world, Vec3d pos) {
	ParticleBuilder glitter = new ParticleBuilder(RandUtil.nextInt(100, 150));
	glitter.setColorFunction(new InterpColorHSV(Color.BLUE, 50, 20.0F));
	glitter.setRender(new ResourceLocation(Wizardry.MODID, MISC.SPARKLE_BLURRED));
	glitter.setAlphaFunction(new InterpFloatInOut(0.1f, 0.1f));

	ParticleSpawner.spawn(glitter, world, new StaticInterp<>(pos), RandUtil.nextInt(40, 100), 0, (i, build) -> {
		double radius = 0.2;
		double theta = 2.0f * (float) Math.PI * RandUtil.nextFloat();
		double r = radius * RandUtil.nextFloat();
		double x = r * MathHelper.cos((float) theta);
		double z = r * MathHelper.sin((float) theta);

		glitter.setPositionOffset(new Vec3d(x, RandUtil.nextDouble(0, 0.4), z));
		glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(0, 0.02), 0));
	});
}
 
源代码14 项目: Wurst7   文件: KillauraLegitHack.java
private boolean faceEntityClient(LivingEntity entity)
{
	// get position & rotation
	Vec3d eyesPos = RotationUtils.getEyesPos();
	Vec3d lookVec = RotationUtils.getServerLookVec();
	
	// try to face center of boundingBox
	Box bb = entity.getBoundingBox();
	if(faceVectorClient(bb.getCenter()))
		return true;
	
	// if not facing center, check if facing anything in boundingBox
	return bb.rayTrace(eyesPos,
		eyesPos.add(lookVec.multiply(range.getValue()))) != null;
}
 
源代码15 项目: fabric-carpet   文件: Tracer.java
public static EntityHitResult rayTraceEntities(Entity source, float partialTicks, double reach, double maxSqDist)
{
    Vec3d pos = source.getCameraPosVec(partialTicks);
    Vec3d reachVec = source.getRotationVec(partialTicks).multiply(reach);
    Box box = source.getBoundingBox().stretch(reachVec).expand(1);
    return rayTraceEntities(source, pos, pos.add(reachVec), box, e -> !e.isSpectator() && e.collides(), maxSqDist);
}
 
源代码16 项目: the-hallow   文件: BarrowFeature.java
private boolean generate(IWorld world, Random rand, BlockPos pos, CoordinateFunction<SurfaceConfig> configFunction) {
	int centreX = pos.getX() + rand.nextInt(16) - 8;
	int centreZ = pos.getZ() + rand.nextInt(16) - 8;
	int lowY = pos.getY() - 3;
	
	int radius = rand.nextInt(6) + 7;
	int height = rand.nextInt(4) + 6;
	
	double radiusSquared = radius * radius;
	
	Vec3d origin = new Vec3d(centreX, 0, centreZ);
	
	BlockPos.Mutable posMutable = new BlockPos.Mutable();
	
	for (int xOffset = -radius; xOffset <= radius; ++xOffset) {
		int x = centreX + xOffset;
		
		for (int zOffset = -radius; zOffset <= radius; ++zOffset) {
			int z = centreZ + zOffset;
			
			Vec3d position = new Vec3d(x, 0, z);
			double sqrDistTo = position.squaredDistanceTo(origin);
			if (sqrDistTo <= radiusSquared) {
				double progress = MathHelper.perlinFade(sqrDistTo / radiusSquared);
				int heightOffset = (int) MathHelper.lerp(progress, height, 0);
				heightOffset += (int) MathHelper.lerp(progress, offsetNoise.sample(x, z), 0);
				
				posMutable.setX(x);
				posMutable.setZ(z);
				
				this.generateBarrowColumn(world, rand, lowY, heightOffset, posMutable, configFunction.get(posMutable));
			}
		}
	}
	return true;
}
 
源代码17 项目: Wizardry   文件: EntityFairy.java
public void setLookTarget(Vec3d lookTarget) {
	NBTTagCompound compound = new NBTTagCompound();
	if (lookTarget == null) return;
	else {
		compound.setDouble("look_target_x", lookTarget.x);
		compound.setDouble("look_target_y", lookTarget.y);
		compound.setDouble("look_target_z", lookTarget.z);
	}

	this.getDataManager().set(DATA_LOOK_TARGET, compound);
	this.getDataManager().setDirty(DATA_LOOK_TARGET);
}
 
源代码18 项目: ForgeWurst   文件: RotationUtils.java
public static boolean faceVectorPacket(Vec3d vec)
{
	float[] rotations = getNeededRotations(vec);
	
	fakeRotation = true;
	serverYaw = rotations[0];
	serverPitch = rotations[1];
	
	return Math.abs(serverYaw - rotations[0]) < 1F;
}
 
源代码19 项目: bleachhack-1.14   文件: Tracers.java
@Subscribe
public void onRender(Event3DRender event) {
	final float thick = (float) getSettings().get(6).toSlider().getValue();
	
	for (Entity e: mc.world.getEntities()) {
		Vec3d vec = e.getPos();
		
		Vec3d vec2 = new Vec3d(0, 0, 75).rotateX(-(float) Math.toRadians(mc.cameraEntity.pitch))
				.rotateY(-(float) Math.toRadians(mc.cameraEntity.yaw))
				.add(mc.cameraEntity.getPos().add(0, mc.cameraEntity.getEyeHeight(mc.cameraEntity.getPose()), 0));
		
		if (e instanceof PlayerEntity && e != mc.player && e != mc.cameraEntity && getSettings().get(0).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f,0f,0f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f,0f,0f,thick);
		}
		else if (e instanceof Monster && getSettings().get(1).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0f,0f,0f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0f,0f,0f,thick);
		}
		else if (EntityUtils.isAnimal(e) && getSettings().get(2).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0f,1f,0f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0f,1f,0f,thick);
		}
		else if (e instanceof ItemEntity && getSettings().get(3).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f,0.7f,0f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f,0.7f,0f,thick);
		}
		else if (e instanceof EnderCrystalEntity && getSettings().get(4).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f, 0f, 1f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f, 0f, 1f,thick);
		}
		else if ((e instanceof BoatEntity || e instanceof AbstractMinecartEntity) && getSettings().get(5).toToggle().state) {
			RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0.5f, 0.5f, 0.5f,thick);
			RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0.5f, 0.5f, 0.5f,thick);
		}
	}
}
 
源代码20 项目: the-hallow   文件: BramblesBlock.java
@SuppressWarnings("deprecation")
@Override
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
	if (entity instanceof LivingEntity && entity.getType() != HallowedEntities.CROW && entity.getType() != HallowedEntities.PUMPCOWN) {
		entity.slowMovement(state, new Vec3d(0.800000011920929D, 0.75D, 0.800000011920929D));
		if (!world.isClient && (entity.lastRenderX != entity.getX() || entity.lastRenderZ != entity.getZ())) {
			double entityX = Math.abs(entity.getX() - entity.lastRenderX);
			double entityZ = Math.abs(entity.getZ() - entity.lastRenderZ);
			if (entityX >= 0.003000000026077032D || entityZ >= 0.003000000026077032D) {
				entity.damage(DAMAGE_SOURCE, 1.0F);
			}
		}
	}
}
 
源代码21 项目: bleachhack-1.14   文件: ElytraFly.java
public void onUpdate() {
	if (this.isToggled()) {
		if (mc.player.isElytraFlying()) {
			Vec3d vec3d = new Vec3d(0,0,getSettings().get(0).toSlider().getValue())
					.rotatePitch(-(float) Math.toRadians(mc.player.rotationPitch))
					.rotateYaw(-(float) Math.toRadians(mc.player.rotationYaw));
			
			mc.player.setMotion(
					mc.player.getMotion().x + vec3d.x + (vec3d.x - mc.player.getMotion().x),
					mc.player.getMotion().y + vec3d.y + (vec3d.y - mc.player.getMotion().y),
					mc.player.getMotion().z + vec3d.z + (vec3d.z - mc.player.getMotion().z));
			
		}
	}
}
 
源代码22 项目: litematica   文件: RayTraceUtils.java
private static boolean traceToOrigin(BlockPos pos, Vec3d start, Vec3d end, HitType type, @Nullable SchematicPlacement placement)
{
    if (pos != null)
    {
        AxisAlignedBB bb = PositionUtils.createAABBForPosition(pos);
        RayTraceResult trace = bb.calculateIntercept(start, end);

        if (trace != null)
        {
            double dist = trace.hitVec.distanceTo(start);

            if (closestOriginDistance < 0 || dist < closestOriginDistance)
            {
                closestOriginDistance = dist;
                originType = type;

                if (type == HitType.PLACEMENT_ORIGIN)
                {
                    closestOrigin = new RayTraceWrapper(placement, trace.hitVec, null);
                }

                return true;
            }
        }
    }

    return false;
}
 
源代码23 项目: Wurst7   文件: RotationFaker.java
public void faceVectorClient(Vec3d vec)
{
	RotationUtils.Rotation rotations =
		RotationUtils.getNeededRotations(vec);
	
	WurstClient.MC.player.yaw = rotations.getYaw();
	WurstClient.MC.player.pitch = rotations.getPitch();
}
 
源代码24 项目: Wizardry   文件: ModuleEffectFrost.java
@ModuleOverride("shape_zone_run")
public boolean onRunZone(World world, SpellData data, SpellRing ring, @ContextRing SpellRing childRing) {
	if(!world.isRemote) return false;

	double aoe = ring.getAttributeValue(world, AttributeRegistry.AREA, data);
	double range = ring.getAttributeValue(world, AttributeRegistry.RANGE, data);

	Vec3d targetPos = data.getTarget(world);

	if (targetPos == null) return false;

	Vec3d min = targetPos.subtract(aoe, range, aoe);
	Vec3d max = targetPos.add(aoe, range, aoe);

	List<Entity> entities = world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(min, max));
	for (Entity entity : entities) {
		entity.extinguish();
		if (entity instanceof EntityLivingBase) {
			if (!((EntityLivingBase) entity).isPotionActive(ModPotions.SLIPPERY) && entity.getDistanceSq(targetPos.x, targetPos.y, targetPos.z) <= aoe * aoe) {

				double time = childRing.getAttributeValue(world, AttributeRegistry.DURATION, data) * 10;
				world.playSound(null, entity.getPosition(), ModSounds.FROST_FORM, SoundCategory.NEUTRAL, 1, 1);
				((EntityLivingBase) entity).addPotionEffect(new PotionEffect(ModPotions.SLIPPERY, (int) time, 0, true, false));
			}
		}
	}
	return false;
}
 
源代码25 项目: seppuku   文件: NukerModule.java
@Listener
public void onWalkingUpdate(EventUpdateWalkingPlayer event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {
        BlockPos pos = null;

        switch (this.mode.getValue()) {
            case SELECTION:
                pos = this.getClosestBlockSelection();
                break;
            case ALL:
                pos = this.getClosestBlockAll();
                break;
        }

        if (pos != null) {
            final Minecraft mc = Minecraft.getMinecraft();

            final float[] angle = MathUtil.calcAngle(mc.player.getPositionEyes(mc.getRenderPartialTicks()), new Vec3d(pos.getX() + 0.5f, pos.getY() + 0.5f, pos.getZ() + 0.5f));
            Seppuku.INSTANCE.getRotationManager().setPlayerRotations(angle[0], angle[1]);

            if (canBreak(pos)) {
                mc.playerController.onPlayerDamageBlock(pos, mc.player.getHorizontalFacing());
                mc.player.swingArm(EnumHand.MAIN_HAND);
            }
        }
    }
}
 
源代码26 项目: Sound-Physics   文件: SoundPhysics.java
private static Vec3d reflect(Vec3d dir, Vec3d normal)
{
	//dir - 2.0 * dot(normal, dir) * normal
	double dot = dir.dotProduct(normal);
	
	double x = dir.xCoord - 2.0 * dot * normal.xCoord;
	double y = dir.yCoord - 2.0 * dot * normal.yCoord;
	double z = dir.zCoord - 2.0 * dot * normal.zCoord;
	
	return new Vec3d(x, y, z);
}
 
源代码27 项目: enderutilities   文件: ItemPortalScaler.java
public Vec3d getDestinationPosition(ItemStack stack, EntityPlayer player, int destDimension)
{
    ItemStack cardStack = this.getSelectedModuleStack(stack, ModuleType.TYPE_MEMORY_CARD_MISC);
    NBTTagCompound moduleNbt = cardStack.getTagCompound();
    NBTTagCompound tag = moduleNbt.getCompoundTag("PortalScaler");
    byte scaleX = tag.getByte("scaleX");
    byte scaleY = tag.getByte("scaleY");
    byte scaleZ = tag.getByte("scaleZ");

    // Don't divide by zero on accident!!
    if (scaleX == 0) { scaleX = 8; }
    if (scaleY == 0) { scaleY = 1; }
    if (scaleZ == 0) { scaleZ = 8; }

    double dScaleX = scaleX;
    double dScaleY = scaleY;
    double dScaleZ = scaleZ;

    if (scaleX < 0) { dScaleX = -1.0d / (double)scaleX; }
    if (scaleY < 0) { dScaleY = -1.0d / (double)scaleY; }
    if (scaleZ < 0) { dScaleZ = -1.0d / (double)scaleZ; }

    // Going from the Overworld to the Nether
    if (destDimension == DimensionType.NETHER.getId())
    {
        dScaleX = 1.0d / dScaleX;
        dScaleY = 1.0d / dScaleY;
        dScaleZ = 1.0d / dScaleZ;
    }

    World world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(destDimension);
    return PositionUtils.getScaledClampedPosition(player.getPositionVector(), world, dScaleX, dScaleY, dScaleZ, 32);
}
 
源代码28 项目: bleachhack-1.14   文件: NoSlow.java
@Subscribe
public void onTick(EventTick event) {
	if (!isToggled()) return;
		
	/* Slowness */
	if (getSettings().get(0).toToggle().state && (mc.player.getStatusEffect(StatusEffects.SLOWNESS) != null || mc.player.getStatusEffect(StatusEffects.BLINDNESS) != null)) {
		if (mc.options.keyForward.isPressed() 
				&& mc.player.getVelocity().x > -0.15 && mc.player.getVelocity().x < 0.15
				&& mc.player.getVelocity().z > -0.15 && mc.player.getVelocity().z < 0.15) {
			mc.player.setVelocity(mc.player.getVelocity().add(addVelocity));
			addVelocity = addVelocity.add(new Vec3d(0, 0, 0.05).rotateY(-(float)Math.toRadians(mc.player.yaw)));
		} else addVelocity = addVelocity.multiply(0.75, 0.75, 0.75);
	}
	
	/* Soul Sand */
	if (getSettings().get(1).toToggle().state && WorldUtils.doesBoxTouchBlock(mc.player.getBoundingBox(), Blocks.SOUL_SAND)) {
		Vec3d m = new Vec3d(0, 0, 0.125).rotateY(-(float) Math.toRadians(mc.player.yaw));
		if (!mc.player.abilities.flying && mc.options.keyForward.isPressed()) {
			mc.player.setVelocity(mc.player.getVelocity().add(m));
		}
	}
	
	/* Slime Block */
	if (getSettings().get(2).toToggle().state && WorldUtils.doesBoxTouchBlock(mc.player.getBoundingBox().offset(0,-0.02,0), Blocks.SLIME_BLOCK)) {
		Vec3d m1 = new Vec3d(0, 0, 0.1).rotateY(-(float) Math.toRadians(mc.player.yaw));
		if (!mc.player.abilities.flying && mc.options.keyForward.isPressed()) {
			mc.player.setVelocity(mc.player.getVelocity().add(m1));
		}
	}
	
	/* Web */
	if (getSettings().get(3).toToggle().state && WorldUtils.doesBoxTouchBlock(mc.player.getBoundingBox(), Blocks.COBWEB)) {
		Vec3d m2 = new Vec3d(0, -1, 0.9).rotateY(-(float) Math.toRadians(mc.player.yaw));
		if (!mc.player.abilities.flying && mc.options.keyForward.isPressed()) {
			mc.player.setVelocity(mc.player.getVelocity().add(m2));
		}
	}
}
 
源代码29 项目: seppuku   文件: BlockHighlightModule.java
@Listener
public void render3D(EventRender3D event) {
    final Minecraft mc = Minecraft.getMinecraft();
    final RayTraceResult ray = mc.objectMouseOver;
    if(ray.typeOfHit == RayTraceResult.Type.BLOCK) {

        final BlockPos blockpos = ray.getBlockPos();
        final IBlockState iblockstate = mc.world.getBlockState(blockpos);

        if (iblockstate.getMaterial() != Material.AIR && mc.world.getWorldBorder().contains(blockpos)) {
            final Vec3d interp = MathUtil.interpolateEntity(mc.player, mc.getRenderPartialTicks());
            RenderUtil.drawBoundingBox(iblockstate.getSelectedBoundingBox(mc.world, blockpos).grow(0.0020000000949949026D).offset(-interp.x, -interp.y, -interp.z), 1.5f, 0xFF9900EE);
        }
    }
}
 
源代码30 项目: Sound-Physics   文件: SoundPhysics.java
private static Vec3d offsetSoundByName(Vec3d soundPos, Vec3d playerPos, String name, String soundCategory)
{
	double offsetX = 0.0;
	double offsetY = 0.0;
	double offsetZ = 0.0;
	
	double offsetTowardsPlayer = 0.0;
	
	Vec3d toPlayerVector = playerPos.subtract(soundPos).normalize();
	
	//names
	if (name.matches(".*step.*"))
	{
		offsetY = 0.1;
	}
	
	//categories
	if (soundCategory.matches("block") || soundCategory.matches("record"))
	{
		offsetTowardsPlayer = 0.89;
	}
	
	if (soundPos.yCoord % 1.0 < 0.001 && soundPos.yCoord > 0.01)
	{
		offsetY = 0.1;
	}
	
	offsetX += toPlayerVector.xCoord * offsetTowardsPlayer;
	offsetY += toPlayerVector.yCoord * offsetTowardsPlayer;
	offsetZ += toPlayerVector.zCoord * offsetTowardsPlayer;
	
	//soundPos.xCoord += offsetX;
	//soundPos.yCoord += offsetY;
	//soundPos.zCoord += offsetZ;
	soundPos = soundPos.addVector(offsetX, offsetY, offsetZ);
	
	//logDetailed("Offset sound by " + offsetX + ", " + offsetY + ", " + offsetZ);
	
	return soundPos;
}
 
 类所在包
 同包方法