Search in sources :

Example 21 with Box

use of net.minecraft.util.math.Box in project BleachHack by BleachDrinker420.

the class NewChunks method onWorldRender.

@BleachSubscribe
public void onWorldRender(EventWorldRender.Post event) {
    int renderY = mc.world.getBottomY() + getSetting(0).asSlider().getValueInt();
    int opacity = (int) (getSetting(2).asToggle().getChild(0).asSlider().getValueFloat() * 255);
    if (getSetting(3).asToggle().getState()) {
        int[] color = getSetting(3).asToggle().getChild(0).asColor().getRGBArray();
        QuadColor outlineColor = QuadColor.single(color[0], color[1], color[2], 255);
        QuadColor fillColor = QuadColor.single(color[0], color[1], color[2], opacity);
        synchronized (newChunks) {
            for (ChunkPos c : newChunks) {
                if (mc.getCameraEntity().getBlockPos().isWithinDistance(c.getStartPos(), 1024)) {
                    Box box = new Box(c.getStartX(), renderY, c.getStartZ(), c.getStartX() + 16, renderY, c.getStartZ() + 16);
                    if (getSetting(2).asToggle().getState()) {
                        Renderer.drawBoxFill(box, fillColor, SKIP_DIRS);
                    }
                    Renderer.drawBoxOutline(box, outlineColor, 2f, SKIP_DIRS);
                }
            }
        }
    }
    if (getSetting(4).asToggle().getState()) {
        int[] color = getSetting(4).asToggle().getChild(0).asColor().getRGBArray();
        QuadColor outlineColor = QuadColor.single(color[0], color[1], color[2], 255);
        QuadColor fillColor = QuadColor.single(color[0], color[1], color[2], opacity);
        synchronized (oldChunks) {
            for (ChunkPos c : oldChunks) {
                if (mc.getCameraEntity().getBlockPos().isWithinDistance(c.getStartPos(), 1024)) {
                    Box box = new Box(c.getStartX(), renderY, c.getStartZ(), c.getStartX() + 16, renderY, c.getStartZ() + 16);
                    if (getSetting(2).asToggle().getState()) {
                        Renderer.drawBoxFill(box, fillColor, SKIP_DIRS);
                    }
                    Renderer.drawBoxOutline(box, outlineColor, 2f, SKIP_DIRS);
                }
            }
        }
    }
}
Also used : QuadColor(org.bleachhack.util.render.color.QuadColor) ChunkPos(net.minecraft.util.math.ChunkPos) Box(net.minecraft.util.math.Box) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 22 with Box

use of net.minecraft.util.math.Box in project BleachHack by BleachDrinker420.

the class BlockHighlight method onWorldRender.

@BleachSubscribe
public void onWorldRender(EventWorldRender.Post event) {
    int mode = getSetting(0).asMode().getMode();
    if (!(mc.crosshairTarget instanceof BlockHitResult))
        return;
    BlockPos pos = ((BlockHitResult) mc.crosshairTarget).getBlockPos();
    BlockState state = mc.world.getBlockState(pos);
    if (state.getMaterial() == Material.AIR || !mc.world.getWorldBorder().contains(pos))
        return;
    int[] color = this.getSetting(4).asColor().getRGBArray();
    if (mode == 0) {
        shader.prepare();
        shader.clearFramebuffer("main");
        Vec3d offset = state.getModelOffset(mc.world, pos);
        MatrixStack matrices = Renderer.matrixFrom(pos.getX() + offset.x, pos.getY() + offset.y, pos.getZ() + offset.z);
        BlockEntity be = mc.world.getBlockEntity(pos);
        BlockEntityRenderer<BlockEntity> renderer = be != null ? mc.getBlockEntityRenderDispatcher().get(be) : null;
        if (renderer != null) {
            renderer.render(be, mc.getTickDelta(), matrices, colorVertexer.createSingleProvider(mc.getBufferBuilders().getEntityVertexConsumers(), color[0], color[1], color[2], getSetting(1).asSlider().getValueInt()), LightmapTextureManager.MAX_LIGHT_COORDINATE, OverlayTexture.DEFAULT_UV);
        } else {
            mc.getBlockRenderManager().getModelRenderer().renderFlat(mc.world, mc.getBlockRenderManager().getModel(state), state, pos, matrices, colorVertexer.createSingleProvider(mc.getBufferBuilders().getEntityVertexConsumers(), color[0], color[1], color[2], getSetting(1).asSlider().getValueInt()).getBuffer(RenderLayers.getMovingBlockLayer(state)), false, new Random(), 0L, OverlayTexture.DEFAULT_UV);
        }
        colorVertexer.draw();
        shader.render();
        shader.drawFramebufferToMain("main");
    } else {
        Box box = state.getOutlineShape(mc.world, pos).getBoundingBox().offset(pos);
        float width = getSetting(2).asSlider().getValueFloat();
        int fill = getSetting(3).asSlider().getValueInt();
        if (width != 0)
            Renderer.drawBoxOutline(box, QuadColor.single(color[0], color[1], color[2], 255), width);
        if (fill != 0)
            Renderer.drawBoxFill(box, QuadColor.single(color[0], color[1], color[2], fill));
    }
}
Also used : BlockState(net.minecraft.block.BlockState) Random(java.util.Random) MatrixStack(net.minecraft.client.util.math.MatrixStack) BlockPos(net.minecraft.util.math.BlockPos) Box(net.minecraft.util.math.Box) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Vec3d(net.minecraft.util.math.Vec3d) BlockEntity(net.minecraft.block.entity.BlockEntity) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 23 with Box

