diff --git a/build.gradle b/build.gradle index 1ca987c..02f8e82 100644 --- a/build.gradle +++ b/build.gradle @@ -52,7 +52,7 @@ dependencies { mappings "org.quiltmc:quilt-mappings:${minecraft_version}+build.${quilt_mappings}:intermediary-v2" modImplementation "org.quiltmc:quilt-loader:${project.loader_version}" - modImplementation "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${quilted_fabric_api_version}" + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" modIncludeImplementation ("dev.onyxstudios.cardinal-components-api:cardinal-components-base:${cca_version}") { transitive = false } modIncludeImplementation ("dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${cca_version}") { transitive = false } diff --git a/gradle.properties b/gradle.properties index 2dee7cd..4c2b8ef 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ org.gradle.jvmargs=-Xmx3G archives_base_name = locki # Dependencies - quilted_fabric_api_version = 9.0.0-alpha.8+0.97.0-1.20.4 + fabric_api_version = 0.97.1+1.20.4 cca_version = 5.4.0 fpa_version=0.2-SNAPSHOT # V1.2.12 diff --git a/src/main/java/org/ladysnake/locki/Locki.java b/src/main/java/org/ladysnake/locki/Locki.java index 3c6be47..7bb6e71 100644 --- a/src/main/java/org/ladysnake/locki/Locki.java +++ b/src/main/java/org/ladysnake/locki/Locki.java @@ -21,6 +21,9 @@ import com.google.common.base.Preconditions; import com.mojang.brigadier.arguments.StringArgumentType; import me.lucko.fabric.api.permissions.v0.PermissionCheckEvent; +import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.command.v2.ArgumentTypeRegistry; +import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.fabricmc.fabric.api.util.TriState; import net.minecraft.command.argument.IdentifierArgumentType; import net.minecraft.command.argument.SingletonArgumentInfo; @@ -35,10 +38,6 @@ import org.ladysnake.locki.impl.InventoryLockArgumentType; import org.ladysnake.locki.impl.InventoryNodeArgumentType; import org.ladysnake.locki.impl.LockiCommand; -import org.quiltmc.loader.api.ModContainer; -import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; -import org.quiltmc.qsl.command.api.CommandRegistrationCallback; -import org.quiltmc.qsl.command.api.ServerArgumentType; import java.util.HashMap; import java.util.Map; @@ -153,15 +152,16 @@ public static Stream streamNodeNames() { } @Override - public void onInitialize(ModContainer mod) { + public void onInitialize() { + this.baseInit(); + ArgumentTypeRegistry.registerArgumentType(new Identifier("locki", "inventory_lock"), InventoryLockArgumentType.class, SingletonArgumentInfo.contextFree(InventoryLockArgumentType::inventoryLock)); + ArgumentTypeRegistry.registerArgumentType(new Identifier("locki", "inventory_node"), InventoryNodeArgumentType.class, SingletonArgumentInfo.contextFree(InventoryNodeArgumentType::inventoryNode)); + } + + void baseInit() { DefaultInventoryNodes.init(); ModdedInventoryNodes.init(); - if (mod != null) { // Unit testing - ServerArgumentType.register(new Identifier("locki", "inventory_lock"), InventoryLockArgumentType.class, SingletonArgumentInfo.contextFree(InventoryLockArgumentType::inventoryLock), t -> IdentifierArgumentType.identifier()); - ServerArgumentType.register(new Identifier("locki", "inventory_node"), InventoryNodeArgumentType.class, SingletonArgumentInfo.contextFree(InventoryNodeArgumentType::inventoryNode), t -> StringArgumentType.string()); - } - CommandRegistrationCallback.EVENT.register((dispatcher, ctx, dedicated) -> LockiCommand.register(dispatcher)); PermissionCheckEvent.EVENT.register((source, permission) -> { if (source instanceof ServerCommandSource && permission.startsWith("locki.access.")) { diff --git a/src/main/java/org/ladysnake/locki/impl/LockiClient.java b/src/main/java/org/ladysnake/locki/impl/LockiClient.java index 52a25f1..4f0f2e4 100644 --- a/src/main/java/org/ladysnake/locki/impl/LockiClient.java +++ b/src/main/java/org/ladysnake/locki/impl/LockiClient.java @@ -17,6 +17,7 @@ */ package org.ladysnake.locki.impl; +import net.fabricmc.api.ClientModInitializer; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.ingame.InventoryScreen; import net.minecraft.client.gui.screen.recipe_book.RecipeBookProvider; @@ -27,7 +28,6 @@ import org.ladysnake.locki.InventoryLockingChangeCallback; import org.ladysnake.locki.InventoryNode; import org.quiltmc.loader.api.ModContainer; -import org.quiltmc.qsl.base.api.entrypoint.client.ClientModInitializer; public class LockiClient implements ClientModInitializer { public static final Identifier LOCKED_SLOT_SPRITE = new Identifier("locki", "gui/locked_slot"); @@ -52,7 +52,7 @@ private static void updateCraftingBookVisibility(PlayerEntity player, InventoryN } @Override - public void onInitializeClient(ModContainer mod) { + public void onInitializeClient() { InventoryLockingChangeCallback.EVENT.register(LockiClient::updateCraftingBookVisibility); } } diff --git a/src/main/resources/quilt.mod.json b/src/main/resources/quilt.mod.json index 6a47ff2..e8dacaa 100644 --- a/src/main/resources/quilt.mod.json +++ b/src/main/resources/quilt.mod.json @@ -20,10 +20,10 @@ }, "intermediate_mappings": "net.fabricmc:intermediary", "entrypoints": { - "init": [ + "main": [ "org.ladysnake.locki.Locki" ], - "client_init": [ + "client": [ "org.ladysnake.locki.impl.LockiClient" ], "cardinal-components": [ diff --git a/src/test/java/org/ladysnake/locki/LockiTest.java b/src/test/java/org/ladysnake/locki/LockiTest.java index 01fc32f..892ff00 100644 --- a/src/test/java/org/ladysnake/locki/LockiTest.java +++ b/src/test/java/org/ladysnake/locki/LockiTest.java @@ -35,7 +35,7 @@ public class LockiTest { @BeforeAll public static void setUpGlobal() { - instance.onInitialize(null); + instance.baseInit(); } @BeforeEach diff --git a/src/testmod/java/org/ladysnake/lockii/Lockii.java b/src/testmod/java/org/ladysnake/lockii/Lockii.java index 950287e..069186e 100644 --- a/src/testmod/java/org/ladysnake/lockii/Lockii.java +++ b/src/testmod/java/org/ladysnake/lockii/Lockii.java @@ -17,12 +17,11 @@ */ package org.ladysnake.lockii; +import net.fabricmc.api.ModInitializer; import net.minecraft.item.Item; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; -import org.quiltmc.loader.api.ModContainer; -import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; public final class Lockii implements ModInitializer { public static Identifier id(String path) { @@ -30,7 +29,7 @@ public static Identifier id(String path) { } @Override - public void onInitialize(ModContainer mod) { + public void onInitialize() { Registry.register(Registries.ITEM, id("inventory_lock"), new InventoryLockItem(new Item.Settings())); } } diff --git a/src/testmod/java/org/ladysnake/lockii/tests/LockiTestSuite.java b/src/testmod/java/org/ladysnake/lockii/tests/LockiTestSuite.java index f51b91f..9e05906 100644 --- a/src/testmod/java/org/ladysnake/lockii/tests/LockiTestSuite.java +++ b/src/testmod/java/org/ladysnake/lockii/tests/LockiTestSuite.java @@ -18,6 +18,7 @@ package org.ladysnake.lockii.tests; import me.lucko.fabric.api.permissions.v0.Permissions; +import net.fabricmc.fabric.api.gametest.v1.FabricGameTest; import net.minecraft.entity.EntityType; import net.minecraft.entity.EquipmentSlot; import net.minecraft.item.ItemStack; @@ -33,12 +34,9 @@ import org.ladysnake.locki.Locki; import org.ladysnake.locki.impl.LockiComponents; import org.ladysnake.lockii.Lockii; -import org.quiltmc.qsl.testing.api.game.QuiltGameTest; -import org.quiltmc.qsl.testing.api.game.QuiltTestContext; - import static org.ladysnake.elmendorf.ByteBufChecker.any; -public class LockiTestSuite implements QuiltGameTest { +public class LockiTestSuite implements FabricGameTest { public static final InventoryLock lock = Locki.registerLock(Lockii.id("test_suite")); @GameTest(structureName = EMPTY_STRUCTURE) @@ -71,7 +69,7 @@ public void checkPermission(TestContext ctx) { } @GameTest(structureName = EMPTY_STRUCTURE) - public void lockingPreventsItemPickup(QuiltTestContext ctx) { + public void lockingPreventsItemPickup(TestContext ctx) { ServerPlayerEntity player = ctx.spawnServerPlayer(1, 0, 1); player.getInventory().addLock(lock, DefaultInventoryNodes.INVENTORY); ctx.spawnItemEntity(Items.DIAMOND, 1, 1, 2); @@ -82,7 +80,7 @@ public void lockingPreventsItemPickup(QuiltTestContext ctx) { } @GameTest(structureName = EMPTY_STRUCTURE) - public void lockingPreventsDropFromMainHand(QuiltTestContext ctx) { + public void lockingPreventsDropFromMainHand(TestContext ctx) { ServerPlayerEntity player = ctx.spawnServerPlayer(1, 0, 1); player.equipStack(EquipmentSlot.MAINHAND, new ItemStack(Items.ENCHANTED_GOLDEN_APPLE)); player.getInventory().addLock(lock, DefaultInventoryNodes.MAIN_HAND); @@ -101,7 +99,7 @@ public void lockingPreventsDropFromMainHand(QuiltTestContext ctx) { } @GameTest(structureName = EMPTY_STRUCTURE) - public void itemPickupWorks(QuiltTestContext ctx) { + public void itemPickupWorks(TestContext ctx) { ServerPlayerEntity player = ctx.spawnServerPlayer(1, 0, 1); ctx.spawnItemEntity(Items.REDSTONE, 1, 1, 1); ctx.expectEntity(EntityType.ITEM); diff --git a/src/testmod/resources/quilt.mod.json b/src/testmod/resources/quilt.mod.json index 4c17f1b..effced8 100644 --- a/src/testmod/resources/quilt.mod.json +++ b/src/testmod/resources/quilt.mod.json @@ -19,10 +19,10 @@ } }, "entrypoints": { - "init": [ + "main": [ "org.ladysnake.lockii.Lockii" ], - "quilt:game_test": [ + "fabric-gametest": [ "org.ladysnake.lockii.tests.LockiTestSuite" ] },