Search in sources :

Example 11 with BlockHitResult

use of net.minecraft.util.hit.BlockHitResult in project BleachHack by BleachDrinker420.

the class AutoBedrockBreak method onTick.

@BleachSubscribe
public void onTick(EventTick event) {
    if (pos != null) {
        switch(step) {
            case 0:
                if (!mc.world.isSpaceEmpty(new Box(pos.up(), pos.add(1, 8, 1)))) {
                    reset();
                    BleachLogger.info("Not enough empty space to break this block!");
                } else if (InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.PISTON) == -1) {
                    reset();
                    BleachLogger.info("Missing pistons!");
                } else if (InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.REDSTONE_BLOCK) == -1) {
                    reset();
                    BleachLogger.info("Missing a redstone block!");
                } else if (InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.TNT) == -1) {
                    reset();
                    BleachLogger.info("Missing TNT!");
                } else if (InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.LEVER) == -1) {
                    reset();
                    BleachLogger.info("Missing a lever!");
                } else if (dirtyPlace(pos.up(3), InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.REDSTONE_BLOCK), Direction.DOWN)) {
                    step++;
                }
                break;
            case 1:
                mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.Full(mc.player.getX(), mc.player.getY(), mc.player.getZ(), mc.player.getYaw(), 90, mc.player.isOnGround()));
                // mc.player.setPitch(90) "its jank either way"
                step++;
                break;
            case 2:
                if (dirtyPlace(pos.up(), InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.PISTON), Direction.DOWN))
                    step++;
                break;
            case 3:
                if (dirtyPlace(pos.up(7), InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.TNT), Direction.DOWN))
                    step++;
                break;
            case 4:
                if (dirtyPlace(pos.up(6), InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.LEVER), Direction.UP))
                    step++;
                break;
            case 5:
                if (dirtyPlace(pos.up(5), InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.TNT), Direction.DOWN))
                    step++;
                break;
            case 6:
                Vec3d leverCenter = Vec3d.ofCenter(pos.up(6));
                if (mc.player.getEyePos().distanceTo(leverCenter) <= 4.75) {
                    mc.interactionManager.interactBlock(mc.player, mc.world, Hand.MAIN_HAND, new BlockHitResult(leverCenter, Direction.DOWN, pos.up(6), false));
                    step++;
                }
                break;
            default:
                if (mc.world.getBlockState(pos).isAir() || mc.world.getBlockState(pos).getBlock() instanceof PistonBlock || (mc.world.getBlockState(pos.up()).getBlock() instanceof PistonBlock && mc.world.getBlockState(pos.up()).get(PistonBlock.FACING) != Direction.UP)) {
                    setEnabled(false);
                    return;
                }
                if (step >= 82) {
                    mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.Full(mc.player.getX(), mc.player.getY(), mc.player.getZ(), mc.player.getYaw(), -90, mc.player.isOnGround()));
                // mc.player.setPitch(-90) "its jank either way"
                }
                if (step > 84) {
                    Hand hand = InventoryUtils.selectSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.PISTON);
                    if (hand != null) {
                        mc.player.networkHandler.sendPacket(new PlayerInteractBlockC2SPacket(hand, new BlockHitResult(Vec3d.ofBottomCenter(pos.up()), Direction.DOWN, pos.up(), false)));
                    }
                }
                step++;
                break;
        }
    }
}
Also used : BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe) ModuleCategory(org.bleachhack.module.ModuleCategory) EventInteract(org.bleachhack.event.events.EventInteract) Box(net.minecraft.util.math.Box) EventWorldRender(org.bleachhack.event.events.EventWorldRender) InventoryUtils(org.bleachhack.util.InventoryUtils) PistonBlock(net.minecraft.block.PistonBlock) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Renderer(org.bleachhack.util.render.Renderer) BlockPos(net.minecraft.util.math.BlockPos) Items(net.minecraft.item.Items) Module(org.bleachhack.module.Module) QuadColor(org.bleachhack.util.render.color.QuadColor) Direction(net.minecraft.util.math.Direction) PlayerInteractBlockC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket) Vec3d(net.minecraft.util.math.Vec3d) BleachLogger(org.bleachhack.util.BleachLogger) PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) Hand(net.minecraft.util.Hand) EventTick(org.bleachhack.event.events.EventTick) PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) Box(net.minecraft.util.math.Box) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Hand(net.minecraft.util.Hand) Vec3d(net.minecraft.util.math.Vec3d) PistonBlock(net.minecraft.block.PistonBlock) PlayerInteractBlockC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 12 with BlockHitResult

