Search in sources :

Example 1 with SettingToggle

use of org.bleachhack.setting.module.SettingToggle in project BleachHack by BleachDrinker420.

the class Search method onRender.

@BleachSubscribe
public void onRender(EventWorldRender.Post event) {
    int mode = getSetting(0).asMode().getMode();
    int i = 0;
    for (BlockPos pos : foundBlocks) {
        if (i > 3000)
            return;
        BlockState state = mc.world.getBlockState(pos);
        int[] color = getColorForBlock(state, pos);
        VoxelShape voxelShape = state.getOutlineShape(mc.world, pos);
        if (voxelShape.isEmpty()) {
            voxelShape = VoxelShapes.cuboid(0, 0, 0, 1, 1, 1);
        }
        if (mode == 0 || mode == 2) {
            int fillAlpha = (int) (getSetting(2).asSlider().getValue() * 255);
            for (Box box : voxelShape.getBoundingBoxes()) {
                Renderer.drawBoxFill(box.offset(pos), QuadColor.single(color[0], color[1], color[2], fillAlpha));
            }
        }
        if (mode == 0 || mode == 1) {
            float outlineWidth = getSetting(1).asSlider().getValueFloat();
            for (Box box : voxelShape.getBoundingBoxes()) {
                Renderer.drawBoxOutline(box.offset(pos), QuadColor.single(color[0], color[1], color[2], 255), outlineWidth);
            }
        }
        SettingToggle tracers = getSetting(3).asToggle();
        if (tracers.getState()) {
            // This is bad when bobbing is enabled!
            Vec3d lookVec = new Vec3d(0, 0, 75).rotateX(-(float) Math.toRadians(mc.gameRenderer.getCamera().getPitch())).rotateY(-(float) Math.toRadians(mc.gameRenderer.getCamera().getYaw())).add(mc.cameraEntity.getEyePos());
            Renderer.drawLine(lookVec.x, lookVec.y, lookVec.z, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, LineColor.single(color[0], color[1], color[2], (int) (tracers.getChild(1).asSlider().getValue() * 255)), tracers.getChild(0).asSlider().getValueFloat());
        }
        i++;
    }
}
Also used : BlockState(net.minecraft.block.BlockState) VoxelShape(net.minecraft.util.shape.VoxelShape) SettingToggle(org.bleachhack.setting.module.SettingToggle) BlockPos(net.minecraft.util.math.BlockPos) Box(net.minecraft.util.math.Box) Vec3d(net.minecraft.util.math.Vec3d) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 2 with SettingToggle

use of org.bleachhack.setting.module.SettingToggle in project BleachHack by BleachDrinker420.

the class NoRender method onSignRender.

@BleachSubscribe
public void onSignRender(EventBlockEntityRender.Single.Pre event) {
    if (event.getBlockEntity() instanceof SignBlockEntity && isWorldToggled(0)) {
        SettingToggle signSetting = getWorldChild(0);
        if (signSetting.getChild(0).asMode().getMode() == 0) {
            event.setCancelled(true);
        } else {
            SignBlockEntity sign = new SignBlockEntity(event.getBlockEntity().getPos(), event.getBlockEntity().getCachedState());
            sign.setWorld(mc.world);
            if (signSetting.getChild(0).asMode().getMode() == 2) {
                for (int i = 0; i < 4; i++) {
                    sign.setTextOnRow(i, signText[i]);
                }
            }
            event.setBlockEntity(sign);
        }
    }
}
Also used : SignBlockEntity(net.minecraft.block.entity.SignBlockEntity) SettingToggle(org.bleachhack.setting.module.SettingToggle) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 3 with SettingToggle

use of org.bleachhack.setting.module.SettingToggle in project BleachHack by BleachDrinker420.

the class NoRender method onRenderGuiBackground.

@BleachSubscribe
public void onRenderGuiBackground(EventRenderScreenBackground event) {
    if (mc.world != null && isOverlayToggled(7)) {
        SettingToggle guiSetting = getOverlayChild(7);
        int opacity = (int) (guiSetting.getChild(0).asSlider().getValue() * 255);
        if (opacity != 0) {
            int opacity2 = (int) (opacity * 0.93);
            Window.verticalGradient(event.getMatrices(), 0, 0, mc.currentScreen.width, mc.currentScreen.height, (opacity2 << 24) | 0x101010, (opacity << 24) | 0x101010);
        }
        event.setCancelled(true);
    }
}
Also used : SettingToggle(org.bleachhack.setting.module.SettingToggle) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 4 with SettingToggle

use of org.bleachhack.setting.module.SettingToggle in project BleachHack by BleachDrinker420.

the class AutoFarm method onTick.

