Skip to content

Commit

Permalink
fix transaction crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Treetrain1 committed Sep 16, 2023
1 parent 1309510 commit 6bdd4bc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 1 addition & 6 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -34,6 +35,13 @@ default long moveResources(Storage<T> 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;
}
}

0 comments on commit 6bdd4bc

Please sign in to comment.