use of mathax.client.eventbus.EventHandler in project Client by MatHax.
the class Surround method onTick.
@EventHandler
private void onTick(TickEvent.Pre event) {
renderBlocks.forEach(Scaffold.RenderBlock::tick);
renderBlocks.removeIf(renderBlock -> renderBlock.ticks <= 0);
if ((disableOnJump.get() && (mc.options.jumpKey.isPressed() || mc.player.input.jumping)) || (disableOnYChange.get() && mc.player.prevY < mc.player.getY())) {
ChatUtils.sendMsg(hashCode(), "Surround", Formatting.DARK_RED, "You jumped, disabling...", Formatting.GRAY);
toggle();
return;
}
if ((centerKeyBind.get()).isPressed())
PlayerUtils.centerPlayer();
final BlockPos roundedPos = PlayerUtils.roundBlockPos(mc.player.getPos());
if (onlyOnGround.get() && !mc.player.isOnGround() && roundedPos.getY() <= lastPos.getY())
lastPos = PlayerUtils.roundBlockPos(mc.player.getPos());
if (surroundInstanceDelay.passedMillis(timeToStart) && (mc.player.isOnGround() || !onlyOnGround.get())) {
if (delay.get() != 0 && ticks++ % delay.get() != 0)
return;
if (!(Modules.get().get(Blink.class)).isActive() || !stayOnBlink.get()) {
final AbstractClientPlayerEntity loc = mc.player;
final BlockPos locRounded = PlayerUtils.roundBlockPos(loc.getPos());
if (!lastPos.equals(loc.isOnGround() ? locRounded : loc.getBlockPos())) {
if (onlyOnGround.get() || loc.getPos().y > lastPos.getY() + 1.5 || ((Math.floor(loc.getPos().x) != lastPos.getX() || Math.floor(loc.getPos().z) != lastPos.getZ()) && loc.getPos().y > lastPos.getY() + 0.75) || (!mc.world.getBlockState(lastPos).getMaterial().isReplaceable() && loc.getBlockPos() != lastPos)) {
toggle();
return;
}
if (!onlyOnGround.get() && locRounded.getY() <= lastPos.getY())
lastPos = locRounded;
}
}
int blockIndex = getInvBlock().slot();
if (blockIndex == -1)
return;
int prevSlot = mc.player.getInventory().selectedSlot;
if (needsToPlace()) {
for (BlockPos pos : getPositions()) {
if (mc.world.getBlockState(pos).getMaterial().isReplaceable())
mc.player.getInventory().selectedSlot = blockIndex;
if (!mc.world.isOutOfHeightLimit(pos.getY()) && canPlace(pos))
renderBlocks.add(renderBlockPool.get().set(pos));
if (PlayerUtils.placeBlockMainHand(pos, oldPlacement.get(), blockIndex, rotate.get(), swing.get(), !onlyOnGround.get(), placeOnCrystal.get()) && delay.get() != 0) {
mc.player.getInventory().selectedSlot = prevSlot;
return;
}
}
mc.player.getInventory().selectedSlot = prevSlot;
}
}
}
use of mathax.client.eventbus.EventHandler in project Client by MatHax.
the class SurroundBreak method onTick.
@EventHandler(priority = EventPriority.MEDIUM + 60)
private void onTick(TickEvent.Pre event) {
CrystalAura crystalAura = Modules.get().get(CrystalAura.class);
if (crystalAura.isActive())
target = crystalAura.getPlayerTarget();
if (target == null || !crystalAura.isActive())
return;
FindItemResult crystal = InvUtils.findInHotbar(Items.END_CRYSTAL);
if (!crystal.found())
return;
if (!PlayerUtils.isSurrounded(target))
return;
placePositions.clear();
findPlacePos(target);
if (delay >= delaySetting.get() && placePositions.size() > 0) {
BlockPos blockPos = placePositions.get(placePositions.size() - 1);
if (PlayerUtils.distanceTo(blockPos) > placeRange.get())
return;
if (BlockUtils.place(blockPos, crystal, rotate.get(), 50, swing.get(), checkEntity.get(), swapBack.get()))
placePositions.remove(blockPos);
delay = 0;
} else
delay++;
if (renderTimer > 0)
renderTimer--;
renderTimer = renderTime.get();
}
use of mathax.client.eventbus.EventHandler in project Client by MatHax.
the class TNTAura method onRender.
@EventHandler
private void onRender(Render3DEvent event) {
if (obsidianRender.get() && !obsidianPos.isEmpty()) {
for (BlockPos pos : obsidianPos) {
boolean isFirst = pos.equals(obsidianPos.get(obsidianPos.size() - 1));
Color side = isFirst ? obsidianNextSideColor.get() : obsidianSideColor.get();
Color line = isFirst ? obsidianNextLineColor.get() : obsidianLineColor.get();
event.renderer.box(pos, side, line, obsidianShapeMode.get(), 0);
}
}
if (tntRender.get() && target != null && allowTNT(target)) {
if (tntBlockstate(target.getBlockPos().add(0, 2, 0)))
event.renderer.box(target.getBlockPos().add(0, 2, 0), tntSideColor.get(), tntLineColor.get(), tntShapeMode.get(), 0);
}
if (breakRender.get() && target != null && autoBreak.get()) {
if (!mineBlockstate(target.getBlockPos().add(0, 2, 0)))
event.renderer.box(target.getBlockPos().add(0, 2, 0), breakSideColor.get(), breakLineColor.get(), breakShapeMode.get(), 0);
}
}
use of mathax.client.eventbus.EventHandler in project Client by MatHax.
the class SelfProtect method onTick.
@EventHandler
private void onTick(TickEvent.Pre event) {
if (antiAnchorAura.get() && mc.world.getBlockState(mc.player.getBlockPos().up(2)).getBlock() == Blocks.RESPAWN_ANCHOR && mc.world.getBlockState(mc.player.getBlockPos().up()).getBlock() == Blocks.AIR)
BlockUtils.place(mc.player.getBlockPos().add(0, 1, 0), InvUtils.findInHotbar(itemStack -> Block.getBlockFromItem(itemStack.getItem()) instanceof SlabBlock), rotate.get(), 15, swing.get(), false, true);
BlockPos top = mc.player.getBlockPos().up(2);
if (antiCEVBreaker.get() && mc.world.getBlockState(top).getBlock() == Blocks.OBSIDIAN) {
Iterator<Entity> iterator = mc.world.getEntities().iterator();
coder: while (true) {
while (true) {
if (!iterator.hasNext())
break coder;
Entity crystal = iterator.next();
if (crystal instanceof EndCrystalEntity && crystal.getBlockPos().equals(top.up())) {
mc.player.networkHandler.sendPacket(PlayerInteractEntityC2SPacket.attack(crystal, mc.player.isSneaking()));
ceved = true;
} else if (ceved) {
BlockUtils.place(top.up(), InvUtils.findInHotbar(Items.OBSIDIAN), rotate.get(), 50, true);
ceved = false;
}
}
}
}
if (antiTNTAura.get()) {
if (mc.world.getBlockState(top).getBlock().equals(Blocks.TNT)) {
if (rotate.get())
Rotations.rotate(Rotations.getYaw(top), Rotations.getPitch(top), () -> mine(top));
else
mine(top);
tntAured = true;
} else if (tntAured) {
if (placeObsidian.get())
BlockUtils.place(top, InvUtils.findInHotbar(Items.OBSIDIAN), rotate.get(), 50, true);
tntAured = false;
}
}
if (antiBedAura.get()) {
if (onlyInHole.get() && !PlayerUtils.isInHole2(true))
return;
BlockPos head = mc.player.getBlockPos().up();
if (mc.world.getBlockState(head).getBlock() instanceof BedBlock && !breaking) {
Rotations.rotate(Rotations.getYaw(head), Rotations.getPitch(head), 50, () -> sendMinePackets(head));
breaking = true;
} else if (breaking) {
Rotations.rotate(Rotations.getYaw(head), Rotations.getPitch(head), 50, () -> sendStopPackets(head));
breaking = false;
}
if (smart.get()) {
if (mc.world.getBlockState(head).getBlock() instanceof BedBlock)
bedAured = true;
else if (bedAured) {
if (placeStringTop.get())
place(mc.player.getBlockPos().up(2));
if (placeStringMiddle.get())
place(mc.player.getBlockPos().up(1));
if (placeStringBottom.get())
place(mc.player.getBlockPos());
tntAured = false;
}
} else if (!smart.get()) {
if (placeStringTop.get())
place(mc.player.getBlockPos().up(2));
if (placeStringMiddle.get())
place(mc.player.getBlockPos().up(1));
if (placeStringBottom.get())
place(mc.player.getBlockPos());
}
}
}
use of mathax.client.eventbus.EventHandler in project Client by MatHax.
the class ClickTP method onTick.
@EventHandler
private void onTick(TickEvent.Post event) {
if (mc.player.isUsingItem())
return;
if (mc.options.useKey.isPressed()) {
HitResult hitResult = mc.player.raycast(maxDistance.get(), 1f / 20f, false);
if (hitResult.getType() == HitResult.Type.ENTITY && mc.player.interact(((EntityHitResult) hitResult).getEntity(), Hand.MAIN_HAND) != ActionResult.PASS)
return;
if (hitResult.getType() == HitResult.Type.BLOCK) {
BlockPos pos = ((BlockHitResult) hitResult).getBlockPos();
Direction side = ((BlockHitResult) hitResult).getSide();
if (mc.world.getBlockState(pos).onUse(mc.world, mc.player, Hand.MAIN_HAND, (BlockHitResult) hitResult) != ActionResult.PASS)
return;
BlockState state = mc.world.getBlockState(pos);
VoxelShape shape = state.getCollisionShape(mc.world, pos);
if (shape.isEmpty())
shape = state.getOutlineShape(mc.world, pos);
double height = shape.isEmpty() ? 1 : shape.getMax(Direction.Axis.Y);
mc.player.setPosition(pos.getX() + 0.5 + side.getOffsetX(), pos.getY() + height, pos.getZ() + 0.5 + side.getOffsetZ());
}
}
}
Aggregations