diff --git a/CHANGELOG.txt b/CHANGELOG.txt index a73003bbe..3cb81b0d2 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,9 +4,4 @@ Make sure to clear this after each release Put changelog here: ----------------- -- Changed NoInteractionStorage from an interface to a class -- Internally added a source set for Kotlin files -- Added utilities for creating GUI config entries for Typed Entries with Cloth Config - - Only available in Kotlin -- Added `TrackedPosition`, a class for use alongside the GameTest framework for relative and absolute positions -- Added `MoveDirection`, a class for interacting with Fabric's Transfer API. +- Fixed transaction depth crash diff --git a/gradle.properties b/gradle.properties index c37f49171..c1441f192 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,7 +16,7 @@ loader_version=0.14.22 # Mod Properties - mod_version = 1.3.8 + mod_version = 1.3.9 mod_loader = Fabric maven_group = net.frozenblock archives_base_name = FrozenLib diff --git a/src/main/java/net/frozenblock/lib/storage/api/StorageInteraction.java b/src/main/java/net/frozenblock/lib/storage/api/StorageInteraction.java index 717641383..803b66f3a 100644 --- a/src/main/java/net/frozenblock/lib/storage/api/StorageInteraction.java +++ b/src/main/java/net/frozenblock/lib/storage/api/StorageInteraction.java @@ -19,6 +19,7 @@ package net.frozenblock.lib.storage.api; import net.fabricmc.fabric.api.transfer.v1.storage.Storage; +import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction; import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext; /** @@ -34,6 +35,13 @@ default long moveResources(Storage storage, T resource, long maxAmount, Trans if (simulate) transactionContext = transaction.openNested(); - return moveResources(storage, resource, maxAmount, transactionContext); - } + long ret = moveResources(storage, resource, maxAmount, transactionContext); + if (simulate) { + // can safely cast to transaction because openNested returns a Transaction + // parent transaction should never be committed or aborted by any means + var transaction1 = (Transaction) transaction; + transaction1.close(); + } + return ret; + } }