Search in sources :

Example 1 with EventTick

use of org.bleachhack.event.events.EventTick in project BleachHack by BleachDrinker420.

the class AutoSteal method onTick.

@BleachSubscribe
public void onTick(EventTick event) {
    currentTime++;
    for (Entry<BlockPos, Integer> e : new HashMap<>(opened).entrySet()) {
        if (e.getValue() <= 0)
            opened.remove(e.getKey());
        else
            opened.replace(e.getKey(), e.getValue() - 1);
    }
    if (currentItems != null && currentSyncId != -1) {
        if (currentTime - lastSteal >= getSetting(1).asSlider().getValue()) {
            for (int i = 0; i < currentItems.size(); i++) {
                if (!currentItems.get(i).isEmpty()) {
                    if (isBlacklisted(currentItems.get(i).getItem())) {
                        continue;
                    }
                    int fi = i;
                    boolean openSlot = InventoryUtils.getSlot(false, j -> mc.player.getInventory().getStack(j).isEmpty() || (mc.player.getInventory().getStack(j).isStackable() && mc.player.getInventory().getStack(j).getCount() < mc.player.getInventory().getStack(j).getMaxCount() && currentItems.get(fi).isItemEqual(mc.player.getInventory().getStack(j)))) != 1;
                    if (openSlot) {
                        mc.interactionManager.clickSlot(currentSyncId, i, 0, SlotActionType.QUICK_MOVE, mc.player);
                        currentItems.set(i, ItemStack.EMPTY);
                        lastSteal = currentTime + RandomUtils.nextInt(0, getSetting(2).asSlider().getValueInt() + 1);
                    }
                    return;
                }
            }
            if (getSetting(0).asMode().getMode() >= 1 || getSetting(3).asToggle().getState()) {
                mc.setScreen(null);
                mc.player.networkHandler.sendPacket(new CloseHandledScreenC2SPacket(currentSyncId));
            }
        }
    } else if (currentItems == null && currentSyncId == -1 && getSetting(3).asToggle().getState()) {
        for (BlockEntity be : WorldUtils.getBlockEntities()) {
            if (!opened.containsKey(be.getPos()) && be instanceof ChestBlockEntity && mc.player.getEyePos().distanceTo(Vec3d.ofCenter(be.getPos())) <= getSetting(3).asToggle().getChild(0).asSlider().getValue() + 0.25) {
                Vec3d lookVec = Vec3d.ofCenter(be.getPos()).add(0, 0.5, 0);
                if (getSetting(3).asToggle().getChild(2).asRotate().getState()) {
                    WorldUtils.facePosAuto(lookVec.x, lookVec.y, lookVec.z, getSetting(3).asToggle().getChild(2).asRotate());
                }
                mc.interactionManager.interactBlock(mc.player, mc.world, Hand.MAIN_HAND, new BlockHitResult(lookVec, Direction.UP, be.getPos(), false));
                opened.put(be.getPos(), getSetting(3).asToggle().getChild(1).asSlider().getValueInt() * 20);
                return;
            }
        }
    }
}
Also used : CloseHandledScreenC2SPacket(net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket) RandomUtils(org.apache.commons.lang3.RandomUtils) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe) LiteralText(net.minecraft.text.LiteralText) BlockEntity(net.minecraft.block.entity.BlockEntity) ModuleCategory(org.bleachhack.module.ModuleCategory) Item(net.minecraft.item.Item) EventOpenScreen(org.bleachhack.event.events.EventOpenScreen) InventoryUtils(org.bleachhack.util.InventoryUtils) HashMap(java.util.HashMap) SettingItemList(org.bleachhack.setting.module.SettingItemList) ArrayList(java.util.ArrayList) ScreenHandlerSlotUpdateS2CPacket(net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket) Direction(net.minecraft.util.math.Direction) WorldUtils(org.bleachhack.util.world.WorldUtils) ItemStack(net.minecraft.item.ItemStack) PlayerInteractBlockC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket) Vec3d(net.minecraft.util.math.Vec3d) SettingMode(org.bleachhack.setting.module.SettingMode) Map(java.util.Map) Hand(net.minecraft.util.Hand) ChestBlock(net.minecraft.block.ChestBlock) ChestBlockEntity(net.minecraft.block.entity.ChestBlockEntity) EventPacket(org.bleachhack.event.events.EventPacket) SettingRotate(org.bleachhack.setting.module.SettingRotate) SettingSlider(org.bleachhack.setting.module.SettingSlider) ScreenHandler(net.minecraft.screen.ScreenHandler) WorldRenderer(org.bleachhack.util.render.WorldRenderer) InventoryS2CPacket(net.minecraft.network.packet.s2c.play.InventoryS2CPacket) BlockHitResult(net.minecraft.util.hit.BlockHitResult) EventWorldRender(org.bleachhack.event.events.EventWorldRender) BlockPos(net.minecraft.util.math.BlockPos) Module(org.bleachhack.module.Module) List(java.util.List) Entry(java.util.Map.Entry) SlotActionType(net.minecraft.screen.slot.SlotActionType) SettingToggle(org.bleachhack.setting.module.SettingToggle) HandledScreen(net.minecraft.client.gui.screen.ingame.HandledScreen) EventTick(org.bleachhack.event.events.EventTick) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) ChestBlockEntity(net.minecraft.block.entity.ChestBlockEntity) BlockPos(net.minecraft.util.math.BlockPos) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Vec3d(net.minecraft.util.math.Vec3d) CloseHandledScreenC2SPacket(net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket) BlockEntity(net.minecraft.block.entity.BlockEntity) ChestBlockEntity(net.minecraft.block.entity.ChestBlockEntity) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 2 with EventTick

