fixes for 22w11a
This commit is contained in:
1 parent
3e419d1557
commit
302a7b4817
39 files changed
+410
-305
No files matched your search
@@ -5,6 +5,7 @@ import carpet.helpers.HopperCounter;
|
||||
import carpet.utils.Messenger;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.CommandRuntimeException;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
@@ -20,7 +21,7 @@ public class CounterCommand
|
||||
/**
|
||||
* The method used to register the command and make it available for the players to use.
|
||||
*/
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext commandBuildContext)
|
||||
{
|
||||
LiteralArgumentBuilder<CommandSourceStack> literalargumentbuilder = Commands.literal("counter").executes((context)
|
||||
-> listAllCounters(context.getSource(), false)).requires((player) ->
|
||||
|
||||
@@ -5,6 +5,7 @@ import carpet.settings.SettingsManager;
|
||||
import carpet.utils.DistanceCalculator;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.arguments.coordinates.Vec3Argument;
|
||||
|
||||
@@ -13,7 +14,7 @@ import static net.minecraft.commands.Commands.literal;
|
||||
|
||||
public class DistanceCommand
|
||||
{
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext commandBuildContext)
|
||||
{
|
||||
LiteralArgumentBuilder<CommandSourceStack> command = literal("distance").
|
||||
requires((player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandDistance)).
|
||||
|
||||
@@ -15,6 +15,8 @@ import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.arguments.blocks.BlockInput;
|
||||
import net.minecraft.commands.arguments.blocks.BlockPredicateArgument;
|
||||
@@ -35,48 +37,48 @@ import static net.minecraft.commands.SharedSuggestionProvider.suggest;
|
||||
|
||||
public class DrawCommand
|
||||
{
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, final CommandBuildContext context)
|
||||
{
|
||||
LiteralArgumentBuilder<CommandSourceStack> command = literal("draw").
|
||||
requires((player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandDraw)).
|
||||
then(literal("sphere").
|
||||
then(argument("center", BlockPosArgument.blockPos()).
|
||||
then(argument("radius", IntegerArgumentType.integer(1)).
|
||||
then(drawShape(c -> DrawCommand.drawSphere(c, false)))))).
|
||||
then(drawShape(c -> DrawCommand.drawSphere(c, false), context))))).
|
||||
then(literal("ball").
|
||||
then(argument("center", BlockPosArgument.blockPos()).
|
||||
then(argument("radius", IntegerArgumentType.integer(1)).
|
||||
then(drawShape(c -> DrawCommand.drawSphere(c, true)))))).
|
||||
then(drawShape(c -> DrawCommand.drawSphere(c, true), context))))).
|
||||
then(literal("diamond").
|
||||
then(argument("center", BlockPosArgument.blockPos()).
|
||||
then(argument("radius", IntegerArgumentType.integer(1)).
|
||||
then(drawShape(c -> DrawCommand.drawDiamond(c, true)))))).
|
||||
then(drawShape(c -> DrawCommand.drawDiamond(c, true), context))))).
|
||||
then(literal("pyramid").
|
||||
then(argument("center", BlockPosArgument.blockPos()).
|
||||
then(argument("radius", IntegerArgumentType.integer(1)).
|
||||
then(argument("height",IntegerArgumentType.integer(1)).
|
||||
then(argument("pointing",StringArgumentType.word()).suggests( (c, b) -> suggest(new String[]{"up","down"},b)).
|
||||
then(argument("orientation",StringArgumentType.word()).suggests( (c, b) -> suggest(new String[]{"y","x","z"},b)).
|
||||
then(drawShape(c -> DrawCommand.drawPyramid(c, "square", true))))))))).
|
||||
then(drawShape(c -> DrawCommand.drawPyramid(c, "square", true), context)))))))).
|
||||
then(literal("cone").
|
||||
then(argument("center", BlockPosArgument.blockPos()).
|
||||
then(argument("radius", IntegerArgumentType.integer(1)).
|
||||
then(argument("height",IntegerArgumentType.integer(1)).
|
||||
then(argument("pointing",StringArgumentType.word()).suggests( (c, b) -> suggest(new String[]{"up","down"},b)).
|
||||
then(argument("orientation",StringArgumentType.word()).suggests( (c, b) -> suggest(new String[]{"y","x","z"},b))
|
||||
.then(drawShape(c -> DrawCommand.drawPyramid(c, "circle", true))))))))).
|
||||
.then(drawShape(c -> DrawCommand.drawPyramid(c, "circle", true), context)))))))).
|
||||
then(literal("cylinder").
|
||||
then(argument("center", BlockPosArgument.blockPos()).
|
||||
then(argument("radius", IntegerArgumentType.integer(1)).
|
||||
then(argument("height",IntegerArgumentType.integer(1)).
|
||||
then(argument("orientation",StringArgumentType.word()).suggests( (c, b) -> suggest(new String[]{"y","x","z"},b))
|
||||
.then(drawShape(c -> DrawCommand.drawPrism(c, "circle")))))))).
|
||||
.then(drawShape(c -> DrawCommand.drawPrism(c, "circle"), context))))))).
|
||||
then(literal("cuboid").
|
||||
then(argument("center", BlockPosArgument.blockPos()).
|
||||
then(argument("radius", IntegerArgumentType.integer(1)).
|
||||
then(argument("height",IntegerArgumentType.integer(1)).
|
||||
then(argument("orientation",StringArgumentType.word()).suggests( (c, b) -> suggest(new String[]{"y","x","z"},b))
|
||||
.then(drawShape(c -> DrawCommand.drawPrism(c, "square"))))))));
|
||||
.then(drawShape(c -> DrawCommand.drawPrism(c, "square"), context)))))));
|
||||
dispatcher.register(command);
|
||||
}
|
||||
|
||||
@@ -87,12 +89,12 @@ public class DrawCommand
|
||||
}
|
||||
|
||||
private static RequiredArgumentBuilder<CommandSourceStack, BlockInput>
|
||||
drawShape(Command<CommandSourceStack> drawer)
|
||||
drawShape(Command<CommandSourceStack> drawer, CommandBuildContext commandBuildContext)
|
||||
{
|
||||
return argument("block", BlockStateArgument.block()).
|
||||
return argument("block", BlockStateArgument.block(commandBuildContext)).
|
||||
executes(drawer)
|
||||
.then(literal("replace")
|
||||
.then(argument("filter", BlockPredicateArgument.blockPredicate())
|
||||
.then(argument("filter", BlockPredicateArgument.blockPredicate(commandBuildContext))
|
||||
.executes(drawer)));
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.arguments.coordinates.BlockPosArgument;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -21,7 +23,7 @@ import static net.minecraft.commands.Commands.literal;
|
||||
|
||||
public class InfoCommand
|
||||
{
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext commandBuildContext)
|
||||
{
|
||||
LiteralArgumentBuilder<CommandSourceStack> command = literal("info").
|
||||
requires((player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandInfo)).
|
||||
|
||||
@@ -14,6 +14,8 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
@@ -24,7 +26,7 @@ import static net.minecraft.commands.SharedSuggestionProvider.suggest;
|
||||
|
||||
public class LogCommand
|
||||
{
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext commandBuildContext)
|
||||
{
|
||||
LiteralArgumentBuilder<CommandSourceStack> literalargumentbuilder = Commands.literal("log").
|
||||
requires((player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandLog)).
|
||||
|
||||
@@ -6,6 +6,7 @@ import carpet.utils.MobAI;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.arguments.EntitySummonArgument;
|
||||
import net.minecraft.core.Registry;
|
||||
@@ -16,7 +17,7 @@ import static net.minecraft.commands.SharedSuggestionProvider.suggest;
|
||||
|
||||
public class MobAICommand
|
||||
{
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, final CommandBuildContext commandBuildContext)
|
||||
{
|
||||
LiteralArgumentBuilder<CommandSourceStack> command = literal("track").
|
||||
requires((player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandTrackAI)).
|
||||
|
||||
@@ -6,6 +6,7 @@ import carpet.utils.Messenger;
|
||||
import carpet.utils.PerimeterDiagnostics;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.arguments.EntitySummonArgument;
|
||||
import net.minecraft.commands.arguments.coordinates.BlockPosArgument;
|
||||
@@ -21,7 +22,7 @@ import static net.minecraft.commands.Commands.literal;
|
||||
|
||||
public class PerimeterInfoCommand
|
||||
{
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext commandBuildContext)
|
||||
{
|
||||
LiteralArgumentBuilder<CommandSourceStack> command = literal("perimeterinfo").
|
||||
requires((player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandPerimeterInfo)).
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.arguments.DimensionArgument;
|
||||
import net.minecraft.commands.arguments.coordinates.RotationArgument;
|
||||
@@ -44,7 +45,7 @@ public class PlayerCommand
|
||||
{
|
||||
|
||||
// TODO: allow any order like execute
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext commandBuildContext)
|
||||
{
|
||||
final String[] gamemodeStrings = Arrays.stream(GameType.values())
|
||||
.map(GameType::getName)
|
||||
|
||||
@@ -4,6 +4,7 @@ import carpet.CarpetSettings;
|
||||
import carpet.settings.SettingsManager;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
|
||||
import static carpet.commands.TickCommand.healthEntities;
|
||||
@@ -15,7 +16,7 @@ import static net.minecraft.commands.Commands.literal;
|
||||
|
||||
public class ProfileCommand
|
||||
{
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext commandBuildContext)
|
||||
{
|
||||
LiteralArgumentBuilder<CommandSourceStack> literalargumentbuilder = literal("profile").
|
||||
requires((player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandProfile)).
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -129,7 +130,7 @@ public class ScriptCommand
|
||||
});
|
||||
}
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, final CommandBuildContext commandBuildContext)
|
||||
{
|
||||
LiteralArgumentBuilder<CommandSourceStack> b = literal("globals").
|
||||
executes(context -> listGlobals(context, false)).
|
||||
@@ -216,7 +217,7 @@ public class ScriptCommand
|
||||
then(argument("from", BlockPosArgument.blockPos()).
|
||||
then(argument("to", BlockPosArgument.blockPos()).
|
||||
then(argument("expr", StringArgumentType.string()).
|
||||
then(argument("block", BlockStateArgument.block()).
|
||||
then(argument("block", BlockStateArgument.block(commandBuildContext)).
|
||||
executes((cc) -> scriptFill(
|
||||
cc,
|
||||
BlockPosArgument.getSpawnablePos(cc, "origin"),
|
||||
@@ -227,7 +228,7 @@ public class ScriptCommand
|
||||
null, "solid"
|
||||
)).
|
||||
then(literal("replace").
|
||||
then(argument("filter", BlockPredicateArgument.blockPredicate())
|
||||
then(argument("filter", BlockPredicateArgument.blockPredicate(commandBuildContext))
|
||||
.executes((cc) -> scriptFill(
|
||||
cc,
|
||||
BlockPosArgument.getSpawnablePos(cc, "origin"),
|
||||
@@ -243,7 +244,7 @@ public class ScriptCommand
|
||||
then(argument("from", BlockPosArgument.blockPos()).
|
||||
then(argument("to", BlockPosArgument.blockPos()).
|
||||
then(argument("expr", StringArgumentType.string()).
|
||||
then(argument("block", BlockStateArgument.block()).
|
||||
then(argument("block", BlockStateArgument.block(commandBuildContext)).
|
||||
executes((cc) -> scriptFill(
|
||||
cc,
|
||||
BlockPosArgument.getSpawnablePos(cc, "origin"),
|
||||
@@ -254,7 +255,7 @@ public class ScriptCommand
|
||||
null, "outline"
|
||||
)).
|
||||
then(literal("replace").
|
||||
then(argument("filter", BlockPredicateArgument.blockPredicate())
|
||||
then(argument("filter", BlockPredicateArgument.blockPredicate(commandBuildContext))
|
||||
.executes((cc) -> scriptFill(
|
||||
cc,
|
||||
BlockPosArgument.getSpawnablePos(cc, "origin"),
|
||||
|
||||
@@ -15,6 +15,8 @@ import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.arguments.DimensionArgument;
|
||||
import net.minecraft.commands.arguments.coordinates.BlockPosArgument;
|
||||
@@ -36,7 +38,7 @@ import static net.minecraft.commands.SharedSuggestionProvider.suggest;
|
||||
|
||||
public class SpawnCommand
|
||||
{
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext commandBuildContext)
|
||||
{
|
||||
LiteralArgumentBuilder<CommandSourceStack> literalargumentbuilder = literal("spawn").
|
||||
requires((player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandSpawn));
|
||||
|
||||
@@ -9,6 +9,7 @@ import carpet.utils.Messenger;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -25,7 +26,7 @@ import static net.minecraft.commands.SharedSuggestionProvider.suggest;
|
||||
|
||||
public class TickCommand
|
||||
{
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext commandBuildContext)
|
||||
{
|
||||
LiteralArgumentBuilder<CommandSourceStack> literalargumentbuilder = literal("tick").
|
||||
requires((player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandTick)).
|
||||
|
||||
Reference in new issue
Block a user