WIP 1.15 and ReplayStudio v2 update

This commit is contained in:
Jonas Herzig
2020-03-13 14:18:19 +01:00
parent 8bc0b0a4df
commit af8803d6b5
65 changed files with 874 additions and 1303 deletions

View File

@@ -152,9 +152,9 @@ public class RecordingEventHandler extends EventRegistrations {
boolean force = false;
if(lastX == null || lastY == null || lastZ == null) {
force = true;
lastX = player.x;
lastY = player.y;
lastZ = player.z;
lastX = Entity_getX(player);
lastY = Entity_getY(player);
lastZ = Entity_getZ(player);
}
ticksSinceLastCorrection++;
@@ -163,13 +163,13 @@ public class RecordingEventHandler extends EventRegistrations {
force = true;
}
double dx = player.x - lastX;
double dy = player.y - lastY;
double dz = player.z - lastZ;
double dx = Entity_getX(player) - lastX;
double dy = Entity_getY(player) - lastY;
double dz = Entity_getZ(player) - lastZ;
lastX = player.x;
lastY = player.y;
lastZ = player.z;
lastX = Entity_getX(player);
lastY = Entity_getY(player);
lastZ = Entity_getZ(player);
Packet packet;
if (force || Math.abs(dx) > 8.0 || Math.abs(dy) > 8.0 || Math.abs(dz) > 8.0) {

View File

@@ -12,8 +12,9 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
//#if MC>=10800
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerPlayerListEntryPacket;
import com.github.steveice10.packetlib.io.buffer.ByteBufferNetInput;
import com.replaymod.replaystudio.protocol.Packet;
import com.replaymod.replaystudio.protocol.PacketType;
import com.replaymod.replaystudio.protocol.packets.PacketPlayerListEntry;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.util.PacketByteBuf;
@@ -21,7 +22,6 @@ import net.minecraft.client.network.packet.PlayerListS2CPacket;
import net.minecraft.client.network.PlayerListEntry;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Map;
import java.util.UUID;
//#else
@@ -62,10 +62,9 @@ public abstract class MixinNetHandlerPlayClient {
RecordingEventHandler handler = getRecordingEventHandler();
if (handler != null && packet.getAction() == PlayerListS2CPacket.Action.ADD_PLAYER) {
// We cannot reference SPacketPlayerListItem.AddPlayerData directly for complicated (and yet to be
// resolved) reasons (see https://github.com/MinecraftForge/ForgeGradle/issues/472), so we "simply" convert
// the back to the MCProtocolLib equivalent and deal with that one.
// resolved) reasons (see https://github.com/MinecraftForge/ForgeGradle/issues/472), so we use ReplayStudio
// to parse it instead.
ByteBuf byteBuf = Unpooled.buffer();
ServerPlayerListEntryPacket mcpl = new ServerPlayerListEntryPacket(null, null);
try {
packet.write(new PacketByteBuf(byteBuf));
@@ -73,21 +72,22 @@ public abstract class MixinNetHandlerPlayClient {
byte[] array = new byte[byteBuf.readableBytes()];
byteBuf.readBytes(array);
mcpl.read(new ByteBufferNetInput(ByteBuffer.wrap(array)));
for (PacketPlayerListEntry data : PacketPlayerListEntry.read(new Packet(
MCVer.getPacketTypeRegistry(false), 0, PacketType.PlayerListEntry,
com.github.steveice10.netty.buffer.Unpooled.wrappedBuffer(array)
))) {
if (data.getUuid() == null) continue;
// Only add spawn packet for our own player and only if he isn't known yet
if (data.getUuid().equals(mcStatic.player.getGameProfile().getId())
&& !this.playerListEntries.containsKey(data.getUuid())) {
handler.onPlayerJoin();
}
}
} catch (IOException e) {
throw new RuntimeException(e); // we just parsed this?
} finally {
byteBuf.release();
}
for (com.github.steveice10.mc.protocol.data.game.PlayerListEntry data : mcpl.getEntries()) {
if (data.getProfile() == null || data.getProfile().getId() == null) continue;
// Only add spawn packet for our own player and only if he isn't known yet
if (data.getProfile().getId().equals(mcStatic.player.getGameProfile().getId())
&& !this.playerListEntries.containsKey(data.getProfile().getId())) {
handler.onPlayerJoin();
}
}
}
}
//#else

View File

@@ -7,8 +7,10 @@ import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(MobSpawnS2CPacket.class)
public interface SPacketSpawnMobAccessor {
//#if MC<11500
@Accessor("dataTracker")
DataTracker getDataManager();
@Accessor("dataTracker")
void setDataManager(DataTracker value);
//#endif
}

View File

@@ -7,8 +7,10 @@ import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(PlayerSpawnS2CPacket.class)
public interface SPacketSpawnPlayerAccessor {
//#if MC<11500
@Accessor("dataTracker")
DataTracker getDataManager();
@Accessor("dataTracker")
void setDataManager(DataTracker value);
//#endif
}

View File

@@ -114,7 +114,7 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
this.metaData = metaData;
this.resourcePackRecorder = new ResourcePackRecorder(replayFile);
// Note: doesn't actually always include the login phase, see `connectionState` field instead.
this.packetOutputStream = new DataOutputStream(replayFile.writePacketData(true));
this.packetOutputStream = new DataOutputStream(replayFile.writePacketData());
this.startTime = metaData.getDate();
saveMetaData();
@@ -139,7 +139,7 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
out.write(json.getBytes());
}
} else {
replayFile.writeMetaData(metaData);
replayFile.writeMetaData(MCVer.getPacketTypeRegistry(true), metaData);
}
}
} catch (IOException e) {
@@ -325,6 +325,7 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
@SuppressWarnings("unchecked")
private byte[] getPacketData(Packet packet) throws Exception {
//#if MC<11500
if (packet instanceof MobSpawnS2CPacket) {
MobSpawnS2CPacket p = (MobSpawnS2CPacket) packet;
SPacketSpawnMobAccessor pa = (SPacketSpawnMobAccessor) p;
@@ -368,6 +369,7 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
}
}
}
//#endif
//#if MC>=10800
Integer packetId = connectionState.getPacketId(NetworkSide.CLIENTBOUND, packet);
@@ -401,9 +403,9 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
marker.setName(name);
marker.setTime(timestamp);
if (view != null) {
marker.setX(view.x);
marker.setY(view.y);
marker.setZ(view.z);
marker.setX(Entity_getX(view));
marker.setY(Entity_getY(view));
marker.setZ(Entity_getZ(view));
marker.setYaw(view.yaw);
marker.setPitch(view.pitch);
}