@BleachSubscribe
public void onTick(EventTick event) {
    mossMap.entrySet().removeIf(e -> e.setValue(e.getValue() - 1) == 0);
    double range = getSetting(0).asSlider().getValue();
    int ceilRange = MathHelper.ceil(range);
    SettingToggle tillSetting = getSetting(1).asToggle();
    SettingToggle harvestSetting = getSetting(2).asToggle();
    SettingToggle plantSetting = getSetting(3).asToggle();
    SettingToggle bonemealSetting = getSetting(4).asToggle();
    // Special case for moss to maximize efficiency
    if (bonemealSetting.getState() && bonemealSetting.getChild(6).asToggle().getState()) {
        int slot = InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.BONE_MEAL);
        if (slot != -1) {
            BlockPos bestBlock = BlockPos.streamOutwards(new BlockPos(mc.player.getEyePos()), ceilRange, ceilRange, ceilRange).filter(b -> mc.player.getEyePos().distanceTo(Vec3d.ofCenter(b)) <= range && !mossMap.containsKey(b)).map(b -> Pair.of(b.toImmutable(), getMossSpots(b))).filter(p -> p.getRight() > 10).map(Pair::getLeft).min(Comparator.reverseOrder()).orElse(null);
            if (bestBlock != null) {
                if (!mc.world.isAir(bestBlock.up())) {
                    mc.interactionManager.updateBlockBreakingProgress(bestBlock.up(), Direction.UP);
                }
                Hand hand = InventoryUtils.selectSlot(slot);
                mc.interactionManager.interactBlock(mc.player, mc.world, hand, new BlockHitResult(Vec3d.ofCenter(bestBlock, 1), Direction.UP, bestBlock, false));
                mossMap.put(bestBlock, 100);
                return;
            }
        }
    }
    for (BlockPos pos : BlockPos.iterateOutwards(new BlockPos(mc.player.getEyePos()), ceilRange, ceilRange, ceilRange)) {
        if (mc.player.getEyePos().distanceTo(Vec3d.ofCenter(pos)) > range)
            continue;
        BlockState state = mc.world.getBlockState(pos);
        Block block = state.getBlock();
        if (tillSetting.getState() && canTill(block) && mc.world.isAir(pos.up())) {
            if (!tillSetting.getChild(0).asToggle().getState() || BlockPos.stream(pos.getX() - 4, pos.getY(), pos.getZ() - 4, pos.getX() + 4, pos.getY(), pos.getZ() + 4).anyMatch(b -> mc.world.getFluidState(b).isIn(FluidTags.WATER))) {
                Hand hand = InventoryUtils.selectSlot(true, i -> mc.player.getInventory().getStack(i).getItem() instanceof HoeItem);
                if (hand != null) {
                    mc.interactionManager.interactBlock(mc.player, mc.world, hand, new BlockHitResult(Vec3d.ofCenter(pos, 1), Direction.UP, pos, false));
                    return;
                }
            }
        }
        if (harvestSetting.getState()) {
            if ((harvestSetting.getChild(0).asToggle().getState() && block instanceof CropBlock && ((CropBlock) block).isMature(state)) || (harvestSetting.getChild(1).asToggle().getState() && block instanceof GourdBlock) || (harvestSetting.getChild(2).asToggle().getState() && block instanceof NetherWartBlock && state.get(NetherWartBlock.AGE) >= 3) || (harvestSetting.getChild(3).asToggle().getState() && block instanceof CocoaBlock && state.get(CocoaBlock.AGE) >= 2) || (harvestSetting.getChild(4).asToggle().getState() && block instanceof SweetBerryBushBlock && state.get(SweetBerryBushBlock.AGE) >= 3) || (harvestSetting.getChild(5).asToggle().getState() && shouldHarvestTallCrop(pos, block, SugarCaneBlock.class)) || (harvestSetting.getChild(6).asToggle().getState() && shouldHarvestTallCrop(pos, block, CactusBlock.class))) {
                mc.interactionManager.updateBlockBreakingProgress(pos, Direction.UP);
                return;
            }
        }
        if (plantSetting.getState() && mc.world.getOtherEntities(null, new Box(pos.up()), EntityPredicates.VALID_LIVING_ENTITY).isEmpty()) {
            if (block instanceof FarmlandBlock && mc.world.isAir(pos.up())) {
                int slot = InventoryUtils.getSlot(true, i -> {
                    Item item = mc.player.getInventory().getStack(i).getItem();
                    if (plantSetting.getChild(0).asToggle().getState() && (item == Items.WHEAT_SEEDS || item == Items.CARROT || item == Items.POTATO || item == Items.BEETROOT_SEEDS)) {
                        return true;
                    }
                    return plantSetting.getChild(1).asToggle().getState() && (item == Items.PUMPKIN_SEEDS || item == Items.MELON_SEEDS);
                });
                if (slot != -1) {
                    WorldUtils.placeBlock(pos.up(), slot, 0, false, false, true);
                    return;
                }
            }
            if (block instanceof SoulSandBlock && mc.world.isAir(pos.up()) && plantSetting.getChild(2).asToggle().getState()) {
                int slot = InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.NETHER_WART);
                if (slot != -1) {
                    WorldUtils.placeBlock(pos.up(), slot, 0, false, false, true);
                    return;
                }
            }
        }
        if (bonemealSetting.getState()) {
            int slot = InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.BONE_MEAL);
            if (slot != -1) {
                if ((bonemealSetting.getChild(0).asToggle().getState() && block instanceof CropBlock && !((CropBlock) block).isMature(state)) || (bonemealSetting.getChild(1).asToggle().getState() && block instanceof StemBlock && state.get(StemBlock.AGE) < StemBlock.MAX_AGE) || (bonemealSetting.getChild(2).asToggle().getState() && block instanceof CocoaBlock && state.get(CocoaBlock.AGE) < 2) || (bonemealSetting.getChild(3).asToggle().getState() && block instanceof SweetBerryBushBlock && state.get(SweetBerryBushBlock.AGE) < 3) || (bonemealSetting.getChild(4).asToggle().getState() && block instanceof MushroomPlantBlock) || (bonemealSetting.getChild(5).asToggle().getState() && (block instanceof SaplingBlock || block instanceof AzaleaBlock) && canPlaceSapling(pos))) {
                    Hand hand = InventoryUtils.selectSlot(slot);
                    mc.interactionManager.interactBlock(mc.player, mc.world, hand, new BlockHitResult(Vec3d.ofCenter(pos, 1), Direction.UP, pos, false));
                    return;
                }
            }
        }
    }
}
Also used : BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe) SettingSlider(org.bleachhack.setting.module.SettingSlider) ModuleCategory(org.bleachhack.module.ModuleCategory) Item(net.minecraft.item.Item) net.minecraft.util.math(net.minecraft.util.math) BlockHitResult(net.minecraft.util.hit.BlockHitResult) InventoryUtils(org.bleachhack.util.InventoryUtils) HashMap(java.util.HashMap) Items(net.minecraft.item.Items) Module(org.bleachhack.module.Module) FluidTags(net.minecraft.tag.FluidTags) WorldUtils(org.bleachhack.util.world.WorldUtils) Pair(org.apache.commons.lang3.tuple.Pair) net.minecraft.block(net.minecraft.block) EntityPredicates(net.minecraft.predicate.entity.EntityPredicates) TreeFeature(net.minecraft.world.gen.feature.TreeFeature) Map(java.util.Map) Hand(net.minecraft.util.Hand) SettingToggle(org.bleachhack.setting.module.SettingToggle) Comparator(java.util.Comparator) EventTick(org.bleachhack.event.events.EventTick) HoeItem(net.minecraft.item.HoeItem) HoeItem(net.minecraft.item.HoeItem) Item(net.minecraft.item.Item) HoeItem(net.minecraft.item.HoeItem) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Pair(org.apache.commons.lang3.tuple.Pair) Hand(net.minecraft.util.Hand) SettingToggle(org.bleachhack.setting.module.SettingToggle) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 5 with SettingToggle

