diff --git a/neoforge/src/mixins/java/org/spongepowered/neoforge/mixin/core/server/level/ServerPlayerMixin_Neo.java b/neoforge/src/mixins/java/org/spongepowered/neoforge/mixin/core/server/level/ServerPlayerMixin_Neo.java index a3e3bd1629e..20edf213fbe 100644 --- a/neoforge/src/mixins/java/org/spongepowered/neoforge/mixin/core/server/level/ServerPlayerMixin_Neo.java +++ b/neoforge/src/mixins/java/org/spongepowered/neoforge/mixin/core/server/level/ServerPlayerMixin_Neo.java @@ -24,8 +24,10 @@ */ package org.spongepowered.neoforge.mixin.core.server.level; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.common.event.tracking.PhaseContext; import org.spongepowered.common.event.tracking.PhaseTracker; @@ -37,10 +39,14 @@ @Mixin(ServerPlayer.class) public abstract class ServerPlayerMixin_Neo extends LivingEntityMixin_Neo { + // @formatter:off + @Shadow public abstract ServerLevel shadow$serverLevel(); + // @formatter:on + // override from LivingEntityMixin_Neo @Override protected void neo$onElytraUse(final CallbackInfo ci) { - final PhaseContext context = PhaseTracker.SERVER.getPhaseContext(); + final PhaseContext context = PhaseTracker.getWorldInstance(this.shadow$serverLevel()).getPhaseContext(); final TransactionalCaptureSupplier transactor = context.getTransactor(); final net.minecraft.server.level.ServerPlayer player = (net.minecraft.server.level.ServerPlayer) (Object) this; try (final EffectTransactor ignored = transactor.logPlayerInventoryChangeWithEffect(player, PlayerInventoryTransaction.EventCreator.STANDARD)) { diff --git a/neoforge/src/mixins/java/org/spongepowered/neoforge/mixin/core/server/network/ServerGamePacketListenerImplMixin_Neo.java b/neoforge/src/mixins/java/org/spongepowered/neoforge/mixin/core/server/network/ServerGamePacketListenerImplMixin_Neo.java index ef2000360bf..665f8bc25d7 100644 --- a/neoforge/src/mixins/java/org/spongepowered/neoforge/mixin/core/server/network/ServerGamePacketListenerImplMixin_Neo.java +++ b/neoforge/src/mixins/java/org/spongepowered/neoforge/mixin/core/server/network/ServerGamePacketListenerImplMixin_Neo.java @@ -54,7 +54,7 @@ public abstract class ServerGamePacketListenerImplMixin_Neo implements ServerGam private RecipeBookMenu.PostPlaceAction neo$onPlaceRecipe( final RecipeBookMenu recipeBookMenu, final boolean shift, final boolean isCreative, final RecipeHolder recipe, final ServerLevel serverLevel, final net.minecraft.world.entity.player.Inventory inventory) { - final PhaseContext<@NonNull ?> context = PhaseTracker.SERVER.getPhaseContext(); + final PhaseContext<@NonNull ?> context = PhaseTracker.getWorldInstance(this.player.serverLevel()).getPhaseContext(); final TransactionalCaptureSupplier transactor = context.getTransactor(); final var player = this.player; diff --git a/neoforge/src/mixins/java/org/spongepowered/neoforge/mixin/inventory/event/server/level/ServerPlayerMixin_Inventory_Neo.java b/neoforge/src/mixins/java/org/spongepowered/neoforge/mixin/inventory/event/server/level/ServerPlayerMixin_Inventory_Neo.java index 89551943e50..28309aa5e48 100644 --- a/neoforge/src/mixins/java/org/spongepowered/neoforge/mixin/inventory/event/server/level/ServerPlayerMixin_Inventory_Neo.java +++ b/neoforge/src/mixins/java/org/spongepowered/neoforge/mixin/inventory/event/server/level/ServerPlayerMixin_Inventory_Neo.java @@ -25,6 +25,7 @@ package org.spongepowered.neoforge.mixin.inventory.event.server.level; import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.player.Player; @@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; @@ -43,7 +45,12 @@ import java.util.function.Consumer; @Mixin(ServerPlayer.class) -public class ServerPlayerMixin_Inventory_Neo { +public abstract class ServerPlayerMixin_Inventory_Neo { + + // @formatter:off + @Shadow public abstract ServerLevel shadow$serverLevel(); + // @formatter:on + @Nullable private Object inventory$menuProvider; @Inject( @@ -56,7 +63,7 @@ public class ServerPlayerMixin_Inventory_Neo { ) ) private void impl$afterOpenMenu(final CallbackInfoReturnable cir) { - PhaseTracker.SERVER.getPhaseContext().getTransactor().logContainerSet((ServerPlayer) (Object) this); + PhaseTracker.getWorldInstance(this.shadow$serverLevel()).getPhaseContext().getTransactor().logContainerSet((ServerPlayer) (Object) this); } @Inject(method = "openMenu(Lnet/minecraft/world/MenuProvider;Ljava/util/function/Consumer;)Ljava/util/OptionalInt;", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayer;initMenu(Lnet/minecraft/world/inventory/AbstractContainerMenu;)V")) @@ -75,7 +82,7 @@ public class ServerPlayerMixin_Inventory_Neo { final MenuProvider menuProvider, final int containerCounter, final net.minecraft.world.entity.player.Inventory inventory, final Player player ) { - try (final EffectTransactor ignored = PhaseTracker.SERVER.getPhaseContext() + try (final EffectTransactor ignored = PhaseTracker.getWorldInstance(this.shadow$serverLevel()).getPhaseContext() .getTransactor() .logOpenInventory((ServerPlayer) (Object) this) ) { diff --git a/neoforge/src/mixins/java/org/spongepowered/neoforge/mixin/tracker/server/level/ServerPlayerGameModeMixin_Neo_Tracker.java b/neoforge/src/mixins/java/org/spongepowered/neoforge/mixin/tracker/server/level/ServerPlayerGameModeMixin_Neo_Tracker.java index 915e707ea5d..089f212ea2d 100644 --- a/neoforge/src/mixins/java/org/spongepowered/neoforge/mixin/tracker/server/level/ServerPlayerGameModeMixin_Neo_Tracker.java +++ b/neoforge/src/mixins/java/org/spongepowered/neoforge/mixin/tracker/server/level/ServerPlayerGameModeMixin_Neo_Tracker.java @@ -63,7 +63,7 @@ public abstract class ServerPlayerGameModeMixin_Neo_Tracker { final ItemStack itemStack, final Level level, final BlockState state, final BlockPos pos, final Player player ) { - final PhaseContext<@NonNull ?> context = PhaseTracker.SERVER.getPhaseContext(); + final PhaseContext<@NonNull ?> context = PhaseTracker.getWorldInstance(this.player.serverLevel()).getPhaseContext(); final TransactionalCaptureSupplier transactor = context.getTransactor(); // Log the prepare drops here because Forge rewrites // this method to call mine block before calling destroy block