use of org.spongepowered.common.event.tracking.phase.tick.PlayerTickContext in project SpongeCommon by SpongePowered.
the class MixinNetHandlerPlayServer method onPlayerTick.
@Redirect(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/EntityPlayerMP;onUpdateEntity()V"))
private void onPlayerTick(EntityPlayerMP player) {
if (player.world.isRemote) {
player.onUpdateEntity();
return;
}
try (CauseStackManager.StackFrame frame = Sponge.getCauseStackManager().pushCauseFrame();
PlayerTickContext context = TickPhase.Tick.PLAYER.createPhaseContext().source(player).buildAndSwitch()) {
Sponge.getCauseStackManager().pushCause(player);
player.onUpdateEntity();
}
}
use of org.spongepowered.common.event.tracking.phase.tick.PlayerTickContext in project SpongeCommon by SpongePowered.
the class ServerGamePacketListenerImplMixin_Tracker method tracker$wrapPlayerTickWithPhase.
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayer;doTick()V"))
private void tracker$wrapPlayerTickWithPhase(final ServerPlayer player) {
if (((PlatformEntityBridge) player).bridge$isFakePlayer() || ((LevelBridge) player.level).bridge$isFake()) {
player.doTick();
return;
}
try (final PlayerTickContext context = TickPhase.Tick.PLAYER.createPhaseContext(PhaseTracker.SERVER).source(player)) {
context.buildAndSwitch();
player.doTick();
}
}
Aggregations