diff --git a/src/main/java/widecat/meteorcrashaddon/modules/AACCrash.java b/src/main/java/widecat/meteorcrashaddon/modules/AACCrash.java index c21ae98..57ab898 100644 --- a/src/main/java/widecat/meteorcrashaddon/modules/AACCrash.java +++ b/src/main/java/widecat/meteorcrashaddon/modules/AACCrash.java @@ -43,6 +43,8 @@ public AACCrash() { @Override public void onActivate() { + if (mc.getNetworkHandler() == null || mc.player == null) return; + if (Utils.canUpdate() && !onTick.get()) { switch (crashMode.get()) { case NEW -> { @@ -63,6 +65,8 @@ public void onActivate() { @EventHandler public void onTick(TickEvent.Pre tickEvent) { + if (mc.getNetworkHandler() == null || mc.player == null) return; + if (onTick.get()) { switch (crashMode.get()) { case NEW -> { diff --git a/src/main/java/widecat/meteorcrashaddon/modules/BookCrash.java b/src/main/java/widecat/meteorcrashaddon/modules/BookCrash.java index 7320fc0..6b9d8ae 100644 --- a/src/main/java/widecat/meteorcrashaddon/modules/BookCrash.java +++ b/src/main/java/widecat/meteorcrashaddon/modules/BookCrash.java @@ -55,6 +55,8 @@ private void onTick(TickEvent.Pre event) { } private void sendBadBook() { + if (mc.getNetworkHandler() == null || mc.player == null) return; + String title = "/stop" + Math.random() * 400; String mm255 = RandomStringUtils.randomAlphanumeric(255); diff --git a/src/main/java/widecat/meteorcrashaddon/modules/ContainerCrash.java b/src/main/java/widecat/meteorcrashaddon/modules/ContainerCrash.java index 3a9a6dc..939b724 100644 --- a/src/main/java/widecat/meteorcrashaddon/modules/ContainerCrash.java +++ b/src/main/java/widecat/meteorcrashaddon/modules/ContainerCrash.java @@ -48,6 +48,8 @@ public ContainerCrash() { @EventHandler private void onTick(TickEvent.Pre event) { + if (mc.getNetworkHandler() == null || mc.player == null) return; + if (GLFW.glfwGetKey(mc.getWindow().getHandle(), GLFW.GLFW_KEY_ESCAPE) == GLFW.GLFW_PRESS) { toggle(); mc.player.closeHandledScreen(); diff --git a/src/main/java/widecat/meteorcrashaddon/modules/CraftingCrash.java b/src/main/java/widecat/meteorcrashaddon/modules/CraftingCrash.java index d428440..319dffa 100644 --- a/src/main/java/widecat/meteorcrashaddon/modules/CraftingCrash.java +++ b/src/main/java/widecat/meteorcrashaddon/modules/CraftingCrash.java @@ -31,7 +31,8 @@ public CraftingCrash() { @EventHandler private void onTick(TickEvent.Post event) { - if (!(mc.player.currentScreenHandler instanceof CraftingScreenHandler) || mc.getNetworkHandler() == null) return; + if (mc.getNetworkHandler() == null || mc.player == null || !(mc.player.currentScreenHandler instanceof CraftingScreenHandler)) return; + try { List recipeResultCollectionList = mc.player.getRecipeBook().getOrderedResults(); for (RecipeResultCollection recipeResultCollection : recipeResultCollectionList) { diff --git a/src/main/java/widecat/meteorcrashaddon/modules/CreativeCrash.java b/src/main/java/widecat/meteorcrashaddon/modules/CreativeCrash.java index 957323f..091abbb 100644 --- a/src/main/java/widecat/meteorcrashaddon/modules/CreativeCrash.java +++ b/src/main/java/widecat/meteorcrashaddon/modules/CreativeCrash.java @@ -39,6 +39,8 @@ public CreativeCrash() { @EventHandler private void onTick(TickEvent.Post event) { + if (mc.getNetworkHandler() == null || mc.player == null) return; + if (!mc.player.getAbilities().creativeMode) { error("its literally called creative crash why are you trying this in survival"); toggle(); diff --git a/src/main/java/widecat/meteorcrashaddon/modules/EntityCrash.java b/src/main/java/widecat/meteorcrashaddon/modules/EntityCrash.java index 684ad82..37190bf 100644 --- a/src/main/java/widecat/meteorcrashaddon/modules/EntityCrash.java +++ b/src/main/java/widecat/meteorcrashaddon/modules/EntityCrash.java @@ -57,6 +57,8 @@ public EntityCrash() { @EventHandler public void onTick(TickEvent.Post event) { + if (mc.getNetworkHandler() == null || mc.player == null) return; + Entity vehicle = mc.player.getVehicle(); if (vehicle == null) { error("You must be riding an entity, toggling"); diff --git a/src/main/java/widecat/meteorcrashaddon/modules/ErrorCrash.java b/src/main/java/widecat/meteorcrashaddon/modules/ErrorCrash.java index 8628044..33704f8 100644 --- a/src/main/java/widecat/meteorcrashaddon/modules/ErrorCrash.java +++ b/src/main/java/widecat/meteorcrashaddon/modules/ErrorCrash.java @@ -36,6 +36,8 @@ public ErrorCrash() { @EventHandler private void onTick(TickEvent.Post event) { + if (mc.getNetworkHandler() == null || mc.player == null) return; + Int2ObjectMap REAL = new Int2ObjectArrayMap<>(); REAL.put(0, new ItemStack(Items.RED_DYE, 1)); for (int i = 0; i < amount.get(); i++) { diff --git a/src/main/java/widecat/meteorcrashaddon/modules/InteractCrash.java b/src/main/java/widecat/meteorcrashaddon/modules/InteractCrash.java index 77b18f1..38bb6cb 100644 --- a/src/main/java/widecat/meteorcrashaddon/modules/InteractCrash.java +++ b/src/main/java/widecat/meteorcrashaddon/modules/InteractCrash.java @@ -41,11 +41,13 @@ private Vec3d pickRandomPos() { @EventHandler private void onTick(TickEvent.Post event) { + if (mc.getNetworkHandler() == null) return; + switch (mode.get()) { case NoCom -> { for (int i = 0; i < amount.get(); i++) { - Vec3d cpos = pickRandomPos(); - mc.getNetworkHandler().sendPacket(new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND, new BlockHitResult(cpos, Direction.DOWN, BlockPos.ofFloored(cpos), false), 0)); + Vec3d cpos = pickRandomPos(); + mc.getNetworkHandler().sendPacket(new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND, new BlockHitResult(cpos, Direction.DOWN, BlockPos.ofFloored(cpos), false), 0)); } } case OOB -> { diff --git a/src/main/java/widecat/meteorcrashaddon/modules/LecternCrash.java b/src/main/java/widecat/meteorcrashaddon/modules/LecternCrash.java index fedc4cd..1dcdf32 100644 --- a/src/main/java/widecat/meteorcrashaddon/modules/LecternCrash.java +++ b/src/main/java/widecat/meteorcrashaddon/modules/LecternCrash.java @@ -17,7 +17,7 @@ public LecternCrash() { @EventHandler private void onOpenScreenEvent(OpenScreenEvent event) { - if (!(event.screen instanceof LecternScreen)) return; + if (!(event.screen instanceof LecternScreen) || mc.getNetworkHandler() == null || mc.player == null) return; mc.getNetworkHandler().sendPacket(new ClickSlotC2SPacket(mc.player.currentScreenHandler.syncId, mc.player.currentScreenHandler.getRevision(), 0, 0, SlotActionType.QUICK_MOVE, mc.player.currentScreenHandler.getCursorStack().copy(), Int2ObjectMaps.emptyMap())); toggle(); } diff --git a/src/main/java/widecat/meteorcrashaddon/modules/MessageLagger.java b/src/main/java/widecat/meteorcrashaddon/modules/MessageLagger.java index 0c87877..771410d 100644 --- a/src/main/java/widecat/meteorcrashaddon/modules/MessageLagger.java +++ b/src/main/java/widecat/meteorcrashaddon/modules/MessageLagger.java @@ -101,7 +101,7 @@ private void onGameLeft(GameLeftEvent event) { private void sendLagMessage() { String message = generateLagMessage(); - ChatUtils.sendPlayerMsg(message); + ChatUtils.sendPlayerMsg(message); } private void sendLagWhisper() { @@ -109,14 +109,14 @@ private void sendLagWhisper() { PlayerEntity player = players.get(new Random().nextInt(players.size())); String message = generateLagMessage(); - ChatUtils.sendPlayerMsg("/msg " + player.getGameProfile().getName() + " " + message); + ChatUtils.sendPlayerMsg("/msg " + player.getGameProfile().getName() + " " + message); } private String generateLagMessage() { - String message = null; + StringBuilder message = new StringBuilder(); for (int i = 0; i < messageLength.get(); i++) { - message += (char) (Math.floor(Math.random() * 0x1D300) + 0x800); + message.append((char) (Math.floor(Math.random() * 0x1D300) + 0x800)); } - return message; + return message.toString(); } } diff --git a/src/main/java/widecat/meteorcrashaddon/modules/MovementCrash.java b/src/main/java/widecat/meteorcrashaddon/modules/MovementCrash.java index ec84828..87cd5ac 100644 --- a/src/main/java/widecat/meteorcrashaddon/modules/MovementCrash.java +++ b/src/main/java/widecat/meteorcrashaddon/modules/MovementCrash.java @@ -42,7 +42,8 @@ public static double rndD(double rad) { @EventHandler private void onTick(TickEvent.Post event) { - if (mc.getNetworkHandler() == null) return; + if (mc.getNetworkHandler() == null || mc.player == null) return; + try { Vec3d current_pos = mc.player.getPos(); for (int i = 0; i < packets.get(); i++) { diff --git a/src/main/java/widecat/meteorcrashaddon/modules/PacketSpammer.java b/src/main/java/widecat/meteorcrashaddon/modules/PacketSpammer.java index 4a9a5b0..4aede4b 100644 --- a/src/main/java/widecat/meteorcrashaddon/modules/PacketSpammer.java +++ b/src/main/java/widecat/meteorcrashaddon/modules/PacketSpammer.java @@ -36,6 +36,8 @@ public PacketSpammer() { @EventHandler private void onTick(TickEvent.Post event) { + if (mc.getNetworkHandler() == null) return; + for (int i = 0; i < amount.get(); i++) { mc.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(Math.random() >= 0.5)); mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND)); diff --git a/src/main/java/widecat/meteorcrashaddon/modules/SequenceCrash.java b/src/main/java/widecat/meteorcrashaddon/modules/SequenceCrash.java index 664dfcc..d2aac3d 100644 --- a/src/main/java/widecat/meteorcrashaddon/modules/SequenceCrash.java +++ b/src/main/java/widecat/meteorcrashaddon/modules/SequenceCrash.java @@ -42,6 +42,8 @@ public SequenceCrash() { @EventHandler private void onTick(TickEvent.Post event) { + if (mc.getNetworkHandler() == null || mc.player == null) return; + switch (mode.get()) { case Item -> { for (int i = 0; i < amount.get(); i++) {