diff --git a/src/main/java/me/senseiwells/replay/mixin/common/ChunkMapMixin.java b/src/main/java/me/senseiwells/replay/mixin/common/ChunkMapMixin.java new file mode 100644 index 0000000..c0c1bad --- /dev/null +++ b/src/main/java/me/senseiwells/replay/mixin/common/ChunkMapMixin.java @@ -0,0 +1,28 @@ +package me.senseiwells.replay.mixin.common; + +import me.senseiwells.replay.player.PlayerRecorder; +import me.senseiwells.replay.player.PlayerRecorders; +import net.minecraft.network.protocol.Packet; +import net.minecraft.server.level.ChunkMap; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Entity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(ChunkMap.class) +public class ChunkMapMixin { + @Inject( + method = "broadcast", + at = @At("HEAD") + ) + private void onBroadcast(Entity entity, Packet packet, CallbackInfo ci) { + if (entity instanceof ServerPlayer player) { + PlayerRecorder recorder = PlayerRecorders.get(player); + if (recorder != null) { + recorder.record(packet); + } + } + } +} diff --git a/src/main/resources/serverreplay.mixins.json b/src/main/resources/serverreplay.mixins.json index 1b26990..8b2840b 100644 --- a/src/main/resources/serverreplay.mixins.json +++ b/src/main/resources/serverreplay.mixins.json @@ -14,6 +14,7 @@ "chunk.ServerBossEventMixin", "chunk.TrackedEntityMixin", "chunk.WitherBossAccessor", + "common.ChunkMapMixin", "common.MinecraftServerMixin", "common.PlayerListAccessor", "common.ServerLevelMixin",