use of org.bleachhack.event.events.EventTick in project BleachHack by BleachDrinker420.

the class AutoEXP method onTick.

@BleachSubscribe
public void onTick(EventTick event) {
    if (mc.player.currentScreenHandler != mc.player.playerScreenHandler)
        return;
    int xpSlot = InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.EXPERIENCE_BOTTLE);
    if (xpSlot == -1)
        return;
    int damage = getSetting(3).asSlider().getValueInt();
    double target = getSetting(4).asSlider().getValue();
    if (slot != -1) {
        if (xpNeeded == 0) {
            ItemStack item = slot < 45 ? mc.player.currentScreenHandler.getSlot(slot).getStack() : mc.player.getOffHandStack();
            if (item.isDamaged() && item.getMaxDamage() - item.getDamage() <= damage)
                return;
            for (int i = 1; i <= 4; i++) {
                ItemStack stack = mc.player.currentScreenHandler.getSlot(i).getStack();
                if (!stack.isEmpty()) {
                    for (int j = 5; j <= 8; j++) {
                        if (mc.player.currentScreenHandler.getSlot(j).canInsert(stack)) {
                            mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, i, 0, SlotActionType.PICKUP, mc.player);
                            mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, j, 0, SlotActionType.PICKUP, mc.player);
                            return;
                        }
                    }
                }
            }
            if (slot >= 46) {
                if (slot - 46 != mc.player.getInventory().selectedSlot) {
                    mc.player.getInventory().selectedSlot = slot - 46;
                    mc.player.networkHandler.sendPacket(new UpdateSelectedSlotC2SPacket(slot - 46));
                }
                mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(Action.SWAP_ITEM_WITH_OFFHAND, BlockPos.ORIGIN, Direction.DOWN));
            }
            delay = 0;
            slot = -1;
            return;
        }
        for (int i = 5; i <= 8; i++) {
            if (i != slot && EnchantmentHelper.getLevel(Enchantments.MENDING, mc.player.currentScreenHandler.getSlot(i).getStack()) != 0) {
                for (int j = 1; j <= 4; j++) {
                    ItemStack craftingStack = mc.player.currentScreenHandler.getSlot(j).getStack();
                    if (!craftingStack.isDamageable()) {
                        mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, i, 0, SlotActionType.PICKUP, mc.player);
                        mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, j, 0, SlotActionType.PICKUP, mc.player);
                        if (!craftingStack.isEmpty())
                            mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, j, 1, SlotActionType.THROW, mc.player);
                        return;
                    }
                }
            }
        }
        if (slot > 8 && slot < 45) {
            if (slot - 36 != mc.player.getInventory().selectedSlot) {
                mc.player.getInventory().selectedSlot = slot - 36;
                mc.player.networkHandler.sendPacket(new UpdateSelectedSlotC2SPacket(slot - 36));
            }
            mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(Action.SWAP_ITEM_WITH_OFFHAND, BlockPos.ORIGIN, Direction.DOWN));
            // hack
            slot += 10;
            return;
        }
        delay++;
        if (delay >= getSetting(6).asSlider().getValueInt()) {
            delay = 0;
            int toThrow = Math.min(getSetting(5).asSlider().getValueInt(), xpNeeded);
            if (toThrow != 0) {
                mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(mc.player.getYaw(), 90, mc.player.isOnGround()));
                for (int t = 0; t < toThrow; t++) {
                    if (InventoryUtils.selectSlot(false, i -> mc.player.getInventory().getStack(i).getItem() == Items.EXPERIENCE_BOTTLE) == Hand.MAIN_HAND) {
                        // Trying to use without bruh
                        mc.player.networkHandler.sendPacket(new PlayerInteractItemC2SPacket(Hand.MAIN_HAND));
                        ItemStack itemStack2 = mc.player.getMainHandStack().use(mc.world, mc.player, Hand.MAIN_HAND).getValue();
                        if (itemStack2 != mc.player.getMainHandStack()) {
                            mc.player.setStackInHand(Hand.MAIN_HAND, itemStack2);
                        }
                        xpNeeded--;
                    }
                }
            }
        }
        return;
    }
    IntSet slots = new IntArraySet();
    if (getSetting(0).asToggle().getState()) {
        slots.add(5);
        slots.add(6);
        slots.add(7);
        slots.add(8);
    }
    if (getSetting(1).asToggle().getState())
        slots.add(36 + mc.player.getInventory().selectedSlot);
    if (getSetting(2).asToggle().getState())
        slots.add(45);
    if (getSetting(0).asToggle().getState()) {
        for (int s : slots) {
            ItemStack item = mc.player.currentScreenHandler.getSlot(s).getStack();
            if (item.isDamageable() && item.getMaxDamage() - item.getDamage() <= damage && item.getMaxDamage() - item.getDamage() < item.getMaxDamage() * target) {
                slot = s;
                xpNeeded = (int) Math.ceil((item.getMaxDamage() * target - (item.getMaxDamage() - item.getDamage())) / 14d);
                return;
            }
        }
    }
}
Also used : BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe) SettingSlider(org.bleachhack.setting.module.SettingSlider) CloseHandledScreenC2SPacket(net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket) ModuleCategory(org.bleachhack.module.ModuleCategory) PlayerInteractItemC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket) InventoryUtils(org.bleachhack.util.InventoryUtils) IntArraySet(it.unimi.dsi.fastutil.ints.IntArraySet) PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) BlockPos(net.minecraft.util.math.BlockPos) Items(net.minecraft.item.Items) EnchantmentHelper(net.minecraft.enchantment.EnchantmentHelper) Module(org.bleachhack.module.Module) Action(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket.Action) Direction(net.minecraft.util.math.Direction) ItemStack(net.minecraft.item.ItemStack) UpdateSelectedSlotC2SPacket(net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket) Enchantments(net.minecraft.enchantment.Enchantments) PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) IntSet(it.unimi.dsi.fastutil.ints.IntSet) Hand(net.minecraft.util.Hand) SettingToggle(org.bleachhack.setting.module.SettingToggle) SlotActionType(net.minecraft.screen.slot.SlotActionType) EventPacket(org.bleachhack.event.events.EventPacket) EventTick(org.bleachhack.event.events.EventTick) PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) IntSet(it.unimi.dsi.fastutil.ints.IntSet) UpdateSelectedSlotC2SPacket(net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket) PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) PlayerInteractItemC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket) IntArraySet(it.unimi.dsi.fastutil.ints.IntArraySet) ItemStack(net.minecraft.item.ItemStack) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 3 with EventTick

