Migrate the Carpet codebase to Mojang Mappings

This commit is contained in:
altrisi committed 2022-01-24 20:33:16 +01:00
1 parent a1a2488bc3
commit 06af9ce8b1
346 files changed
+8353 -8492

No files matched your search

+15 -16
View File
@@ -6,42 +6,41 @@ import carpet.utils.BlockInfo;
import carpet.utils.Messenger;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.text.BaseText;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.command.argument.BlockPosArgumentType;
import net.minecraft.util.math.BlockPos;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.arguments.coordinates.BlockPosArgument;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.BaseComponent;
import static com.mojang.brigadier.arguments.StringArgumentType.getString;
import static com.mojang.brigadier.arguments.StringArgumentType.greedyString;
import static net.minecraft.server.command.CommandManager.argument;
import static net.minecraft.server.command.CommandManager.literal;
import static net.minecraft.commands.Commands.argument;
import static net.minecraft.commands.Commands.literal;
public class InfoCommand
{
public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
{
LiteralArgumentBuilder<ServerCommandSource> command = literal("info").
LiteralArgumentBuilder<CommandSourceStack> command = literal("info").
requires((player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandInfo)).
then(literal("block").
then(argument("block position", BlockPosArgumentType.blockPos()).
then(argument("block position", BlockPosArgument.blockPos()).
executes( (c) -> infoBlock(
c.getSource(),
BlockPosArgumentType.getBlockPos(c, "block position"), null)).
BlockPosArgument.getSpawnablePos(c, "block position"), null)).
then(literal("grep").
then(argument("regexp",greedyString()).
executes( (c) -> infoBlock(
c.getSource(),
BlockPosArgumentType.getBlockPos(c, "block position"),
BlockPosArgument.getSpawnablePos(c, "block position"),
getString(c, "regexp")))))));
dispatcher.register(command);
}
public static void printBlock(List<BaseText> messages, ServerCommandSource source, String grep)
public static void printBlock(List<BaseComponent> messages, CommandSourceStack source, String grep)
{
Messenger.m(source, "");
if (grep != null)
@@ -50,7 +49,7 @@ public class InfoCommand
Messenger.m(source, messages.get(0));
for (int i = 1; i<messages.size(); i++)
{
BaseText line = messages.get(i);
BaseComponent line = messages.get(i);
Matcher m = p.matcher(line.getString());
if (m.find())
{
@@ -64,9 +63,9 @@ public class InfoCommand
}
}
private static int infoBlock(ServerCommandSource source, BlockPos pos, String grep)
private static int infoBlock(CommandSourceStack source, BlockPos pos, String grep)
{
printBlock(BlockInfo.blockInfo(pos, source.getWorld()),source, grep);
printBlock(BlockInfo.blockInfo(pos, source.getLevel()),source, grep);
return 1;
}