Skip to content

Commit d787830

Browse files
Fix meteor crash
1 parent 21167d8 commit d787830

13 files changed

+95
-51
lines changed

src/main/java/com/nxyi/addon/Addon.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package com.nxyi.addon;
22

3-
import com.nxyi.addon.commands.*;
4-
import com.nxyi.addon.hud.HudExample;
5-
import com.nxyi.addon.modules.*;
63
import com.mojang.logging.LogUtils;
74
import com.nxyi.addon.commands.*;
5+
import com.nxyi.addon.hud.HudExample;
86
import com.nxyi.addon.modules.*;
97
import meteordevelopment.meteorclient.addons.MeteorAddon;
10-
import meteordevelopment.meteorclient.systems.commands.Commands;
8+
import meteordevelopment.meteorclient.commands.Commands;
119
import meteordevelopment.meteorclient.systems.hud.Hud;
1210
import meteordevelopment.meteorclient.systems.hud.HudGroup;
1311
import meteordevelopment.meteorclient.systems.modules.Category;
@@ -61,18 +59,18 @@ public void onInitialize() {
6159

6260

6361
// Commands
64-
Commands.get().add(new CheckCMD());
65-
Commands.get().add(new ClearInventoryCommand());
66-
Commands.get().add(new CrashItemCommand());
67-
Commands.get().add(new CreativeBanCommand());
68-
Commands.get().add(new CreativeKickAllCommand());
69-
Commands.get().add(new DesyncCommand());
70-
Commands.get().add(new DisableVehicleGrav());
71-
Commands.get().add(new HologramCommand());
72-
Commands.get().add(new ImageBookCommand());
73-
Commands.get().add(new ImageLoreCommand());
74-
Commands.get().add(new TrashCommand());
75-
Commands.get().add(new ReloadCapes());
62+
Commands.add(new CheckCMD());
63+
Commands.add(new ClearInventoryCommand());
64+
Commands.add(new CrashItemCommand());
65+
Commands.add(new CreativeBanCommand());
66+
Commands.add(new CreativeKickAllCommand());
67+
Commands.add(new DesyncCommand());
68+
Commands.add(new DisableVehicleGrav());
69+
Commands.add(new HologramCommand());
70+
Commands.add(new ImageBookCommand());
71+
Commands.add(new ImageLoreCommand());
72+
Commands.add(new TrashCommand());
73+
Commands.add(new ReloadCapes());
7674

7775
// HUD
7876
Hud.get().register(HudExample.INFO);

src/main/java/com/nxyi/addon/commands/CheckCMD.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,43 @@
55

66
package com.nxyi.addon.commands;
77

8-
import com.mojang.brigadier.Message;
98
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
10-
import com.mojang.brigadier.context.CommandContext;
11-
import com.mojang.brigadier.exceptions.CommandSyntaxException;
129
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
1310
import meteordevelopment.meteorclient.MeteorClient;
11+
import meteordevelopment.meteorclient.commands.Command;
1412
import meteordevelopment.meteorclient.events.packets.PacketEvent;
1513
import meteordevelopment.meteorclient.events.world.TickEvent;
16-
import meteordevelopment.meteorclient.systems.commands.Command;
1714
import meteordevelopment.meteorclient.utils.player.ChatUtils;
1815
import meteordevelopment.orbit.EventHandler;
1916
import net.minecraft.block.entity.CommandBlockBlockEntity;
17+
import net.minecraft.client.MinecraftClient;
2018
import net.minecraft.command.CommandSource;
21-
import net.minecraft.network.packet.Packet;
2219
import net.minecraft.network.packet.c2s.play.UpdateCommandBlockC2SPacket;
2320
import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket;
2421
import net.minecraft.text.Text;
2522
import net.minecraft.text.TranslatableTextContent;
2623

2724
public class CheckCMD extends Command {
28-
private static final SimpleCommandExceptionType ALWAYS_CHECKING = new SimpleCommandExceptionType((Message) Text.of("Already executing Command Check!"));
25+
// crappy hack to make it compile
26+
private final MinecraftClient mc = MinecraftClient.getInstance();
27+
28+
private static final SimpleCommandExceptionType ALWAYS_CHECKING = new SimpleCommandExceptionType(Text.of("Already executing Command Check!"));
2929

3030
private int checking = 0;
3131

3232
public CheckCMD() {
33-
super("checkcmd", "Checks if commandblocks are active.", new String[0]);
33+
super("checkcmd", "Checks if commandblocks are active.");
3434
}
3535

3636
public void build(LiteralArgumentBuilder<CommandSource> builder) {
3737
builder.executes(context -> {
38+
assert mc.player != null; // impossible, but still
3839
if (this.checking > 0)
3940
throw ALWAYS_CHECKING.create();
4041
this.checking = 200;
4142
MeteorClient.EVENT_BUS.subscribe(this);
42-
mc.player.networkHandler.sendPacket((Packet<?>) new UpdateCommandBlockC2SPacket(mc.player.getBlockPos(), "", CommandBlockBlockEntity.Type.AUTO, false, false, false));
43-
ChatUtils.info("Checking..", new Object[0]);
43+
mc.player.networkHandler.sendPacket(new UpdateCommandBlockC2SPacket(mc.player.getBlockPos(), "", CommandBlockBlockEntity.Type.AUTO, false, false, false));
44+
ChatUtils.info("Checking..");
4445
return 1;
4546
});
4647
}
@@ -53,11 +54,11 @@ private void onReceivePacket(PacketEvent.Receive event) {
5354
if (message.getContent() instanceof TranslatableTextContent) {
5455
String key = ((TranslatableTextContent)message.getContent()).getKey();
5556
if (key.equals("advMode.notEnabled")) {
56-
ChatUtils.info("Command blocks are deactivated", new Object[0]);
57+
ChatUtils.info("Command blocks are deactivated");
5758
event.cancel();
5859
this.checking = 0;
5960
} else if (key.equals("advMode.notAllowed") || key.equals("advMode.setCommand.success")) {
60-
ChatUtils.info("Command blocks are activated", new Object[0]);
61+
ChatUtils.info("Command blocks are activated");
6162
event.cancel();
6263
this.checking = 0;
6364
}
@@ -67,7 +68,7 @@ private void onReceivePacket(PacketEvent.Receive event) {
6768
@EventHandler
6869
private void onTick(TickEvent.Pre event) {
6970
if (this.checking == 1)
70-
ChatUtils.error("Server didnt send a response!", new Object[0]);
71+
ChatUtils.error("Server didnt send a response!");
7172
if (this.checking < 1) {
7273
this.checking = 0;
7374
MeteorClient.EVENT_BUS.unsubscribe(this);

src/main/java/com/nxyi/addon/commands/ClearInventoryCommand.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@
66
package com.nxyi.addon.commands;
77

88
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
9-
import meteordevelopment.meteorclient.systems.commands.Command;
10-
import meteordevelopment.meteorclient.systems.config.Config;
9+
import meteordevelopment.meteorclient.commands.Command;
10+
import net.minecraft.client.MinecraftClient;
1111
import net.minecraft.command.CommandSource;
1212
import net.minecraft.screen.slot.SlotActionType;
1313

1414
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
1515

1616
public class ClearInventoryCommand extends Command {
17+
// crappy hack to make it compile
18+
private final MinecraftClient mc = MinecraftClient.getInstance();
19+
1720
boolean confirm = false;
1821
public ClearInventoryCommand() {
1922
super("clear-inventory", "clear your inventory.");
@@ -22,6 +25,7 @@ public ClearInventoryCommand() {
2225
@Override
2326
public void build(LiteralArgumentBuilder<CommandSource> builder) {
2427
builder.executes(ctx -> {
28+
assert mc.interactionManager != null && mc.player != null; // impossible, but still
2529
if(!confirm) {
2630
warning("Are you sure that you want to clear your inventory? if yes, use the command again.");
2731
confirm = true;

src/main/java/com/nxyi/addon/commands/CrashItemCommand.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
package com.nxyi.addon.commands;
77

88
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
9-
import meteordevelopment.meteorclient.systems.commands.Command;
9+
import meteordevelopment.meteorclient.commands.Command;
10+
import net.minecraft.client.MinecraftClient;
1011
import net.minecraft.command.CommandSource;
1112
import net.minecraft.item.ItemStack;
1213
import net.minecraft.item.Items;
@@ -18,6 +19,9 @@
1819
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
1920

2021
public class CrashItemCommand extends Command {
22+
// crappy hack to make it compile
23+
private final MinecraftClient mc = MinecraftClient.getInstance();
24+
2125

2226
public CrashItemCommand() {
2327
super("crashitem", "Gives you crash items.");
@@ -26,6 +30,7 @@ public CrashItemCommand() {
2630
@Override
2731
public void build(LiteralArgumentBuilder<CommandSource> builder) {
2832
builder.then(literal("CrashFireball").executes(ctx -> {
33+
assert mc.player != null && mc.getNetworkHandler() != null; // impossible, but still
2934
ItemStack CrashFireball = new ItemStack(Items.CAVE_SPIDER_SPAWN_EGG);
3035
NbtCompound tag1 = new NbtCompound();
3136
NbtList power = new NbtList();
@@ -41,6 +46,7 @@ public void build(LiteralArgumentBuilder<CommandSource> builder) {
4146
}));
4247

4348
builder.then(literal("OOBEgg").executes(ctx -> {
49+
assert mc.player != null && mc.getNetworkHandler() != null; // impossible, but still
4450
ItemStack gato = new ItemStack(Items.CAT_SPAWN_EGG);
4551
NbtCompound tag2 = new NbtCompound();
4652
NbtList pos = new NbtList();

src/main/java/com/nxyi/addon/commands/CreativeBanCommand.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77

88
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
99
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
10-
import meteordevelopment.meteorclient.systems.commands.Command;
11-
import meteordevelopment.meteorclient.systems.commands.arguments.PlayerListEntryArgumentType;
10+
import meteordevelopment.meteorclient.commands.Command;
11+
import meteordevelopment.meteorclient.commands.arguments.PlayerListEntryArgumentType;
12+
import net.minecraft.client.MinecraftClient;
1213
import net.minecraft.client.network.PlayerListEntry;
1314
import net.minecraft.command.CommandSource;
1415
import net.minecraft.item.ItemStack;
@@ -21,6 +22,9 @@
2122
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
2223

2324
public class CreativeBanCommand extends Command {
25+
// crappy hack to make it compile
26+
private final MinecraftClient mc = MinecraftClient.getInstance();
27+
2428
private static final SimpleCommandExceptionType NOT_IN_CREATIVE = new SimpleCommandExceptionType(Text.literal("You must be in creative mode to use this."));
2529

2630
public CreativeBanCommand() {
@@ -30,6 +34,7 @@ public CreativeBanCommand() {
3034
@Override
3135
public void build(LiteralArgumentBuilder<CommandSource> builder) {
3236
builder.then(argument("player", PlayerListEntryArgumentType.create()).executes(ctx -> {
37+
assert mc.player != null && mc.interactionManager != null; // impossible, but still
3338
ItemStack stack = new ItemStack(Items.ARMOR_STAND);
3439
PlayerListEntry player = PlayerListEntryArgumentType.get(ctx);
3540
int[] uuid = decodeUUID(player.getProfile().getId());

src/main/java/com/nxyi/addon/commands/CreativeKickAllCommand.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
import com.nxyi.addon.Utils.JinxUtils;
99
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
1010
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
11-
import meteordevelopment.meteorclient.systems.commands.Command;
11+
import meteordevelopment.meteorclient.commands.Command;
12+
import net.minecraft.client.MinecraftClient;
1213
import net.minecraft.command.CommandSource;
1314
import net.minecraft.item.ItemStack;
1415
import net.minecraft.item.Items;
@@ -19,6 +20,9 @@
1920
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
2021

2122
public class CreativeKickAllCommand extends Command {
23+
// crappy hack to make it compile
24+
private final MinecraftClient mc = MinecraftClient.getInstance();
25+
2226
private static final SimpleCommandExceptionType NOT_IN_CREATIVE = new SimpleCommandExceptionType(Text.literal("You must be in creative mode to use this."));
2327

2428
public CreativeKickAllCommand() {
@@ -28,6 +32,7 @@ public CreativeKickAllCommand() {
2832
@Override
2933
public void build(LiteralArgumentBuilder<CommandSource> builder) {
3034
builder.executes(ctx -> {
35+
assert mc.player != null && mc.interactionManager != null; // impossible, but still
3136
ItemStack stack = JinxUtils.generateItemWithNbt("{title:\"bomb\",author:\"shadowe\",pages:['[{\"selector\":\"@e\",\"separator\":\"￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿\"},{\"selector\":\"@e\",\"separator\":\"￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿\"},{\"selector\":\"@e\",\"separator\":\"￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿\"},{\"selector\":\"@e\",\"separator\":\"￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿\"},{\"selector\":\"@e\",\"separator\":\"￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿\"},{\"selector\":\"@e\",\"separator\":\"￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿\"},{\"selector\":\"@e\",\"separator\":\"￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿\"},{\"selector\":\"@e\",\"separator\":\"￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿\"},{\"selector\":\"@e\",\"separator\":\"￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿\"},{\"selector\":\"@e\",\"separator\":\"￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿\"},{\"selector\":\"@e\",\"separator\":\"￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿\"}]']}", Items.WRITTEN_BOOK);
3237
if (!mc.player.getAbilities().creativeMode) throw NOT_IN_CREATIVE.create();
3338
mc.interactionManager.clickCreativeStack(stack, 36 + mc.player.getInventory().selectedSlot);

src/main/java/com/nxyi/addon/commands/DesyncCommand.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@
66
package com.nxyi.addon.commands;
77

88
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
9-
import meteordevelopment.meteorclient.systems.commands.Command;
9+
import meteordevelopment.meteorclient.commands.Command;
10+
import net.minecraft.client.MinecraftClient;
1011
import net.minecraft.command.CommandSource;
1112
import net.minecraft.entity.Entity;
1213

1314
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
1415

1516
public class DesyncCommand extends Command {
17+
// crappy hack to make it compile
18+
private final MinecraftClient mc = MinecraftClient.getInstance();
19+
1620
private Entity entity = null;
1721

1822
public DesyncCommand() {
@@ -22,6 +26,7 @@ public DesyncCommand() {
2226
@Override
2327
public void build(LiteralArgumentBuilder<CommandSource> builder) {
2428
builder.executes(context -> {
29+
assert mc.player != null && mc.world != null; // impossible, but still
2530
if (this.entity == null) {
2631
if (mc.player.hasVehicle()) {
2732
this.entity = mc.player.getVehicle();

src/main/java/com/nxyi/addon/commands/DisableVehicleGrav.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,28 @@
66
package com.nxyi.addon.commands;
77

88
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
9-
import meteordevelopment.meteorclient.systems.commands.Command;
9+
import meteordevelopment.meteorclient.commands.Command;
10+
import net.minecraft.client.MinecraftClient;
1011
import net.minecraft.command.CommandSource;
11-
import net.minecraft.network.packet.s2c.play.DisconnectS2CPacket;
12-
import net.minecraft.text.Text;
12+
13+
import java.util.Objects;
1314

1415
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
1516

1617
public class DisableVehicleGrav extends Command {
18+
// crappy hack to make it compile
19+
private final MinecraftClient mc = MinecraftClient.getInstance();
20+
1721
public DisableVehicleGrav() {
1822
super("antigrav", "Disables Vehicle Gravity");
1923
}
2024

2125
@Override
2226
public void build(LiteralArgumentBuilder<CommandSource> builder) {
2327
builder.executes(context -> {
28+
assert mc.player != null; // impossible, but still
2429
if (mc.player.hasVehicle()){
25-
mc.player.getVehicle().setNoGravity(true);
30+
Objects.requireNonNull(mc.player.getVehicle()).setNoGravity(true);
2631
} else info("You need to have a vehicle");
2732
return SINGLE_SUCCESS;
2833
});

src/main/java/com/nxyi/addon/commands/HologramCommand.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,22 @@
88
import com.mojang.brigadier.arguments.StringArgumentType;
99
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
1010
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
11-
import meteordevelopment.meteorclient.systems.commands.Command;
11+
import meteordevelopment.meteorclient.commands.Command;
12+
import net.minecraft.client.MinecraftClient;
1213
import net.minecraft.command.CommandSource;
1314
import net.minecraft.item.ItemStack;
1415
import net.minecraft.item.Items;
1516
import net.minecraft.nbt.NbtCompound;
1617
import net.minecraft.nbt.NbtDouble;
1718
import net.minecraft.nbt.NbtList;
1819
import net.minecraft.text.Text;
19-
import net.minecraft.util.math.Vec3d;
2020

2121
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
2222

2323
public class HologramCommand extends Command {
24+
// crappy hack to make it compile
25+
private final MinecraftClient mc = MinecraftClient.getInstance();
26+
2427
private static final SimpleCommandExceptionType NOT_IN_CREATIVE = new SimpleCommandExceptionType(Text.literal("You must be in creative mode to use this."));
2528

2629
public HologramCommand() {
@@ -30,6 +33,7 @@ public HologramCommand() {
3033
@Override
3134
public void build(LiteralArgumentBuilder<CommandSource> builder) {
3235
builder.then(argument("message", StringArgumentType.greedyString()).executes(ctx -> {
36+
assert mc.player != null && mc.interactionManager != null; // impossible, but still
3337
String message = ctx.getArgument("message", String.class).replace("&", "\247");
3438
ItemStack stack = new ItemStack(Items.ARMOR_STAND);
3539
NbtCompound tag = new NbtCompound();
@@ -45,6 +49,7 @@ public void build(LiteralArgumentBuilder<CommandSource> builder) {
4549
return SINGLE_SUCCESS;
4650
}));
4751
builder.then(literal("currentPos").then(argument("message", StringArgumentType.greedyString()).executes(ctx -> {
52+
assert mc.player != null && mc.interactionManager != null; // impossible, but still
4853
String message = ctx.getArgument("message", String.class).replace("&", "\247");
4954
ItemStack stack = new ItemStack(Items.ARMOR_STAND);
5055
NbtCompound tag = new NbtCompound();

src/main/java/com/nxyi/addon/commands/ImageBookCommand.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
import com.mojang.brigadier.arguments.StringArgumentType;
99
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
1010
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
11-
import meteordevelopment.meteorclient.systems.commands.Command;
11+
import meteordevelopment.meteorclient.commands.Command;
12+
import net.minecraft.client.MinecraftClient;
1213
import net.minecraft.command.CommandSource;
1314
import net.minecraft.item.ItemStack;
1415
import net.minecraft.item.Items;
@@ -25,6 +26,9 @@
2526
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
2627

2728
public class ImageBookCommand extends Command {
29+
// crappy hack to make it compile
30+
private final MinecraftClient mc = MinecraftClient.getInstance();
31+
2832
private static final SimpleCommandExceptionType NOT_IN_CREATIVE = new SimpleCommandExceptionType(Text.literal("You must be in creative mode to use this."));
2933
private final String block = "█";
3034
private BufferedImage imageToBuild;
@@ -36,6 +40,7 @@ public ImageBookCommand() {
3640
@Override
3741
public void build(LiteralArgumentBuilder<CommandSource> builder) {
3842
builder.then(argument("url", StringArgumentType.greedyString()).executes(ctx -> {
43+
assert mc.player != null && mc.interactionManager != null; // impossible, but still
3944
ItemStack stack = new ItemStack(Items.WRITTEN_BOOK);
4045
StringBuilder page = new StringBuilder();
4146
loadImage(ctx.getArgument("url", String.class));

0 commit comments

Comments
 (0)