use of org.bleachhack.setting.module.SettingToggle in project BleachHack by BleachDrinker420.

the class BowBot method onTick.

@BleachSubscribe
public void onTick(EventTick event) {
    if (!(mc.player.getMainHandStack().getItem() instanceof RangedWeaponItem) || !mc.player.isUsingItem())
        return;
    if (getSetting(0).asToggle().getState()) {
        if (mc.player.getMainHandStack().getItem() == Items.CROSSBOW && (float) mc.player.getItemUseTime() / (float) CrossbowItem.getPullTime(mc.player.getMainHandStack()) >= 1f) {
            mc.player.stopUsingItem();
            mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, Direction.UP));
            mc.interactionManager.interactItem(mc.player, mc.world, Hand.MAIN_HAND);
        } else if (mc.player.getMainHandStack().getItem() == Items.BOW && BowItem.getPullProgress(mc.player.getItemUseTime()) >= getSetting(0).asToggle().getChild(0).asSlider().getValueFloat()) {
            mc.player.stopUsingItem();
            mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, Direction.UP));
        }
    }
    // Credit: https://github.com/Wurst-Imperium/Wurst7/blob/master/src/main/java/net/wurstclient/hacks/BowAimbotHack.java
    SettingToggle aimToggle = getSetting(1).asToggle();
    if (aimToggle.getState()) {
        LivingEntity target = Streams.stream(mc.world.getEntities()).filter(e -> EntityUtils.isAttackable(e, true) && (!aimToggle.getChild(3).asToggle().getState() || mc.player.canSee(e))).filter(e -> (aimToggle.getChild(0).asToggle().getState() && EntityUtils.isPlayer(e)) || (aimToggle.getChild(1).asToggle().getState() && EntityUtils.isMob(e)) || (aimToggle.getChild(2).asToggle().getState() && EntityUtils.isAnimal(e))).sorted(Comparator.comparing(mc.player::distanceTo)).map(e -> (LivingEntity) e).findFirst().orElse(null);
        if (target == null)
            return;
        // set velocity
        float velocity = (72000 - mc.player.getItemUseTimeLeft()) / 20F;
        velocity = Math.min(1f, (velocity * velocity + velocity * 2) / 3);
        // set position to aim at
        Vec3d newTargetVec = target.getPos().add(target.getVelocity());
        double d = mc.player.getEyePos().distanceTo(target.getBoundingBox().offset(target.getVelocity()).getCenter());
        double x = newTargetVec.x + (newTargetVec.x - target.getX()) * d - mc.player.getX();
        double y = newTargetVec.y + (newTargetVec.y - target.getY()) * d + target.getHeight() * 0.5 - mc.player.getY() - mc.player.getEyeHeight(mc.player.getPose());
        double z = newTargetVec.z + (newTargetVec.z - target.getZ()) * d - mc.player.getZ();
        // set yaw
        mc.player.setYaw((float) Math.toDegrees(Math.atan2(z, x)) - 90);
        // calculate needed pitch
        double hDistance = Math.sqrt(x * x + z * z);
        double hDistanceSq = hDistance * hDistance;
        float g = 0.006F;
        float velocitySq = velocity * velocity;
        float velocityPow4 = velocitySq * velocitySq;
        float neededPitch = (float) -Math.toDegrees(Math.atan((velocitySq - Math.sqrt(velocityPow4 - g * (g * hDistanceSq + 2 * y * velocitySq))) / (g * hDistance)));
        // set pitch
        if (Float.isNaN(neededPitch)) {
            WorldUtils.facePos(target.getX(), target.getY() + target.getHeight() / 2, target.getZ());
        } else {
            mc.player.setPitch(neededPitch);
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe) SettingSlider(org.bleachhack.setting.module.SettingSlider) EntityUtils(org.bleachhack.util.world.EntityUtils) ModuleCategory(org.bleachhack.module.ModuleCategory) CrossbowItem(net.minecraft.item.CrossbowItem) LivingEntity(net.minecraft.entity.LivingEntity) RangedWeaponItem(net.minecraft.item.RangedWeaponItem) PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) BlockPos(net.minecraft.util.math.BlockPos) Items(net.minecraft.item.Items) Streams(com.google.common.collect.Streams) Module(org.bleachhack.module.Module) Action(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket.Action) WorldUtils(org.bleachhack.util.world.WorldUtils) Direction(net.minecraft.util.math.Direction) Vec3d(net.minecraft.util.math.Vec3d) Hand(net.minecraft.util.Hand) SettingToggle(org.bleachhack.setting.module.SettingToggle) BowItem(net.minecraft.item.BowItem) Comparator(java.util.Comparator) EventTick(org.bleachhack.event.events.EventTick) PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) SettingToggle(org.bleachhack.setting.module.SettingToggle) RangedWeaponItem(net.minecraft.item.RangedWeaponItem) Vec3d(net.minecraft.util.math.Vec3d) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Aggregations

BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)7 SettingToggle (org.bleachhack.setting.module.SettingToggle)7 Items (net.minecraft.item.Items)3 Hand (net.minecraft.util.Hand)3 BlockPos (net.minecraft.util.math.BlockPos)3 Vec3d (net.minecraft.util.math.Vec3d)3 EventTick (org.bleachhack.event.events.EventTick)3 Module (org.bleachhack.module.Module)3 ModuleCategory (org.bleachhack.module.ModuleCategory)3 SettingSlider (org.bleachhack.setting.module.SettingSlider)3 WorldUtils (org.bleachhack.util.world.WorldUtils)3 Streams (com.google.common.collect.Streams)2 Comparator (java.util.Comparator)2 BlockState (net.minecraft.block.BlockState)2 LivingEntity (net.minecraft.entity.LivingEntity)2 Item (net.minecraft.item.Item)2 BlockHitResult (net.minecraft.util.hit.BlockHitResult)2 Box (net.minecraft.util.math.Box)2 Direction (net.minecraft.util.math.Direction)2 InventoryUtils (org.bleachhack.util.InventoryUtils)2