use of mathax.client.eventbus.EventHandler in project Client by MatHax.
the class ColorSigns method onPacketSend.
@EventHandler
private void onPacketSend(PacketEvent.Send event) {
if (event.packet instanceof GameJoinS2CPacket) {
checkWarning();
return;
}
if (!(event.packet instanceof UpdateSignC2SPacket))
return;
UpdateSignC2SPacket p = (UpdateSignC2SPacket) event.packet;
for (int l = 0; l < p.getText().length; l++) {
String newText = p.getText()[l].replaceAll("(?i)\u00a7|&([0-9A-FK-OR])", "\u00a7\u00a7$1$1");
p.getText()[l] = newText;
}
event.packet = p;
}
use of mathax.client.eventbus.EventHandler in project Client by MatHax.
the class SpawnProofer method onTickPost.
@EventHandler
private void onTickPost(TickEvent.Post event) {
if (delay.get() != 0 && ticksWaited < delay.get() - 1) {
ticksWaited++;
return;
}
if (spawns.isEmpty())
return;
FindItemResult block = InvUtils.findInHotbar(itemStack -> blocks.get().contains(Block.getBlockFromItem(itemStack.getItem())));
if (delay.get() == 0)
for (BlockPos blockPos : spawns) BlockUtils.place(blockPos, block, rotate.get(), -50, false);
else {
if (isLightSource(Block.getBlockFromItem(mc.player.getInventory().getStack(block.slot()).getItem()))) {
int lowestLightLevel = 16;
BlockPos.Mutable selectedBlockPos = spawns.get(0);
for (BlockPos blockPos : spawns) {
int lightLevel = mc.world.getLightLevel(blockPos);
if (lightLevel < lowestLightLevel) {
lowestLightLevel = lightLevel;
selectedBlockPos.set(blockPos);
}
}
BlockUtils.place(selectedBlockPos, block, rotate.get(), -50, false);
} else
BlockUtils.place(spawns.get(0), block, rotate.get(), -50, false);
}
ticksWaited = 0;
}
use of mathax.client.eventbus.EventHandler in project Client by MatHax.
the class VeinMiner method onStartBreakingBlock.
@EventHandler
private void onStartBreakingBlock(StartBreakingBlockEvent event) {
BlockState state = mc.world.getBlockState(event.blockPos);
if (state.getHardness(mc.world, event.blockPos) < 0)
return;
if (mode.get() == ListMode.Whitelist && !selectedBlocks.get().contains(state.getBlock()))
return;
if (mode.get() == ListMode.Blacklist && selectedBlocks.get().contains(state.getBlock()))
return;
foundBlockPositions.clear();
if (!isMiningBlock(event.blockPos)) {
MyBlock block = blockPool.get();
block.set(event);
blocks.add(block);
mineNearbyBlocks(block.originalBlock.asItem(), event.blockPos, event.direction, depth.get());
}
}
use of mathax.client.eventbus.EventHandler in project Client by MatHax.
the class InfinityMiner method onTick.
@EventHandler
private void onTick(TickEvent.Post event) {
if (mc.player.getInventory().getEmptySlot() == -1) {
if (walkHome.get()) {
if (isBaritoneNotWalking()) {
info("Walking home.");
baritone.getCustomGoalProcess().setGoalAndPath(new GoalBlock(homePos));
} else if (mc.player.getBlockPos().equals(homePos))
logOut();
} else if (logOut.get())
logOut();
else
toggle();
return;
}
if (!findPickaxe()) {
error("Could not find a usable mending pickaxe.");
toggle();
return;
}
if (repairing) {
if (!needsRepair()) {
warning("Finished repairing, going back to mining.");
repairing = false;
mineTargetBlocks();
return;
}
if (isBaritoneNotMining())
mineRepairBlocks();
} else {
if (needsRepair()) {
warning("Pickaxe needs repair, beginning repair process");
repairing = true;
mineRepairBlocks();
return;
}
if (isBaritoneNotMining())
mineTargetBlocks();
}
}
use of mathax.client.eventbus.EventHandler in project Client by MatHax.
the class Nuker method onTickPre.
@EventHandler
private void onTickPre(TickEvent.Pre event) {
renderBlocks.forEach(RenderBlock::tick);
// Update timer
if (timer > 0) {
timer--;
return;
}
if (mc.player.isDead())
return;
// Calculate some stuff
double pX = mc.player.getX();
double pY = mc.player.getY();
double pZ = mc.player.getZ();
double rangeSq = Math.pow(range.get(), 2);
// Find blocks to break
BlockIterator.register((int) Math.ceil(range.get()), (int) Math.ceil(range.get()), (blockPos, blockState) -> {
// Check for air, unbreakable blocks and distance
if (!BlockUtils.canBreak(blockPos, blockState) || Utils.squaredDistance(pX, pY, pZ, blockPos.getX() + 0.5, blockPos.getY() + 0.5, blockPos.getZ() + 0.5) > rangeSq)
return;
// Flatten
if (mode.get() == Mode.Flatten && blockPos.getY() < mc.player.getY())
return;
// Smash
if (mode.get() == Mode.Smash && blockState.getHardness(mc.world, blockPos) != 0)
return;
// Check for selected
if (whitelistEnabled.get() && !whitelist.get().contains(blockState.getBlock()))
return;
// Add block
blocks.add(blockPosPool.get().set(blockPos));
});
// Break block if found
BlockIterator.after(() -> {
// Sort blocks
if (sortMode.get() != SortMode.None)
blocks.sort(Comparator.comparingDouble(value -> Utils.squaredDistance(pX, pY, pZ, value.getX() + 0.5, value.getY() + 0.5, value.getZ() + 0.5) * (sortMode.get() == SortMode.Closest ? 1 : -1)));
// Check if some block was found
if (blocks.isEmpty()) {
// If no block was found for long enough then set firstBlock flag to true to not wait before breaking another again
if (noBlockTimer++ >= delay.get())
firstBlock = true;
return;
} else
noBlockTimer = 0;
// Update timer
if (!firstBlock && !lastBlockPos.equals(blocks.get(0))) {
timer = delay.get();
firstBlock = false;
lastBlockPos.set(blocks.get(0));
if (timer > 0)
return;
}
// Break
int count = 0;
for (BlockPos block : blocks) {
if (count >= maxBlocksPerTick.get())
break;
boolean canInstaMine = BlockUtils.canInstaBreak(block);
BlockUtils.breakBlock(block, swingHand.get());
renderBlocks.add(renderBlockPool.get().set(block));
lastBlockPos.set(block);
count++;
if (!canInstaMine)
break;
}
firstBlock = false;
// Clear current block positions
for (BlockPos.Mutable blockPos : blocks) blockPosPool.free(blockPos);
blocks.clear();
});
}
Aggregations