This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
RelicCraft/src/main/java/com/thebrokenrail/reliccraft/mixin/MixinLocateCommand.java

28 lines
1.2 KiB
Java
Raw Normal View History

2020-04-04 02:32:34 +00:00
package com.thebrokenrail.reliccraft.mixin;
import com.mojang.brigadier.CommandDispatcher;
import com.thebrokenrail.reliccraft.RelicCraft;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.LocateCommand;
import net.minecraft.server.command.ServerCommandSource;
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;
@SuppressWarnings("unused")
@Mixin(LocateCommand.class)
public abstract class MixinLocateCommand {
@Shadow
private static int execute(ServerCommandSource source, String structure) {
throw new UnsupportedOperationException();
}
@Inject(method = "register", at = @At(value = "RETURN"))
private static void onRegister(CommandDispatcher<ServerCommandSource> dispatcher, CallbackInfo info) {
dispatcher.register(CommandManager.literal("locate").requires(source -> source.hasPermissionLevel(2))
.then(CommandManager.literal("RelicCraft_Time_Temple").executes(ctx -> execute(ctx.getSource(), RelicCraft.TIME_TEMPLE_ID))));
}
}