CottonMC / ClientCommands

A Minecraft mod that adds support for client-side commands.
MIT License
21 stars 7 forks source link

Crash with MC 1.16 as some methods aren't existing anymore #11

Closed gbl closed 4 years ago

gbl commented 4 years ago

Describe the bug A clear and concise description of what the bug is.

In 1.16, Version 1.0.0+1.15.2 (I know it's intended to be 1.15 but there's no newer one), if you use a invalid/unsupported syntax in your /command, CCC crashes with a stack trace:

java.lang.NoSuchMethodError: net.minecraft.class_2585.method_10854(Lnet/minecraft/class_124;)Lnet/minecraft/class_2561;
    at net.minecraft.class_746.handler$zfp000$onChatMessage(class_746.java:1269)
    at net.minecraft.class_746.method_3142(class_746.java)
    at net.minecraft.class_437.method_25425(class_437.java:309)

method_10854 is Text.formatted in 1.15.2 and doesn't exist in this way any more in 1.16.

To Reproduce

After registering commands like this:

    public void registerCommands(CommandDispatcher<CottonClientCommandSource> cd) {

        cd.register(
            literal("rblock")
                .then(
                    literal("off").executes(c->{
                        instance.setInactive();
                        return 1;
                    })
                )
                .then(
                    argument("b1", integer(1, 9)).then (
                        argument("b2", integer(1, 9)).executes(c->{
                            instance.setActive(getInteger(c, "b1"), getInteger(c, "b2"));
                            return 1;
                        })
                        .executes(c->{
                            return badCommandLine();
                        })
                    )
                )
                .executes(c->{
                    return badCommandLine();
                })
        );
    }

typing "/rblock blabla" results in above crash.

Expected behavior Optional An error message that tells the user the command syntax was invalid instead of crashing.

Version of the (please complete the following information):

Additional context Optional

If I don't get a response "we are working on porting to 1.16" I'll fix it myself and send a pull request.