From 3833f8df0259e59b6248ac6f76717637cf0d3c54 Mon Sep 17 00:00:00 2001 From: senseiwells Date: Sun, 4 Feb 2024 22:33:04 +0000 Subject: [PATCH] Cleaning up --- .../replay/mixin/chunk/TrackedEntityMixin.java | 1 - .../senseiwells/replay/mixin/rejoin/ChunkMapAccessor.java | 3 --- .../me/senseiwells/replay/config/chunk/ChunkAreaConfig.kt | 2 +- .../kotlin/me/senseiwells/replay/recorder/ChunkSender.kt | 8 +++++--- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/senseiwells/replay/mixin/chunk/TrackedEntityMixin.java b/src/main/java/me/senseiwells/replay/mixin/chunk/TrackedEntityMixin.java index cb6ed3a..14d2f16 100644 --- a/src/main/java/me/senseiwells/replay/mixin/chunk/TrackedEntityMixin.java +++ b/src/main/java/me/senseiwells/replay/mixin/chunk/TrackedEntityMixin.java @@ -3,7 +3,6 @@ import me.senseiwells.replay.chunk.ChunkRecorder; import me.senseiwells.replay.chunk.ChunkRecorders; import me.senseiwells.replay.ducks.ServerReplay$ChunkRecordable; -import me.senseiwells.replay.player.PlayerRecorder; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.network.protocol.game.ClientboundBundlePacket; diff --git a/src/main/java/me/senseiwells/replay/mixin/rejoin/ChunkMapAccessor.java b/src/main/java/me/senseiwells/replay/mixin/rejoin/ChunkMapAccessor.java index 896bbd9..3f0b8d6 100644 --- a/src/main/java/me/senseiwells/replay/mixin/rejoin/ChunkMapAccessor.java +++ b/src/main/java/me/senseiwells/replay/mixin/rejoin/ChunkMapAccessor.java @@ -14,9 +14,6 @@ public interface ChunkMapAccessor { @Accessor("entityMap") Int2ObjectMap getEntityMap(); - @Accessor("serverViewDistance") - int getViewDistance(); - @Accessor("lightEngine") ThreadedLevelLightEngine getLightEngine(); diff --git a/src/main/kotlin/me/senseiwells/replay/config/chunk/ChunkAreaConfig.kt b/src/main/kotlin/me/senseiwells/replay/config/chunk/ChunkAreaConfig.kt index 034dae7..fe0f2fd 100644 --- a/src/main/kotlin/me/senseiwells/replay/config/chunk/ChunkAreaConfig.kt +++ b/src/main/kotlin/me/senseiwells/replay/config/chunk/ChunkAreaConfig.kt @@ -12,7 +12,7 @@ import net.minecraft.world.level.ChunkPos import net.minecraft.world.level.Level @Serializable -class ChunkAreaConfig constructor( +class ChunkAreaConfig( val name: String, @SerialName("dimension") @Serializable(with = ResourceLocationSerializer::class) diff --git a/src/main/kotlin/me/senseiwells/replay/recorder/ChunkSender.kt b/src/main/kotlin/me/senseiwells/replay/recorder/ChunkSender.kt index 2af16bf..b55dddb 100644 --- a/src/main/kotlin/me/senseiwells/replay/recorder/ChunkSender.kt +++ b/src/main/kotlin/me/senseiwells/replay/recorder/ChunkSender.kt @@ -37,7 +37,7 @@ interface ChunkSender { fun addTrackedEntity(tracking: TrackedEntity) fun getViewDistance(): Int { - return (this.level.chunkSource.chunkMap as ChunkMapAccessor).viewDistance + return this.level.server.playerList.viewDistance } @NonExtendable @@ -87,11 +87,12 @@ interface ChunkSender { val leashed = ArrayList() val ridden = ArrayList() + val viewDistance = this.level.server.playerList.viewDistance for (tracked in chunks.entityMap.values) { val entity = (tracked as TrackedEntityAccessor).entity if (this.isValidEntity(entity) && entity.chunkPosition() == chunk.pos) { if (!seen.contains(entity.id)) { - val range = min(tracked.getRange(), chunks.viewDistance * 16).toDouble() + val range = min(tracked.getRange(), viewDistance * 16).toDouble() if (this.shouldTrackEntity(entity, range)) { this.addTrackedEntity(tracked) seen.add(entity.id) @@ -119,9 +120,10 @@ interface ChunkSender { fun sendChunkEntities(seen: IntSet) { val chunks = this.level.chunkSource.chunkMap val entities = (chunks as ChunkMapAccessor).entityMap + val viewDistance = this.level.server.playerList.viewDistance for (tracked in entities.values) { val entity = (tracked as TrackedEntityAccessor).entity - val range = min(tracked.getRange(), chunks.viewDistance * 16).toDouble() + val range = min(tracked.getRange(), viewDistance * 16).toDouble() if (this.shouldTrackEntity(entity, range)) { this.addTrackedEntity(tracked) }