From acba09d4b9c8356e559fda9aca55f77903ec0859 Mon Sep 17 00:00:00 2001 From: Ennui Langeweile <85590273+EnnuiL@users.noreply.github.com> Date: Tue, 9 Jul 2024 22:48:18 -0300 Subject: [PATCH 1/3] Backport Recipe Remainder bridge --- build.gradle | 2 +- .../fabric/api/item/v1/FabricItemStack.java | 3 ++- .../impl/item/RecipeRemainderHandler.java | 24 ------------------- .../RecipeRemainderLogicHandlerMixin.java} | 20 +++++++--------- .../src/main/resources/quilt.mod.json | 3 --- .../quilted_fabric_item_api_v1.mixins.json | 4 ++-- gradle.properties | 4 ++-- 7 files changed, 16 insertions(+), 44 deletions(-) delete mode 100644 fabric-item-api-v1/src/main/java/net/fabricmc/fabric/impl/item/RecipeRemainderHandler.java rename fabric-item-api-v1/src/main/java/net/fabricmc/fabric/{impl/qsl/item/v1/QuiltItemCompatMod.java => mixin/item/RecipeRemainderLogicHandlerMixin.java} (51%) diff --git a/build.gradle b/build.gradle index d73cbff9df..43ad866d45 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { id "idea" id "maven-publish" id "jacoco" - id "org.quiltmc.loom" version "1.6.8" apply false + id "org.quiltmc.loom" version "1.7.3" apply false id "org.quiltmc.gradle.licenser" version "2.0.1" id "com.diffplug.spotless" version "6.20.0" id "net.kyori.indra.git" version "3.1.3" diff --git a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/FabricItemStack.java b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/FabricItemStack.java index cca1008766..49e502e287 100644 --- a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/FabricItemStack.java +++ b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/FabricItemStack.java @@ -17,6 +17,7 @@ package net.fabricmc.fabric.api.item.v1; +import org.quiltmc.qsl.item.setting.api.RecipeRemainderLocation; import org.quiltmc.qsl.item.setting.api.RecipeRemainderLogicHandler; import net.minecraft.item.Item; @@ -37,6 +38,6 @@ public interface FabricItemStack { * @return the leftover item */ default ItemStack getRecipeRemainder() { - return RecipeRemainderLogicHandler.getRemainder((ItemStack) (Object) this, null); + return RecipeRemainderLogicHandler.getRemainder((ItemStack) (Object) this, null, RecipeRemainderLocation.DEFAULT_LOCATIONS); } } diff --git a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/impl/item/RecipeRemainderHandler.java b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/impl/item/RecipeRemainderHandler.java deleted file mode 100644 index f2f13be5e3..0000000000 --- a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/impl/item/RecipeRemainderHandler.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2016, 2017, 2018, 2019 FabricMC - * Copyright 2022 The Quilt Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.impl.item; - -import net.minecraft.item.ItemStack; - -public class RecipeRemainderHandler { - public static final ThreadLocal REMAINDER_STACK = new ThreadLocal<>(); -} diff --git a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/impl/qsl/item/v1/QuiltItemCompatMod.java b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/RecipeRemainderLogicHandlerMixin.java similarity index 51% rename from fabric-item-api-v1/src/main/java/net/fabricmc/fabric/impl/qsl/item/v1/QuiltItemCompatMod.java rename to fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/RecipeRemainderLogicHandlerMixin.java index 6d6abb0ef3..0c93b36571 100644 --- a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/impl/qsl/item/v1/QuiltItemCompatMod.java +++ b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/RecipeRemainderLogicHandlerMixin.java @@ -14,19 +14,17 @@ * limitations under the License. */ -package net.fabricmc.fabric.impl.qsl.item.v1; +package net.fabricmc.fabric.mixin.item; -import org.quiltmc.loader.api.ModContainer; -import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; import org.quiltmc.qsl.item.setting.api.RecipeRemainderProvider; -import org.quiltmc.qsl.item.setting.impl.CustomItemSettingImpl; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; -import net.fabricmc.fabric.mixin.item.CustomItemSettingImplAccessor; - -public class QuiltItemCompatMod implements ModInitializer { - @Override - public void onInitialize(ModContainer mod) { - var accessor = ((CustomItemSettingImplAccessor) CustomItemSettingImpl.RECIPE_REMAINDER_PROVIDER); - accessor.setDefaultValue(() -> (original, recipe) -> original.getItem().getRecipeRemainder(original)); +@Mixin(org.quiltmc.qsl.item.setting.api.RecipeRemainderLogicHandler.class) +public interface RecipeRemainderLogicHandlerMixin { + @ModifyVariable(method = "getRemainder", index = 4, at = @At(value = "INVOKE", target = "Ljava/util/Set;contains(Ljava/lang/Object;)Z")) + private static RecipeRemainderProvider setDefaultProvider(RecipeRemainderProvider value) { + return (original, recipe) -> original.getItem().getRecipeRemainder(original); } } diff --git a/fabric-item-api-v1/src/main/resources/quilt.mod.json b/fabric-item-api-v1/src/main/resources/quilt.mod.json index fbed398341..6e16a8ce86 100644 --- a/fabric-item-api-v1/src/main/resources/quilt.mod.json +++ b/fabric-item-api-v1/src/main/resources/quilt.mod.json @@ -20,9 +20,6 @@ "icon": "assets/quilted_fabric_item_api_v1/icon.png" }, "intermediate_mappings": "net.fabricmc:intermediary", - "entrypoints": { - "init": "net.fabricmc.fabric.impl.qsl.item.v1.QuiltItemCompatMod" - }, "depends": [ "quilt_loader", "quilted_fabric_api_base", diff --git a/fabric-item-api-v1/src/main/resources/quilted_fabric_item_api_v1.mixins.json b/fabric-item-api-v1/src/main/resources/quilted_fabric_item_api_v1.mixins.json index 01a92fd01c..f3177f112c 100644 --- a/fabric-item-api-v1/src/main/resources/quilted_fabric_item_api_v1.mixins.json +++ b/fabric-item-api-v1/src/main/resources/quilted_fabric_item_api_v1.mixins.json @@ -3,9 +3,9 @@ "package": "net.fabricmc.fabric.mixin.item", "compatibilityLevel": "JAVA_17", "mixins": [ - "CustomItemSettingImplAccessor", "ItemMixin", - "ItemStackMixin" + "ItemStackMixin", + "RecipeRemainderLogicHandlerMixin" ], "injectors": { "defaultRequire": 1 diff --git a/gradle.properties b/gradle.properties index 5e7ceeacca..d71f0a11d1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,12 +3,12 @@ org.gradle.parallel=true fabric.loom.multiProjectOptimisation=true archivesBaseName=quilted_fabric_api -version=7.5.0 +version=7.6.0 upstream_version=0.92.2 minecraft_version=1.20.1 yarn_version=+build.1 loader_version=0.26.0 -qsl_version=6.1.2+1.20.1 +qsl_version=6.2.0+1.20.1 installer_version=0.11.1 prerelease=false From be63b64c338a5ea33cd18551466d93f652f919e6 Mon Sep 17 00:00:00 2001 From: Ennui Langeweile <85590273+EnnuiL@users.noreply.github.com> Date: Tue, 9 Jul 2024 23:24:27 -0300 Subject: [PATCH 2/3] Try --warning-mode=fail Everything should work now --- .github/workflows/build.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4be691fdc2..b5cd245a5d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,8 +14,7 @@ jobs: with: fetch-depth: 0 - uses: gradle/wrapper-validation-action@v1 - # TODO - Go back to "--warning-mode=fail" - - run: ./gradlew check build publishToMavenLocal --stacktrace --warning-mode=all -Porg.gradle.parallel.threads=4 + - run: ./gradlew check build publishToMavenLocal --stacktrace --warning-mode=fail -Porg.gradle.parallel.threads=4 - uses: Juuxel/publish-checkstyle-report@v1 if: ${{ failure() }} with: @@ -53,8 +52,7 @@ jobs: - name: Run Auto test Client uses: modmuss50/xvfb-action@v1 with: - # TODO - Go back to "--warning-mode=fail" - run: ./gradlew runProductionAutoTestClient --stacktrace --warning-mode=all + run: ./gradlew runProductionAutoTestClient --stacktrace --warning-mode=fail - uses: actions/upload-artifact@v3 if: always() with: From fff064ebfea25434141f3c8df4fb4554f8dcfc00 Mon Sep 17 00:00:00 2001 From: Ennui Langeweile <85590273+EnnuiL@users.noreply.github.com> Date: Tue, 9 Jul 2024 23:39:31 -0300 Subject: [PATCH 3/3] Delete unused mixin --- .../item/CustomItemSettingImplAccessor.java | 30 ------------------- 1 file changed, 30 deletions(-) delete mode 100644 fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/CustomItemSettingImplAccessor.java diff --git a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/CustomItemSettingImplAccessor.java b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/CustomItemSettingImplAccessor.java deleted file mode 100644 index f3db01b72f..0000000000 --- a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/CustomItemSettingImplAccessor.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2022 The Quilt Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.mixin.item; - -import java.util.function.Supplier; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(org.quiltmc.qsl.item.setting.impl.CustomItemSettingImpl.class) -public interface CustomItemSettingImplAccessor { - @Mutable - @Accessor(remap = false) - void setDefaultValue(Supplier defaultValue); -}