Migrate the Carpet codebase to Mojang Mappings
This commit is contained in:
346 files changed
+8353
-8492
No files matched your search
@@ -37,56 +37,6 @@ import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||
import com.mojang.brigadier.tree.ArgumentCommandNode;
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
import net.minecraft.advancement.Advancement;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.argument.AngleArgumentType;
|
||||
import net.minecraft.command.argument.BlockPosArgumentType;
|
||||
import net.minecraft.command.argument.BlockPredicateArgumentType;
|
||||
import net.minecraft.command.argument.BlockStateArgument;
|
||||
import net.minecraft.command.argument.BlockStateArgumentType;
|
||||
import net.minecraft.command.argument.ColorArgumentType;
|
||||
import net.minecraft.command.argument.ColumnPosArgumentType;
|
||||
import net.minecraft.command.argument.DimensionArgumentType;
|
||||
import net.minecraft.command.argument.EntityAnchorArgumentType;
|
||||
import net.minecraft.command.argument.EntityArgumentType;
|
||||
import net.minecraft.command.argument.EntitySummonArgumentType;
|
||||
import net.minecraft.command.argument.GameProfileArgumentType;
|
||||
import net.minecraft.command.argument.IdentifierArgumentType;
|
||||
import net.minecraft.command.argument.EnchantmentArgumentType;
|
||||
import net.minecraft.command.argument.ItemSlotArgumentType;
|
||||
import net.minecraft.command.argument.ItemStackArgumentType;
|
||||
import net.minecraft.command.argument.MessageArgumentType;
|
||||
import net.minecraft.command.argument.StatusEffectArgumentType;
|
||||
import net.minecraft.command.argument.NbtCompoundArgumentType;
|
||||
import net.minecraft.command.argument.NbtPathArgumentType;
|
||||
import net.minecraft.command.argument.NbtElementArgumentType;
|
||||
import net.minecraft.command.argument.NumberRangeArgumentType;
|
||||
import net.minecraft.command.argument.ScoreboardObjectiveArgumentType;
|
||||
import net.minecraft.command.argument.ScoreboardCriterionArgumentType;
|
||||
import net.minecraft.command.argument.ParticleEffectArgumentType;
|
||||
import net.minecraft.command.argument.RotationArgumentType;
|
||||
import net.minecraft.command.argument.ScoreHolderArgumentType;
|
||||
import net.minecraft.command.argument.ScoreboardSlotArgumentType;
|
||||
import net.minecraft.command.argument.SwizzleArgumentType;
|
||||
import net.minecraft.command.argument.TeamArgumentType;
|
||||
import net.minecraft.command.argument.TimeArgumentType;
|
||||
import net.minecraft.command.argument.UuidArgumentType;
|
||||
import net.minecraft.command.argument.Vec2ArgumentType;
|
||||
import net.minecraft.command.argument.Vec3ArgumentType;
|
||||
import net.minecraft.command.suggestion.SuggestionProviders;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.predicate.NumberRange;
|
||||
import net.minecraft.scoreboard.Scoreboard;
|
||||
import net.minecraft.server.command.BossBarCommand;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -100,14 +50,60 @@ import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.critereon.MinMaxBounds;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.AngleArgument;
|
||||
import net.minecraft.commands.arguments.ColorArgument;
|
||||
import net.minecraft.commands.arguments.CompoundTagArgument;
|
||||
import net.minecraft.commands.arguments.DimensionArgument;
|
||||
import net.minecraft.commands.arguments.EntityAnchorArgument;
|
||||
import net.minecraft.commands.arguments.EntitySummonArgument;
|
||||
import net.minecraft.commands.arguments.GameProfileArgument;
|
||||
import net.minecraft.commands.arguments.ItemEnchantmentArgument;
|
||||
import net.minecraft.commands.arguments.MessageArgument;
|
||||
import net.minecraft.commands.arguments.MobEffectArgument;
|
||||
import net.minecraft.commands.arguments.NbtPathArgument;
|
||||
import net.minecraft.commands.arguments.NbtTagArgument;
|
||||
import net.minecraft.commands.arguments.ObjectiveArgument;
|
||||
import net.minecraft.commands.arguments.ObjectiveCriteriaArgument;
|
||||
import net.minecraft.commands.arguments.ParticleArgument;
|
||||
import net.minecraft.commands.arguments.RangeArgument;
|
||||
import net.minecraft.commands.arguments.ResourceLocationArgument;
|
||||
import net.minecraft.commands.arguments.ScoreHolderArgument;
|
||||
import net.minecraft.commands.arguments.ScoreboardSlotArgument;
|
||||
import net.minecraft.commands.arguments.TeamArgument;
|
||||
import net.minecraft.commands.arguments.TimeArgument;
|
||||
import net.minecraft.commands.arguments.UuidArgument;
|
||||
import net.minecraft.commands.arguments.blocks.BlockInput;
|
||||
import net.minecraft.commands.arguments.blocks.BlockPredicateArgument;
|
||||
import net.minecraft.commands.arguments.blocks.BlockStateArgument;
|
||||
import net.minecraft.commands.arguments.coordinates.ColumnPosArgument;
|
||||
import net.minecraft.commands.arguments.coordinates.RotationArgument;
|
||||
import net.minecraft.commands.arguments.coordinates.SwizzleArgument;
|
||||
import net.minecraft.commands.arguments.coordinates.Vec2Argument;
|
||||
import net.minecraft.commands.arguments.coordinates.Vec3Argument;
|
||||
import net.minecraft.commands.arguments.item.ItemArgument;
|
||||
import net.minecraft.commands.synchronization.SuggestionProviders;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.commands.BossBarCommands;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.scores.Scoreboard;
|
||||
|
||||
import static net.minecraft.server.command.CommandManager.argument;
|
||||
import static net.minecraft.commands.Commands.argument;
|
||||
|
||||
public abstract class CommandArgument
|
||||
{
|
||||
public static CommandSyntaxException error(String text)
|
||||
{
|
||||
return new SimpleCommandExceptionType(new LiteralText(text)).create();
|
||||
return new SimpleCommandExceptionType(new TextComponent(text)).create();
|
||||
}
|
||||
|
||||
private static final List<? extends CommandArgument> baseTypes = Lists.newArrayList(
|
||||
@@ -120,107 +116,107 @@ public abstract class CommandArgument
|
||||
new FloatArgument(),
|
||||
new IntArgument(),
|
||||
new WordArgument(), new GreedyStringArgument(),
|
||||
new VanillaUnconfigurableArgument( "yaw", AngleArgumentType::angle, // angle
|
||||
(c, p) -> new NumericValue(AngleArgumentType.getAngle(c, p)), true
|
||||
new VanillaUnconfigurableArgument( "yaw", AngleArgument::angle, // angle
|
||||
(c, p) -> new NumericValue(AngleArgument.getAngle(c, p)), true
|
||||
),
|
||||
new BlockPosArgument(),
|
||||
new VanillaUnconfigurableArgument( "block", BlockStateArgumentType::blockState,
|
||||
new VanillaUnconfigurableArgument( "block", BlockStateArgument::block,
|
||||
(c, p) -> {
|
||||
BlockStateArgument result = BlockStateArgumentType.getBlockState(c, p);
|
||||
return new BlockValue(result.getBlockState(), null, null, ((BlockStateArgumentInterface)result).getCMTag() );
|
||||
BlockInput result = BlockStateArgument.getBlock(c, p);
|
||||
return new BlockValue(result.getState(), null, null, ((BlockStateArgumentInterface)result).getCMTag() );
|
||||
},
|
||||
false
|
||||
),
|
||||
new VanillaUnconfigurableArgument( "blockpredicate", BlockPredicateArgumentType::blockPredicate,
|
||||
(c, p) -> ValueConversions.ofBlockPredicate(c.getSource().getServer().getTagManager(), BlockPredicateArgumentType.getBlockPredicate(c, p)), false
|
||||
new VanillaUnconfigurableArgument( "blockpredicate", BlockPredicateArgument::blockPredicate,
|
||||
(c, p) -> ValueConversions.ofBlockPredicate(c.getSource().getServer().getTags(), BlockPredicateArgument.getBlockPredicate(c, p)), false
|
||||
),
|
||||
new VanillaUnconfigurableArgument("teamcolor", ColorArgumentType::color,
|
||||
new VanillaUnconfigurableArgument("teamcolor", ColorArgument::color,
|
||||
(c, p) -> {
|
||||
Formatting format = ColorArgumentType.getColor(c, p);
|
||||
return ListValue.of(StringValue.of(format.getName()), ValueConversions.ofRGB(format.getColorValue()));
|
||||
ChatFormatting format = ColorArgument.getColor(c, p);
|
||||
return ListValue.of(StringValue.of(format.getName()), ValueConversions.ofRGB(format.getColor()));
|
||||
},
|
||||
false
|
||||
),
|
||||
new VanillaUnconfigurableArgument("columnpos", ColumnPosArgumentType::columnPos,
|
||||
(c, p) -> ValueConversions.of(ColumnPosArgumentType.getColumnPos(c, p)), false
|
||||
new VanillaUnconfigurableArgument("columnpos", ColumnPosArgument::columnPos,
|
||||
(c, p) -> ValueConversions.of(ColumnPosArgument.getColumnPos(c, p)), false
|
||||
),
|
||||
// component // raw json
|
||||
new VanillaUnconfigurableArgument("dimension", DimensionArgumentType::dimension,
|
||||
(c, p) -> ValueConversions.of(DimensionArgumentType.getDimensionArgument(c, p)), false
|
||||
new VanillaUnconfigurableArgument("dimension", DimensionArgument::dimension,
|
||||
(c, p) -> ValueConversions.of(DimensionArgument.getDimension(c, p)), false
|
||||
),
|
||||
new EntityArgument(),
|
||||
new VanillaUnconfigurableArgument("anchor", EntityAnchorArgumentType::entityAnchor,
|
||||
(c, p) -> StringValue.of(EntityAnchorArgumentType.getEntityAnchor(c, p).name()), false
|
||||
new VanillaUnconfigurableArgument("anchor", EntityAnchorArgument::anchor,
|
||||
(c, p) -> StringValue.of(EntityAnchorArgument.getAnchor(c, p).name()), false
|
||||
),
|
||||
new VanillaUnconfigurableArgument("entitytype", EntitySummonArgumentType::entitySummon,
|
||||
(c, p) -> ValueConversions.of(EntitySummonArgumentType.getEntitySummon(c, p)), SuggestionProviders.SUMMONABLE_ENTITIES
|
||||
new VanillaUnconfigurableArgument("entitytype", EntitySummonArgument::id,
|
||||
(c, p) -> ValueConversions.of(EntitySummonArgument.getSummonableEntity(c, p)), SuggestionProviders.SUMMONABLE_ENTITIES
|
||||
),
|
||||
new VanillaUnconfigurableArgument("floatrange", NumberRangeArgumentType::floatRange,
|
||||
(c, p) -> ValueConversions.of(c.getArgument(p, NumberRange.FloatRange.class)), true
|
||||
new VanillaUnconfigurableArgument("floatrange", RangeArgument::floatRange,
|
||||
(c, p) -> ValueConversions.of(c.getArgument(p, MinMaxBounds.Doubles.class)), true
|
||||
),
|
||||
// function??
|
||||
|
||||
new PlayerProfileArgument(),
|
||||
new VanillaUnconfigurableArgument("intrange", NumberRangeArgumentType::intRange,
|
||||
(c, p) -> ValueConversions.of(NumberRangeArgumentType.IntRangeArgumentType.getRangeArgument(c, p)), true
|
||||
new VanillaUnconfigurableArgument("intrange", RangeArgument::intRange,
|
||||
(c, p) -> ValueConversions.of(RangeArgument.Ints.getRange(c, p)), true
|
||||
),
|
||||
new VanillaUnconfigurableArgument("enchantment", EnchantmentArgumentType::enchantment,
|
||||
(c, p) -> ValueConversions.of(Registry.ENCHANTMENT.getId(EnchantmentArgumentType.getEnchantment(c, p))), false
|
||||
new VanillaUnconfigurableArgument("enchantment", ItemEnchantmentArgument::enchantment,
|
||||
(c, p) -> ValueConversions.of(Registry.ENCHANTMENT.getKey(ItemEnchantmentArgument.getEnchantment(c, p))), false
|
||||
),
|
||||
// item_predicate ?? //same as item but accepts tags, not sure right now
|
||||
new SlotArgument(),
|
||||
new VanillaUnconfigurableArgument("item", ItemStackArgumentType::itemStack,
|
||||
(c, p) -> ValueConversions.of(ItemStackArgumentType.getItemStackArgument(c, p).createStack(1, false)), false
|
||||
new VanillaUnconfigurableArgument("item", ItemArgument::item,
|
||||
(c, p) -> ValueConversions.of(ItemArgument.getItem(c, p).createItemStack(1, false)), false
|
||||
),
|
||||
new VanillaUnconfigurableArgument("message", MessageArgumentType::message,
|
||||
(c, p) -> new FormattedTextValue(MessageArgumentType.getMessage(c, p)), true
|
||||
new VanillaUnconfigurableArgument("message", MessageArgument::message,
|
||||
(c, p) -> new FormattedTextValue(MessageArgument.getMessage(c, p)), true
|
||||
),
|
||||
new VanillaUnconfigurableArgument("effect", StatusEffectArgumentType::statusEffect,
|
||||
(c, p) -> ValueConversions.of(Registry.STATUS_EFFECT.getId(StatusEffectArgumentType.getStatusEffect(c, p))),false
|
||||
new VanillaUnconfigurableArgument("effect", MobEffectArgument::effect,
|
||||
(c, p) -> ValueConversions.of(Registry.MOB_EFFECT.getKey(MobEffectArgument.getEffect(c, p))),false
|
||||
),
|
||||
new TagArgument(), // for nbt_compound_tag and nbt_tag
|
||||
new VanillaUnconfigurableArgument("path", NbtPathArgumentType::nbtPath,
|
||||
(c, p) -> StringValue.of(NbtPathArgumentType.getNbtPath(c, p).toString()), true
|
||||
new VanillaUnconfigurableArgument("path", NbtPathArgument::nbtPath,
|
||||
(c, p) -> StringValue.of(NbtPathArgument.getPath(c, p).toString()), true
|
||||
),
|
||||
new VanillaUnconfigurableArgument("objective", ScoreboardObjectiveArgumentType::scoreboardObjective,
|
||||
(c, p) -> ValueConversions.of(ScoreboardObjectiveArgumentType.getObjective(c, p)), false
|
||||
new VanillaUnconfigurableArgument("objective", ObjectiveArgument::objective,
|
||||
(c, p) -> ValueConversions.of(ObjectiveArgument.getObjective(c, p)), false
|
||||
),
|
||||
new VanillaUnconfigurableArgument("criterion", ScoreboardCriterionArgumentType::scoreboardCriterion,
|
||||
(c, p) -> StringValue.of(ScoreboardCriterionArgumentType.getCriterion(c, p).getName()), false
|
||||
new VanillaUnconfigurableArgument("criterion", ObjectiveCriteriaArgument::criteria,
|
||||
(c, p) -> StringValue.of(ObjectiveCriteriaArgument.getCriteria(c, p).getName()), false
|
||||
),
|
||||
// operation // not sure if we need it, you have scarpet for that
|
||||
new VanillaUnconfigurableArgument("particle", ParticleEffectArgumentType::particleEffect,
|
||||
(c, p) -> ValueConversions.of(ParticleEffectArgumentType.getParticle(c, p)), false
|
||||
new VanillaUnconfigurableArgument("particle", ParticleArgument::particle,
|
||||
(c, p) -> ValueConversions.of(ParticleArgument.getParticle(c, p)), false
|
||||
),
|
||||
|
||||
// resource / identifier section
|
||||
|
||||
new VanillaUnconfigurableArgument("recipe", IdentifierArgumentType::identifier,
|
||||
(c, p) -> ValueConversions.of( IdentifierArgumentType.getRecipeArgument(c, p).getId()), SuggestionProviders.ALL_RECIPES
|
||||
new VanillaUnconfigurableArgument("recipe", ResourceLocationArgument::id,
|
||||
(c, p) -> ValueConversions.of( ResourceLocationArgument.getRecipe(c, p).getId()), SuggestionProviders.ALL_RECIPES
|
||||
),
|
||||
new VanillaUnconfigurableArgument("advancement", IdentifierArgumentType::identifier,
|
||||
(c, p) -> ValueConversions.of( IdentifierArgumentType.getAdvancementArgument(c, p).getId()), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getServer().getAdvancementLoader().getAdvancements().stream().map(Advancement::getId), builder)
|
||||
new VanillaUnconfigurableArgument("advancement", ResourceLocationArgument::id,
|
||||
(c, p) -> ValueConversions.of( ResourceLocationArgument.getAdvancement(c, p).getId()), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getAdvancements().getAllAdvancements().stream().map(Advancement::getId), builder)
|
||||
),
|
||||
new VanillaUnconfigurableArgument("lootcondition", IdentifierArgumentType::identifier,
|
||||
(c, p) -> ValueConversions.of( Registry.LOOT_CONDITION_TYPE.getId(IdentifierArgumentType.getPredicateArgument(c, p).getType())), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getServer().getPredicateManager().getIds(), builder)
|
||||
new VanillaUnconfigurableArgument("lootcondition", ResourceLocationArgument::id,
|
||||
(c, p) -> ValueConversions.of( Registry.LOOT_CONDITION_TYPE.getKey(ResourceLocationArgument.getPredicate(c, p).getType())), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getPredicateManager().getKeys(), builder)
|
||||
),
|
||||
new VanillaUnconfigurableArgument("loottable", IdentifierArgumentType::identifier,
|
||||
(c, p) -> ValueConversions.of( IdentifierArgumentType.getIdentifier(c, p)), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getServer().getLootManager().getTableIds(), builder)
|
||||
new VanillaUnconfigurableArgument("loottable", ResourceLocationArgument::id,
|
||||
(c, p) -> ValueConversions.of( ResourceLocationArgument.getId(c, p)), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getLootTables().getIds(), builder)
|
||||
),
|
||||
new VanillaUnconfigurableArgument("attribute", IdentifierArgumentType::identifier,
|
||||
(c, p) -> ValueConversions.of( Registry.ATTRIBUTE.getId(IdentifierArgumentType.getAttributeArgument(c, p))), (ctx, builder) -> CommandSource.suggestIdentifiers(Registry.ATTRIBUTE.getIds(), builder)
|
||||
new VanillaUnconfigurableArgument("attribute", ResourceLocationArgument::id,
|
||||
(c, p) -> ValueConversions.of( Registry.ATTRIBUTE.getKey(ResourceLocationArgument.getAttribute(c, p))), (ctx, builder) -> SharedSuggestionProvider.suggestResource(Registry.ATTRIBUTE.keySet(), builder)
|
||||
),
|
||||
new VanillaUnconfigurableArgument("boss", IdentifierArgumentType::identifier,
|
||||
(c, p) -> ValueConversions.of( IdentifierArgumentType.getIdentifier(c, p)), BossBarCommand.SUGGESTION_PROVIDER
|
||||
new VanillaUnconfigurableArgument("boss", ResourceLocationArgument::id,
|
||||
(c, p) -> ValueConversions.of( ResourceLocationArgument.getId(c, p)), BossBarCommands.SUGGEST_BOSS_BAR
|
||||
),
|
||||
new VanillaUnconfigurableArgument("biome", IdentifierArgumentType::identifier,
|
||||
(c, p) -> ValueConversions.of( IdentifierArgumentType.getIdentifier(c, p)), SuggestionProviders.ALL_BIOMES
|
||||
new VanillaUnconfigurableArgument("biome", ResourceLocationArgument::id,
|
||||
(c, p) -> ValueConversions.of( ResourceLocationArgument.getId(c, p)), SuggestionProviders.AVAILABLE_BIOMES
|
||||
),
|
||||
new VanillaUnconfigurableArgument("sound", IdentifierArgumentType::identifier,
|
||||
(c, p) -> ValueConversions.of( IdentifierArgumentType.getIdentifier(c, p)), SuggestionProviders.AVAILABLE_SOUNDS
|
||||
new VanillaUnconfigurableArgument("sound", ResourceLocationArgument::id,
|
||||
(c, p) -> ValueConversions.of( ResourceLocationArgument.getId(c, p)), SuggestionProviders.AVAILABLE_SOUNDS
|
||||
),
|
||||
new VanillaUnconfigurableArgument("storekey", IdentifierArgumentType::identifier,
|
||||
(c, p) -> ValueConversions.of( IdentifierArgumentType.getIdentifier(c, p)), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getServer().getDataCommandStorage().getIds(), builder)
|
||||
new VanillaUnconfigurableArgument("storekey", ResourceLocationArgument::id,
|
||||
(c, p) -> ValueConversions.of( ResourceLocationArgument.getId(c, p)), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getCommandStorage().keys(), builder)
|
||||
),
|
||||
|
||||
// default
|
||||
@@ -229,32 +225,32 @@ public abstract class CommandArgument
|
||||
// end resource / identifier // I would be great if you guys have suggestions for that.
|
||||
|
||||
new VanillaUnconfigurableArgument("rotation",
|
||||
RotationArgumentType::rotation,
|
||||
RotationArgument::rotation,
|
||||
(c, p) -> {
|
||||
Vec2f rot = RotationArgumentType.getRotation(c, p).toAbsoluteRotation(c.getSource());
|
||||
Vec2 rot = RotationArgument.getRotation(c, p).getRotation(c.getSource());
|
||||
return ListValue.of(new NumericValue(rot.x), new NumericValue(rot.y));
|
||||
},
|
||||
true
|
||||
),
|
||||
new ScoreholderArgument(),
|
||||
new VanillaUnconfigurableArgument("scoreboardslot", ScoreboardSlotArgumentType::scoreboardSlot,
|
||||
(c, p) -> StringValue.of(Scoreboard.getDisplaySlotName(ScoreboardSlotArgumentType.getScoreboardSlot(c, p))), false
|
||||
new VanillaUnconfigurableArgument("scoreboardslot", ScoreboardSlotArgument::displaySlot,
|
||||
(c, p) -> StringValue.of(Scoreboard.getDisplaySlotName(ScoreboardSlotArgument.getDisplaySlot(c, p))), false
|
||||
),
|
||||
new VanillaUnconfigurableArgument("swizzle", SwizzleArgumentType::swizzle,
|
||||
(c, p) -> StringValue.of(SwizzleArgumentType.getSwizzle(c, p).stream().map(Direction.Axis::asString).collect(Collectors.joining())), true
|
||||
new VanillaUnconfigurableArgument("swizzle", SwizzleArgument::swizzle,
|
||||
(c, p) -> StringValue.of(SwizzleArgument.getSwizzle(c, p).stream().map(Direction.Axis::getSerializedName).collect(Collectors.joining())), true
|
||||
),
|
||||
new VanillaUnconfigurableArgument("team", TeamArgumentType::team,
|
||||
(c, p) -> StringValue.of(TeamArgumentType.getTeam(c, p).getName()), false
|
||||
new VanillaUnconfigurableArgument("team", TeamArgument::team,
|
||||
(c, p) -> StringValue.of(TeamArgument.getTeam(c, p).getName()), false
|
||||
),
|
||||
new VanillaUnconfigurableArgument("time", TimeArgumentType::time,
|
||||
new VanillaUnconfigurableArgument("time", TimeArgument::time,
|
||||
(c, p) -> new NumericValue(IntegerArgumentType.getInteger(c, p)), false
|
||||
),
|
||||
new VanillaUnconfigurableArgument("uuid", UuidArgumentType::uuid,
|
||||
(c, p) -> StringValue.of(UuidArgumentType.getUuid(c, p).toString()), false
|
||||
new VanillaUnconfigurableArgument("uuid", UuidArgument::uuid,
|
||||
(c, p) -> StringValue.of(UuidArgument.getUuid(c, p).toString()), false
|
||||
),
|
||||
new VanillaUnconfigurableArgument("surfacelocation", Vec2ArgumentType::vec2, // vec2
|
||||
new VanillaUnconfigurableArgument("surfacelocation", Vec2Argument::vec2, // vec2
|
||||
(c, p) -> {
|
||||
Vec2f res = Vec2ArgumentType.getVec2(c, p);
|
||||
Vec2 res = Vec2Argument.getVec2(c, p);
|
||||
return ListValue.of(NumericValue.of(res.x), NumericValue.of(res.y));
|
||||
},
|
||||
false
|
||||
@@ -281,7 +277,7 @@ public abstract class CommandArgument
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
public static RequiredArgumentBuilder<ServerCommandSource, ?> argumentNode(String param, CarpetScriptHost host) throws CommandSyntaxException
|
||||
public static RequiredArgumentBuilder<CommandSourceStack, ?> argumentNode(String param, CarpetScriptHost host) throws CommandSyntaxException
|
||||
{
|
||||
CommandArgument arg = getTypeForArgument(param, host);
|
||||
if (arg.suggestionProvider != null) return argument(param, arg.getArgumentType()).suggests(arg.suggestionProvider);
|
||||
@@ -297,7 +293,7 @@ public abstract class CommandArgument
|
||||
protected Collection<String> examples;
|
||||
protected boolean needsMatching;
|
||||
protected boolean caseSensitive = true;
|
||||
protected SuggestionProvider<ServerCommandSource> suggestionProvider;
|
||||
protected SuggestionProvider<CommandSourceStack> suggestionProvider;
|
||||
protected FunctionArgument customSuggester;
|
||||
|
||||
|
||||
@@ -314,12 +310,12 @@ public abstract class CommandArgument
|
||||
protected abstract ArgumentType<?> getArgumentType() throws CommandSyntaxException;
|
||||
|
||||
|
||||
public static Value getValue(CommandContext<ServerCommandSource> context, String param, CarpetScriptHost host) throws CommandSyntaxException
|
||||
public static Value getValue(CommandContext<CommandSourceStack> context, String param, CarpetScriptHost host) throws CommandSyntaxException
|
||||
{
|
||||
return getTypeForArgument(param, host).getValueFromContext(context, param);
|
||||
}
|
||||
|
||||
protected abstract Value getValueFromContext(CommandContext<ServerCommandSource> context, String param) throws CommandSyntaxException;
|
||||
protected abstract Value getValueFromContext(CommandContext<CommandSourceStack> context, String param) throws CommandSyntaxException;
|
||||
|
||||
public String getTypeSuffix()
|
||||
{
|
||||
@@ -359,7 +355,7 @@ public abstract class CommandArgument
|
||||
}
|
||||
|
||||
public CompletableFuture<Suggestions> suggest(
|
||||
CommandContext<ServerCommandSource> context,
|
||||
CommandContext<CommandSourceStack> context,
|
||||
SuggestionsBuilder suggestionsBuilder,
|
||||
CarpetScriptHost host
|
||||
) throws CommandSyntaxException
|
||||
@@ -370,20 +366,20 @@ public abstract class CommandArgument
|
||||
return suggestionsBuilder.buildFuture();
|
||||
}
|
||||
|
||||
protected List<String> suggestFor(CommandContext<ServerCommandSource> context, String prefix, CarpetScriptHost host) throws CommandSyntaxException
|
||||
protected List<String> suggestFor(CommandContext<CommandSourceStack> context, String prefix, CarpetScriptHost host) throws CommandSyntaxException
|
||||
{
|
||||
return getOptions(context, host).stream().filter(s -> optionMatchesPrefix(prefix, s)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
protected Collection<String> getOptions(CommandContext<ServerCommandSource> context, CarpetScriptHost host) throws CommandSyntaxException
|
||||
protected Collection<String> getOptions(CommandContext<CommandSourceStack> context, CarpetScriptHost host) throws CommandSyntaxException
|
||||
{
|
||||
if (customSuggester != null)
|
||||
{
|
||||
CarpetProfiler.ProfilerToken currentSection = CarpetProfiler.start_section(null, "Scarpet command", CarpetProfiler.TYPE.GENERAL);
|
||||
Map<Value, Value> params = new HashMap<>();
|
||||
for(ParsedCommandNode<ServerCommandSource> pnode : context.getNodes())
|
||||
for(ParsedCommandNode<CommandSourceStack> pnode : context.getNodes())
|
||||
{
|
||||
CommandNode<ServerCommandSource> node = pnode.getNode();
|
||||
CommandNode<CommandSourceStack> node = pnode.getNode();
|
||||
if (node instanceof ArgumentCommandNode)
|
||||
{
|
||||
params.put(StringValue.of(node.getName()), CommandArgument.getValue(context, node.getName(), host));
|
||||
@@ -437,13 +433,13 @@ public abstract class CommandArgument
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value getValueFromContext(CommandContext<ServerCommandSource> context, String param) throws CommandSyntaxException
|
||||
public Value getValueFromContext(CommandContext<CommandSourceStack> context, String param) throws CommandSyntaxException
|
||||
{
|
||||
String choseValue = StringArgumentType.getString(context, param);
|
||||
if (!caseSensitive) choseValue = choseValue.toLowerCase(Locale.ROOT);
|
||||
if (!validOptions.isEmpty() && !validOptions.contains(choseValue))
|
||||
{
|
||||
throw new SimpleCommandExceptionType(new LiteralText("Incorrect value for "+param+": "+choseValue+" for custom type "+suffix)).create();
|
||||
throw new SimpleCommandExceptionType(new TextComponent("Incorrect value for "+param+": "+choseValue+" for custom type "+suffix)).create();
|
||||
}
|
||||
return StringValue.of(choseValue);
|
||||
}
|
||||
@@ -463,7 +459,7 @@ public abstract class CommandArgument
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<String> getOptions(CommandContext<ServerCommandSource> context, CarpetScriptHost host) throws CommandSyntaxException
|
||||
protected Collection<String> getOptions(CommandContext<CommandSourceStack> context, CarpetScriptHost host) throws CommandSyntaxException
|
||||
{
|
||||
return validOptions.isEmpty()?super.getOptions(context, host):validOptions;
|
||||
}
|
||||
@@ -496,21 +492,21 @@ public abstract class CommandArgument
|
||||
|
||||
private BlockPosArgument()
|
||||
{
|
||||
super("pos", BlockPosArgumentType.blockPos().getExamples(), false);
|
||||
super("pos", net.minecraft.commands.arguments.coordinates.BlockPosArgument.blockPos().getExamples(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArgumentType<?> getArgumentType()
|
||||
{
|
||||
return BlockPosArgumentType.blockPos();
|
||||
return net.minecraft.commands.arguments.coordinates.BlockPosArgument.blockPos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value getValueFromContext(CommandContext<ServerCommandSource> context, String param) throws CommandSyntaxException
|
||||
public Value getValueFromContext(CommandContext<CommandSourceStack> context, String param) throws CommandSyntaxException
|
||||
{
|
||||
BlockPos pos = mustBeLoaded
|
||||
? BlockPosArgumentType.getLoadedBlockPos(context, param)
|
||||
: BlockPosArgumentType.getBlockPos(context, param);
|
||||
? net.minecraft.commands.arguments.coordinates.BlockPosArgument.getLoadedBlockPos(context, param)
|
||||
: net.minecraft.commands.arguments.coordinates.BlockPosArgument.getSpawnablePos(context, param);
|
||||
return ValueConversions.of(pos);
|
||||
}
|
||||
|
||||
@@ -534,19 +530,19 @@ public abstract class CommandArgument
|
||||
|
||||
private LocationArgument()
|
||||
{
|
||||
super("location", Vec3ArgumentType.vec3().getExamples(), false);
|
||||
super("location", Vec3Argument.vec3().getExamples(), false);
|
||||
blockCentered = true;
|
||||
}
|
||||
@Override
|
||||
protected ArgumentType<?> getArgumentType()
|
||||
{
|
||||
return Vec3ArgumentType.vec3(blockCentered);
|
||||
return Vec3Argument.vec3(blockCentered);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Value getValueFromContext(CommandContext<ServerCommandSource> context, String param) throws CommandSyntaxException
|
||||
protected Value getValueFromContext(CommandContext<CommandSourceStack> context, String param) throws CommandSyntaxException
|
||||
{
|
||||
return ValueConversions.of(Vec3ArgumentType.getVec3(context, param));
|
||||
return ValueConversions.of(Vec3Argument.getVec3(context, param));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -570,7 +566,7 @@ public abstract class CommandArgument
|
||||
|
||||
private EntityArgument()
|
||||
{
|
||||
super("entities", EntityArgumentType.entities().getExamples(), false);
|
||||
super("entities", net.minecraft.commands.arguments.EntityArgument.entities().getExamples(), false);
|
||||
onlyFans = false;
|
||||
single = false;
|
||||
}
|
||||
@@ -579,22 +575,22 @@ public abstract class CommandArgument
|
||||
{
|
||||
if (onlyFans)
|
||||
{
|
||||
return single?EntityArgumentType.player():EntityArgumentType.players();
|
||||
return single?net.minecraft.commands.arguments.EntityArgument.player():net.minecraft.commands.arguments.EntityArgument.players();
|
||||
}
|
||||
else
|
||||
{
|
||||
return single?EntityArgumentType.entity():EntityArgumentType.entities();
|
||||
return single?net.minecraft.commands.arguments.EntityArgument.entity():net.minecraft.commands.arguments.EntityArgument.entities();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Value getValueFromContext(CommandContext<ServerCommandSource> context, String param) throws CommandSyntaxException
|
||||
protected Value getValueFromContext(CommandContext<CommandSourceStack> context, String param) throws CommandSyntaxException
|
||||
{
|
||||
Collection<? extends Entity> founds = EntityArgumentType.getOptionalEntities(context, param);
|
||||
Collection<? extends Entity> founds = net.minecraft.commands.arguments.EntityArgument.getOptionalEntities(context, param);
|
||||
if (!single) return ListValue.wrap(founds.stream().map(EntityValue::new).collect(Collectors.toList()));
|
||||
if (founds.size() == 0) return Value.NULL;
|
||||
if (founds.size() == 1) return new EntityValue(founds.iterator().next());
|
||||
throw new SimpleCommandExceptionType(new LiteralText("Multiple entities returned while only one was requested"+" for custom type "+suffix)).create();
|
||||
throw new SimpleCommandExceptionType(new TextComponent("Multiple entities returned while only one was requested"+" for custom type "+suffix)).create();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -618,24 +614,24 @@ public abstract class CommandArgument
|
||||
|
||||
private PlayerProfileArgument()
|
||||
{
|
||||
super("players", GameProfileArgumentType.gameProfile().getExamples(), false);
|
||||
super("players", GameProfileArgument.gameProfile().getExamples(), false);
|
||||
single = false;
|
||||
}
|
||||
@Override
|
||||
protected ArgumentType<?> getArgumentType()
|
||||
{
|
||||
return GameProfileArgumentType.gameProfile();
|
||||
return GameProfileArgument.gameProfile();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Value getValueFromContext(CommandContext<ServerCommandSource> context, String param) throws CommandSyntaxException
|
||||
protected Value getValueFromContext(CommandContext<CommandSourceStack> context, String param) throws CommandSyntaxException
|
||||
{
|
||||
Collection<GameProfile> profiles = GameProfileArgumentType.getProfileArgument(context, param);
|
||||
Collection<GameProfile> profiles = GameProfileArgument.getGameProfiles(context, param);
|
||||
if (!single) return ListValue.wrap(profiles.stream().map(p -> StringValue.of(p.getName())).collect(Collectors.toList()));
|
||||
int size = profiles.size();
|
||||
if (size == 0) return Value.NULL;
|
||||
if (size == 1) return StringValue.of(profiles.iterator().next().getName());
|
||||
throw new SimpleCommandExceptionType(new LiteralText("Multiple game profiles returned while only one was requested"+" for custom type "+suffix)).create();
|
||||
throw new SimpleCommandExceptionType(new TextComponent("Multiple game profiles returned while only one was requested"+" for custom type "+suffix)).create();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -658,25 +654,25 @@ public abstract class CommandArgument
|
||||
|
||||
private ScoreholderArgument()
|
||||
{
|
||||
super("scoreholder", ScoreHolderArgumentType.scoreHolder().getExamples(), false);
|
||||
super("scoreholder", ScoreHolderArgument.scoreHolder().getExamples(), false);
|
||||
single = false;
|
||||
suggestionProvider = ScoreHolderArgumentType.SUGGESTION_PROVIDER;
|
||||
suggestionProvider = ScoreHolderArgument.SUGGEST_SCORE_HOLDERS;
|
||||
}
|
||||
@Override
|
||||
protected ArgumentType<?> getArgumentType()
|
||||
{
|
||||
return single?ScoreHolderArgumentType.scoreHolder():ScoreHolderArgumentType.scoreHolders();
|
||||
return single?ScoreHolderArgument.scoreHolder():ScoreHolderArgument.scoreHolders();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Value getValueFromContext(CommandContext<ServerCommandSource> context, String param) throws CommandSyntaxException
|
||||
protected Value getValueFromContext(CommandContext<CommandSourceStack> context, String param) throws CommandSyntaxException
|
||||
{
|
||||
Collection<String> holders = ScoreHolderArgumentType.getScoreHolders(context, param);
|
||||
Collection<String> holders = ScoreHolderArgument.getNames(context, param);
|
||||
if (!single) return ListValue.wrap(holders.stream().map(StringValue::of).collect(Collectors.toList()));
|
||||
int size = holders.size();
|
||||
if (size == 0) return Value.NULL;
|
||||
if (size == 1) return StringValue.of(holders.iterator().next());
|
||||
throw new SimpleCommandExceptionType(new LiteralText("Multiple score holders returned while only one was requested"+" for custom type "+suffix)).create();
|
||||
throw new SimpleCommandExceptionType(new TextComponent("Multiple score holders returned while only one was requested"+" for custom type "+suffix)).create();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -698,22 +694,22 @@ public abstract class CommandArgument
|
||||
boolean mapRequired;
|
||||
private TagArgument()
|
||||
{
|
||||
super("tag", NbtCompoundArgumentType.nbtCompound().getExamples(), false);
|
||||
super("tag", CompoundTagArgument.compoundTag().getExamples(), false);
|
||||
mapRequired = true;
|
||||
}
|
||||
@Override
|
||||
protected ArgumentType<?> getArgumentType()
|
||||
{
|
||||
return mapRequired?NbtCompoundArgumentType.nbtCompound(): NbtElementArgumentType.nbtElement();
|
||||
return mapRequired?CompoundTagArgument.compoundTag(): NbtTagArgument.nbtTag();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Value getValueFromContext(CommandContext<ServerCommandSource> context, String param) throws CommandSyntaxException
|
||||
protected Value getValueFromContext(CommandContext<CommandSourceStack> context, String param) throws CommandSyntaxException
|
||||
{
|
||||
if (mapRequired)
|
||||
return new NBTSerializableValue(NbtCompoundArgumentType.getNbtCompound(context, param));
|
||||
return new NBTSerializableValue(CompoundTagArgument.getCompoundTag(context, param));
|
||||
else
|
||||
return new NBTSerializableValue(NbtElementArgumentType.getNbtElement(context, param));
|
||||
return new NBTSerializableValue(NbtTagArgument.getNbtTag(context, param));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -732,7 +728,7 @@ public abstract class CommandArgument
|
||||
|
||||
private static class CustomIdentifierArgument extends CommandArgument
|
||||
{
|
||||
Set<Identifier> validOptions = Collections.emptySet();
|
||||
Set<ResourceLocation> validOptions = Collections.emptySet();
|
||||
|
||||
protected CustomIdentifierArgument()
|
||||
{
|
||||
@@ -742,16 +738,16 @@ public abstract class CommandArgument
|
||||
@Override
|
||||
protected ArgumentType<?> getArgumentType()
|
||||
{
|
||||
return IdentifierArgumentType.identifier();
|
||||
return ResourceLocationArgument.id();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Value getValueFromContext(CommandContext<ServerCommandSource> context, String param) throws CommandSyntaxException
|
||||
protected Value getValueFromContext(CommandContext<CommandSourceStack> context, String param) throws CommandSyntaxException
|
||||
{
|
||||
Identifier choseValue = IdentifierArgumentType.getIdentifier(context, param);
|
||||
ResourceLocation choseValue = ResourceLocationArgument.getId(context, param);
|
||||
if (!validOptions.isEmpty() && !validOptions.contains(choseValue))
|
||||
{
|
||||
throw new SimpleCommandExceptionType(new LiteralText("Incorrect value for "+param+": "+choseValue+" for custom type "+suffix)).create();
|
||||
throw new SimpleCommandExceptionType(new TextComponent("Incorrect value for "+param+": "+choseValue+" for custom type "+suffix)).create();
|
||||
}
|
||||
return ValueConversions.of(choseValue);
|
||||
}
|
||||
@@ -770,7 +766,7 @@ public abstract class CommandArgument
|
||||
{
|
||||
Value optionsValue = config.get("options");
|
||||
if (!(optionsValue instanceof ListValue)) throw error("Custom sting type requires options passed as a list"+" for custom type "+suffix);
|
||||
validOptions = ((ListValue) optionsValue).getItems().stream().map(v -> new Identifier(v.getString())).collect(Collectors.toSet());
|
||||
validOptions = ((ListValue) optionsValue).getItems().stream().map(v -> new ResourceLocation(v.getString())).collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -799,7 +795,7 @@ public abstract class CommandArgument
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value getValueFromContext(CommandContext<ServerCommandSource> context, String param) throws CommandSyntaxException
|
||||
public Value getValueFromContext(CommandContext<CommandSourceStack> context, String param) throws CommandSyntaxException
|
||||
{
|
||||
return new NumericValue(DoubleArgumentType.getDouble(context, param));
|
||||
}
|
||||
@@ -850,7 +846,7 @@ public abstract class CommandArgument
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value getValueFromContext(CommandContext<ServerCommandSource> context, String param) throws CommandSyntaxException
|
||||
public Value getValueFromContext(CommandContext<CommandSourceStack> context, String param) throws CommandSyntaxException
|
||||
{
|
||||
return new NumericValue(LongArgumentType.getLong(context, param));
|
||||
}
|
||||
@@ -926,22 +922,22 @@ public abstract class CommandArgument
|
||||
|
||||
protected SlotArgument()
|
||||
{
|
||||
super("slot", ItemSlotArgumentType.itemSlot().getExamples(), false);
|
||||
super("slot", net.minecraft.commands.arguments.SlotArgument.slot().getExamples(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArgumentType<?> getArgumentType() throws CommandSyntaxException
|
||||
{
|
||||
return ItemSlotArgumentType.itemSlot();
|
||||
return net.minecraft.commands.arguments.SlotArgument.slot();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Value getValueFromContext(CommandContext<ServerCommandSource> context, String param) throws CommandSyntaxException
|
||||
protected Value getValueFromContext(CommandContext<CommandSourceStack> context, String param) throws CommandSyntaxException
|
||||
{
|
||||
int slot = ItemSlotArgumentType.getItemSlot(context, param);
|
||||
int slot = net.minecraft.commands.arguments.SlotArgument.getSlot(context, param);
|
||||
if (restrict != null && !RESTRICTED_CONTAINERS.get(restrict).numericalIds().contains(slot))
|
||||
{
|
||||
throw new SimpleCommandExceptionType(new LiteralText("Incorrect slot restricted to "+restrict+" for custom type "+suffix)).create();
|
||||
throw new SimpleCommandExceptionType(new TextComponent("Incorrect slot restricted to "+restrict+" for custom type "+suffix)).create();
|
||||
}
|
||||
return ValueConversions.ofVanillaSlotResult(slot);
|
||||
}
|
||||
@@ -960,7 +956,7 @@ public abstract class CommandArgument
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<String> getOptions(CommandContext<ServerCommandSource> context, CarpetScriptHost host) throws CommandSyntaxException
|
||||
protected Collection<String> getOptions(CommandContext<CommandSourceStack> context, CarpetScriptHost host) throws CommandSyntaxException
|
||||
{
|
||||
return restrict==null?super.getOptions(context, host):RESTRICTED_CONTAINERS.get(restrict).commandIds();
|
||||
}
|
||||
@@ -975,7 +971,7 @@ public abstract class CommandArgument
|
||||
@FunctionalInterface
|
||||
private interface ValueExtractor
|
||||
{
|
||||
Value apply(CommandContext<ServerCommandSource> ctx, String param) throws CommandSyntaxException;
|
||||
Value apply(CommandContext<CommandSourceStack> ctx, String param) throws CommandSyntaxException;
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
@@ -1013,7 +1009,7 @@ public abstract class CommandArgument
|
||||
String suffix,
|
||||
ArgumentProvider argumentTypeSupplier,
|
||||
ValueExtractor valueExtractor,
|
||||
SuggestionProvider<ServerCommandSource> suggester
|
||||
SuggestionProvider<CommandSourceStack> suggester
|
||||
)
|
||||
{
|
||||
super(suffix, Collections.emptyList(), false);
|
||||
@@ -1030,7 +1026,7 @@ public abstract class CommandArgument
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Value getValueFromContext(CommandContext<ServerCommandSource> context, String param) throws CommandSyntaxException
|
||||
protected Value getValueFromContext(CommandContext<CommandSourceStack> context, String param) throws CommandSyntaxException
|
||||
{
|
||||
return valueExtractor.apply(context, param);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user