use of org.bleachhack.event.events.EventTick 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 4 with EventTick

use of org.bleachhack.event.events.EventTick 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 5 with EventTick

use of org.bleachhack.event.events.EventTick 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

EventTick (org.bleachhack.event.events.EventTick)8 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)7 Module (org.bleachhack.module.Module)7 ModuleCategory (org.bleachhack.module.ModuleCategory)7 Hand (net.minecraft.util.Hand)6 BlockPos (net.minecraft.util.math.BlockPos)6 SettingToggle (org.bleachhack.setting.module.SettingToggle)6 Items (net.minecraft.item.Items)5 Direction (net.minecraft.util.math.Direction)5 Vec3d (net.minecraft.util.math.Vec3d)5 SettingSlider (org.bleachhack.setting.module.SettingSlider)5 InventoryUtils (org.bleachhack.util.InventoryUtils)5 BlockHitResult (net.minecraft.util.hit.BlockHitResult)4 EventWorldRender (org.bleachhack.event.events.EventWorldRender)4 WorldUtils (org.bleachhack.util.world.WorldUtils)4 Comparator (java.util.Comparator)3 Box (net.minecraft.util.math.Box)3 Renderer (org.bleachhack.util.render.Renderer)3 QuadColor (org.bleachhack.util.render.color.QuadColor)3 Streams (com.google.common.collect.Streams)2