|
37 | 37 | import net.minecraft.world.entity.item.ItemEntity;
|
38 | 38 | import net.minecraft.world.entity.player.Player;
|
39 | 39 | import net.minecraft.world.inventory.AbstractContainerMenu;
|
| 40 | +import net.minecraft.world.inventory.AnvilMenu; |
40 | 41 | import net.minecraft.world.inventory.InventoryMenu;
|
41 | 42 | import net.minecraft.world.inventory.MerchantMenu;
|
42 | 43 | import net.minecraft.world.item.ItemStack;
|
|
54 | 55 | import org.spongepowered.common.event.tracking.PhaseContext;
|
55 | 56 | import org.spongepowered.common.event.tracking.PhaseTracker;
|
56 | 57 | import org.spongepowered.common.event.tracking.context.transaction.EffectTransactor;
|
| 58 | +import org.spongepowered.common.event.tracking.context.transaction.ResultingTransactionBySideEffect; |
57 | 59 | import org.spongepowered.common.event.tracking.context.transaction.TransactionalCaptureSupplier;
|
| 60 | +import org.spongepowered.common.event.tracking.context.transaction.effect.InventoryEffect; |
58 | 61 | import org.spongepowered.common.event.tracking.context.transaction.inventory.PlayerInventoryTransaction;
|
| 62 | +import org.spongepowered.common.event.tracking.context.transaction.inventory.ExplicitInventoryOmittedTransaction; |
59 | 63 | import org.spongepowered.common.inventory.custom.SpongeInventoryMenu;
|
60 | 64 | import org.spongepowered.common.item.util.ItemStackUtil;
|
61 | 65 |
|
@@ -152,6 +156,17 @@ public class ServerGamePacketListenerImplMixin_Inventory {
|
152 | 156 | }
|
153 | 157 | }
|
154 | 158 |
|
| 159 | + @Inject(method = "handleRenameItem", |
| 160 | + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/inventory/AnvilMenu;setItemName(Ljava/lang/String;)V", shift = At.Shift.BEFORE)) |
| 161 | + private void impl$onHandleRenameItem(final CallbackInfo ci) { |
| 162 | + final PhaseContext<@NonNull ?> context = PhaseTracker.SERVER.getPhaseContext(); |
| 163 | + final TransactionalCaptureSupplier transactor = context.getTransactor(); |
| 164 | + final ExplicitInventoryOmittedTransaction transaction = new ExplicitInventoryOmittedTransaction(this.player.containerMenu); |
| 165 | + transactor.logTransaction(transaction); |
| 166 | + try (EffectTransactor ignored = transactor.pushEffect(new ResultingTransactionBySideEffect(InventoryEffect.getInstance()))) { |
| 167 | + } |
| 168 | + } |
| 169 | + |
155 | 170 | @Inject(method = "handleSelectTrade", at = @At("RETURN"))
|
156 | 171 | private void impl$onHandleSelectTrade(final ServerboundSelectTradePacket param0, final CallbackInfo ci) {
|
157 | 172 | if (this.player.containerMenu instanceof MerchantMenu) {
|
|
0 commit comments