55
66package com .nxyi .addon .commands ;
77
8- import com .mojang .brigadier .Message ;
98import com .mojang .brigadier .builder .LiteralArgumentBuilder ;
10- import com .mojang .brigadier .context .CommandContext ;
11- import com .mojang .brigadier .exceptions .CommandSyntaxException ;
129import com .mojang .brigadier .exceptions .SimpleCommandExceptionType ;
1310import meteordevelopment .meteorclient .MeteorClient ;
11+ import meteordevelopment .meteorclient .commands .Command ;
1412import meteordevelopment .meteorclient .events .packets .PacketEvent ;
1513import meteordevelopment .meteorclient .events .world .TickEvent ;
16- import meteordevelopment .meteorclient .systems .commands .Command ;
1714import meteordevelopment .meteorclient .utils .player .ChatUtils ;
1815import meteordevelopment .orbit .EventHandler ;
1916import net .minecraft .block .entity .CommandBlockBlockEntity ;
17+ import net .minecraft .client .MinecraftClient ;
2018import net .minecraft .command .CommandSource ;
21- import net .minecraft .network .packet .Packet ;
2219import net .minecraft .network .packet .c2s .play .UpdateCommandBlockC2SPacket ;
2320import net .minecraft .network .packet .s2c .play .GameMessageS2CPacket ;
2421import net .minecraft .text .Text ;
2522import net .minecraft .text .TranslatableTextContent ;
2623
2724public 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 );
0 commit comments