Skip to content

Commit

Permalink
Port to 1.19.4
Browse files Browse the repository at this point in the history
  • Loading branch information
senseiwells committed Feb 4, 2024
1 parent b9cb1a7 commit ed70c05
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 48 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -14,7 +12,6 @@

import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Mixin(ChunkHolder.class)
Expand All @@ -25,24 +22,12 @@ public class ChunkHolderMixin implements ServerReplay$ChunkRecordable {
method = "broadcast",
at = @At("HEAD")
)
private void onBroadcast(List<ServerPlayer> 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<ChunkRecorder> replay$getRecorders() {
return this.replay$recorders;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private void onBroadcast(Packet<?> packet, CallbackInfo ci) {
)
private void onUpdate(List<ServerPlayer> playersList, CallbackInfo ci) {
ChunkPos pos = this.entity.chunkPosition();
ResourceKey<Level> level = this.entity.level().dimension();
ResourceKey<Level> level = this.entity.getLevel().dimension();
ChunkRecorders.updateRecordable(this, level, pos);
}

Expand All @@ -69,8 +69,7 @@ private void onRemoved(CallbackInfo ci) {
if (this.replay$chunks.add(recorder)) {
recorder.addRecordable(this);
List<Packet<ClientGamePacketListener>> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions src/main/kotlin/me/senseiwells/replay/commands/ReplayCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}

Expand All @@ -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
}

Expand Down Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down Expand Up @@ -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
}

Expand All @@ -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<CommandSourceStack>): 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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -65,9 +65,7 @@ class PlayerRecorder internal constructor(

fun spawnPlayer(player: ServerEntity) {
val list = ArrayList<Packet<ClientGamePacketListener>>()
// 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))
}

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ interface ChunkSender {
chunk,
chunks.lightEngine,
null,
null
null,
true
))

val leashed = ArrayList<Mob>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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(
Expand All @@ -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)))
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit ed70c05

Please sign in to comment.