use of net.minecraft.util.math.Box in project BleachHack by BleachDrinker420.

the class AutoParkour method onTick.

@BleachSubscribe
public void onTick(EventTick event) {
    if (smartPos != null) {
        if (mc.player.getY() - 0.5 < smartPos.getY() && mc.player.getVelocity().y < 0) {
            smartPos = null;
        }
    }
    if (!mc.player.isSneaking() && mc.player.isOnGround()) {
        smartPos = null;
        Box box = mc.player.getBoundingBox().offset(0, -0.51, 0);
        Stream<VoxelShape> blockCollisions = mc.world.getBlockCollisions(mc.player, box);
        if (blockCollisions.findAny().isEmpty()) {
            if (getSetting(0).asToggle().getState() && !mc.player.isSprinting()) {
                mc.player.setSprinting(true);
                mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, Mode.START_SPRINTING));
            }
            if (getSetting(1).asToggle().getState()) {
                Vec3d lookVec = mc.player.getPos().add(new Vec3d(0, 0, 3.5).rotateY(-(float) Math.toRadians(mc.player.getYaw())));
                BlockPos nearestPos = BlockPos.streamOutwards(mc.player.getBlockPos().down(), 4, 1, 4).map(BlockPos::toImmutable).filter(pos -> (mc.world.isTopSolid(pos, mc.player) && mc.world.getBlockCollisions(mc.player, new Box(pos.up(), pos.add(1, 3, 1))).findAny().isEmpty()) || mc.world.getBlockState(pos).getBlock() instanceof LadderBlock || mc.world.getBlockState(pos.up()).getBlock() instanceof LadderBlock).filter(pos -> mc.player.getPos().distanceTo(Vec3d.of(pos).add(0.5, 1, 0.5)) >= 1).filter(pos -> mc.player.getPos().distanceTo(Vec3d.of(pos).add(0.5, 1, 0.5)) <= 4.5).sorted(Comparator.comparing(pos -> pos.getSquaredDistance(lookVec, false))).findFirst().orElse(null);
                if (nearestPos != null) {
                    smartPos = nearestPos;
                }
            }
            mc.player.jump();
        }
    }
}
Also used : BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe) ModuleCategory(org.bleachhack.module.ModuleCategory) EventClientMove(org.bleachhack.event.events.EventClientMove) Box(net.minecraft.util.math.Box) EventWorldRender(org.bleachhack.event.events.EventWorldRender) BlockPos(net.minecraft.util.math.BlockPos) Renderer(org.bleachhack.util.render.Renderer) VoxelShape(net.minecraft.util.shape.VoxelShape) Mode(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket.Mode) Module(org.bleachhack.module.Module) QuadColor(org.bleachhack.util.render.color.QuadColor) LadderBlock(net.minecraft.block.LadderBlock) Stream(java.util.stream.Stream) Vec3d(net.minecraft.util.math.Vec3d) SettingColor(org.bleachhack.setting.module.SettingColor) SettingToggle(org.bleachhack.setting.module.SettingToggle) Comparator(java.util.Comparator) ClientCommandC2SPacket(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket) EventTick(org.bleachhack.event.events.EventTick) VoxelShape(net.minecraft.util.shape.VoxelShape) ClientCommandC2SPacket(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket) LadderBlock(net.minecraft.block.LadderBlock) Box(net.minecraft.util.math.Box) BlockPos(net.minecraft.util.math.BlockPos) Vec3d(net.minecraft.util.math.Vec3d) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 24 with Box

