-
-
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.
wip: Add other interactions as pipeline transactions
- Loading branch information
Showing
34 changed files
with
1,081 additions
and
649 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = false | ||
max_line_length = 120 | ||
tab_width = 4 | ||
|
||
[{*.json,*.jsonc,*.png.mcmeta,mcmod.info,pack.mcmeta}] | ||
indent_size = 2 | ||
|
||
[*mixins.*.json] | ||
indent_size = 4 |
Submodule SpongeAPI
updated
4 files
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
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
40 changes: 40 additions & 0 deletions
40
...epowered/common/event/tracking/context/transaction/effect/InteractionUseItemOnEffect.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,40 @@ | ||
package org.spongepowered.common.event.tracking.context.transaction.effect; | ||
|
||
import net.minecraft.world.InteractionResult; | ||
import org.spongepowered.common.event.tracking.context.transaction.EffectTransactor; | ||
import org.spongepowered.common.event.tracking.context.transaction.inventory.PlayerInventoryTransaction; | ||
import org.spongepowered.common.event.tracking.context.transaction.pipeline.UseBlockPipeline; | ||
|
||
public final class InteractionUseItemOnEffect implements ProcessingSideEffect.Simple<UseBlockPipeline, UseItemOnArgs, InteractionResult> { | ||
|
||
private static final class Holder { | ||
static final InteractionUseItemOnEffect INSTANCE = new InteractionUseItemOnEffect(); | ||
} | ||
|
||
public static InteractionUseItemOnEffect getInstance() { | ||
return InteractionUseItemOnEffect.Holder.INSTANCE; | ||
} | ||
|
||
@Override | ||
public EffectResult<InteractionResult> processSideEffect( | ||
UseBlockPipeline pipeline, InteractionResult oldState, UseItemOnArgs args | ||
) { | ||
// Run vanilla change | ||
InteractionResult result; | ||
final var stack = args.itemStack(); | ||
if (args.isCreative()) { | ||
var i = stack.getCount(); | ||
result = stack.useOn(args.context()); | ||
stack.setCount(i); | ||
} else { | ||
result = stack.useOn(args.context()); | ||
} | ||
|
||
final var player = args.player(); | ||
pipeline.transactor().logPlayerInventoryChange(player, PlayerInventoryTransaction.EventCreator.STANDARD); | ||
try (EffectTransactor ignored = BroadcastInventoryChangesEffect.transact(pipeline.transactor())) { | ||
player.containerMenu.broadcastChanges(); | ||
} | ||
return new EffectResult<>(result, true); | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
...ava/org/spongepowered/common/event/tracking/context/transaction/effect/UseItemAtArgs.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,41 @@ | ||
/* | ||
* This file is part of Sponge, licensed under the MIT License (MIT). | ||
* | ||
* Copyright (c) SpongePowered <https://www.spongepowered.org> | ||
* Copyright (c) contributors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package org.spongepowered.common.event.tracking.context.transaction.effect; | ||
|
||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.InteractionHand; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.phys.BlockHitResult; | ||
|
||
public record UseItemAtArgs( | ||
Level world, | ||
ServerPlayer player, | ||
InteractionHand hand, | ||
BlockHitResult result, | ||
ItemStack copiedStack, | ||
boolean creative | ||
) implements ProcessingSideEffect.Args { | ||
} |
Oops, something went wrong.