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")
|
id("cloud.base-conventions")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
indra {
|
||||||
|
javaVersions().target(17)
|
||||||
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
compileJava {
|
compileJava {
|
||||||
options.errorprone {
|
options.errorprone {
|
||||||
|
|
|
||||||
|
|
@ -69,16 +69,16 @@ import net.minecraft.commands.arguments.ObjectiveCriteriaArgument;
|
||||||
import net.minecraft.commands.arguments.OperationArgument;
|
import net.minecraft.commands.arguments.OperationArgument;
|
||||||
import net.minecraft.commands.arguments.ParticleArgument;
|
import net.minecraft.commands.arguments.ParticleArgument;
|
||||||
import net.minecraft.commands.arguments.RangeArgument;
|
import net.minecraft.commands.arguments.RangeArgument;
|
||||||
|
import net.minecraft.commands.arguments.ResourceKeyArgument;
|
||||||
import net.minecraft.commands.arguments.ResourceLocationArgument;
|
import net.minecraft.commands.arguments.ResourceLocationArgument;
|
||||||
import net.minecraft.commands.arguments.ResourceOrTagLocationArgument;
|
|
||||||
import net.minecraft.commands.arguments.UuidArgument;
|
import net.minecraft.commands.arguments.UuidArgument;
|
||||||
import net.minecraft.commands.arguments.blocks.BlockPredicateArgument;
|
import net.minecraft.commands.arguments.blocks.BlockPredicateArgument;
|
||||||
import net.minecraft.commands.arguments.coordinates.SwizzleArgument;
|
import net.minecraft.commands.arguments.coordinates.SwizzleArgument;
|
||||||
import net.minecraft.commands.arguments.item.ItemArgument;
|
import net.minecraft.commands.arguments.item.ItemArgument;
|
||||||
import net.minecraft.commands.arguments.item.ItemInput;
|
import net.minecraft.commands.arguments.item.ItemInput;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Registry;
|
|
||||||
import net.minecraft.core.particles.ParticleOptions;
|
import net.minecraft.core.particles.ParticleOptions;
|
||||||
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.resources.ResourceKey;
|
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(NbtPathArgument.NbtPath.class, NbtPathArgument.nbtPath());
|
||||||
this.registerConstantNativeParserSupplier(ObjectiveCriteria.class, ObjectiveCriteriaArgument.criteria());
|
this.registerConstantNativeParserSupplier(ObjectiveCriteria.class, ObjectiveCriteriaArgument.criteria());
|
||||||
this.registerConstantNativeParserSupplier(OperationArgument.Operation.class, OperationArgument.operation());
|
this.registerConstantNativeParserSupplier(OperationArgument.Operation.class, OperationArgument.operation());
|
||||||
this.registerConstantNativeParserSupplier(ParticleOptions.class, ParticleArgument.particle());
|
|
||||||
this.registerConstantNativeParserSupplier(AngleArgument.SingleAngle.class, AngleArgument.angle());
|
this.registerConstantNativeParserSupplier(AngleArgument.SingleAngle.class, AngleArgument.angle());
|
||||||
this.registerConstantNativeParserSupplier(new TypeToken<EnumSet<Direction.Axis>>() {
|
this.registerConstantNativeParserSupplier(new TypeToken<EnumSet<Direction.Axis>>() {
|
||||||
}, SwizzleArgument.swizzle());
|
}, SwizzleArgument.swizzle());
|
||||||
|
|
@ -189,6 +188,7 @@ public abstract class FabricCommandManager<C, S extends SharedSuggestionProvider
|
||||||
this.registerConstantNativeParserSupplier(EntityAnchorArgument.Anchor.class, EntityAnchorArgument.anchor());
|
this.registerConstantNativeParserSupplier(EntityAnchorArgument.Anchor.class, EntityAnchorArgument.anchor());
|
||||||
this.registerConstantNativeParserSupplier(MinMaxBounds.Ints.class, RangeArgument.intRange());
|
this.registerConstantNativeParserSupplier(MinMaxBounds.Ints.class, RangeArgument.intRange());
|
||||||
this.registerConstantNativeParserSupplier(MinMaxBounds.Doubles.class, RangeArgument.floatRange());
|
this.registerConstantNativeParserSupplier(MinMaxBounds.Doubles.class, RangeArgument.floatRange());
|
||||||
|
this.registerContextualNativeParserSupplier(ParticleOptions.class, ParticleArgument::particle);
|
||||||
this.registerContextualNativeParserSupplier(ItemInput.class, ItemArgument::item);
|
this.registerContextualNativeParserSupplier(ItemInput.class, ItemArgument::item);
|
||||||
this.registerContextualNativeParserSupplier(BlockPredicateArgument.Result.class, BlockPredicateArgument::blockPredicate);
|
this.registerContextualNativeParserSupplier(BlockPredicateArgument.Result.class, BlockPredicateArgument::blockPredicate);
|
||||||
|
|
||||||
|
|
@ -206,7 +206,7 @@ public abstract class FabricCommandManager<C, S extends SharedSuggestionProvider
|
||||||
new TypeToken<RegistryEntryArgument.Parser<C, ?>>() {
|
new TypeToken<RegistryEntryArgument.Parser<C, ?>>() {
|
||||||
},
|
},
|
||||||
builder -> {
|
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? */
|
* Eventually, these could be resolved by using ParserParameters in some way? */
|
||||||
seenClasses.add(ResourceLocation.class);
|
seenClasses.add(ResourceLocation.class);
|
||||||
seenClasses.add(Codec.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) {
|
if ((field.getModifiers() & MOD_PUBLIC_STATIC_FINAL) != MOD_PUBLIC_STATIC_FINAL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ abstract class FabricCommandRegistrationHandler<C, S extends SharedSuggestionPro
|
||||||
}
|
}
|
||||||
FabricArgumentParsers.ContextualArgumentTypeProvider.withBuildContext(
|
FabricArgumentParsers.ContextualArgumentTypeProvider.withBuildContext(
|
||||||
this.commandManager(),
|
this.commandManager(),
|
||||||
new CommandBuildContext(connection.registryAccess()),
|
CommandBuildContext.simple(connection.registryAccess(), connection.enabledFeatures()),
|
||||||
false,
|
false,
|
||||||
() -> this.registerClientCommand(dispatcher, (Command<C>) command)
|
() -> this.registerClientCommand(dispatcher, (Command<C>) command)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import java.util.List;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import net.minecraft.commands.arguments.item.ItemArgument;
|
import net.minecraft.commands.arguments.item.ItemArgument;
|
||||||
import net.minecraft.commands.arguments.item.ItemInput;
|
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 net.minecraft.world.item.ItemStack;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
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) {
|
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull ItemStack defaultValue) {
|
||||||
final String serializedDefault;
|
final String serializedDefault;
|
||||||
if (defaultValue.hasTag()) {
|
if (defaultValue.hasTag()) {
|
||||||
serializedDefault = Registry.ITEM.getKey(defaultValue.getItem()) + defaultValue.getTag().toString();
|
serializedDefault = BuiltInRegistries.ITEM.getKey(defaultValue.getItem()) + defaultValue.getTag().toString();
|
||||||
} else {
|
} else {
|
||||||
serializedDefault = Registry.ITEM.getKey(defaultValue.getItem()).toString();
|
serializedDefault = BuiltInRegistries.ITEM.getKey(defaultValue.getItem()).toString();
|
||||||
}
|
}
|
||||||
return this.asOptionalWithDefault(serializedDefault);
|
return this.asOptionalWithDefault(serializedDefault);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,21 +25,25 @@ package cloud.commandframework.fabric.argument;
|
||||||
|
|
||||||
import cloud.commandframework.ArgumentDescription;
|
import cloud.commandframework.ArgumentDescription;
|
||||||
import cloud.commandframework.arguments.CommandArgument;
|
import cloud.commandframework.arguments.CommandArgument;
|
||||||
import cloud.commandframework.brigadier.argument.WrappedBrigadierParser;
|
|
||||||
import cloud.commandframework.context.CommandContext;
|
import cloud.commandframework.context.CommandContext;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.BiFunction;
|
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 net.minecraft.world.effect.MobEffect;
|
||||||
|
import org.apiguardian.api.API;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
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
|
* @param <C> the sender type
|
||||||
* @since 1.5.0
|
* @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> {
|
public final class MobEffectArgument<C> extends CommandArgument<C, MobEffect> {
|
||||||
|
|
||||||
MobEffectArgument(
|
MobEffectArgument(
|
||||||
|
|
@ -52,7 +56,7 @@ public final class MobEffectArgument<C> extends CommandArgument<C, MobEffect> {
|
||||||
super(
|
super(
|
||||||
required,
|
required,
|
||||||
name,
|
name,
|
||||||
new WrappedBrigadierParser<>(net.minecraft.commands.arguments.MobEffectArgument.effect()),
|
new RegistryEntryArgument.Parser<>(Registries.MOB_EFFECT),
|
||||||
defaultValue,
|
defaultValue,
|
||||||
MobEffect.class,
|
MobEffect.class,
|
||||||
suggestionsProvider,
|
suggestionsProvider,
|
||||||
|
|
@ -151,7 +155,7 @@ public final class MobEffectArgument<C> extends CommandArgument<C, MobEffect> {
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull MobEffect defaultValue) {
|
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.ArgumentDescription;
|
||||||
import cloud.commandframework.arguments.CommandArgument;
|
import cloud.commandframework.arguments.CommandArgument;
|
||||||
import cloud.commandframework.brigadier.argument.WrappedBrigadierParser;
|
|
||||||
import cloud.commandframework.context.CommandContext;
|
import cloud.commandframework.context.CommandContext;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
@ -51,7 +50,7 @@ public final class ParticleArgument<C> extends CommandArgument<C, ParticleOption
|
||||||
super(
|
super(
|
||||||
required,
|
required,
|
||||||
name,
|
name,
|
||||||
new WrappedBrigadierParser<>(net.minecraft.commands.arguments.ParticleArgument.particle()),
|
FabricArgumentParsers.contextual(net.minecraft.commands.arguments.ParticleArgument::particle),
|
||||||
defaultValue,
|
defaultValue,
|
||||||
ParticleOptions.class,
|
ParticleOptions.class,
|
||||||
suggestionsProvider,
|
suggestionsProvider,
|
||||||
|
|
|
||||||
|
|
@ -234,16 +234,9 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
||||||
return ArgumentParseResult.success(entry);
|
return ArgumentParseResult.success(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Registry<V> resolveRegistry(final CommandContext<C> ctx) {
|
Registry<V> resolveRegistry(final CommandContext<C> ctx) {
|
||||||
final SharedSuggestionProvider reverseMapped = ctx.get(FabricCommandContextKeys.NATIVE_COMMAND_SOURCE);
|
final SharedSuggestionProvider reverseMapped = ctx.get(FabricCommandContextKeys.NATIVE_COMMAND_SOURCE);
|
||||||
// First try dynamic registries (for things loaded from data-packs)
|
return reverseMapped.registryAccess().registry(this.registryIdent).orElse(null);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||||
import cloud.commandframework.fabric.FabricServerCommandManager;
|
import cloud.commandframework.fabric.FabricServerCommandManager;
|
||||||
import cloud.commandframework.fabric.argument.ItemInputArgument;
|
import cloud.commandframework.fabric.argument.ItemInputArgument;
|
||||||
import cloud.commandframework.fabric.argument.NamedColorArgument;
|
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.ColumnPosArgument;
|
||||||
import cloud.commandframework.fabric.argument.server.MultipleEntitySelectorArgument;
|
import cloud.commandframework.fabric.argument.server.MultipleEntitySelectorArgument;
|
||||||
import cloud.commandframework.fabric.argument.server.MultiplePlayerSelectorArgument;
|
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.ChatFormatting;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.arguments.item.ItemInput;
|
import net.minecraft.commands.arguments.item.ItemInput;
|
||||||
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.network.chat.ClickEvent;
|
import net.minecraft.network.chat.ClickEvent;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.ComponentUtils;
|
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.network.chat.TextColor;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.level.ChunkPos;
|
import net.minecraft.world.level.ChunkPos;
|
||||||
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
public final class FabricExample implements ModInitializer {
|
public final class FabricExample implements ModInitializer {
|
||||||
|
|
@ -96,6 +99,27 @@ public final class FabricExample implements ModInitializer {
|
||||||
.withStyle(style -> style.withBold(true)), false);
|
.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 =
|
final CommandArgument<CommandSourceStack, MultiplePlayerSelector> playerSelector =
|
||||||
MultiplePlayerSelectorArgument.of("players");
|
MultiplePlayerSelectorArgument.of("players");
|
||||||
final CommandArgument<CommandSourceStack, ChatFormatting> textColor = NamedColorArgument.of("color");
|
final CommandArgument<CommandSourceStack, ChatFormatting> textColor = NamedColorArgument.of("color");
|
||||||
|
|
|
||||||
|
|
@ -47,10 +47,10 @@ versions:
|
||||||
velocityApi: 3.1.0
|
velocityApi: 3.1.0
|
||||||
spongeApi7: 7.3.0
|
spongeApi7: 7.3.0
|
||||||
jetbrainsAnnotations: 23.0.0
|
jetbrainsAnnotations: 23.0.0
|
||||||
fabricMinecraft: 1.19
|
fabricMinecraft: 1.19.3
|
||||||
fabricLoader: 0.14.7
|
fabricLoader: 0.14.11
|
||||||
fabricApi: 0.55.3+1.19
|
fabricApi: 0.68.1+1.19.3
|
||||||
fabricPermissionsApi: 0.1-SNAPSHOT
|
fabricPermissionsApi: 0.2-SNAPSHOT
|
||||||
|
|
||||||
# testing
|
# testing
|
||||||
jupiterEngine : 5.8.2
|
jupiterEngine : 5.8.2
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue