WIP 1.15 and ReplayStudio v2 update
This commit is contained in:
@@ -15,7 +15,9 @@ import com.replaymod.recording.ReplayModRecording;
|
||||
import com.replaymod.render.ReplayModRender;
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
import com.replaymod.replaystudio.studio.ReplayStudio;
|
||||
import com.replaymod.replaystudio.us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||
import com.replaymod.replaystudio.util.I18n;
|
||||
import com.replaymod.replaystudio.viaversion.ViaVersionPacketConverter;
|
||||
import com.replaymod.simplepathing.ReplayModSimplePathing;
|
||||
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||
import lombok.Getter;
|
||||
@@ -30,8 +32,6 @@ import net.minecraft.util.Formatting;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
//#if MC>=11400
|
||||
import com.github.steveice10.mc.protocol.MinecraftConstants;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.client.options.Option;
|
||||
import net.minecraft.resource.ResourcePackCreator;
|
||||
import net.minecraft.resource.ResourcePackContainer;
|
||||
@@ -99,8 +99,6 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
//#if FABRIC<=0
|
||||
//#if MC>=11300
|
||||
//$$ @Mod(ReplayMod.MOD_ID)
|
||||
@@ -180,19 +178,8 @@ public class ReplayMod implements
|
||||
|
||||
//#if MC>=11400
|
||||
// Check Minecraft protocol version for compatibility
|
||||
int supportedProtocol = MinecraftConstants.PROTOCOL_VERSION;
|
||||
int actualProtocol = SharedConstants.getGameVersion().getProtocolVersion();
|
||||
if (supportedProtocol != actualProtocol && !Boolean.parseBoolean(System.getProperty("replaymod.skipversioncheck", "false"))) {
|
||||
if (!ProtocolVersion.isRegistered(MCVer.getProtocolVersion()) && !Boolean.parseBoolean(System.getProperty("replaymod.skipversioncheck", "false"))) {
|
||||
minimalMode = true;
|
||||
// Only allow use of older RM on newer (e.g. snapshot, pre-release) versions.
|
||||
// The other way around is almost certainly user error.
|
||||
if (actualProtocol < supportedProtocol && !Boolean.parseBoolean(System.getProperty("replaymod.allowoldsnapshot", "false"))) {
|
||||
throw new UnsupportedOperationException(String.format(
|
||||
"Unsupported Minecraft version, supporting protocol version %s (%s) but actual version is %s (%s).",
|
||||
supportedProtocol, MinecraftConstants.GAME_VERSION,
|
||||
actualProtocol, SharedConstants.getGameVersion().getName()
|
||||
));
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -453,7 +440,10 @@ public class ReplayMod implements
|
||||
public static class ReplayModExecutor extends NonBlockingThreadExecutor<Runnable> {
|
||||
private final Thread mcThread = Thread.currentThread();
|
||||
// Fail-fast in case we ever switch to async loading and forget to change this
|
||||
// (except for fabric 1.15+ because it loads the mod before the client thread is set)
|
||||
//#if FABRIC<1 || MC<11500
|
||||
{ if (!MinecraftClient.getInstance().isOnThread()) throw new RuntimeException(); }
|
||||
//#endif
|
||||
|
||||
private ReplayModExecutor(String string_1) {
|
||||
super(string_1);
|
||||
@@ -474,7 +464,7 @@ public class ReplayMod implements
|
||||
return mcThread;
|
||||
}
|
||||
|
||||
//#if FABRIC>=1
|
||||
//#if FABRIC>=1 && MC<11500
|
||||
@Override
|
||||
public void send(Runnable runnable) {
|
||||
method_18858(runnable);
|
||||
@@ -649,7 +639,7 @@ public class ReplayMod implements
|
||||
if (isMinimalMode()) {
|
||||
return protocolVersion == MCVer.getProtocolVersion();
|
||||
} else {
|
||||
return new ReplayStudio().isCompatible(fileFormatVersion, protocolVersion);
|
||||
return new ReplayStudio().isCompatible(fileFormatVersion, protocolVersion, MCVer.getProtocolVersion());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.replaymod.core.gui;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.google.gson.Gson;
|
||||
import com.replaymod.core.versions.MCVer;
|
||||
import com.replaymod.replaystudio.io.ReplayInputStream;
|
||||
import com.replaymod.replaystudio.io.ReplayOutputStream;
|
||||
import com.replaymod.replaystudio.replay.ReplayFile;
|
||||
@@ -56,8 +57,8 @@ public class RestoreReplayGui extends AbstractGuiScreen<RestoreReplayGui> {
|
||||
if (metaData != null && metaData.getDuration() == 0) {
|
||||
// Try to restore replay duration
|
||||
// We need to re-write the packet data in case there are any incomplete packets dangling at the end
|
||||
try (ReplayInputStream in = replayFile.getPacketData(studio, true);
|
||||
ReplayOutputStream out = replayFile.writePacketData(true)) {
|
||||
try (ReplayInputStream in = replayFile.getPacketData(MCVer.getPacketTypeRegistry(true));
|
||||
ReplayOutputStream out = replayFile.writePacketData()) {
|
||||
while (true) {
|
||||
// To prevent failing at un-parsable packets and to support recovery in minimal mode,
|
||||
// we do not use the ReplayIn/OutputStream methods but instead parse the packets ourselves.
|
||||
|
||||
@@ -32,9 +32,6 @@ public interface MinecraftAccessor {
|
||||
//$$ Queue<FutureTask<?>> getScheduledTasks();
|
||||
//#endif
|
||||
|
||||
@Accessor("crashed")
|
||||
boolean hasCrashed();
|
||||
|
||||
@Accessor("crashReport")
|
||||
CrashReport getCrashReporter();
|
||||
|
||||
|
||||
@@ -10,6 +10,10 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
//#if MC>=11500
|
||||
//$$ import net.minecraft.client.util.math.MatrixStack;
|
||||
//#endif
|
||||
|
||||
@Mixin(GameRenderer.class)
|
||||
public class MixinGameRenderer {
|
||||
@Inject(
|
||||
@@ -19,12 +23,24 @@ public class MixinGameRenderer {
|
||||
target = "Lnet/minecraft/client/render/GameRenderer;renderHand:Z"
|
||||
)
|
||||
)
|
||||
private void postRenderWorld(float partialTicks, long nanoTime, CallbackInfo ci) {
|
||||
private void postRenderWorld(
|
||||
float partialTicks,
|
||||
long nanoTime,
|
||||
//#if MC>=11500
|
||||
//$$ MatrixStack matrixStack,
|
||||
//#endif
|
||||
CallbackInfo ci) {
|
||||
PostRenderWorldCallback.EVENT.invoker().postRenderWorld();
|
||||
}
|
||||
|
||||
@Inject(method = "renderHand", at = @At("HEAD"), cancellable = true)
|
||||
private void preRenderHand(Camera camera, float partialTicks, CallbackInfo ci) {
|
||||
private void preRenderHand(
|
||||
//#if MC>=11500
|
||||
//$$ MatrixStack matrixStack,
|
||||
//#endif
|
||||
Camera camera,
|
||||
float partialTicks,
|
||||
CallbackInfo ci) {
|
||||
if (PreRenderHandCallback.EVENT.invoker().preRenderHand()) {
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.replaymod.core.utils;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.net.PercentEscaper;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import com.replaymod.replaystudio.us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||
import de.johni0702.minecraft.gui.GuiRenderer;
|
||||
import de.johni0702.minecraft.gui.RenderInfo;
|
||||
import de.johni0702.minecraft.gui.container.AbstractGuiScrollable;
|
||||
@@ -37,11 +39,9 @@ import org.apache.logging.log4j.Logger;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
import com.github.steveice10.mc.protocol.MinecraftConstants;
|
||||
import net.minecraft.client.network.PlayerListEntry;
|
||||
import net.minecraft.client.util.DefaultSkinHelper;
|
||||
//#else
|
||||
//$$ import com.github.steveice10.mc.protocol.ProtocolConstants;
|
||||
//$$ import net.minecraft.client.Minecraft;
|
||||
//$$ import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
//$$ import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -366,11 +366,9 @@ public class Utils {
|
||||
new GuiLabel()
|
||||
.setColor(Colors.BLACK)
|
||||
.setI18nText("replaymod.gui.minimalmode.supportedversion",
|
||||
//#if MC>=10800
|
||||
MinecraftConstants.GAME_VERSION
|
||||
//#else
|
||||
//$$ ProtocolConstants.GAME_VERSION
|
||||
//#endif
|
||||
ProtocolVersion.v1_7_6.getName()
|
||||
+ " - "
|
||||
+ Iterables.getLast(ProtocolVersion.getProtocols()).getName()
|
||||
));
|
||||
|
||||
open();
|
||||
|
||||
@@ -137,7 +137,15 @@ public class LangResourcePack extends AbstractFileResourcePack {
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<Identifier> findResources(ResourceType resourcePackType, String path, int maxDepth, Predicate<String> filter) {
|
||||
public Collection<Identifier> findResources(
|
||||
ResourceType resourcePackType,
|
||||
//#if MC>=11500
|
||||
//$$ String namespace,
|
||||
//#endif
|
||||
String path,
|
||||
int maxDepth,
|
||||
Predicate<String> filter
|
||||
) {
|
||||
if (resourcePackType == ResourceType.CLIENT_RESOURCES && "lang".equals(path)) {
|
||||
Path base = baseLangPath();
|
||||
//#if MC<11400
|
||||
|
||||
@@ -2,6 +2,9 @@ package com.replaymod.core.versions;
|
||||
|
||||
import com.replaymod.core.mixin.GuiScreenAccessor;
|
||||
import com.replaymod.core.mixin.MinecraftAccessor;
|
||||
import com.replaymod.replaystudio.protocol.PacketTypeRegistry;
|
||||
import com.replaymod.replaystudio.us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||
import com.replaymod.replaystudio.us.myles.ViaVersion.packets.State;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
@@ -27,6 +30,8 @@ import net.minecraft.SharedConstants;
|
||||
import net.minecraft.client.gui.screen.TitleScreen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
//#else
|
||||
//$$ import com.google.common.util.concurrent.FutureCallback;
|
||||
@@ -76,7 +81,9 @@ import net.minecraft.client.render.BufferBuilder;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.render.VertexFormat;
|
||||
import net.minecraft.client.render.VertexFormatElement;
|
||||
//#if MC<11500
|
||||
import net.minecraft.client.render.chunk.ChunkRenderTask;
|
||||
//#endif
|
||||
//#else
|
||||
//$$ import com.replaymod.core.mixin.ResourcePackRepositoryAccessor;
|
||||
//$$ import com.google.common.util.concurrent.Futures;
|
||||
@@ -134,10 +141,18 @@ public class MCVer {
|
||||
//#if MC>=11400
|
||||
return SharedConstants.getGameVersion().getProtocolVersion();
|
||||
//#else
|
||||
// FIXME
|
||||
//$$ throw new UnsupportedOperationException("Minimal mode not supported pre-1.14");
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static PacketTypeRegistry getPacketTypeRegistry(boolean loginPhase) {
|
||||
return PacketTypeRegistry.get(
|
||||
ProtocolVersion.getProtocol(getProtocolVersion()),
|
||||
loginPhase ? State.LOGIN : State.PLAY
|
||||
);
|
||||
}
|
||||
|
||||
public static void addDetail(CrashReportSection category, String name, Callable<String> callable) {
|
||||
//#if MC>=10904
|
||||
//#if MC>=11200
|
||||
@@ -150,6 +165,40 @@ public class MCVer {
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static double Entity_getX(Entity entity) {
|
||||
//#if MC>=11500
|
||||
//$$ return entity.getX();
|
||||
//#else
|
||||
return entity.x;
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static double Entity_getY(Entity entity) {
|
||||
//#if MC>=11500
|
||||
//$$ return entity.getY();
|
||||
//#else
|
||||
return entity.y;
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static double Entity_getZ(Entity entity) {
|
||||
//#if MC>=11500
|
||||
//$$ return entity.getZ();
|
||||
//#else
|
||||
return entity.z;
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static void Entity_setPos(Entity entity, double x, double y, double z) {
|
||||
//#if MC>=11500
|
||||
//$$ entity.setPos(x, y, z);
|
||||
//#else
|
||||
entity.x = x;
|
||||
entity.y = y;
|
||||
entity.z = z;
|
||||
//#endif
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
public static void width(AbstractButtonWidget button, int value) {
|
||||
button.setWidth(value);
|
||||
@@ -314,7 +363,11 @@ public class MCVer {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<Box> cubeList(Cuboid modelRenderer) {
|
||||
//#if MC>=11400
|
||||
//$$ return new ArrayList<>(); // FIXME 1.15
|
||||
//#else
|
||||
return modelRenderer.boxes;
|
||||
//#endif
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -335,8 +388,18 @@ public class MCVer {
|
||||
}
|
||||
|
||||
//#if MC>=11300
|
||||
public static Window newScaledResolution(MinecraftClient mc) {
|
||||
public static Window getWindow(MinecraftClient mc) {
|
||||
//#if MC>=11500
|
||||
//$$ return mc.getWindow();
|
||||
//#else
|
||||
return mc.window;
|
||||
//#endif
|
||||
}
|
||||
//#endif
|
||||
|
||||
//#if MC>=11300
|
||||
public static Window newScaledResolution(MinecraftClient mc) {
|
||||
return getWindow(mc);
|
||||
}
|
||||
//#else
|
||||
//$$ public static ScaledResolution newScaledResolution(Minecraft mc) {
|
||||
@@ -410,10 +473,6 @@ public class MCVer {
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
public static void BufferBuilder_setTranslation(double x, double y, double z) {
|
||||
Tessellator_getBufferBuilder().setOffset(x, y, z);
|
||||
}
|
||||
|
||||
public static void BufferBuilder_beginPosCol(int mode) {
|
||||
Tessellator_getBufferBuilder().begin(
|
||||
mode
|
||||
@@ -441,7 +500,7 @@ public class MCVer {
|
||||
);
|
||||
}
|
||||
|
||||
public static void BufferBuilder_addPosTex(double x, double y, double z, double u, double v) {
|
||||
public static void BufferBuilder_addPosTex(double x, double y, double z, float u, float v) {
|
||||
//#if MC>=10809
|
||||
Tessellator_getBufferBuilder().vertex(x, y, z).texture(u, v).next();
|
||||
//#else
|
||||
@@ -458,7 +517,7 @@ public class MCVer {
|
||||
);
|
||||
}
|
||||
|
||||
public static void BufferBuilder_addPosTexCol(double x, double y, double z, double u, double v, int r, int g, int b, int a) {
|
||||
public static void BufferBuilder_addPosTexCol(double x, double y, double z, float u, float v, int r, int g, int b, int a) {
|
||||
//#if MC>=10809
|
||||
Tessellator_getBufferBuilder().vertex(x, y, z).texture(u, v).color(r, g, b, a).next();
|
||||
//#else
|
||||
@@ -542,7 +601,7 @@ public class MCVer {
|
||||
//#endif
|
||||
}
|
||||
|
||||
//#if MC>=10800
|
||||
//#if MC>=10800 && MC<11500
|
||||
public interface ChunkRenderWorkerAccessor {
|
||||
void doRunTask(ChunkRenderTask task) throws InterruptedException;
|
||||
}
|
||||
@@ -557,11 +616,15 @@ public class MCVer {
|
||||
}
|
||||
|
||||
public static void bindTexture(Identifier texture) {
|
||||
//#if MC>=11500
|
||||
//$$ getMinecraft().getTextureManager().bindTexture(texture);
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
getMinecraft().getTextureManager().bindTexture(texture);
|
||||
//#else
|
||||
//$$ getMinecraft().renderEngine.bindTexture(texture);
|
||||
//#endif
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static float cos(float val) {
|
||||
@@ -751,6 +814,9 @@ public class MCVer {
|
||||
//#endif
|
||||
|
||||
public static boolean isKeyDown(int keyCode) {
|
||||
//#if MC>=11500
|
||||
//$$ return InputUtil.isKeyPressed(getMinecraft().getWindow().getHandle(), keyCode);
|
||||
//#else
|
||||
//#if MC>=11400
|
||||
return InputUtil.isKeyPressed(getMinecraft().window.getHandle(), keyCode);
|
||||
//#else
|
||||
@@ -760,6 +826,7 @@ public class MCVer {
|
||||
//$$ return org.lwjgl.input.Keyboard.isKeyDown(keyCode);
|
||||
//#endif
|
||||
//#endif
|
||||
//#endif
|
||||
}
|
||||
|
||||
//#if MC<11300
|
||||
|
||||
Reference in New Issue
Block a user