Port to MC 1.20

This commit is contained in:
Jonas Herzig
2023-06-12 09:39:48 +02:00
parent 96a05e256f
commit 7726550131
14 changed files with 90 additions and 11 deletions

View File

@@ -252,6 +252,7 @@ dependencies {
11902: '1.19.2', 11902: '1.19.2',
11903: '1.19.3-rc3', 11903: '1.19.3-rc3',
11904: '1.19.4', 11904: '1.19.4',
12000: '1.20',
][mcVersion] ][mcVersion]
mappings 'net.fabricmc:yarn:' + [ mappings 'net.fabricmc:yarn:' + [
11404: '1.14.4+build.16', 11404: '1.14.4+build.16',
@@ -268,6 +269,7 @@ dependencies {
11902: '1.19.2+build.28:v2', 11902: '1.19.2+build.28:v2',
11903: '1.19.3-rc3+build.1:v2', 11903: '1.19.3-rc3+build.1:v2',
11904: '1.19.4+build.1:v2', 11904: '1.19.4+build.1:v2',
12000: '1.20+build.1:v2',
][mcVersion] ][mcVersion]
modImplementation 'net.fabricmc:fabric-loader:0.14.11' modImplementation 'net.fabricmc:fabric-loader:0.14.11'
def fabricApiVersion = [ def fabricApiVersion = [
@@ -285,6 +287,7 @@ dependencies {
11902: '0.68.0+1.19.2', 11902: '0.68.0+1.19.2',
11903: '0.68.1+1.19.3', 11903: '0.68.1+1.19.3',
11904: '0.76.0+1.19.4', 11904: '0.76.0+1.19.4',
12000: '0.83.0+1.20',
][mcVersion] ][mcVersion]
def fabricApiModules = [ def fabricApiModules = [
"api-base", "api-base",
@@ -365,7 +368,7 @@ dependencies {
shadow 'com.github.ReplayMod.JavaBlend:2.79.0:a0696f8' shadow 'com.github.ReplayMod.JavaBlend:2.79.0:a0696f8'
shadow "com.github.ReplayMod:ReplayStudio:d3f8506", shadeExclusions shadow "com.github.ReplayMod:ReplayStudio:a1e2b83", shadeExclusions
// FIXME this should be pulled in by ReplayStudio, and IntelliJ sees it, but javac for some reason does not // FIXME this should be pulled in by ReplayStudio, and IntelliJ sees it, but javac for some reason does not
implementation 'com.github.viaversion:opennbt:0a02214' // 2.0-SNAPSHOT (ViaVersion Edition) implementation 'com.github.viaversion:opennbt:0a02214' // 2.0-SNAPSHOT (ViaVersion Edition)
@@ -376,7 +379,9 @@ dependencies {
shadow 'com.github.ReplayMod:lwjgl-utils:27dcd66' shadow 'com.github.ReplayMod:lwjgl-utils:27dcd66'
if (FABRIC) { if (FABRIC) {
if (mcVersion >= 11904) { if (mcVersion >= 12000) {
modImplementation 'com.terraformersmc:modmenu:7.0.1'
} else if (mcVersion >= 11904) {
modImplementation 'com.terraformersmc:modmenu:6.1.0-rc.4' modImplementation 'com.terraformersmc:modmenu:6.1.0-rc.4'
} else if (mcVersion >= 11903) { } else if (mcVersion >= 11903) {
modImplementation 'com.terraformersmc:modmenu:5.0.0-alpha.4' modImplementation 'com.terraformersmc:modmenu:5.0.0-alpha.4'

2
jGui

Submodule jGui updated: 05f8ac3ed5...7d002840c4

View File

@@ -193,6 +193,7 @@ val doRelease by tasks.registering {
defaultTasks("bundleJar") defaultTasks("bundleJar")
preprocess { preprocess {
val mc12000 = createNode("1.20", 12000, "yarn")
val mc11904 = createNode("1.19.4", 11904, "yarn") val mc11904 = createNode("1.19.4", 11904, "yarn")
val mc11903 = createNode("1.19.3", 11903, "yarn") val mc11903 = createNode("1.19.3", 11903, "yarn")
val mc11902 = createNode("1.19.2", 11902, "yarn") val mc11902 = createNode("1.19.2", 11902, "yarn")
@@ -217,6 +218,7 @@ preprocess {
val mc10800 = createNode("1.8", 10800, "srg") val mc10800 = createNode("1.8", 10800, "srg")
val mc10710 = createNode("1.7.10", 10710, "srg") val mc10710 = createNode("1.7.10", 10710, "srg")
mc12000.link(mc11904)
mc11904.link(mc11903) mc11904.link(mc11903)
mc11903.link(mc11902, file("versions/mapping-fabric-1.19.3-1.19.2.txt")) mc11903.link(mc11902, file("versions/mapping-fabric-1.19.3-1.19.2.txt"))
mc11902.link(mc11901) mc11902.link(mc11901)

View File

@@ -37,6 +37,7 @@ val jGuiVersions = listOf(
"1.19.2", "1.19.2",
"1.19.3", "1.19.3",
"1.19.4", "1.19.4",
"1.20",
) )
val replayModVersions = listOf( val replayModVersions = listOf(
// "1.7.10", // "1.7.10",
@@ -62,6 +63,7 @@ val replayModVersions = listOf(
"1.19.2", "1.19.2",
"1.19.3", "1.19.3",
"1.19.4", "1.19.4",
"1.20",
) )
rootProject.buildFileName = "root.gradle.kts" rootProject.buildFileName = "root.gradle.kts"

View File

@@ -897,4 +897,13 @@ class Patterns {
//#else //#else
//$$ @Pattern private static void REGISTRIES() {} //$$ @Pattern private static void REGISTRIES() {}
//#endif //#endif
@Pattern
public World getWorld(Entity entity) {
//#if MC>=12000
//$$ return entity.getWorld();
//#else
return entity.world;
//#endif
}
} }

View File

@@ -9,12 +9,17 @@ import de.johni0702.minecraft.gui.versions.callbacks.RenderHudCallback;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer; import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.resource.language.I18n; import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.util.math.MatrixStack;
import static com.replaymod.core.ReplayMod.TEXTURE; import static com.replaymod.core.ReplayMod.TEXTURE;
import static com.replaymod.core.ReplayMod.TEXTURE_SIZE; import static com.replaymod.core.ReplayMod.TEXTURE_SIZE;
import static com.mojang.blaze3d.platform.GlStateManager.*; import static com.mojang.blaze3d.platform.GlStateManager.*;
//#if MC>=12000
//$$ import net.minecraft.client.gui.DrawContext;
//#else
import net.minecraft.client.util.math.MatrixStack;
//#endif
/** /**
* Renders overlay during recording. * Renders overlay during recording.
*/ */
@@ -33,7 +38,11 @@ public class GuiRecordingOverlay extends EventRegistrations {
* Render the recording icon and text in the top left corner of the screen. * Render the recording icon and text in the top left corner of the screen.
*/ */
{ on(RenderHudCallback.EVENT, (stack, partialTicks) -> renderRecordingIndicator(stack)); } { on(RenderHudCallback.EVENT, (stack, partialTicks) -> renderRecordingIndicator(stack)); }
//#if MC>=12000
//$$ private void renderRecordingIndicator(DrawContext stack) {
//#else
private void renderRecordingIndicator(MatrixStack stack) { private void renderRecordingIndicator(MatrixStack stack) {
//#endif
if (guiControls.isStopped()) return; if (guiControls.isStopped()) return;
if (settingsRegistry.get(Setting.INDICATOR)) { if (settingsRegistry.get(Setting.INDICATOR)) {
TextRenderer fontRenderer = mc.textRenderer; TextRenderer fontRenderer = mc.textRenderer;

View File

@@ -27,6 +27,9 @@ import net.minecraft.client.render.WorldRenderer;
public abstract class Mixin_ChromaKeyForceSky { public abstract class Mixin_ChromaKeyForceSky {
@Shadow @Final private MinecraftClient client; @Shadow @Final private MinecraftClient client;
//#if MC>=11700
//$$ // Sky appears to be rendered unconditionally now
//#else
//#if MC>=11500 //#if MC>=11500
@ModifyConstant(method = "render", constant = @Constant(intValue = 4)) @ModifyConstant(method = "render", constant = @Constant(intValue = 4))
//#elseif MC>=11400 //#elseif MC>=11400
@@ -44,4 +47,5 @@ public abstract class Mixin_ChromaKeyForceSky {
} }
return value; return value;
} }
//#endif
} }

View File

@@ -41,6 +41,11 @@ import net.minecraft.sound.SoundCategory;
import net.minecraft.client.render.RenderTickCounter; import net.minecraft.client.render.RenderTickCounter;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
//#if MC>=12000
//$$ import com.mojang.blaze3d.systems.VertexSorter;
//$$ import net.minecraft.client.gui.DrawContext;
//#endif
//#if MC>=11700 //#if MC>=11700
//$$ import net.minecraft.client.render.DiffuseLighting; //$$ import net.minecraft.client.render.DiffuseLighting;
//$$ import net.minecraft.util.math.Matrix4f; //$$ import net.minecraft.util.math.Matrix4f;
@@ -492,7 +497,11 @@ public class VideoRenderer implements RenderInfo {
//$$ (float) (window.getFramebufferHeight() / window.getScaleFactor()), //$$ (float) (window.getFramebufferHeight() / window.getScaleFactor()),
//$$ 1000, //$$ 1000,
//$$ 3000 //$$ 3000
//$$ )); //$$ )
//#if MC>=12000
//$$ , VertexSorter.BY_Z
//#endif
//$$ );
//$$ MatrixStack matrixStack = RenderSystem.getModelViewStack(); //$$ MatrixStack matrixStack = RenderSystem.getModelViewStack();
//$$ matrixStack.loadIdentity(); //$$ matrixStack.loadIdentity();
//$$ matrixStack.translate(0, 0, -2000); //$$ matrixStack.translate(0, 0, -2000);
@@ -544,7 +553,9 @@ public class VideoRenderer implements RenderInfo {
try { try {
mc.currentScreen = gui.toMinecraft(); mc.currentScreen = gui.toMinecraft();
mc.getOverlay().render( mc.getOverlay().render(
//#if MC>=11600 //#if MC>=12000
//$$ new DrawContext(mc, mc.getBufferBuilders().getEntityVertexConsumers()),
//#elseif MC>=11600
new MatrixStack(), new MatrixStack(),
//#endif //#endif
mouseX, mouseY, 0); mouseX, mouseY, 0);
@@ -554,7 +565,9 @@ public class VideoRenderer implements RenderInfo {
} else { } else {
gui.toMinecraft().tick(); gui.toMinecraft().tick();
gui.toMinecraft().render( gui.toMinecraft().render(
//#if MC>=11600 //#if MC>=12000
//$$ new DrawContext(mc, mc.getBufferBuilders().getEntityVertexConsumers()),
//#elseif MC>=11600
new MatrixStack(), new MatrixStack(),
//#endif //#endif
mouseX, mouseY, 0); mouseX, mouseY, 0);

View File

@@ -440,7 +440,11 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
//#endif //#endif
LightingProvider provider = world.getChunkManager().getLightingProvider(); LightingProvider provider = world.getChunkManager().getLightingProvider();
while (provider.hasUpdates()) { while (provider.hasUpdates()) {
//#if MC>=12000
//$$ provider.doLightUpdates();
//#else
provider.doLightUpdates(Integer.MAX_VALUE, true, true); provider.doLightUpdates(Integer.MAX_VALUE, true, true);
//#endif
} }
} }
}; };
@@ -712,6 +716,9 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
//#if MC>=11900 //#if MC>=11900
//$$ , java.util.Optional.empty() //$$ , java.util.Optional.empty()
//#endif //#endif
//#if MC>=12000
//$$ , packet.portalCooldown()
//#endif
); );
//#else //#else
//#if MC>=10800 //#if MC>=10800
@@ -775,6 +782,9 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
//#if MC>=11900 //#if MC>=11900
//$$ , java.util.Optional.empty() //$$ , java.util.Optional.empty()
//#endif //#endif
//#if MC>=12000
//$$ , respawn.getPortalCooldown()
//#endif
); );
//#else //#else
//#if MC>=10809 //#if MC>=10809

View File

@@ -5,6 +5,7 @@ import com.replaymod.core.utils.WrappedTimer;
import com.replaymod.core.versions.MCVer; import com.replaymod.core.versions.MCVer;
import com.replaymod.replay.camera.CameraController; import com.replaymod.replay.camera.CameraController;
import com.replaymod.replay.camera.CameraEntity; import com.replaymod.replay.camera.CameraEntity;
import de.johni0702.minecraft.gui.versions.ScreenExt;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.RenderTickCounter; import net.minecraft.client.render.RenderTickCounter;
@@ -78,7 +79,7 @@ public class InputReplayTimer extends WrappedTimer {
// tick speed may vary or there may not be any ticks at all (when the replay is paused) // tick speed may vary or there may not be any ticks at all (when the replay is paused)
if (mod.getReplayHandler() != null && mc.world != null && mc.player != null) { if (mod.getReplayHandler() != null && mc.world != null && mc.player != null) {
//#if MC>=11400 //#if MC>=11400
if (mc.currentScreen == null || mc.currentScreen.passEvents) { if (mc.currentScreen == null || ((ScreenExt) mc.currentScreen).doesPassEvents()) {
GLFW.glfwPollEvents(); GLFW.glfwPollEvents();
MCVer.processKeyBinds(); MCVer.processKeyBinds();
} }

View File

@@ -42,6 +42,11 @@ import net.minecraft.network.ClientConnection;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
//#if MC>=12000
//$$ import com.mojang.blaze3d.systems.VertexSorter;
//$$ import net.minecraft.client.gui.DrawContext;
//#endif
//#if MC>=11904 //#if MC>=11904
//$$ import net.minecraft.network.PacketBundler; //$$ import net.minecraft.network.PacketBundler;
//#endif //#endif
@@ -653,7 +658,11 @@ public class ReplayHandler {
//$$ (float) (window.getFramebufferHeight() / window.getScaleFactor()), //$$ (float) (window.getFramebufferHeight() / window.getScaleFactor()),
//$$ 1000, //$$ 1000,
//$$ 3000 //$$ 3000
//$$ )); //$$ )
//#if MC>=12000
//$$ , VertexSorter.BY_Z
//#endif
//$$ );
//$$ MatrixStack matrixStack = RenderSystem.getModelViewStack(); //$$ MatrixStack matrixStack = RenderSystem.getModelViewStack();
//$$ matrixStack.loadIdentity(); //$$ matrixStack.loadIdentity();
//$$ matrixStack.translate(0, 0, -2000); //$$ matrixStack.translate(0, 0, -2000);
@@ -676,7 +685,9 @@ public class ReplayHandler {
//#endif //#endif
guiScreen.toMinecraft().init(mc, window.getScaledWidth(), window.getScaledHeight()); guiScreen.toMinecraft().init(mc, window.getScaledWidth(), window.getScaledHeight());
//#if MC>=11600 //#if MC>=12000
//$$ guiScreen.toMinecraft().render(new DrawContext(mc, mc.getBufferBuilders().getEntityVertexConsumers()), 0, 0, 0);
//#elseif MC>=11600
guiScreen.toMinecraft().render(new MatrixStack(), 0, 0, 0); guiScreen.toMinecraft().render(new MatrixStack(), 0, 0, 0);
//#else //#else
//#if MC>=11400 //#if MC>=11400

View File

@@ -332,7 +332,12 @@ public class CameraEntity
public void afterSpawn() { public void afterSpawn() {
// Make sure our world is up-to-date in case of world changes // Make sure our world is up-to-date in case of world changes
if (this.client.world != null) { if (this.client.world != null) {
// FIXME cannot use Patters because `setWorld` is `protected` in 1.20
//#if MC>=12000
//$$ this.setWorld(this.client.world);
//#else
this.world = this.client.world; this.world = this.client.world;
//#endif
} }
super.afterSpawn(); super.afterSpawn();
} }

View File

@@ -16,6 +16,10 @@ import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.AbstractButtonWidget; import net.minecraft.client.gui.widget.AbstractButtonWidget;
//#if MC>=12000
//$$ import net.minecraft.client.gui.DrawContext;
//#endif
//#if MC>=11904 //#if MC>=11904
//#else //#else
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
@@ -316,7 +320,10 @@ public class GuiHandler extends EventRegistrations {
this::onButton this::onButton
) { ) {
@Override @Override
//#if MC>=11904 //#if MC>=12000
//$$ public void renderButton(DrawContext context, int mouseX, int mouseY, float delta) {
//$$ super.renderButton(context, mouseX, mouseY, delta);
//#elseif MC>=11904
//$$ public void renderButton(MatrixStack context, int mouseX, int mouseY, float delta) { //$$ public void renderButton(MatrixStack context, int mouseX, int mouseY, float delta) {
//$$ super.renderButton(context, mouseX, mouseY, delta); //$$ super.renderButton(context, mouseX, mouseY, delta);
//#else //#else

View File

@@ -30,6 +30,7 @@ public class LoadingPlugin implements IFMLLoadingPlugin {
MixinBootstrap.init(); MixinBootstrap.init();
} }
Mixins.addConfiguration("mixins.jgui.json");
Mixins.addConfiguration("mixins.core.replaymod.json"); Mixins.addConfiguration("mixins.core.replaymod.json");
Mixins.addConfiguration("mixins.recording.replaymod.json"); Mixins.addConfiguration("mixins.recording.replaymod.json");
Mixins.addConfiguration("mixins.render.replaymod.json"); Mixins.addConfiguration("mixins.render.replaymod.json");