Skip to content

Commit

Permalink
Fix #48 for <=1.20.4
Browse files Browse the repository at this point in the history
  • Loading branch information
senseiwells committed Sep 17, 2024
1 parent f82b816 commit 0327c86
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 50 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ repositories {
}

dependencies {
modImplementation("me.senseiwells:server-replay:1.1.2+1.20.6")
modImplementation("me.senseiwells:server-replay:1.1.3+1.20.4")
}
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ plugins {
val shade: Configuration by configurations.creating

repositories {
mavenLocal()
maven("https://maven.parchmentmc.org/")
maven("https://masa.dy.fi/maven")
maven("https://jitpack.io")
Expand Down Expand Up @@ -45,7 +46,6 @@ dependencies {

modCompileOnly(libs.carpet)
modCompileOnly(libs.vmp)
modCompileOnly(libs.servux)
modCompileOnly(libs.syncmatica)
modCompileOnly(libs.voicechat)
implementation(libs.voicechat.api)
Expand Down
20 changes: 9 additions & 11 deletions libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ fabric-loom = "1.7-SNAPSHOT"
mod-publish = "0.7.0"
kotlin-serialization = "1.9.21"
shadow = "8.1.1"
minecraft = "1.20.6"
minecraft = "1.20.4"
fabric-loader = "0.16.5"
parchment = "1.20.6:2024.05.01"
fabric-api = "0.99.0+1.20.6"
fabric-kotlin = "1.11.0+kotlin.2.0.0"
parchment = "1.20.4:2024.04.14"
fabric-api = "0.95.3+1.20.4"
fabric-kotlin = "1.9.2+kotlin.1.8.10"
permissions = "0.3.1"
carpet = "1.4.141"
voicechat = "fabric-1.20.6-2.5.17"
carpet = "1.4.128"
voicechat = "fabric-1.20.4-2.5.1"
voicechat-api = "2.4.0"
vmp = "0.2.0+beta.7.155+1.20.6"
servux = "1.20.6-0.2.0"
syncmatica = "1.20.6-sakura.10"
vmp = "0.2.0+beta.7.139+1.20.4"
syncmatica = "0.3.11"
replay-studio = "1e96fda605"

[libraries]
Expand All @@ -27,8 +26,7 @@ carpet = { module = "com.github.gnembon:fabric-carpet" , version.ref
voicechat = { module = "maven.modrinth:simple-voice-chat" , version.ref = "voicechat" }
voicechat-api = { module = "de.maxhenkel.voicechat:voicechat-api" , version.ref = "voicechat-api" }
vmp = { module = "maven.modrinth:vmp-fabric" , version.ref = "vmp" }
servux = { module = "com.github.sakura-ryoko:servux" , version.ref = "servux" }
syncmatica = { module = "com.github.sakura-ryoko:syncmatica" , version.ref = "syncmatica" }
syncmatica = { module = "com.github.sakura:syncmatica" , version.ref = "syncmatica" }
replay-studio = { module = "com.github.ReplayMod:ReplayStudio" , version.ref = "replay-studio" }

[plugins]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
import net.minecraft.server.level.ChunkHolder;
import net.minecraft.server.level.ChunkMap;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.chunk.LevelChunk;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
Expand All @@ -30,7 +32,7 @@ public abstract class ChunkHolderMixin implements ChunkRecordable {

@Unique private final Set<ChunkRecorder> replay$recorders = new HashSet<>();

@Shadow @Final private ChunkPos pos;
@Shadow @Final ChunkPos pos;

@Shadow public abstract @Nullable LevelChunk getFullChunk();

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ChunkGamePacketPacketListener(
recorder.server,
RejoinConnection(),
player,
CommonListenerCookie.createInitial(recorder.profile, false)
CommonListenerCookie.createInitial(recorder.profile)
) {
override fun send(packet: Packet<*>, listener: PacketSendListener?) {
this.recorder.record(packet)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ object PackCommand {
uuid: UUID = UuidArgument.getUuid(context, "uuid")
): Int {
val url = StringArgumentType.getString(context, "url")
val packet = ClientboundResourcePackPushPacket(uuid, url, "", false, Optional.empty())
val packet = ClientboundResourcePackPushPacket(uuid, url, "", false, null)
for (player in context.source.server.playerList.players) {
player.connection.send(packet)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ abstract class ReplayRecorder(
return if (this is ClientboundCustomPayloadPacket) {
"CustomPayload(${this.payload.id()})"
} else {
this.type().id.toString()
this::class.java.simpleName
}
}
}
Expand Down
21 changes: 10 additions & 11 deletions src/main/kotlin/me/senseiwells/replay/viewer/ReplayViewerUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,18 @@ object ReplayViewerUtils {
private val CLIENTBOUND_CONFIG_CODEC = ConnectionProtocol.CONFIGURATION.codec(PacketFlow.CLIENTBOUND)

fun ReplayPacket.toClientboundPlayPacket(): Packet<*> {
val buf = toFriendlyByteBuf(this.buf)
try {
useByteBuf(this.buf) { buf ->
val decoded = CLIENTBOUND_PLAY_CODEC.createPacket(this.id, buf)
?: throw IllegalStateException("Failed to create play packet with id ${this.id}")
return fixFabricCustomPayloadPacket(decoded)
} finally {
buf.release()
}
}

fun ReplayPacket.toClientboundConfigurationPacket(): Packet<*> {
val buf = toFriendlyByteBuf(this.buf)
try {
useByteBuf(this.buf) { buf ->
val decoded = CLIENTBOUND_CONFIG_CODEC.createPacket(this.id, buf)
?: throw IllegalStateException("Failed to create configuration packet with id ${this.id}")
return fixFabricCustomPayloadPacket(decoded)
} finally {
buf.release()
}
}

Expand All @@ -55,17 +49,22 @@ object ReplayViewerUtils {
return packet
}

private fun toFriendlyByteBuf(buf: com.github.steveice10.netty.buffer.ByteBuf): FriendlyByteBuf {
private inline fun <T> useByteBuf(buf: com.github.steveice10.netty.buffer.ByteBuf, block: (FriendlyByteBuf) -> T): T {
// When we compile we map steveice10.netty -> io.netty
// We just need this check for dev environment
@Suppress("USELESS_IS_CHECK")
if (buf is ByteBuf) {
return FriendlyByteBuf(buf)
return block(FriendlyByteBuf(buf))
}

val array = ByteArray(buf.readableBytes())
buf.readBytes(array)
return FriendlyByteBuf(Unpooled.wrappedBuffer(array))
val copy = FriendlyByteBuf(Unpooled.wrappedBuffer(array))
try {
return block(copy)
} finally {
copy.release()
}
}

fun ServerGamePacketListenerImpl.sendReplayPacket(packet: Packet<*>) {
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/serverreplay.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"compat.carpet.ChunkMapMixin",
"compat.carpet.EntityPlayerMPFakeMixin",
"compat.carpet.NetHandlerPlayServerFakeMixin",
"compat.servux.ServuxPacketMixin",
"compat.syncmatica.SyncmaticaPacketPayloadMixin",
"compat.vmp.NearbyEntityTrackingMixin",
"compat.vmp.TrackedEntityMixin",
Expand Down

0 comments on commit 0327c86

Please sign in to comment.