diff --git a/gradle.properties b/gradle.properties index a915a70..b6581d9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,13 +7,13 @@ archives_base_name=serverreplay maven_group=me.senseiwells loom_version=1.5-SNAPSHOT -minecraft_version=1.20.1 -parchment_version=1.20.1:2023.08.06 +minecraft_version=1.19.4 +parchment_version=1.19.4:2023.06.26 loader_version=0.15.2 fabric_kotlin_version=1.9.2+kotlin.1.8.10 permissions_version=0.3-SNAPSHOT -fabric_version=0.91.0+1.20.1 -carpet_version=1.4.112 +fabric_version=0.87.2+1.19.4 +carpet_version=1.4.101 mod_version=1.0.3 diff --git a/src/main/java/me/senseiwells/replay/mixin/chunk/ChunkHolderMixin.java b/src/main/java/me/senseiwells/replay/mixin/chunk/ChunkHolderMixin.java index 60d4917..962a74d 100644 --- a/src/main/java/me/senseiwells/replay/mixin/chunk/ChunkHolderMixin.java +++ b/src/main/java/me/senseiwells/replay/mixin/chunk/ChunkHolderMixin.java @@ -1,11 +1,9 @@ package me.senseiwells.replay.mixin.chunk; -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import me.senseiwells.replay.chunk.ChunkRecorder; import me.senseiwells.replay.ducks.ServerReplay$ChunkRecordable; import net.minecraft.network.protocol.Packet; import net.minecraft.server.level.ChunkHolder; -import net.minecraft.server.level.ServerPlayer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -14,7 +12,6 @@ import java.util.Collection; import java.util.HashSet; -import java.util.List; import java.util.Set; @Mixin(ChunkHolder.class) @@ -25,24 +22,12 @@ public class ChunkHolderMixin implements ServerReplay$ChunkRecordable { method = "broadcast", at = @At("HEAD") ) - private void onBroadcast(List players, Packet packet, CallbackInfo ci) { + private void onBroadcast(Packet packet, boolean boundaryOnly, CallbackInfo ci) { for (ChunkRecorder recorder : this.replay$recorders) { recorder.record(packet); } } - @ModifyExpressionValue( - method = "broadcastChanges", - at = @At( - value = "INVOKE", - target = "Ljava/util/List;isEmpty()Z", - remap = false - ) - ) - private boolean shouldSkipBroadcasting(boolean noPlayers) { - return noPlayers && !this.replay$recorders.isEmpty(); - } - @Override public Collection replay$getRecorders() { return this.replay$recorders; diff --git a/src/main/java/me/senseiwells/replay/mixin/chunk/EndDragonFightMixin.java b/src/main/java/me/senseiwells/replay/mixin/chunk/EndDragonFightMixin.java index ec81792..9e975e7 100644 --- a/src/main/java/me/senseiwells/replay/mixin/chunk/EndDragonFightMixin.java +++ b/src/main/java/me/senseiwells/replay/mixin/chunk/EndDragonFightMixin.java @@ -3,7 +3,7 @@ import me.senseiwells.replay.chunk.ChunkRecordable; import me.senseiwells.replay.chunk.ChunkRecorders; import me.senseiwells.replay.util.MathUtils; -import net.minecraft.core.BlockPos; +import net.minecraft.core.Vec3i; import net.minecraft.server.level.ServerBossEvent; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.dimension.end.EndDragonFight; @@ -17,8 +17,6 @@ @Mixin(EndDragonFight.class) public class EndDragonFightMixin { - @Shadow @Final private BlockPos origin; - @Shadow @Final private ServerBossEvent dragonEvent; @Shadow @Final private ServerLevel level; @@ -29,7 +27,7 @@ public class EndDragonFightMixin { ) private void onUpdate(CallbackInfo ci) { int fightRange = 192; - BoundingBox box = MathUtils.createBoxAround(this.origin, fightRange); + BoundingBox box = MathUtils.createBoxAround(Vec3i.ZERO, fightRange); ChunkRecorders.updateRecordable((ChunkRecordable) this.dragonEvent, this.level.dimension(), box); } } diff --git a/src/main/java/me/senseiwells/replay/mixin/chunk/PlayerListMixin.java b/src/main/java/me/senseiwells/replay/mixin/chunk/PlayerListMixin.java index ca1ea92..53c5be4 100644 --- a/src/main/java/me/senseiwells/replay/mixin/chunk/PlayerListMixin.java +++ b/src/main/java/me/senseiwells/replay/mixin/chunk/PlayerListMixin.java @@ -71,7 +71,7 @@ private void onBroadcast( Packet packet, CallbackInfo ci ) { - if (except instanceof ServerPlayer player && player.level().dimension() == dimension) { + if (except instanceof ServerPlayer player && player.getLevel().dimension() == dimension) { PlayerRecorder recorder = PlayerRecorders.get(player); if (recorder != null) { recorder.record(packet); 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 14d2f16..78fa4ec 100644 --- a/src/main/java/me/senseiwells/replay/mixin/chunk/TrackedEntityMixin.java +++ b/src/main/java/me/senseiwells/replay/mixin/chunk/TrackedEntityMixin.java @@ -47,7 +47,7 @@ private void onBroadcast(Packet packet, CallbackInfo ci) { ) private void onUpdate(List playersList, CallbackInfo ci) { ChunkPos pos = this.entity.chunkPosition(); - ResourceKey level = this.entity.level().dimension(); + ResourceKey level = this.entity.getLevel().dimension(); ChunkRecorders.updateRecordable(this, level, pos); } @@ -69,8 +69,7 @@ private void onRemoved(CallbackInfo ci) { if (this.replay$chunks.add(recorder)) { recorder.addRecordable(this); List> list = new ArrayList<>(); - // The player parameter is never used, we can just pass in null - this.serverEntity.sendPairingData(null, list::add); + this.serverEntity.sendPairingData(list::add); recorder.record(new ClientboundBundlePacket(list)); recorder.onEntityTracked(this.entity); diff --git a/src/main/kotlin/me/senseiwells/replay/chunk/ChunkRecorder.kt b/src/main/kotlin/me/senseiwells/replay/chunk/ChunkRecorder.kt index 0d873f2..d8fcad0 100644 --- a/src/main/kotlin/me/senseiwells/replay/chunk/ChunkRecorder.kt +++ b/src/main/kotlin/me/senseiwells/replay/chunk/ChunkRecorder.kt @@ -55,7 +55,7 @@ class ChunkRecorder internal constructor( val z = center.middleBlockZ val y = this.level.getHeight(Heightmap.Types.WORLD_SURFACE, x, z) this.dummy.setPosRaw(x.toDouble(), y + 10.0, z.toDouble()) - this.dummy.setServerLevel(this.level) + this.dummy.setLevel(this.level) this.dummy.isInvisible = true RejoinedReplayPlayer.rejoin(this.dummy, this) diff --git a/src/main/kotlin/me/senseiwells/replay/commands/ReplayCommand.kt b/src/main/kotlin/me/senseiwells/replay/commands/ReplayCommand.kt index 6c6ae00..af3a937 100644 --- a/src/main/kotlin/me/senseiwells/replay/commands/ReplayCommand.kt +++ b/src/main/kotlin/me/senseiwells/replay/commands/ReplayCommand.kt @@ -138,7 +138,7 @@ object ReplayCommand { return 0 } ServerReplay.config.enabled = true - context.source.sendSuccess({ Component.literal("ServerReplay is now enabled!") }, true) + context.source.sendSuccess(Component.literal("ServerReplay is now enabled!"), true) ServerReplay.config.startPlayers(context.source.server) ServerReplay.config.startChunks(context.source.server) @@ -158,7 +158,7 @@ object ReplayCommand { for (recorders in ChunkRecorders.all()) { recorders.stop() } - context.source.sendSuccess({ Component.literal("ServerReplay is now disabled! Stopped all recordings.") }, true) + context.source.sendSuccess(Component.literal("ServerReplay is now disabled! Stopped all recordings."), true) return 1 } @@ -170,7 +170,7 @@ object ReplayCommand { i++ } } - context.source.sendSuccess({ Component.literal("Successfully started $i recordings") }, true) + context.source.sendSuccess(Component.literal("Successfully started $i recordings"), true) return i } @@ -213,7 +213,7 @@ object ReplayCommand { } val recorder = ChunkRecorders.create(area, id) recorder.tryStart() - context.source.sendSuccess({ Component.literal("Successfully started chunk replay: ${recorder.getName()}") }, true) + context.source.sendSuccess(Component.literal("Successfully started chunk replay: ${recorder.getName()}"), true) return 1 } @@ -230,7 +230,7 @@ object ReplayCommand { i++ } } - context.source.sendSuccess({ Component.literal("Successfully stopped $i recordings") }, true) + context.source.sendSuccess(Component.literal("Successfully stopped $i recordings"), true) return i } @@ -266,7 +266,7 @@ object ReplayCommand { return 0 } recorder.stop(save) - context.source.sendSuccess({ Component.literal("Successfully stopped recording") }, true) + context.source.sendSuccess(Component.literal("Successfully stopped recording"), true) return 1 } @@ -278,13 +278,13 @@ object ReplayCommand { for (recorder in recorders) { recorder.stop(save) } - context.source.sendSuccess({ Component.literal("Successfully stopped all recordings.") }, true) + context.source.sendSuccess(Component.literal("Successfully stopped all recordings."), true) return 1 } private fun onReload(context: CommandContext): Int { ServerReplay.config = ReplayConfig.read() - context.source.sendSuccess({ Component.literal("Successfully reloaded config.") }, true) + context.source.sendSuccess(Component.literal("Successfully reloaded config."), true) return 1 } diff --git a/src/main/kotlin/me/senseiwells/replay/player/PlayerRecorder.kt b/src/main/kotlin/me/senseiwells/replay/player/PlayerRecorder.kt index 77325fb..212a92b 100644 --- a/src/main/kotlin/me/senseiwells/replay/player/PlayerRecorder.kt +++ b/src/main/kotlin/me/senseiwells/replay/player/PlayerRecorder.kt @@ -30,7 +30,7 @@ class PlayerRecorder internal constructor( get() = this.server.playerList.getPlayer(this.recordingPlayerUUID) override val level: ServerLevel - get() = this.getPlayerOrThrow().serverLevel() + get() = this.getPlayerOrThrow().getLevel() fun getPlayerOrThrow(): ServerPlayer { return this.player ?: throw IllegalStateException("Tried to get player before player joined") @@ -65,9 +65,7 @@ class PlayerRecorder internal constructor( fun spawnPlayer(player: ServerEntity) { val list = ArrayList>() - // The player parameter is never used, we can just pass in null - @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") - player.sendPairingData(null, list::add) + player.sendPairingData(list::add) this.record(ClientboundBundlePacket(list)) } @@ -121,7 +119,7 @@ class PlayerRecorder internal constructor( private fun getPlayerServerEntity(): ServerEntity { val player = this.getPlayerOrThrow() - val chunks = player.serverLevel().chunkSource.chunkMap as ChunkMapAccessor + val chunks = player.getLevel().chunkSource.chunkMap as ChunkMapAccessor val tracking = chunks.entityMap.get(player.id) return (tracking as TrackedEntityAccessor).serverEntity diff --git a/src/main/kotlin/me/senseiwells/replay/recorder/ChunkSender.kt b/src/main/kotlin/me/senseiwells/replay/recorder/ChunkSender.kt index b55dddb..7148d5c 100644 --- a/src/main/kotlin/me/senseiwells/replay/recorder/ChunkSender.kt +++ b/src/main/kotlin/me/senseiwells/replay/recorder/ChunkSender.kt @@ -81,7 +81,8 @@ interface ChunkSender { chunk, chunks.lightEngine, null, - null + null, + true )) val leashed = ArrayList() diff --git a/src/main/kotlin/me/senseiwells/replay/rejoin/RejoinedReplayPlayer.kt b/src/main/kotlin/me/senseiwells/replay/rejoin/RejoinedReplayPlayer.kt index c8672ed..ebba6bd 100644 --- a/src/main/kotlin/me/senseiwells/replay/rejoin/RejoinedReplayPlayer.kt +++ b/src/main/kotlin/me/senseiwells/replay/rejoin/RejoinedReplayPlayer.kt @@ -15,7 +15,7 @@ import net.minecraft.world.scores.Objective class RejoinedReplayPlayer private constructor( val original: ServerPlayer, val recorder: ReplayRecorder -): ServerPlayer(original.server, original.serverLevel(), original.gameProfile) { +): ServerPlayer(original.server, original.getLevel(), original.gameProfile) { companion object { fun rejoin(player: ServerPlayer, recorder: ReplayRecorder) { recorder.afterLogin() @@ -38,7 +38,7 @@ class RejoinedReplayPlayer private constructor( val server = this.server val players = server.playerList - val level = this.serverLevel() + val level = this.getLevel() val levelData = level.levelData val rules = level.gameRules this.recorder.record(ClientboundLoginPacket( @@ -58,8 +58,7 @@ class RejoinedReplayPlayer private constructor( !rules.getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN), level.isDebug, level.isFlat, - this.original.lastDeathLocation, - this.original.portalCooldown + this.original.lastDeathLocation )) this.recorder.record(ClientboundUpdateEnabledFeaturesPacket(FeatureFlags.REGISTRY.toNames(level.enabledFeatures()))) this.recorder.record(ClientboundCustomPayloadPacket(ClientboundCustomPayloadPacket.BRAND, PacketByteBufs.create().writeUtf(this.server.serverModName))) diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 16bcd0a..5b8bc36 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -27,7 +27,7 @@ "depends": { "fabricloader": ">=0.14.12", "fabric-api": "*", - "minecraft": "1.20.x", + "minecraft": "1.19.x", "java": ">=17", "fabric-language-kotlin": ">=1.9.0+kotlin.1.8.0" }