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