net.minecraft.util.math.Direction#values ( )源码实例Demo

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

源代码1 项目: Galacticraft-Rewoven   文件: WireBlock.java
@Override
@Deprecated
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
    super.onStateReplaced(state, world, pos, newState, moved);
    if (!world.isClient()) {
        WireNetwork myNet = ((ServerWorldAccessor) world).getNetworkManager().getNetwork(pos);
        ((ServerWorldAccessor) world).getNetworkManager().removeWire(pos);
        myNet.removeWire(pos);
        WireNetwork network = ((ServerWorldAccessor) world).getNetworkManager().getNetwork(pos);
        if (network == null) return;
        for (Direction d : Direction.values()) {
            if (world.getBlockState(pos.offset(d)).getBlock() instanceof WireConnectable) {
                WireConnectionType type = ((WireConnectable) world.getBlockState(pos.offset(d)).getBlock()).canWireConnect(world, d.getOpposite(), pos, pos.offset(d));
                if (type != WireConnectionType.WIRE && type != WireConnectionType.NONE) {
                    if (type == WireConnectionType.ENERGY_INPUT) {
                        network.removeConsumer(pos.offset(d));
                    } else {
                        network.removeProducer(pos.offset(d));
                    }
                }
            }
        }
    }
}
 
源代码2 项目: bleachhack-1.14   文件: Scaffold.java
public boolean placeBlockAuto(BlockPos block) {
	if (lastPlaced.containsKey(block) || !WorldUtils.NONSOLID_BLOCKS.contains(mc.world.getBlockState(block).getBlock())) {
		return false;
	}
	
	for (Direction d: Direction.values()) {
		if (!WorldUtils.NONSOLID_BLOCKS.contains(mc.world.getBlockState(block.offset(d)).getBlock())) {
			if (WorldUtils.RIGHTCLICKABLE_BLOCKS.contains(mc.world.getBlockState(block.offset(d)).getBlock())) {
				mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, Mode.PRESS_SHIFT_KEY));
			
			}
			mc.interactionManager.interactBlock(mc.player, mc.world, Hand.MAIN_HAND, 
					new BlockHitResult(Vec3d.of(block), d.getOpposite(), block.offset(d), false));
			mc.player.swingHand(Hand.MAIN_HAND);
			if (WorldUtils.RIGHTCLICKABLE_BLOCKS.contains(mc.world.getBlockState(block.offset(d)).getBlock())) {
				mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, Mode.RELEASE_SHIFT_KEY));
			}
			lastPlaced.put(block, 5);
			return true;
		}
	}
	
	return false;
}
 
源代码3 项目: bleachhack-1.14   文件: Scaffold.java
public boolean placeBlockAuto(BlockPos block) {
	if (lastPlaced.containsKey(block) || !WorldUtils.NONSOLID_BLOCKS.contains(mc.world.getBlockState(block).getBlock())) {
		return false;
	}
	
	for (Direction d: Direction.values()) {
		if (!WorldUtils.NONSOLID_BLOCKS.contains(mc.world.getBlockState(block.offset(d)).getBlock())) {
			if (WorldUtils.RIGHTCLICKABLE_BLOCKS.contains(mc.world.getBlockState(block.offset(d)).getBlock())) {
				mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, Mode.START_SNEAKING));
			
			}
			mc.interactionManager.interactBlock(mc.player, mc.world, Hand.MAIN_HAND, 
					new BlockHitResult(new Vec3d(block), d.getOpposite(), block.offset(d), false));
			mc.player.swingHand(Hand.MAIN_HAND);
			if (WorldUtils.RIGHTCLICKABLE_BLOCKS.contains(mc.world.getBlockState(block.offset(d)).getBlock())) {
				mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, Mode.STOP_SNEAKING));
			}
			lastPlaced.put(block, 5);
			return true;
		}
	}
	
	return false;
}
 
源代码4 项目: Galacticraft-Rewoven   文件: WireBlock.java
@Override
@Deprecated
public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean moved) {
    super.onBlockAdded(state, world, pos, oldState, moved);
    if (!world.isClient) {
        WireNetwork network = ((ServerWorldAccessor) world).getNetworkManager().getNetwork(pos);
        if (network == null) network = new WireNetwork(pos, ((ServerWorld) world));
        for (Direction d : Direction.values()) {
            if (world.getBlockState(pos.offset(d)).getBlock() instanceof WireConnectable) {
                WireConnectionType type = ((WireConnectable) world.getBlockState(pos.offset(d)).getBlock()).canWireConnect(world, d.getOpposite(), pos, pos.offset(d));
                if (type == WireConnectionType.WIRE) {
                    WireNetwork network1 = ((ServerWorldAccessor) world).getNetworkManager().getNetwork(pos.offset(d));
                    if (network1 != network) {
                        if (network1 != null) {
                            network = network1.merge(network); // prefer other network rather than this one
                        } else {
                            network.addWire(pos.offset(d));
                        }
                        state.method_30101(world, pos, 3);
                    }
                } else if (type != WireConnectionType.NONE) {
                    if (type == WireConnectionType.ENERGY_INPUT) {
                        network.addConsumer(pos.offset(d));
                    } else {
                        network.addProducer(pos.offset(d));
                    }
                }
            }
        }
    }
}
 
源代码5 项目: Galacticraft-Rewoven   文件: WireNetwork.java
public void addWire(BlockPos pos) {
    addVertex(pos);
    ((ServerWorldAccessor) world).getNetworkManager().addWire(pos, this);
    for (Direction dir : Direction.values()) {
        if (adjacentVertices.containsKey(new BlockPos(pos.offset(dir)))) {
            addEdge(pos, new BlockPos(pos.offset(dir)));
        }
    }
}
 
源代码6 项目: Galacticraft-Rewoven   文件: FluidPipeBlock.java
@Override
public BlockState getPlacementState(ItemPlacementContext context) {
    BlockState state = this.getDefaultState();
    for (Direction direction : Direction.values()) {
        Block block = context.getWorld().getBlockState(context.getBlockPos().offset(direction)).getBlock();
        if (block instanceof FluidPipeBlock)
            state = state.with(propFromDirection(direction), true);
    }
    return state;
}
 
源代码7 项目: Galacticraft-Rewoven   文件: AluminumWireBlock.java
@Override
public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean moved) {
    super.onBlockAdded(state, world, pos, oldState, moved);
    if (!world.isClient) {
        WireNetwork network = ((ServerWorldAccessor) world).getNetworkManager().getNetwork(pos);
        if (network == null) network = new WireNetwork(pos, ((ServerWorld) world));
        for (Direction d : Direction.values()) {
            if (state.get(getPropForDirection(d)) && world.getBlockState(pos.offset(d)).getBlock() instanceof WireConnectable) {
                WireConnectionType type = ((WireConnectable) world.getBlockState(pos.offset(d)).getBlock()).canWireConnect(world, d.getOpposite(), pos, pos.offset(d));
                if (type == WireConnectionType.WIRE) {
                    WireNetwork network1 = ((ServerWorldAccessor) world).getNetworkManager().getNetwork(pos.offset(d));
                    if (network1 != network) {
                        if (network1 != null) {
                            network = network1.merge(network); // prefer other network rather than this one
                        } else {
                            network.addWire(pos.offset(d));
                        }
                        //this.updateNeighborStates(state, world, pos, 3);
                    }
                } else if (type != WireConnectionType.NONE) {
                    if (type == WireConnectionType.ENERGY_INPUT) {
                        network.addConsumer(pos.offset(d));
                    } else {
                        network.addProducer(pos.offset(d));
                    }
                }
            }
        }
    }
}
 
源代码8 项目: carpet-extra   文件: ObsidianBlock.java
@Override
public void scheduledTick(BlockState blockState_1, ServerWorld serverWorld_1, BlockPos blockPos_1, Random random_1)
{
    for (Direction dir : Direction.values())
    {
        FluidState neighbor = serverWorld_1.getFluidState(blockPos_1.offset(dir));
        if (neighbor.getFluid() != Fluids.LAVA || !neighbor.isStill())
            return;
    }
    if (random_1.nextInt(10) == 0)
    {
        serverWorld_1.setBlockState(blockPos_1, Blocks.LAVA.getDefaultState());
    }
}
 
private static List<ModelElement> generateCube() {
    Map<Direction, ModelElementFace> faces = new HashMap<>();
    for (Direction direction : Direction.values()) {
        faces.put(direction, new ModelElementFace(null, -1, direction.getName(), new ModelElementTexture(null, 0)));
    }
    return Collections.singletonList(new ModelElement(new Vector3f(0, 0, 0), new Vector3f(16, 16, 16), faces, null, true));
}
 
public void render(MatrixStack.Entry entry, VertexConsumer vertexConsumer, @Nullable BlockState blockState, BakedModel bakedModel, float red, float green, float blue, int[] light, int overlay) {
    Random random = new Random();
    Direction[] var13 = Direction.values();

    for (Direction direction : var13) {
        random.setSeed(42L);
        renderQuad(entry, vertexConsumer, red, green, blue, bakedModel.getQuads(blockState, direction, random), light[getId(direction)], overlay);
    }

    random.setSeed(42L);
    renderQuad(entry, vertexConsumer, red, green, blue, bakedModel.getQuads(blockState, null, random), light[getId(Direction.UP)], overlay);
}
 
源代码11 项目: Wurst7   文件: BonemealAuraHack.java
private boolean rightClickBlockLegit(BlockPos pos)
{
	Vec3d eyesPos = RotationUtils.getEyesPos();
	Vec3d posVec = Vec3d.ofCenter(pos);
	double distanceSqPosVec = eyesPos.squaredDistanceTo(posVec);
	
	for(Direction side : Direction.values())
	{
		Vec3d hitVec = posVec.add(Vec3d.of(side.getVector()).multiply(0.5));
		double distanceSqHitVec = eyesPos.squaredDistanceTo(hitVec);
		
		// check if hitVec is within range (4.25 blocks)
		if(distanceSqHitVec > 18.0625)
			continue;
		
		// check if side is facing towards player
		if(distanceSqHitVec >= distanceSqPosVec)
			continue;
		
		// check line of sight
		if(MC.world
			.rayTrace(new RayTraceContext(eyesPos, hitVec,
				RayTraceContext.ShapeType.COLLIDER,
				RayTraceContext.FluidHandling.NONE, MC.player))
			.getType() != HitResult.Type.MISS)
			continue;
		
		// face block
		WURST.getRotationFaker().faceVectorPacket(hitVec);
		
		// place block
		IMC.getInteractionManager().rightClickBlock(pos, side, hitVec);
		MC.player.swingHand(Hand.MAIN_HAND);
		IMC.setItemUseCooldown(4);
		
		return true;
	}
	
	return false;
}
 
