Created
November 7, 2018 20:21
-
-
Save NikkyAI/a51a1aa6c3245a445f071192245c0d7a to your computer and use it in GitHub Desktop.
how to register custom commands in fabric
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.mojang.brigadier.CommandDispatcher; | |
import net.fabricmc.konfig.TestCommand; | |
import net.minecraft.command.ServerCommandManager; | |
import net.minecraft.command.ServerCommandSource; | |
import org.spongepowered.asm.mixin.Final; | |
import org.spongepowered.asm.mixin.Mixin; | |
import org.spongepowered.asm.mixin.Shadow; | |
import org.spongepowered.asm.mixin.injection.At; | |
import org.spongepowered.asm.mixin.injection.Inject; | |
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | |
@Mixin(ServerCommandManager.class) | |
public class CommandManagerServerMixin { | |
@Shadow | |
@Final | |
public CommandDispatcher<ServerCommandSource> dispatcher; | |
@Inject(at = @At("RETURN"), method = "<init>(Z)V") | |
private void init(CallbackInfo info) { | |
TestCommand.INSTANCE.register(dispatcher); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment