cloud-fabric: Update for Minecraft 1.19.3 (#411)
This also removes support for older versions (1.19-1.19.2) Co-authored-by: zml <zml@stellardrift.ca>
This commit is contained in:
parent
c0cdd3310d
commit
7777a85d41
9 changed files with 52 additions and 28 deletions
|
|
@ -6,6 +6,10 @@ plugins {
|
|||
id("cloud.base-conventions")
|
||||
}
|
||||
|
||||
indra {
|
||||
javaVersions().target(17)
|
||||
}
|
||||
|
||||
tasks {
|
||||
compileJava {
|
||||
options.errorprone {
|
||||
|
|
|
|||
|
|
@ -69,16 +69,16 @@ import net.minecraft.commands.arguments.ObjectiveCriteriaArgument;
|
|||
import net.minecraft.commands.arguments.OperationArgument;
|
||||
import net.minecraft.commands.arguments.ParticleArgument;
|
||||
import net.minecraft.commands.arguments.RangeArgument;
|
||||
import net.minecraft.commands.arguments.ResourceKeyArgument;
|
||||
import net.minecraft.commands.arguments.ResourceLocationArgument;
|
||||
import net.minecraft.commands.arguments.ResourceOrTagLocationArgument;
|
||||
import net.minecraft.commands.arguments.UuidArgument;
|
||||
import net.minecraft.commands.arguments.blocks.BlockPredicateArgument;
|
||||
import net.minecraft.commands.arguments.coordinates.SwizzleArgument;
|
||||
import net.minecraft.commands.arguments.item.ItemArgument;
|
||||
import net.minecraft.commands.arguments.item.ItemInput;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
|
|
@ -181,7 +181,6 @@ public abstract class FabricCommandManager<C, S extends SharedSuggestionProvider
|
|||
this.registerConstantNativeParserSupplier(NbtPathArgument.NbtPath.class, NbtPathArgument.nbtPath());
|
||||
this.registerConstantNativeParserSupplier(ObjectiveCriteria.class, ObjectiveCriteriaArgument.criteria());
|
||||
this.registerConstantNativeParserSupplier(OperationArgument.Operation.class, OperationArgument.operation());
|
||||
this.registerConstantNativeParserSupplier(ParticleOptions.class, ParticleArgument.particle());
|
||||
this.registerConstantNativeParserSupplier(AngleArgument.SingleAngle.class, AngleArgument.angle());
|
||||
this.registerConstantNativeParserSupplier(new TypeToken<EnumSet<Direction.Axis>>() {
|
||||
}, SwizzleArgument.swizzle());
|
||||
|
|
@ -189,6 +188,7 @@ public abstract class FabricCommandManager<C, S extends SharedSuggestionProvider
|
|||
this.registerConstantNativeParserSupplier(EntityAnchorArgument.Anchor.class, EntityAnchorArgument.anchor());
|
||||
this.registerConstantNativeParserSupplier(MinMaxBounds.Ints.class, RangeArgument.intRange());
|
||||
this.registerConstantNativeParserSupplier(MinMaxBounds.Doubles.class, RangeArgument.floatRange());
|
||||
this.registerContextualNativeParserSupplier(ParticleOptions.class, ParticleArgument::particle);
|
||||
this.registerContextualNativeParserSupplier(ItemInput.class, ItemArgument::item);
|
||||
this.registerContextualNativeParserSupplier(BlockPredicateArgument.Result.class, BlockPredicateArgument::blockPredicate);
|
||||
|
||||
|
|
@ -206,7 +206,7 @@ public abstract class FabricCommandManager<C, S extends SharedSuggestionProvider
|
|||
new TypeToken<RegistryEntryArgument.Parser<C, ?>>() {
|
||||
},
|
||||
builder -> {
|
||||
builder.to(argument -> ResourceOrTagLocationArgument.<Object>resourceOrTag((ResourceKey) argument.registryKey()));
|
||||
builder.to(argument -> ResourceKeyArgument.key((ResourceKey) argument.registryKey()));
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -217,7 +217,7 @@ public abstract class FabricCommandManager<C, S extends SharedSuggestionProvider
|
|||
* Eventually, these could be resolved by using ParserParameters in some way? */
|
||||
seenClasses.add(ResourceLocation.class);
|
||||
seenClasses.add(Codec.class);
|
||||
for (final Field field : Registry.class.getDeclaredFields()) {
|
||||
for (final Field field : Registries.class.getDeclaredFields()) {
|
||||
if ((field.getModifiers() & MOD_PUBLIC_STATIC_FINAL) != MOD_PUBLIC_STATIC_FINAL) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ abstract class FabricCommandRegistrationHandler<C, S extends SharedSuggestionPro
|
|||
}
|
||||
FabricArgumentParsers.ContextualArgumentTypeProvider.withBuildContext(
|
||||
this.commandManager(),
|
||||
new CommandBuildContext(connection.registryAccess()),
|
||||
CommandBuildContext.simple(connection.registryAccess(), connection.enabledFeatures()),
|
||||
false,
|
||||
() -> this.registerClientCommand(dispatcher, (Command<C>) command)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
import net.minecraft.commands.arguments.item.ItemArgument;
|
||||
import net.minecraft.commands.arguments.item.ItemInput;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
|
@ -150,9 +150,9 @@ public final class ItemInputArgument<C> extends CommandArgument<C, ItemInput> {
|
|||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull ItemStack defaultValue) {
|
||||
final String serializedDefault;
|
||||
if (defaultValue.hasTag()) {
|
||||
serializedDefault = Registry.ITEM.getKey(defaultValue.getItem()) + defaultValue.getTag().toString();
|
||||
serializedDefault = BuiltInRegistries.ITEM.getKey(defaultValue.getItem()) + defaultValue.getTag().toString();
|
||||
} else {
|
||||
serializedDefault = Registry.ITEM.getKey(defaultValue.getItem()).toString();
|
||||
serializedDefault = BuiltInRegistries.ITEM.getKey(defaultValue.getItem()).toString();
|
||||
}
|
||||
return this.asOptionalWithDefault(serializedDefault);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,21 +25,25 @@ package cloud.commandframework.fabric.argument;
|
|||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.brigadier.argument.WrappedBrigadierParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import org.apiguardian.api.API;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* An argument parsing a status effect from the {@link net.minecraft.core.Registry#MOB_EFFECT status effect registry}.
|
||||
* An argument parsing a status effect from the {@link net.minecraft.core.registries.Registries#MOB_EFFECT status effect registry}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
* @deprecated backing vanilla type was removed in Minecraft 1.19.3. Uses {@link RegistryEntryArgument.Parser}.
|
||||
*/
|
||||
@API(status = API.Status.DEPRECATED, since = "1.8.0")
|
||||
@Deprecated
|
||||
public final class MobEffectArgument<C> extends CommandArgument<C, MobEffect> {
|
||||
|
||||
MobEffectArgument(
|
||||
|
|
@ -52,7 +56,7 @@ public final class MobEffectArgument<C> extends CommandArgument<C, MobEffect> {
|
|||
super(
|
||||
required,
|
||||
name,
|
||||
new WrappedBrigadierParser<>(net.minecraft.commands.arguments.MobEffectArgument.effect()),
|
||||
new RegistryEntryArgument.Parser<>(Registries.MOB_EFFECT),
|
||||
defaultValue,
|
||||
MobEffect.class,
|
||||
suggestionsProvider,
|
||||
|
|
@ -151,7 +155,7 @@ public final class MobEffectArgument<C> extends CommandArgument<C, MobEffect> {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull MobEffect defaultValue) {
|
||||
return this.asOptionalWithDefault(Registry.MOB_EFFECT.getKey(defaultValue).toString());
|
||||
return this.asOptionalWithDefault(BuiltInRegistries.MOB_EFFECT.getKey(defaultValue).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ package cloud.commandframework.fabric.argument;
|
|||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.brigadier.argument.WrappedBrigadierParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
|
|
@ -51,7 +50,7 @@ public final class ParticleArgument<C> extends CommandArgument<C, ParticleOption
|
|||
super(
|
||||
required,
|
||||
name,
|
||||
new WrappedBrigadierParser<>(net.minecraft.commands.arguments.ParticleArgument.particle()),
|
||||
FabricArgumentParsers.contextual(net.minecraft.commands.arguments.ParticleArgument::particle),
|
||||
defaultValue,
|
||||
ParticleOptions.class,
|
||||
suggestionsProvider,
|
||||
|
|
|
|||
|
|
@ -234,16 +234,9 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
return ArgumentParseResult.success(entry);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Registry<V> resolveRegistry(final CommandContext<C> ctx) {
|
||||
final SharedSuggestionProvider reverseMapped = ctx.get(FabricCommandContextKeys.NATIVE_COMMAND_SOURCE);
|
||||
// First try dynamic registries (for things loaded from data-packs)
|
||||
Registry<V> registry = reverseMapped.registryAccess().registry(this.registryIdent).orElse(null);
|
||||
if (registry == null) {
|
||||
// And then static registries
|
||||
registry = (Registry<V>) Registry.REGISTRY.get(this.registryIdent.location());
|
||||
}
|
||||
return registry;
|
||||
return reverseMapped.registryAccess().registry(this.registryIdent).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import cloud.commandframework.execution.CommandExecutionCoordinator;
|
|||
import cloud.commandframework.fabric.FabricServerCommandManager;
|
||||
import cloud.commandframework.fabric.argument.ItemInputArgument;
|
||||
import cloud.commandframework.fabric.argument.NamedColorArgument;
|
||||
import cloud.commandframework.fabric.argument.RegistryEntryArgument;
|
||||
import cloud.commandframework.fabric.argument.server.ColumnPosArgument;
|
||||
import cloud.commandframework.fabric.argument.server.MultipleEntitySelectorArgument;
|
||||
import cloud.commandframework.fabric.argument.server.MultiplePlayerSelectorArgument;
|
||||
|
|
@ -54,6 +55,7 @@ import net.fabricmc.loader.api.metadata.Person;
|
|||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.arguments.item.ItemInput;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.ComponentUtils;
|
||||
|
|
@ -62,6 +64,7 @@ import net.minecraft.network.chat.MutableComponent;
|
|||
import net.minecraft.network.chat.TextColor;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public final class FabricExample implements ModInitializer {
|
||||
|
|
@ -96,6 +99,27 @@ public final class FabricExample implements ModInitializer {
|
|||
.withStyle(style -> style.withBold(true)), false);
|
||||
}));
|
||||
|
||||
final CommandArgument<CommandSourceStack, Biome> biomeArgument = RegistryEntryArgument.of(
|
||||
"biome",
|
||||
Biome.class,
|
||||
Registries.BIOME
|
||||
);
|
||||
|
||||
manager.command(base
|
||||
.literal("land")
|
||||
.argument(biomeArgument)
|
||||
.handler(ctx -> {
|
||||
ctx.getSender().sendSuccess(Component.literal("Yes, the biome ")
|
||||
.append(Component.literal(
|
||||
ctx.getSender().registryAccess()
|
||||
.registryOrThrow(Registries.BIOME)
|
||||
.getKey(ctx.get(biomeArgument)).toString())
|
||||
.withStyle(ChatFormatting.DARK_PURPLE, ChatFormatting.BOLD))
|
||||
.append(Component.literal(" is pretty cool"))
|
||||
.withStyle(style -> style.withColor(0x884433)), false);
|
||||
})
|
||||
);
|
||||
|
||||
final CommandArgument<CommandSourceStack, MultiplePlayerSelector> playerSelector =
|
||||
MultiplePlayerSelectorArgument.of("players");
|
||||
final CommandArgument<CommandSourceStack, ChatFormatting> textColor = NamedColorArgument.of("color");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue