From 3d229ab0b0914ec5433ed349ca4a09f074c02f01 Mon Sep 17 00:00:00 2001 From: Misode Date: Thu, 21 Mar 2024 03:45:24 +0100 Subject: [PATCH] 24w12a --- gradle.properties | 6 ++--- .../packtest/commands/AssertCommand.java | 23 +++++++++---------- src/main/resources/fabric.mod.json | 2 +- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/gradle.properties b/gradle.properties index 9cb68d9..81a2e3a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,13 +4,13 @@ org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_version=24w09a +minecraft_version=24w12a loader_version=0.15.7 # Mod Properties -mod_version=1.7.0-beta1 +mod_version=1.7.0-beta2 maven_group=io.github.misode archives_base_name=packtest # Dependencies -fabric_version=0.96.6+1.20.5 +fabric_version=0.96.12+1.20.5 diff --git a/src/main/java/io/github/misode/packtest/commands/AssertCommand.java b/src/main/java/io/github/misode/packtest/commands/AssertCommand.java index b146299..2fb0a2d 100644 --- a/src/main/java/io/github/misode/packtest/commands/AssertCommand.java +++ b/src/main/java/io/github/misode/packtest/commands/AssertCommand.java @@ -23,18 +23,18 @@ import net.minecraft.commands.execution.ExecutionControl; import net.minecraft.commands.execution.Frame; import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.nbt.Tag; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.ReloadableServerRegistries; import net.minecraft.server.commands.data.DataCommands; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.block.state.pattern.BlockInWorld; import net.minecraft.world.level.storage.loot.LootContext; -import net.minecraft.world.level.storage.loot.LootDataManager; -import net.minecraft.world.level.storage.loot.LootDataType; import net.minecraft.world.level.storage.loot.LootParams; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; @@ -62,8 +62,8 @@ public class AssertCommand { Component.literal("Not inside a test") ); private static final SuggestionProvider SUGGEST_PREDICATE = (ctx, suggestions) -> { - LootDataManager lootData = ctx.getSource().getServer().getLootData(); - return SharedSuggestionProvider.suggestResource(lootData.getKeys(LootDataType.PREDICATE), suggestions); + ReloadableServerRegistries.Holder registries = ctx.getSource().getServer().reloadableRegistries(); + return SharedSuggestionProvider.suggestResource(registries.getKeys(Registries.PREDICATE), suggestions); }; public static void register(CommandDispatcher dispatcher, CommandBuildContext buildContext) { @@ -89,7 +89,7 @@ public static void addConditions(LiteralArgumentBuilder buil .then(literal("inside") .executes(expect.apply(AssertCommand::assertEntityInside))))) .then(literal("predicate") - .then(argument("predicate", ResourceLocationArgument.id()) + .then(argument("predicate", ResourceOrIdArgument.lootPredicate(buildContext)) .suggests(SUGGEST_PREDICATE) .executes(expect.apply(AssertCommand::assertPredicate)))) .then(literal("score") @@ -161,18 +161,17 @@ private static AssertResult assertEntityInside(CommandContext ctx) throws CommandSyntaxException { - ResourceLocation id = ctx.getArgument("predicate", ResourceLocation.class); - LootItemCondition predicate = ResourceLocationArgument.getPredicate(ctx, "predicate"); + private static AssertResult assertPredicate(CommandContext ctx) { + Holder predicate = ResourceOrIdArgument.getLootPredicate(ctx, "predicate"); CommandSourceStack sourceStack = ctx.getSource(); LootParams lootParams = new LootParams.Builder(sourceStack.getLevel()) .withParameter(LootContextParams.ORIGIN, sourceStack.getPosition()) .withOptionalParameter(LootContextParams.THIS_ENTITY, sourceStack.getEntity()) .create(LootContextParamSets.COMMAND); LootContext lootContext = new LootContext.Builder(lootParams).create(Optional.empty()); - lootContext.pushVisitedElement(LootContext.createVisitedEntry(predicate)); - String expected = "predicate " + id + " to pass"; - if (predicate.test(lootContext)) { + lootContext.pushVisitedElement(LootContext.createVisitedEntry(predicate.value())); + String expected = "predicate " + predicate.getRegisteredName() + " to pass"; + if (predicate.value().test(lootContext)) { return ok(expected); } return err(expected); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 3946072..fc9638e 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -24,7 +24,7 @@ "accessWidener": "packtest.accesswidener", "depends": { "fabricloader": ">=0.15.0", - "minecraft": "~1.20.4", + "minecraft": ">=1.20.5-", "java": ">=17", "fabric-api": "*" }