use of net.minecraft.util.hit.BlockHitResult in project BleachHack by BleachDrinker420.

the class AutoBedrockBreak method dirtyPlace.

private boolean dirtyPlace(BlockPos pos, int slot, Direction dir) {
    Vec3d hitPos = Vec3d.ofCenter(pos).add(dir.getOffsetX() * 0.5, dir.getOffsetY() * 0.5, dir.getOffsetZ() * 0.5);
    if (mc.player.getEyePos().distanceTo(hitPos) >= 4.75 || !mc.world.getOtherEntities(null, new Box(pos)).isEmpty()) {
        return false;
    }
    Hand hand = InventoryUtils.selectSlot(slot);
    if (hand != null) {
        mc.interactionManager.interactBlock(mc.player, mc.world, hand, new BlockHitResult(hitPos, dir, pos, false));
        return true;
    }
    return false;
}
Also used : Box(net.minecraft.util.math.Box) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Hand(net.minecraft.util.Hand) Vec3d(net.minecraft.util.math.Vec3d)

Example 13 with BlockHitResult

use of net.minecraft.util.hit.BlockHitResult in project BleachHack by BleachDrinker420.

the class Ghosthand method onTick.

@BleachSubscribe
public void onTick(EventTick event) {
    if (!mc.options.keyUse.isPressed() || mc.player.isSneaking())
        return;
    // Return if we are looking at any block entities
    BlockPos lookingPos = new BlockPos(mc.player.raycast(4.25, mc.getTickDelta(), false).getPos());
    for (BlockEntity b : WorldUtils.getBlockEntities()) {
        if (lookingPos.equals(b.getPos())) {
            return;
        }
    }
    Set<BlockPos> posList = new HashSet<>();
    Vec3d nextPos = new Vec3d(0, 0, 0.1).rotateX(-(float) Math.toRadians(mc.player.getPitch())).rotateY(-(float) Math.toRadians(mc.player.getYaw()));
    for (int i = 1; i < 50; i++) {
        BlockPos curPos = new BlockPos(mc.player.getCameraPosVec(mc.getTickDelta()).add(nextPos.multiply(i)));
        if (!posList.contains(curPos)) {
            posList.add(curPos);
            for (BlockEntity b : WorldUtils.getBlockEntities()) {
                if (b.getPos().equals(curPos)) {
                    mc.interactionManager.interactBlock(mc.player, mc.world, Hand.MAIN_HAND, new BlockHitResult(mc.player.getPos(), Direction.UP, curPos, true));
                    return;
                }
            }
        }
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Vec3d(net.minecraft.util.math.Vec3d) BlockEntity(net.minecraft.block.entity.BlockEntity) HashSet(java.util.HashSet) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 14 with BlockHitResult

use of net.minecraft.util.hit.BlockHitResult in project BleachHack by BleachDrinker420.

the class ClickTp method onTick.

@BleachSubscribe
public void onTick(EventTick event) {
    if (InputUtil.isKeyPressed(mc.getWindow().getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT)) {
        pos = null;
        dir = null;
        return;
    }
    BlockHitResult hit = (BlockHitResult) mc.player.raycast(100, mc.getTickDelta(), getSetting(1).asToggle().getState());
    boolean miss = hit.getType() == Type.MISS && !getSetting(0).asToggle().getState();
    pos = miss ? null : hit.getBlockPos();
    dir = miss ? null : getSetting(3).asToggle().getState() ? Direction.UP : hit.getSide();
    if (pos != null && dir != null) {
        if (GLFW.glfwGetMouseButton(mc.getWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == 1 && mc.currentScreen == null && !antiSpamClick) {
            antiSpamClick = true;
            Vec3d tpPos = Vec3d.ofBottomCenter(pos.offset(dir, dir == Direction.DOWN ? 2 : 1));
            if (getSetting(2).asToggle().getState()) {
                mc.player.updatePosition(mc.player.getX(), tpPos.y, mc.player.getZ());
                mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(mc.player.getX(), tpPos.y, mc.player.getZ(), false));
            }
            mc.player.updatePosition(tpPos.x, tpPos.y, tpPos.z);
            mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(tpPos.x, tpPos.y, tpPos.z, false));
        } else if (GLFW.glfwGetMouseButton(mc.getWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == 0) {
            antiSpamClick = false;
        }
    }
}
Also used : PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Vec3d(net.minecraft.util.math.Vec3d) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 15 with BlockHitResult

use of net.minecraft.util.hit.BlockHitResult in project BleachHack by BleachDrinker420.

the class CmdNBT method getNbt.

private NbtCompound getNbt(String arg) {
    if (arg.equalsIgnoreCase("hand")) {
        return mc.player.getMainHandStack().getOrCreateNbt();
    } else if (arg.equalsIgnoreCase("block")) {
        HitResult target = mc.crosshairTarget;
        if (target.getType() == HitResult.Type.BLOCK) {
            BlockPos pos = ((BlockHitResult) target).getBlockPos();
            BlockEntity be = mc.world.getBlockEntity(pos);
            if (be != null) {
                return be.writeNbt(new NbtCompound());
            } else {
                return new NbtCompound();
            }
        }
        BleachLogger.error("Not looking at a block.");
        return null;
    } else if (arg.equalsIgnoreCase("entity")) {
        HitResult target = mc.crosshairTarget;
        if (target.getType() == HitResult.Type.ENTITY) {
            return ((EntityHitResult) target).getEntity().writeNbt(new NbtCompound());
        }
        BleachLogger.error("Not looking at an entity.");
        return null;
    }
    throw new CmdSyntaxException();
}
Also used : BlockHitResult(net.minecraft.util.hit.BlockHitResult) HitResult(net.minecraft.util.hit.HitResult) EntityHitResult(net.minecraft.util.hit.EntityHitResult) NbtCompound(net.minecraft.nbt.NbtCompound) CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) BlockPos(net.minecraft.util.math.BlockPos) BlockEntity(net.minecraft.block.entity.BlockEntity)

Aggregations

BlockHitResult (net.minecraft.util.hit.BlockHitResult)83 BlockPos (net.minecraft.util.math.BlockPos)45 Vec3d (net.minecraft.util.math.Vec3d)36 Direction (net.minecraft.util.math.Direction)20 Hand (net.minecraft.util.Hand)17 BlockState (net.minecraft.block.BlockState)15 HitResult (net.minecraft.util.hit.HitResult)14 RaycastContext (net.minecraft.world.RaycastContext)13 BlockEntity (net.minecraft.block.entity.BlockEntity)12 ItemStack (net.minecraft.item.ItemStack)11 PlayerInteractBlockC2SPacket (net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket)11 PlayerEntity (net.minecraft.entity.player.PlayerEntity)10 Box (net.minecraft.util.math.Box)10 PlayerMoveC2SPacket (net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket)9 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)9 List (java.util.List)8 EventHandler (meteordevelopment.orbit.EventHandler)8 Entity (net.minecraft.entity.Entity)8 World (net.minecraft.world.World)6 ArrayList (java.util.ArrayList)5