Port to MC 1.19.4

This commit is contained in:
Jonas Herzig
2023-03-26 18:58:49 +02:00
parent ae5f893014
commit 78bd060249
13 changed files with 78 additions and 80 deletions

View File

@@ -2,6 +2,7 @@ package com.replaymod.core;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.SharedConstants;
import static com.replaymod.core.ReplayMod.MOD_ID;
@@ -20,7 +21,7 @@ public class ReplayModBackend implements ClientModInitializer {
}
public String getMinecraftVersion() {
return mod.getMinecraft().getGame().getVersion().getName();
return SharedConstants.getGameVersion().getName();
}
public boolean isModLoaded(String id) {

View File

@@ -6,7 +6,6 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket;
import net.minecraft.util.profiler.Profiler;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.math.BlockPos;
@@ -21,87 +20,26 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
//$$ import net.minecraft.util.registry.RegistryEntry;
//#endif
//#if MC>=11600
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.MutableWorldProperties;
import java.util.function.Supplier;
//#else
//$$ import net.minecraft.world.level.LevelProperties;
//#endif
//#if MC>=11400
import net.minecraft.world.chunk.ChunkManager;
//#if MC<11600
//$$ import net.minecraft.world.dimension.Dimension;
//#endif
import net.minecraft.world.dimension.DimensionType;
import java.util.function.BiFunction;
//#else
//$$ import net.minecraft.world.storage.ISaveHandler;
//#if MC>=11400
//$$ import net.minecraft.world.dimension.Dimension;
//$$ import net.minecraft.world.storage.WorldSavedDataStorage;
//#else
//$$ import net.minecraft.world.WorldProvider;
//#endif
//#endif
@Mixin(ClientWorld.class)
public abstract class MixinWorldClient extends World implements RecordingEventHandler.RecordingEventSender {
@Shadow
private MinecraftClient client;
//#if MC>=11600
protected MixinWorldClient(MutableWorldProperties mutableWorldProperties, RegistryKey<World> registryKey,
//#if MC<11602
//$$ RegistryKey<DimensionType> registryKey2,
//#endif
//#if MC>=11802
//$$ RegistryEntry<DimensionType> dimensionType,
//#else
DimensionType dimensionType,
//#endif
Supplier<Profiler> profiler, boolean bl, boolean bl2, long l
//#if MC>=11900
//$$ , int maxChainedNeighborUpdates
//#endif
) {
super(mutableWorldProperties, registryKey,
//#if MC<11602
//$$ registryKey2,
//#endif
dimensionType, profiler, bl, bl2, l
//#if MC>=11900
//$$ , maxChainedNeighborUpdates
//#endif
);
@SuppressWarnings("ConstantConditions")
protected MixinWorldClient() {
//#if MC>=11904
//$$ super(null, null, null, null, null, false, false, 0, 0);
//#elseif MC>=11900
//$$ super(null, null, null, null, false, false, 0, 0);
//#elseif MC>=11602
super(null, null, null, null, false, false, 0);
//#elseif MC>=11600
//$$ super(null, null, null, null, null, false, false, 0);
//#else
//$$ super(null, null, null, null, false);
//#endif
}
//#else
//#if MC>=11400
//$$ protected MixinWorldClient(LevelProperties levelProperties_1, DimensionType dimensionType_1, BiFunction<World, Dimension, ChunkManager> biFunction_1, Profiler profiler_1, boolean boolean_1) {
//$$ super(levelProperties_1, dimensionType_1, biFunction_1, profiler_1, boolean_1);
//$$ }
//#else
//$$ protected MixinWorldClient(ISaveHandler saveHandlerIn,
//#if MC>=11400
//$$ WorldSavedDataStorage mapStorage,
//#endif
//$$ WorldInfo info,
//#if MC>=11400
//$$ Dimension providerIn,
//#else
//$$ WorldProvider providerIn,
//#endif
//$$ Profiler profilerIn, boolean client) {
//$$ super(saveHandlerIn,
//#if MC>=11400
//$$ mapStorage,
//#endif
//$$ info, providerIn, profilerIn, client);
//$$ }
//#endif
//#endif
private RecordingEventHandler replayModRecording_getRecordingEventHandler() {
return ((RecordingEventHandler.RecordingEventSender) this.client.worldRenderer).getRecordingEventHandler();

View File

@@ -69,6 +69,11 @@ import static com.replaymod.core.versions.MCVer.*;
import static com.replaymod.replaystudio.util.Utils.writeInt;
import static java.util.Objects.requireNonNull;
//#if MC>=11904
//$$ import net.minecraft.network.PacketBundleHandler;
//$$ import java.util.ArrayList;
//#endif
@ChannelHandler.Sharable // so we can re-order it
public class PacketListener extends ChannelInboundHandlerAdapter {
@@ -341,7 +346,25 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
} else if (msg instanceof net.minecraft.network.Packet) {
// for integrated server connections MC is passing the packet objects directly, so we need to encode them
// ourselves to be able to store them
//#if MC>=11904
//$$ PacketBundleHandler bundleHandler = ctx.channel().attr(PacketBundleHandler.KEY).get().getBundler(NetworkSide.CLIENTBOUND);
//$$ List<Packet> packets = new ArrayList<>(1);
//$$ bundleHandler.forEachPacket((net.minecraft.network.packet.Packet<?>) msg, unbundledPacket -> {
//$$ try {
//$$ packets.add(encodeMcPacket(connectionState, unbundledPacket));
//$$ } catch (Exception e) {
//$$ throw new RuntimeException(e);
//$$ }
//$$ });
//$$ if (packets.size() > 1) {
//$$ packets.forEach(this::save);
//$$ super.channelRead(ctx, msg);
//$$ return;
//$$ }
//$$ packet = packets.isEmpty() ? null : packets.get(0);
//#else
packet = encodeMcPacket(connectionState, (net.minecraft.network.Packet) msg);
//#endif
}
if (packet != null) {

View File

@@ -88,7 +88,9 @@ public abstract class OpenGlFrameCapturer<F extends Frame, D extends CaptureData
, false
//#endif
);
//#if MC<11904
GlStateManager.enableTexture();
//#endif
worldRenderer.renderWorld(partialTicks, captureData);

View File

@@ -477,7 +477,9 @@ public class VideoRenderer implements RenderInfo {
, false
//#endif
);
//#if MC<11904
GlStateManager.enableTexture();
//#endif
guiWindow.beginWrite();
//#if MC>=11500

View File

@@ -57,6 +57,10 @@ import net.minecraft.util.math.Vec3d;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
//#if MC>=11904
//$$ import net.minecraft.network.packet.s2c.play.PositionFlag;
//#endif
//#if MC>=11903
//$$ import net.minecraft.network.packet.s2c.play.ProfilelessChatMessageS2CPacket;
//#endif
@@ -804,7 +808,10 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
if(replayHandler.shouldSuppressCameraMovements()) return null;
//#if MC>=10800
//#if MC>=11400
//#if MC>=11904
//$$ for (PositionFlag relative : ppl.getFlags()) {
//$$ if (relative == PositionFlag.X || relative == PositionFlag.Y || relative == PositionFlag.Z) {
//#elseif MC>=11400
for (PlayerPositionLookS2CPacket.Flag relative : ppl.getFlags()) {
if (relative == PlayerPositionLookS2CPacket.Flag.X
|| relative == PlayerPositionLookS2CPacket.Flag.Y

View File

@@ -69,7 +69,9 @@ public class NoGuiScreenshot {
//#endif
);
mc.getFramebuffer().beginWrite(true);
//#if MC<11904
GlStateManager.enableTexture();
//#endif
float tickDelta = mc.getTickDelta();
//#if MC>=11500

View File

@@ -33,6 +33,7 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.DownloadingTerrainScreen;
import net.minecraft.client.network.ClientLoginNetworkHandler;
import net.minecraft.client.util.Window;
import net.minecraft.network.NetworkState;
import net.minecraft.util.crash.CrashReport;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
@@ -41,6 +42,10 @@ import net.minecraft.network.ClientConnection;
import java.io.IOException;
import java.util.*;
//#if MC>=11904
//$$ import net.minecraft.network.PacketBundler;
//#endif
//#if MC>=11700
//$$ import net.minecraft.client.render.DiffuseLighting;
//$$ import net.minecraft.util.math.Matrix4f;
@@ -317,9 +322,16 @@ public class ReplayHandler {
channel.pipeline().addLast("ReplayModReplay_quickReplaySender", quickReplaySender);
//#endif
channel.pipeline().addLast("ReplayModReplay_replaySender", fullReplaySender);
//#if MC>=11904
//$$ channel.pipeline().addLast("bundler", new PacketBundler(NetworkSide.CLIENTBOUND));
//#endif
channel.pipeline().addLast("packet_handler", networkManager);
channel.pipeline().fireChannelActive();
// MC usually transitions from handshake to login via the packets it sends.
// We don't send any packets (there is no server to receive them), so we need to switch manually.
networkManager.setState(NetworkState.LOGIN);
//#if MC>=11400
((MinecraftAccessor) mc).setConnection(networkManager);
//#endif
@@ -626,7 +638,9 @@ public class ReplayHandler {
, true
//#endif
);
//#if MC<11904
GlStateManager.enableTexture();
//#endif
mc.getFramebuffer().beginWrite(true);
Window window = mc.getWindow();
//#if MC>=11500