public BakedModel getModelForState(T entity, BlockState state) {
    StringBuilder builder = new StringBuilder();
    for (ConfigurableElectricMachineBlock.BlockFace face : ConfigurableElectricMachineBlock.BlockFace.values()) {
        builder.append(((ConfigurableElectricMachineBlock) state.getBlock()).getOption(state, face).asString());
    }
    if (!MODEL_CACHE.containsKey(builder.toString())) {
        Map<String, Either<SpriteIdentifier, String>> texMap = new HashMap<>();
        texMap.put("particle", Either.left(EMPTY));
        for (Direction direction : Direction.values()) {
            switch (((ConfigurableElectricMachineBlock) state.getBlock()).getOption(state, ConfigurableElectricMachineBlock.BlockFace.toFace(Direction.NORTH, direction))) { //north so that the model doesn't rotate
                case DEFAULT:
                    texMap.put(direction.getName(), Either.left(getDefaultSpriteId(entity, direction)));
                    break;
                case POWER_INPUT:
                    texMap.put(direction.getName(), Either.left(new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine_power_input"))));
                    break;
                case POWER_OUTPUT:
                    texMap.put(direction.getName(), Either.left(new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine_power_output"))));
                    break;
                case OXYGEN_INPUT:
                    texMap.put(direction.getName(), Either.left(new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine_oxygen_input"))));
                    break;
                case OXYGEN_OUTPUT:
                    texMap.put(direction.getName(), Either.left(new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine_oxygen_output"))));
                    break;
                case FLUID_INPUT:
                    texMap.put(direction.getName(), Either.left(new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine_fluid_input"))));
                    break;
                case FLUID_OUTPUT:
                    texMap.put(direction.getName(), Either.left(new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier(Constants.MOD_ID, "block/machine_fluid_output"))));
                    break;
            }
        }

        BakedModel model = this.bakeModel(new JsonUnbakedModel(null, element, texMap, true,
                        JsonUnbakedModel.GuiLight.field_21859, ModelTransformation.NONE, new ArrayList<>()),
                spriteIdentifier -> MinecraftClient.getInstance().getSpriteAtlas(spriteIdentifier.getAtlasId()).apply(spriteIdentifier.getTextureId()),
                ModelRotation.X0_Y0, new Identifier(Constants.MOD_ID, builder.toString()), true);
        MODEL_CACHE.put(builder.toString(), model);

        return model;
    } else {
        return MODEL_CACHE.get(builder.toString());
    }
}
 
源代码13 项目: multiconnect   文件: ChunkUpgrader.java
public static void fix(WorldAccess world, BlockPos pos, int flags) {
    doFix(world, pos, flags);
    for (Direction dir : Direction.values())
        doFix(world, pos.offset(dir), flags);
}
 
源代码14 项目: Wurst7   文件: InstantBunkerHack.java
private void placeBlockSimple(BlockPos pos)
{
	Direction side = null;
	Direction[] sides = Direction.values();
	
	Vec3d eyesPos = RotationUtils.getEyesPos();
	Vec3d posVec = Vec3d.ofCenter(pos);
	double distanceSqPosVec = eyesPos.squaredDistanceTo(posVec);
	
	Vec3d[] hitVecs = new Vec3d[sides.length];
	for(int i = 0; i < sides.length; i++)
		hitVecs[i] =
			posVec.add(Vec3d.of(sides[i].getVector()).multiply(0.5));
	
	for(int i = 0; i < sides.length; i++)
	{
		// check if neighbor can be right clicked
		BlockPos neighbor = pos.offset(sides[i]);
		if(!BlockUtils.canBeClicked(neighbor))
			continue;
		
		// check line of sight
		BlockState neighborState = BlockUtils.getState(neighbor);
		VoxelShape neighborShape =
			neighborState.getOutlineShape(MC.world, neighbor);
		if(MC.world.rayTraceBlock(eyesPos, hitVecs[i], neighbor,
			neighborShape, neighborState) != null)
			continue;
		
		side = sides[i];
		break;
	}
	
	if(side == null)
		for(int i = 0; i < sides.length; i++)
		{
			// check if neighbor can be right clicked
			if(!BlockUtils.canBeClicked(pos.offset(sides[i])))
				continue;
			
			// check if side is facing away from player
			if(distanceSqPosVec > eyesPos.squaredDistanceTo(hitVecs[i]))
				continue;
			
			side = sides[i];
			break;
		}
	
	if(side == null)
		return;
	
	Vec3d hitVec = hitVecs[side.ordinal()];
	
	// face block
	// WURST.getRotationFaker().faceVectorPacket(hitVec);
	// if(RotationUtils.getAngleToLastReportedLookVec(hitVec) > 1)
	// return;
	
	// check timer
	// if(IMC.getItemUseCooldown() > 0)
	// return;
	
	// place block
	IMC.getInteractionManager().rightClickBlock(pos.offset(side),
		side.getOpposite(), hitVec);
	
	// swing arm
	MC.player.networkHandler
		.sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
	
	// reset timer
	IMC.setItemUseCooldown(4);
}
 
源代码15 项目: Wurst7   文件: NukerLegitHack.java
private boolean breakBlockExtraLegit(BlockPos pos)
{
	Vec3d eyesPos = RotationUtils.getEyesPos();
	Vec3d posVec = Vec3d.ofCenter(pos);
	double distanceSqPosVec = eyesPos.squaredDistanceTo(posVec);
	
	for(Direction side : Direction.values())
	{
		Vec3d hitVec = posVec.add(Vec3d.of(side.getVector()).multiply(0.5));
		double distanceSqHitVec = eyesPos.squaredDistanceTo(hitVec);
		
		// check if hitVec is within range (4.25 blocks)
		if(distanceSqHitVec > 18.0625)
			continue;
		
		// check if side is facing towards player
		if(distanceSqHitVec >= distanceSqPosVec)
			continue;
		
		// check line of sight
		if(MC.world
			.rayTrace(new RayTraceContext(eyesPos, hitVec,
				RayTraceContext.ShapeType.COLLIDER,
				RayTraceContext.FluidHandling.NONE, MC.player))
			.getType() != HitResult.Type.MISS)
			continue;
		
		// face block
		WURST.getRotationFaker().faceVectorClient(hitVec);
		
		if(currentBlock != null)
			WURST.getHax().autoToolHack.equipIfEnabled(currentBlock);
			
		// if attack key is down but nothing happens, release it for one
		// tick
		if(MC.options.keyAttack.isPressed()
			&& !MC.interactionManager.isBreakingBlock())
		{
			MC.options.keyAttack.setPressed(false);
			return true;
		}
		
		// damage block
		MC.options.keyAttack.setPressed(true);
		
		return true;
	}
	
	return false;
}
 
源代码16 项目: Wurst7   文件: AutoBuildHack.java
private boolean tryToPlace(BlockPos pos, Vec3d eyesPos, double rangeSq)
{
	Vec3d posVec = Vec3d.ofCenter(pos);
	double distanceSqPosVec = eyesPos.squaredDistanceTo(posVec);
	
	for(Direction side : Direction.values())
	{
		BlockPos neighbor = pos.offset(side);
		
		// check if neighbor can be right clicked
		if(!BlockUtils.canBeClicked(neighbor)
			|| BlockUtils.getState(neighbor).getMaterial().isReplaceable())
			continue;
		
		Vec3d dirVec = Vec3d.of(side.getVector());
		Vec3d hitVec = posVec.add(dirVec.multiply(0.5));
		
		// check if hitVec is within range
		if(eyesPos.squaredDistanceTo(hitVec) > rangeSq)
			continue;
		
		// check if side is visible (facing away from player)
		if(distanceSqPosVec > eyesPos.squaredDistanceTo(posVec.add(dirVec)))
			continue;
		
		// check line of sight
		if(checkLOS.isChecked() && MC.world
			.rayTrace(new RayTraceContext(eyesPos, hitVec,
				RayTraceContext.ShapeType.COLLIDER,
				RayTraceContext.FluidHandling.NONE, MC.player))
			.getType() != HitResult.Type.MISS)
			continue;
		
		// face block
		Rotation rotation = RotationUtils.getNeededRotations(hitVec);
		PlayerMoveC2SPacket.LookOnly packet =
			new PlayerMoveC2SPacket.LookOnly(rotation.getYaw(),
				rotation.getPitch(), MC.player.isOnGround());
		MC.player.networkHandler.sendPacket(packet);
		
		// place block
		IMC.getInteractionManager().rightClickBlock(neighbor,
			side.getOpposite(), hitVec);
		MC.player.swingHand(Hand.MAIN_HAND);
		IMC.setItemUseCooldown(4);
		return true;
	}
	
	return false;
}
 
源代码17 项目: Wurst7   文件: TunnellerHack.java
private void placeBlockSimple(BlockPos pos)
{
	Direction side = null;
	Direction[] sides = Direction.values();
	
	Vec3d eyesPos = RotationUtils.getEyesPos();
	Vec3d posVec = Vec3d.ofCenter(pos);
	double distanceSqPosVec = eyesPos.squaredDistanceTo(posVec);
	
	Vec3d[] hitVecs = new Vec3d[sides.length];
	for(int i = 0; i < sides.length; i++)
		hitVecs[i] =
			posVec.add(Vec3d.of(sides[i].getVector()).multiply(0.5));
	
	for(int i = 0; i < sides.length; i++)
	{
		// check if neighbor can be right clicked
		BlockPos neighbor = pos.offset(sides[i]);
		if(!BlockUtils.canBeClicked(neighbor))
			continue;
		
		// check line of sight
		BlockState neighborState = BlockUtils.getState(neighbor);
		VoxelShape neighborShape =
			neighborState.getOutlineShape(MC.world, neighbor);
		if(MC.world.rayTraceBlock(eyesPos, hitVecs[i], neighbor,
			neighborShape, neighborState) != null)
			continue;
		
		side = sides[i];
		break;
	}
	
	if(side == null)
		for(int i = 0; i < sides.length; i++)
		{
			// check if neighbor can be right clicked
			if(!BlockUtils.canBeClicked(pos.offset(sides[i])))
				continue;
			
			// check if side is facing away from player
			if(distanceSqPosVec > eyesPos.squaredDistanceTo(hitVecs[i]))
				continue;
			
			side = sides[i];
			break;
		}
	
	if(side == null)
		return;
	
	Vec3d hitVec = hitVecs[side.ordinal()];
	
	// face block
	WURST.getRotationFaker().faceVectorPacket(hitVec);
	if(RotationUtils.getAngleToLastReportedLookVec(hitVec) > 1)
		return;
	
	// check timer
	if(IMC.getItemUseCooldown() > 0)
		return;
	
	// place block
	IMC.getInteractionManager().rightClickBlock(pos.offset(side),
		side.getOpposite(), hitVec);
	
	// swing arm
	MC.player.networkHandler
		.sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
	
	// reset timer
	IMC.setItemUseCooldown(4);
}
 
源代码18 项目: Wurst7   文件: TunnellerHack.java
private boolean breakBlockSimple(BlockPos pos)
{
	Direction side = null;
	Direction[] sides = Direction.values();
	
	Vec3d eyesPos = RotationUtils.getEyesPos();
	Vec3d relCenter = BlockUtils.getBoundingBox(pos)
		.offset(-pos.getX(), -pos.getY(), -pos.getZ()).getCenter();
	Vec3d center = Vec3d.of(pos).add(relCenter);
	
	Vec3d[] hitVecs = new Vec3d[sides.length];
	for(int i = 0; i < sides.length; i++)
	{
		Vec3i dirVec = sides[i].getVector();
		Vec3d relHitVec = new Vec3d(relCenter.x * dirVec.getX(),
			relCenter.y * dirVec.getY(), relCenter.z * dirVec.getZ());
		hitVecs[i] = center.add(relHitVec);
	}
	
	for(int i = 0; i < sides.length; i++)
	{
		// check line of sight
		if(MC.world
			.rayTrace(new RayTraceContext(eyesPos, hitVecs[i],
				RayTraceContext.ShapeType.COLLIDER,
				RayTraceContext.FluidHandling.NONE, MC.player))
			.getType() != HitResult.Type.MISS)
			continue;
		
		side = sides[i];
		break;
	}
	
	if(side == null)
	{
		double distanceSqToCenter = eyesPos.squaredDistanceTo(center);
		for(int i = 0; i < sides.length; i++)
		{
			// check if side is facing towards player
			if(eyesPos.squaredDistanceTo(hitVecs[i]) >= distanceSqToCenter)
				continue;
			
			side = sides[i];
			break;
		}
	}
	
	if(side == null)
		throw new RuntimeException(
			"How could none of the sides be facing towards the player?!");
	
	// face block
	WURST.getRotationFaker().faceVectorPacket(hitVecs[side.ordinal()]);
	
	// damage block
	if(!MC.interactionManager.updateBlockBreakingProgress(pos, side))
		return false;
	
	// swing arm
	MC.player.networkHandler
		.sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
	
	return true;
}
 
源代码19 项目: Wurst7   文件: BuildRandomHack.java
private boolean placeBlockLegit(BlockPos pos)
{
	Vec3d eyesPos = RotationUtils.getEyesPos();
	Vec3d posVec = Vec3d.ofCenter(pos);
	double distanceSqPosVec = eyesPos.squaredDistanceTo(posVec);
	
	for(Direction side : Direction.values())
	{
		BlockPos neighbor = pos.offset(side);
		
		// check if neighbor can be right clicked
		if(!BlockUtils.canBeClicked(neighbor))
			continue;
		
		Vec3d dirVec = Vec3d.of(side.getVector());
		Vec3d hitVec = posVec.add(dirVec.multiply(0.5));
		
		// check if hitVec is within range (4.25 blocks)
		if(eyesPos.squaredDistanceTo(hitVec) > 18.0625)
			continue;
		
		// check if side is visible (facing away from player)
		if(distanceSqPosVec > eyesPos.squaredDistanceTo(posVec.add(dirVec)))
			continue;
		
		// check line of sight
		if(MC.world
			.rayTrace(new RayTraceContext(eyesPos, hitVec,
				RayTraceContext.ShapeType.COLLIDER,
				RayTraceContext.FluidHandling.NONE, MC.player))
			.getType() != HitResult.Type.MISS)
			continue;
		
		// face block
		Rotation rotation = RotationUtils.getNeededRotations(hitVec);
		PlayerMoveC2SPacket.LookOnly packet =
			new PlayerMoveC2SPacket.LookOnly(rotation.getYaw(),
				rotation.getPitch(), MC.player.isOnGround());
		MC.player.networkHandler.sendPacket(packet);
		
		// place block
		IMC.getInteractionManager().rightClickBlock(neighbor,
			side.getOpposite(), hitVec);
		MC.player.swingHand(Hand.MAIN_HAND);
		IMC.setItemUseCooldown(4);
		
		return true;
	}
	
	return false;
}
 
源代码20 项目: Wurst7   文件: ScaffoldWalkHack.java
private boolean placeBlock(BlockPos pos)
{
	Vec3d eyesPos = new Vec3d(MC.player.getX(),
		MC.player.getY() + MC.player.getEyeHeight(MC.player.getPose()),
		MC.player.getZ());
	
	for(Direction side : Direction.values())
	{
		BlockPos neighbor = pos.offset(side);
		Direction side2 = side.getOpposite();
		
		// check if side is visible (facing away from player)
		if(eyesPos.squaredDistanceTo(Vec3d.ofCenter(pos)) >= eyesPos
			.squaredDistanceTo(Vec3d.ofCenter(neighbor)))
			continue;
		
		// check if neighbor can be right clicked
		if(!BlockUtils.canBeClicked(neighbor))
			continue;
		
		Vec3d hitVec = Vec3d.ofCenter(neighbor)
			.add(Vec3d.of(side2.getVector()).multiply(0.5));
		
		// check if hitVec is within range (4.25 blocks)
		if(eyesPos.squaredDistanceTo(hitVec) > 18.0625)
			continue;
		
		// place block
		Rotation rotation = RotationUtils.getNeededRotations(hitVec);
		PlayerMoveC2SPacket.LookOnly packet =
			new PlayerMoveC2SPacket.LookOnly(rotation.getYaw(),
				rotation.getPitch(), MC.player.isOnGround());
		MC.player.networkHandler.sendPacket(packet);
		IMC.getInteractionManager().rightClickBlock(neighbor, side2,
			hitVec);
		MC.player.swingHand(Hand.MAIN_HAND);
		IMC.setItemUseCooldown(4);
		
		return true;
	}
	
	return false;
}