use of mathax.client.eventbus.EventHandler in project Client by MatHax.
the class ChatEncryption method onMessageReceive.
@EventHandler
private void onMessageReceive(ReceiveMessageEvent event) {
((ChatHudAccessor) mc.inGameHud.getChatHud()).getVisibleMessages().removeIf((message) -> message.getId() == event.id && event.id != 0);
((ChatHudAccessor) mc.inGameHud.getChatHud()).getMessages().removeIf((message) -> message.getId() == event.id && event.id != 0);
Text message = event.getMessage();
if (message.getString().endsWith(suffix.get()) && !suffix.get().isEmpty()) {
String[] msg = message.getString().split(encryptedPrefix);
try {
String chat = decrypt(msg[1], customKey.get() ? groupKey.get() : password);
BaseText prefixOpenBorder = new LiteralText("[");
prefixOpenBorder.setStyle(prefixOpenBorder.getStyle().withFormatting(Formatting.GRAY));
BaseText prefix = new LiteralText("Encrypted Chat");
prefix.setStyle(prefix.getStyle().withColor(MatHax.INSTANCE.MATHAX_COLOR.getPacked()));
BaseText prefixCloseBorder = new LiteralText("] ");
prefixCloseBorder.setStyle(prefixCloseBorder.getStyle().withFormatting(Formatting.GRAY));
BaseText chatText = new LiteralText(msg[0] + chat);
chatText.setStyle(chatText.getStyle().withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(msg[1]))));
BaseText chatMessage = new LiteralText("");
if (Modules.get().get(BetterChat.class).displayPlayerHeads())
chatMessage.append(" ");
chatMessage.append(prefixOpenBorder);
chatMessage.append(prefix);
chatMessage.append(prefixCloseBorder);
chatMessage.append(chatText);
message = chatMessage;
} catch (Exception exception) {
message = event.getMessage();
}
}
event.setMessage(message);
}
use of mathax.client.eventbus.EventHandler in project Client by MatHax.
the class ArmorNotifier method onTick.
@EventHandler
private void onTick(TickEvent.Post event) {
Iterable<ItemStack> armorPieces = mc.player.getArmorItems();
for (ItemStack armorPiece : armorPieces) {
if (ArmorUtils.checkThreshold(armorPiece, threshold.get())) {
if (ArmorUtils.isHelmet(armorPiece) && !alertedHelmet) {
warning("Your (highlight)helmet(default) has low durability!");
alertedHelmet = true;
}
if (ArmorUtils.isChestplate(armorPiece) && !alertedChestplate) {
warning("Your (highlight)chestplate(default) has low durability!");
alertedChestplate = true;
}
if (ArmorUtils.areLeggings(armorPiece) && !alertedLeggings) {
warning("Your (highlight)leggings(default) have low durability!");
alertedLeggings = true;
}
if (ArmorUtils.areBoots(armorPiece) && !alertedBoots) {
warning("Your (highlight)boots(default) have low durability!");
alertedBoots = true;
}
}
if (!ArmorUtils.checkThreshold(armorPiece, threshold.get())) {
if (ArmorUtils.isHelmet(armorPiece) && alertedHelmet)
alertedHelmet = false;
if (ArmorUtils.isChestplate(armorPiece) && alertedChestplate)
alertedChestplate = false;
if (ArmorUtils.areLeggings(armorPiece) && alertedLeggings)
alertedLeggings = false;
if (ArmorUtils.areBoots(armorPiece) && alertedBoots)
alertedBoots = false;
}
}
}
use of mathax.client.eventbus.EventHandler in project Client by MatHax.
the class AutoWither method onTick.
@EventHandler
private void onTick(TickEvent.Pre event) {
if (wither == null) {
// Delay
if (witherTicksWaited < witherDelay.get() - 1)
return;
// Clear pool and list
for (Wither wither : withers) witherPool.free(wither);
withers.clear();
// Register
BlockIterator.register(horizontalRadius.get(), verticalRadius.get(), (blockPos, blockState) -> {
Direction dir = Direction.fromRotation(Rotations.getYaw(blockPos)).getOpposite();
if (isValidSpawn(blockPos, dir))
withers.add(witherPool.get().set(blockPos, dir));
});
}
}
use of mathax.client.eventbus.EventHandler in project Client by MatHax.
the class AutoWither method onRender3D.
@EventHandler
private void onRender3D(Render3DEvent event) {
if (wither == null)
return;
// Body
event.renderer.box(wither.foot, sideColor.get(), lineColor.get(), shapeMode.get(), 0);
event.renderer.box(wither.foot.up(), sideColor.get(), lineColor.get(), shapeMode.get(), 0);
event.renderer.box(wither.foot.up().offset(wither.axis, -1), sideColor.get(), lineColor.get(), shapeMode.get(), 0);
event.renderer.box(wither.foot.up().offset(wither.axis, 1), sideColor.get(), lineColor.get(), shapeMode.get(), 0);
// Head
BlockPos midHead = wither.foot.up().up();
BlockPos leftHead = wither.foot.up().up().offset(wither.axis, -1);
BlockPos rightHead = wither.foot.up().up().offset(wither.axis, 1);
event.renderer.box((double) midHead.getX() + 0.2, (double) midHead.getX(), (double) midHead.getX() + 0.2, (double) midHead.getX() + 0.8, (double) midHead.getX() + 0.7, (double) midHead.getX() + 0.8, sideColor.get(), lineColor.get(), shapeMode.get(), 0);
event.renderer.box((double) leftHead.getX() + 0.2, (double) leftHead.getX(), (double) leftHead.getX() + 0.2, (double) leftHead.getX() + 0.8, (double) leftHead.getX() + 0.7, (double) leftHead.getX() + 0.8, sideColor.get(), lineColor.get(), shapeMode.get(), 0);
event.renderer.box((double) rightHead.getX() + 0.2, (double) rightHead.getX(), (double) rightHead.getX() + 0.2, (double) rightHead.getX() + 0.8, (double) rightHead.getX() + 0.7, (double) rightHead.getX() + 0.8, sideColor.get(), lineColor.get(), shapeMode.get(), 0);
}
use of mathax.client.eventbus.EventHandler in project Client by MatHax.
the class AutoWither method onPostTick.
@EventHandler
private void onPostTick(TickEvent.Post event) {
if (wither == null) {
// Delay
if (witherTicksWaited < witherDelay.get() - 1) {
witherTicksWaited++;
return;
}
if (withers.isEmpty())
return;
// Sorting
switch(priority.get()) {
case Closest:
withers.sort(Comparator.comparingDouble(w -> PlayerUtils.distanceTo(w.foot)));
case Furthest:
withers.sort((w1, w2) -> {
int sort = Double.compare(PlayerUtils.distanceTo(w1.foot), PlayerUtils.distanceTo(w2.foot));
if (sort == 0)
return 0;
return sort > 0 ? -1 : 1;
});
case Random:
Collections.shuffle(withers);
}
wither = withers.get(0);
}
// Soul sand/soil and skull slot
FindItemResult findSoulSand = InvUtils.findInHotbar(Items.SOUL_SAND);
if (!findSoulSand.found())
findSoulSand = InvUtils.findInHotbar(Items.SOUL_SOIL);
FindItemResult findWitherSkull = InvUtils.findInHotbar(Items.WITHER_SKELETON_SKULL);
// Check for enough resources
if (!findSoulSand.found() || !findWitherSkull.found()) {
error("Not enough resources in hotbar");
toggle();
return;
}
// Build
if (blockDelay.get() == 0) {
// All in 1 tick
// Body
BlockUtils.place(wither.foot, findSoulSand, rotate.get(), -50);
BlockUtils.place(wither.foot.up(), findSoulSand, rotate.get(), -50);
BlockUtils.place(wither.foot.up().offset(wither.axis, -1), findSoulSand, rotate.get(), -50);
BlockUtils.place(wither.foot.up().offset(wither.axis, 1), findSoulSand, rotate.get(), -50);
// Head
BlockUtils.place(wither.foot.up().up(), findWitherSkull, rotate.get(), -50);
BlockUtils.place(wither.foot.up().up().offset(wither.axis, -1), findWitherSkull, rotate.get(), -50);
BlockUtils.place(wither.foot.up().up().offset(wither.axis, 1), findWitherSkull, rotate.get(), -50);
// Auto turnoff
if (turnOff.get()) {
wither = null;
toggle();
}
} else {
// Delay
if (blockTicksWaited < blockDelay.get() - 1) {
blockTicksWaited++;
return;
}
switch(wither.stage) {
case 0:
if (BlockUtils.place(wither.foot, findSoulSand, rotate.get(), -50))
wither.stage++;
break;
case 1:
if (BlockUtils.place(wither.foot.up(), findSoulSand, rotate.get(), -50))
wither.stage++;
break;
case 2:
if (BlockUtils.place(wither.foot.up().offset(wither.axis, -1), findSoulSand, rotate.get(), -50))
wither.stage++;
break;
case 3:
if (BlockUtils.place(wither.foot.up().offset(wither.axis, 1), findSoulSand, rotate.get(), -50))
wither.stage++;
break;
case 4:
if (BlockUtils.place(wither.foot.up().up(), findWitherSkull, rotate.get(), -50))
wither.stage++;
break;
case 5:
if (BlockUtils.place(wither.foot.up().up().offset(wither.axis, -1), findWitherSkull, rotate.get(), -50))
wither.stage++;
break;
case 6:
if (BlockUtils.place(wither.foot.up().up().offset(wither.axis, 1), findWitherSkull, rotate.get(), -50))
wither.stage++;
break;
case 7:
// Auto turnoff
if (turnOff.get()) {
wither = null;
toggle();
}
break;
}
}
witherTicksWaited = 0;
}
Aggregations