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;
}
}
}
}
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;
}
}
}
}
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;
}
}
}
}
}
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();
}
}
}
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;
}
}
}
Aggregations