-
-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: composite transactions respect event cancellation
- Loading branch information
Showing
13 changed files
with
112 additions
and
484 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...spongepowered/common/event/tracking/context/transaction/pipeline/InteractionPipeline.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.spongepowered.common.event.tracking.context.transaction.pipeline; | ||
|
||
import net.minecraft.world.InteractionResult; | ||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
import org.spongepowered.common.event.tracking.PhaseContext; | ||
import org.spongepowered.common.event.tracking.context.transaction.ResultingTransactionBySideEffect; | ||
import org.spongepowered.common.event.tracking.context.transaction.TransactionalCaptureSupplier; | ||
import org.spongepowered.common.event.tracking.context.transaction.effect.ProcessingSideEffect; | ||
|
||
import java.util.Objects; | ||
|
||
public record InteractionPipeline<@NonNull A extends ProcessingSideEffect.Args>( | ||
A args, | ||
InteractionResult defaultResult, | ||
ProcessingSideEffect<InteractionPipeline<A>, InteractionResult, A, InteractionResult> effect, | ||
TransactionalCaptureSupplier transactor | ||
) { | ||
|
||
public InteractionResult processInteraction(final PhaseContext<?> context) { | ||
var result = this.defaultResult; | ||
final ResultingTransactionBySideEffect<InteractionPipeline<A>, InteractionResult, A, InteractionResult> resultingEffect = new ResultingTransactionBySideEffect<>(this.effect); | ||
try (final var ignored = context.getTransactor().pushEffect(resultingEffect)) { | ||
final var effectResult = this.effect.processSideEffect(this, result, this.args); | ||
if (effectResult.hasResult) { | ||
final @Nullable InteractionResult resultingState = effectResult.resultingState; | ||
result = Objects.requireNonNullElse(resultingState, result); | ||
} | ||
} | ||
return result; | ||
} | ||
} |
101 changes: 0 additions & 101 deletions
101
...rg/spongepowered/common/event/tracking/context/transaction/pipeline/UseBlockPipeline.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.