From 4ee0bc6089a4f5838095febee8185b83ca2b89c7 Mon Sep 17 00:00:00 2001 From: Shnupbups Date: Sun, 22 Oct 2023 23:41:51 +1100 Subject: [PATCH 01/11] Fix FabricBlockSettings copyOf missing settings (#3373) Fixes FabricBlockSettings' copyOf method missing several new settings introduced as a result of the removal of Materials. Specifically, burnable, liquid, forceNotSolid, forceSolid, pistonBehavior, instrument, and replaceable. These are all copied by the vanilla `BlockSettings.copy` as well. The emissiveLightingPredicate is also now copied in vanilla, so I moved the copy of that to reflect that change. (cherry picked from commit 2ff98d3bac2f2252b5c56815aa0a35ede9ee5540) --- .../builder/v1/block/FabricBlockSettings.java | 9 ++++- .../AbstractBlockSettingsAccessor.java | 38 +++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/block/FabricBlockSettings.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/block/FabricBlockSettings.java index 588846c563..5d90b75844 100644 --- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/block/FabricBlockSettings.java +++ b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/block/FabricBlockSettings.java @@ -69,10 +69,18 @@ protected FabricBlockSettings(AbstractBlock.Settings settings) { thisAccessor.setDynamicBounds(otherAccessor.getDynamicBounds()); thisAccessor.setOpaque(otherAccessor.getOpaque()); thisAccessor.setIsAir(otherAccessor.getIsAir()); + thisAccessor.setBurnable(otherAccessor.getBurnable()); + thisAccessor.setLiquid(otherAccessor.getLiquid()); + thisAccessor.setForceNotSolid(otherAccessor.getForceNotSolid()); + thisAccessor.setForceSolid(otherAccessor.getForceSolid()); + this.pistonBehavior(otherAccessor.getPistonBehavior()); thisAccessor.setToolRequired(otherAccessor.isToolRequired()); thisAccessor.setOffsetter(otherAccessor.getOffsetter()); thisAccessor.setBlockBreakParticles(otherAccessor.getBlockBreakParticles()); thisAccessor.setRequiredFeatures(otherAccessor.getRequiredFeatures()); + this.emissiveLighting(otherAccessor.getEmissiveLightingPredicate()); + this.instrument(otherAccessor.getInstrument()); + thisAccessor.setReplaceable(otherAccessor.getReplaceable()); // Not copied in vanilla: field definition order this.jumpVelocityMultiplier(otherAccessor.getJumpVelocityMultiplier()); @@ -82,7 +90,6 @@ protected FabricBlockSettings(AbstractBlock.Settings settings) { this.suffocates(otherAccessor.getSuffocationPredicate()); this.blockVision(otherAccessor.getBlockVisionPredicate()); this.postProcess(otherAccessor.getPostProcessPredicate()); - this.emissiveLighting(otherAccessor.getEmissiveLightingPredicate()); } public static FabricBlockSettings create() { diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsAccessor.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsAccessor.java index 31a9afb1d1..1c4cef0eaf 100644 --- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsAccessor.java +++ b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsAccessor.java @@ -26,6 +26,8 @@ import net.minecraft.block.AbstractBlock; import net.minecraft.block.BlockState; import net.minecraft.block.MapColor; +import net.minecraft.block.enums.Instrument; +import net.minecraft.block.piston.PistonBehavior; import net.minecraft.entity.EntityType; import net.minecraft.resource.featuretoggle.FeatureSet; import net.minecraft.sound.BlockSoundGroup; @@ -106,6 +108,27 @@ public interface AbstractBlockSettingsAccessor { @Accessor FeatureSet getRequiredFeatures(); + @Accessor + boolean getBurnable(); + + @Accessor + boolean getLiquid(); + + @Accessor + boolean getForceNotSolid(); + + @Accessor + boolean getForceSolid(); + + @Accessor + PistonBehavior getPistonBehavior(); + + @Accessor + Instrument getInstrument(); + + @Accessor + boolean getReplaceable(); + /* SETTERS */ @Accessor void setCollidable(boolean collidable); @@ -139,4 +162,19 @@ public interface AbstractBlockSettingsAccessor { @Accessor void setOffsetter(Optional offsetter); + + @Accessor + void setBurnable(boolean burnable); + + @Accessor + void setLiquid(boolean liquid); + + @Accessor + void setForceNotSolid(boolean forceNotSolid); + + @Accessor + void setForceSolid(boolean forceSolid); + + @Accessor + void setReplaceable(boolean replaceable); } From 050aeb47e85d2603bba47775ca20701e3f1aab35 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sun, 22 Oct 2023 14:46:00 +0100 Subject: [PATCH 02/11] Bump version --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index fc42544804..28d1b6dd65 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx2560M org.gradle.parallel=true fabric.loom.multiProjectOptimisation=true -version=0.90.0 +version=0.90.4 minecraft_version=1.20.1 yarn_version=+build.1 loader_version=0.14.21 @@ -43,7 +43,7 @@ fabric-model-loading-api-v1-version=1.0.2 fabric-models-v0-version=0.4.1 fabric-networking-api-v1-version=1.3.10 fabric-networking-v0-version=0.3.50 -fabric-object-builder-api-v1-version=11.1.1 +fabric-object-builder-api-v1-version=11.1.2 fabric-particles-v1-version=1.1.1 fabric-recipe-api-v1-version=1.0.20 fabric-registry-sync-v0-version=2.3.2 From ae9f657a88fd51bcac9f787c601a011f3a4d9ab0 Mon Sep 17 00:00:00 2001 From: Estecka Date: Thu, 2 Nov 2023 11:28:47 +0100 Subject: [PATCH 03/11] Fix Doubles not being editable in the game-rule menu (#3397) * Fix double gamerules rules not being editable in menu * Updated `validate`'s javadoc (cherry picked from commit a44e16a6dc3795db133aee1806ef5455a79ed35a) --- .../fabricmc/fabric/api/gamerule/v1/rule/DoubleRule.java | 7 ++++++- .../fabric/api/gamerule/v1/rule/ValidateableRule.java | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/rule/DoubleRule.java b/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/rule/DoubleRule.java index 8890715ec1..1d89762163 100644 --- a/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/rule/DoubleRule.java +++ b/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/rule/DoubleRule.java @@ -113,7 +113,12 @@ public boolean validate(String value) { try { final double d = Double.parseDouble(value); - return this.inBounds(d); + if (!this.inBounds(d)) { + return false; + } + + this.value = d; + return true; } catch (NumberFormatException ignored) { return false; } diff --git a/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/rule/ValidateableRule.java b/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/rule/ValidateableRule.java index bf2fda2f73..6f7284de99 100644 --- a/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/rule/ValidateableRule.java +++ b/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/rule/ValidateableRule.java @@ -23,9 +23,10 @@ public interface ValidateableRule { /** * Validates if a rule can accept the input. + * If valid, the input will be set as the rule's value. * * @param value the value to validate - * @return true if the value can be accepted. + * @return true if the value was accepted. */ boolean validate(String value); } From 1bc31aeb6077e0a03de6d46f244a5456931f52e9 Mon Sep 17 00:00:00 2001 From: Technici4n <13494793+Technici4n@users.noreply.github.com> Date: Thu, 2 Nov 2023 11:35:06 +0100 Subject: [PATCH 04/11] Fix log spam with multiple calls to `combinedItemApiProvider` (#3387) (cherry picked from commit d6f4a34e15e1d1f6756767a53c4fd9487a5cfc5b) (cherry picked from commit bb1ee60efbcb38e6649376c5f5fe5a1a66dff0ad) --- .../fabric/impl/transfer/fluid/CombinedProvidersImpl.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/fluid/CombinedProvidersImpl.java b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/fluid/CombinedProvidersImpl.java index 54ca2481da..0231d2007a 100644 --- a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/fluid/CombinedProvidersImpl.java +++ b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/fluid/CombinedProvidersImpl.java @@ -82,10 +82,14 @@ public Storage find(ItemStack itemStack, ContainerItemContext cont } public static Event getOrCreateItemEvent(Item item) { - // register here is thread-safe, so the query below will return a valid provider (possibly one registered before or from another thread). - FluidStorage.ITEM.registerForItems(new Provider(), item); ItemApiLookup.ItemApiProvider, ContainerItemContext> existingProvider = FluidStorage.ITEM.getProvider(item); + if (existingProvider == null) { + FluidStorage.ITEM.registerForItems(new Provider(), item); + // The provider might not be new Provider() if a concurrent registration happened, re-query. + existingProvider = FluidStorage.ITEM.getProvider(item); + } + if (existingProvider instanceof Provider registeredProvider) { return registeredProvider.event; } else { From cff34500a0ad9b8e0b084b32b7e1e677692957eb Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Thu, 2 Nov 2023 12:49:49 +0000 Subject: [PATCH 05/11] Bump version --- gradle.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 28d1b6dd65..ddce05e96c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx2560M org.gradle.parallel=true fabric.loom.multiProjectOptimisation=true -version=0.90.4 +version=0.90.7 minecraft_version=1.20.1 yarn_version=+build.1 loader_version=0.14.21 @@ -28,7 +28,7 @@ fabric-dimensions-v1-version=2.1.53 fabric-entity-events-v1-version=1.5.22 fabric-events-interaction-v0-version=0.6.1 fabric-events-lifecycle-v0-version=0.2.62 -fabric-game-rule-api-v1-version=1.0.38 +fabric-game-rule-api-v1-version=1.0.39 fabric-gametest-api-v1-version=1.2.12 fabric-item-api-v1-version=2.1.27 fabric-item-group-api-v1-version=4.0.11 @@ -59,7 +59,7 @@ fabric-resource-loader-v0-version=0.11.9 fabric-screen-api-v1-version=2.0.7 fabric-screen-handler-api-v1-version=1.3.29 fabric-sound-api-v1-version=1.0.12 -fabric-transfer-api-v1-version=3.3.1 +fabric-transfer-api-v1-version=3.3.2 fabric-transitive-access-wideners-v1-version=4.3.0 fabric-convention-tags-v1-version=1.5.4 fabric-client-tags-api-v1-version=1.1.1 From c81d26314dfb6a242993386f6182e49b44c5ad29 Mon Sep 17 00:00:00 2001 From: Technici4n <13494793+technici4n@users.noreply.github.com> Date: Sun, 26 Nov 2023 13:00:57 +0000 Subject: [PATCH 06/11] Fix empty storage iterator returning views that become empty during iteration (#3423) (cherry picked from commit aaf9c9690c0f6511924af65d83ebaff56ec540b2) (cherry picked from commit 9ab11d529d27f9847c218058066d69d77cd44380) --- .../api/transfer/v1/storage/Storage.java | 3 +- .../fabric/impl/transfer/TransferApiImpl.java | 38 ------------------- .../transfer/unittests/BaseStorageTests.java | 25 ++++++++++++ 3 files changed, 27 insertions(+), 39 deletions(-) diff --git a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/storage/Storage.java b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/storage/Storage.java index 7398140fb0..5ab49372a0 100644 --- a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/storage/Storage.java +++ b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/api/transfer/v1/storage/Storage.java @@ -18,6 +18,7 @@ import java.util.Iterator; +import com.google.common.collect.Iterators; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; @@ -152,7 +153,7 @@ default boolean supportsExtraction() { * @return An iterator over the non-empty views of this storage. Calling remove on the iterator is not allowed. */ default Iterator> nonEmptyIterator() { - return TransferApiImpl.filterEmptyViews(iterator()); + return Iterators.filter(iterator(), view -> view.getAmount() > 0 && !view.isResourceBlank()); } /** diff --git a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/TransferApiImpl.java b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/TransferApiImpl.java index 7593228aef..9e588e42ae 100644 --- a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/TransferApiImpl.java +++ b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/TransferApiImpl.java @@ -94,44 +94,6 @@ public T next() { }; } - public static Iterator> filterEmptyViews(Iterator> iterator) { - return new Iterator<>() { - StorageView next; - - { - findNext(); - } - - private void findNext() { - while (iterator.hasNext()) { - next = iterator.next(); - - if (next.getAmount() > 0 && !next.isResourceBlank()) { - return; - } - } - - next = null; - } - - @Override - public boolean hasNext() { - return next != null; - } - - @Override - public StorageView next() { - if (!hasNext()) { - throw new NoSuchElementException(); - } - - StorageView ret = next; - findNext(); - return ret; - } - }; - } - public static List> makeListView(SlottedStorage storage) { return new AbstractList<>() { @Override diff --git a/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/unittests/BaseStorageTests.java b/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/unittests/BaseStorageTests.java index d8f9b22ac0..1f39a034f0 100644 --- a/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/unittests/BaseStorageTests.java +++ b/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/unittests/BaseStorageTests.java @@ -19,11 +19,15 @@ import static net.fabricmc.fabric.api.transfer.v1.fluid.FluidConstants.BUCKET; import static net.fabricmc.fabric.test.transfer.unittests.TestUtil.assertEquals; +import java.util.Iterator; + import net.minecraft.fluid.Fluids; import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant; +import net.fabricmc.fabric.api.transfer.v1.fluid.base.SingleFluidStorage; import net.fabricmc.fabric.api.transfer.v1.storage.Storage; import net.fabricmc.fabric.api.transfer.v1.storage.StorageUtil; +import net.fabricmc.fabric.api.transfer.v1.storage.StorageView; import net.fabricmc.fabric.api.transfer.v1.storage.base.FilteringStorage; import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleVariantStorage; import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction; @@ -31,6 +35,7 @@ public class BaseStorageTests { public static void run() { testFilteringStorage(); + testNonEmptyIteratorWithModifiedView(); } private static void testFilteringStorage() { @@ -92,4 +97,24 @@ protected boolean canInsert(FluidVariant resource) { assertEquals(BUCKET, StorageUtil.simulateExtract(storage, lava, BUCKET, null)); } + + /** + * Regression test for + * {@code nonEmptyIterator} not handling views that become empty during iteration correctly. + */ + private static void testNonEmptyIteratorWithModifiedView() { + SingleVariantStorage storage = SingleFluidStorage.withFixedCapacity(BUCKET, () -> { }); + storage.variant = FluidVariant.of(Fluids.WATER); + + Iterator> iterator = storage.nonEmptyIterator(); + storage.amount = BUCKET; + // Iterator should have a next element now + assertEquals(true, iterator.hasNext()); + assertEquals(storage, iterator.next()); + + iterator = storage.nonEmptyIterator(); + storage.amount = 0; + // Iterator should not have a next element... + assertEquals(false, iterator.hasNext()); + } } From 29de845de0742f49fee78be582cef05aafebe108 Mon Sep 17 00:00:00 2001 From: modmuss Date: Sun, 26 Nov 2023 13:00:48 +0000 Subject: [PATCH 07/11] Fix registry resource conditions on loot tables. (#3432) * Fix registry resource conditions on loot tables. * assert we dont already have the DRM set on this thread. * Use a sync map (cherry picked from commit de5c6cca0ae7d8b5238c4a89f0409a69fd352bec) (cherry picked from commit 239dafd8f96d50735e1b99f51e80ba8c1a13a17f) --- .../resource/conditions/LootManagerMixin.java | 32 +++++++++++++++++++ ...ric-resource-conditions-api-v1.mixins.json | 5 ++- .../conditions/ConditionalResourcesTest.java | 15 +++++++++ .../loot_tables/blocks/loaded.json | 29 +++++++++++++++++ .../loot_tables/blocks/not_loaded.json | 29 +++++++++++++++++ 5 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 fabric-resource-conditions-api-v1/src/testmod/resources/data/fabric-resource-conditions-api-v1-testmod/loot_tables/blocks/loaded.json create mode 100644 fabric-resource-conditions-api-v1/src/testmod/resources/data/fabric-resource-conditions-api-v1-testmod/loot_tables/blocks/not_loaded.json diff --git a/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/mixin/resource/conditions/LootManagerMixin.java b/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/mixin/resource/conditions/LootManagerMixin.java index fedf3b21bb..d265f659ad 100644 --- a/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/mixin/resource/conditions/LootManagerMixin.java +++ b/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/mixin/resource/conditions/LootManagerMixin.java @@ -16,17 +16,27 @@ package net.fabricmc.fabric.mixin.resource.conditions; +import java.util.Collections; +import java.util.IdentityHashMap; import java.util.Map; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import net.minecraft.loot.LootDataType; import net.minecraft.loot.LootManager; +import net.minecraft.registry.DynamicRegistryManager; +import net.minecraft.resource.ResourceManager; import net.minecraft.util.Identifier; import net.fabricmc.fabric.api.resource.conditions.v1.ResourceConditions; @@ -37,6 +47,22 @@ */ @Mixin(LootManager.class) public class LootManagerMixin { + // Keep track of the DynamicRegistryManager instance by assgining it to the map that is passed to the async runnable. + @Unique + private static final Map dynamicRegistryManagerMap = Collections.synchronizedMap(new IdentityHashMap<>()); + + @Inject(method = "load", at = @At(value = "INVOKE", target = "Ljava/util/concurrent/CompletableFuture;runAsync(Ljava/lang/Runnable;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"), locals = LocalCapture.CAPTURE_FAILHARD) + private static void load(LootDataType type, ResourceManager resourceManager, Executor executor, Map, Map> results, CallbackInfoReturnable> cir, Map map) { + dynamicRegistryManagerMap.put(map, ResourceConditionsImpl.CURRENT_REGISTRIES.get()); + } + + // runAsync Runnable in load method + @Inject(method = "method_51189", at = @At("HEAD")) + private static void runAsync(ResourceManager resourceManager, LootDataType lootDataType, Map map, CallbackInfo ci) { + assert ResourceConditionsImpl.CURRENT_REGISTRIES.get() == null; + ResourceConditionsImpl.CURRENT_REGISTRIES.set(Objects.requireNonNull(dynamicRegistryManagerMap.remove(map))); + } + // forEach in load method @Inject(method = "method_51195", at = @At("HEAD"), cancellable = true) private static void applyResourceConditions(LootDataType lootDataType, Map map, Identifier id, JsonElement json, CallbackInfo ci) { @@ -57,4 +83,10 @@ private static void applyResourceConditions(LootDataType lootDataType, Map map, } } } + + // runAsync Runnable in load method + @Inject(method = "method_51189", at = @At("RETURN")) + private static void runAsyncEnd(ResourceManager resourceManager, LootDataType lootDataType, Map map, CallbackInfo ci) { + ResourceConditionsImpl.CURRENT_REGISTRIES.remove(); + } } diff --git a/fabric-resource-conditions-api-v1/src/main/resources/fabric-resource-conditions-api-v1.mixins.json b/fabric-resource-conditions-api-v1/src/main/resources/fabric-resource-conditions-api-v1.mixins.json index 04480258f1..853a3694ac 100644 --- a/fabric-resource-conditions-api-v1/src/main/resources/fabric-resource-conditions-api-v1.mixins.json +++ b/fabric-resource-conditions-api-v1/src/main/resources/fabric-resource-conditions-api-v1.mixins.json @@ -9,5 +9,8 @@ "LootManagerMixin", "SinglePreparationResourceReloaderMixin", "TagManagerLoaderMixin" - ] + ], + "injectors": { + "defaultRequire": 1 + } } diff --git a/fabric-resource-conditions-api-v1/src/testmod/java/net/fabricmc/fabric/test/resource/conditions/ConditionalResourcesTest.java b/fabric-resource-conditions-api-v1/src/testmod/java/net/fabricmc/fabric/test/resource/conditions/ConditionalResourcesTest.java index d86924d2fc..3e69478138 100644 --- a/fabric-resource-conditions-api-v1/src/testmod/java/net/fabricmc/fabric/test/resource/conditions/ConditionalResourcesTest.java +++ b/fabric-resource-conditions-api-v1/src/testmod/java/net/fabricmc/fabric/test/resource/conditions/ConditionalResourcesTest.java @@ -87,4 +87,19 @@ public void conditionalPredicates(TestContext context) { context.complete(); } + + @GameTest(templateName = FabricGameTest.EMPTY_STRUCTURE) + public void conditionalLootTables(TestContext context) { + LootManager manager = context.getWorld().getServer().getLootManager(); + + if (manager.getElementOptional(LootDataType.LOOT_TABLES, id("blocks/loaded")).isEmpty()) { + throw new AssertionError("loaded loot table should have been loaded."); + } + + if (manager.getElementOptional(LootDataType.LOOT_TABLES, id("blocks/not_loaded")).isPresent()) { + throw new AssertionError("not_loaded loot table should not have been loaded."); + } + + context.complete(); + } } diff --git a/fabric-resource-conditions-api-v1/src/testmod/resources/data/fabric-resource-conditions-api-v1-testmod/loot_tables/blocks/loaded.json b/fabric-resource-conditions-api-v1/src/testmod/resources/data/fabric-resource-conditions-api-v1-testmod/loot_tables/blocks/loaded.json new file mode 100644 index 0000000000..f8b15e43d3 --- /dev/null +++ b/fabric-resource-conditions-api-v1/src/testmod/resources/data/fabric-resource-conditions-api-v1-testmod/loot_tables/blocks/loaded.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:cobblestone" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "minecraft:blocks/cobblestone", + "fabric:load_conditions": [ + { + "condition": "fabric:registry_contains", + "values": [ + "minecraft:cobblestone" + ] + } + ] +} diff --git a/fabric-resource-conditions-api-v1/src/testmod/resources/data/fabric-resource-conditions-api-v1-testmod/loot_tables/blocks/not_loaded.json b/fabric-resource-conditions-api-v1/src/testmod/resources/data/fabric-resource-conditions-api-v1-testmod/loot_tables/blocks/not_loaded.json new file mode 100644 index 0000000000..9afcfd9d96 --- /dev/null +++ b/fabric-resource-conditions-api-v1/src/testmod/resources/data/fabric-resource-conditions-api-v1-testmod/loot_tables/blocks/not_loaded.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:cobblestone" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "minecraft:blocks/cobblestone", + "fabric:load_conditions": [ + { + "condition": "fabric:registry_contains", + "values": [ + "minecraft:does_not_exist" + ] + } + ] +} From 9c89d33043b07f5499be8865c88b3d26da3583b4 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sun, 26 Nov 2023 13:52:23 +0000 Subject: [PATCH 08/11] Bump version --- gradle.properties | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index ddce05e96c..45fc08bc3f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx2560M org.gradle.parallel=true fabric.loom.multiProjectOptimisation=true -version=0.90.7 +version=0.91.0 minecraft_version=1.20.1 yarn_version=+build.1 loader_version=0.14.21 @@ -23,7 +23,7 @@ fabric-commands-v0-version=0.2.50 fabric-containers-v0-version=0.1.63 fabric-content-registries-v0-version=4.0.10 fabric-crash-report-info-v1-version=0.2.18 -fabric-data-generation-api-v1-version=12.3.2 +fabric-data-generation-api-v1-version=12.3.3 fabric-dimensions-v1-version=2.1.53 fabric-entity-events-v1-version=1.5.22 fabric-events-interaction-v0-version=0.6.1 @@ -54,12 +54,12 @@ fabric-rendering-data-attachment-v1-version=0.3.36 fabric-rendering-fluids-v1-version=3.0.27 fabric-rendering-v0-version=1.1.48 fabric-rendering-v1-version=3.0.7 -fabric-resource-conditions-api-v1-version=2.3.6 +fabric-resource-conditions-api-v1-version=2.3.7 fabric-resource-loader-v0-version=0.11.9 fabric-screen-api-v1-version=2.0.7 fabric-screen-handler-api-v1-version=1.3.29 fabric-sound-api-v1-version=1.0.12 -fabric-transfer-api-v1-version=3.3.2 +fabric-transfer-api-v1-version=3.3.3 fabric-transitive-access-wideners-v1-version=4.3.0 fabric-convention-tags-v1-version=1.5.4 fabric-client-tags-api-v1-version=1.1.1 From ec4c71fc6d39e71b3830ca4233da2cb92d901b66 Mon Sep 17 00:00:00 2001 From: Kneelawk Date: Sat, 9 Dec 2023 22:31:32 -0800 Subject: [PATCH 09/11] Fix editor botched gradle.properties --- gradle.properties | 4 ---- 1 file changed, 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index 381cba9ed2..7791ff77bd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,13 +2,9 @@ org.gradle.jvmargs=-Xmx2560M org.gradle.parallel=true fabric.loom.multiProjectOptimisation=true -<<<<<<< HEAD archivesBaseName=quilted_fabric_api version=7.4.0 upstream_version=0.90.0 -======= -version=0.91.0 ->>>>>>> fabric/1.20.1 minecraft_version=1.20.1 yarn_version=+build.1 loader_version=0.20.2 From 3aade32914636da7bca6c93a7c0378743c827346 Mon Sep 17 00:00:00 2001 From: Kneelawk Date: Sat, 9 Dec 2023 22:36:07 -0800 Subject: [PATCH 10/11] Update upstream_version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 7791ff77bd..490cb57ddf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ fabric.loom.multiProjectOptimisation=true archivesBaseName=quilted_fabric_api version=7.4.0 -upstream_version=0.90.0 +upstream_version=0.91.0 minecraft_version=1.20.1 yarn_version=+build.1 loader_version=0.20.2 From 991dedf207cbc919fe207da71f38ed24fed404f9 Mon Sep 17 00:00:00 2001 From: Eli Orona Date: Thu, 1 Feb 2024 11:19:35 -0800 Subject: [PATCH 11/11] Update gradle.properties --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 490cb57ddf..f46839aee4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.parallel=true fabric.loom.multiProjectOptimisation=true archivesBaseName=quilted_fabric_api -version=7.4.0 +version=7.5.0 upstream_version=0.91.0 minecraft_version=1.20.1 yarn_version=+build.1