use of net.minecraft.util.math.Box in project BleachHack by BleachDrinker420.

the class ArrowJuke method onTick.

@BleachSubscribe
public void onTick(EventTick envent) {
    for (Entity e : mc.world.getEntities()) {
        if (e.age > 75 || !(e instanceof ArrowEntity) || ((ArrowEntity) e).getOwner() == mc.player)
            continue;
        int mode = getSetting(0).asMode().getMode();
        int steps = getSetting(2).asSlider().getValueInt();
        Box playerBox = mc.player.getBoundingBox().expand(0.3);
        List<Box> futureBoxes = new ArrayList<>(steps);
        Box currentBox = e.getBoundingBox();
        Vec3d currentVel = e.getVelocity();
        for (int i = 0; i < steps; i++) {
            currentBox = currentBox.offset(currentVel);
            currentVel = currentVel.multiply(0.99, 0.94, 0.99);
            futureBoxes.add(currentBox);
            if (!mc.world.getOtherEntities(null, currentBox).isEmpty() || WorldUtils.doesBoxCollide(currentBox)) {
                break;
            }
        }
        for (Box box : futureBoxes) {
            if (playerBox.intersects(box)) {
                for (Vec3d vel : getMoveVecs(e.getVelocity())) {
                    Box newBox = mc.player.getBoundingBox().offset(vel);
                    if (!WorldUtils.doesBoxCollide(newBox) && futureBoxes.stream().noneMatch(playerBox.offset(vel)::intersects)) {
                        if (mode == 0 && vel.y == 0) {
                            mc.player.setVelocity(vel);
                        } else {
                            mc.player.updatePosition(mc.player.getX() + vel.x, mc.player.getY() + vel.y, mc.player.getZ() + vel.z);
                            mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(mc.player.getX(), mc.player.getY(), mc.player.getZ(), false));
                        }
                        return;
                    }
                }
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) ArrowEntity(net.minecraft.entity.projectile.ArrowEntity) ArrowEntity(net.minecraft.entity.projectile.ArrowEntity) ArrayList(java.util.ArrayList) PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) Box(net.minecraft.util.math.Box) Vec3d(net.minecraft.util.math.Vec3d) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 25 with Box

use of net.minecraft.util.math.Box 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)

Aggregations

Box (net.minecraft.util.math.Box)184 Vec3d (net.minecraft.util.math.Vec3d)67 LivingEntity (net.minecraft.entity.LivingEntity)62 BlockPos (net.minecraft.util.math.BlockPos)60 PlayerEntity (net.minecraft.entity.player.PlayerEntity)58 Entity (net.minecraft.entity.Entity)55 Comparator (java.util.Comparator)20 Direction (net.minecraft.util.math.Direction)20 MerchantEntity (net.minecraft.entity.passive.MerchantEntity)19 PersistentProjectileEntity (net.minecraft.entity.projectile.PersistentProjectileEntity)18 ArrayList (java.util.ArrayList)17 List (java.util.List)15 ItemStack (net.minecraft.item.ItemStack)15 Hand (net.minecraft.util.Hand)15 VoxelShape (net.minecraft.util.shape.VoxelShape)15 BlockState (net.minecraft.block.BlockState)14 Stream (java.util.stream.Stream)12 ArmorStandEntity (net.minecraft.entity.decoration.ArmorStandEntity)12 PlayerMoveC2SPacket (net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket)12 FakePlayerEntity (net.wurstclient.util.FakePlayerEntity)12