From b8e1a0a4e487aff3da0e1fe7bc407cdfa8fbcb4a Mon Sep 17 00:00:00 2001 From: ferriarnus <61201275+ferriarnus@users.noreply.github.com> Date: Mon, 3 Jun 2024 02:19:53 +0200 Subject: [PATCH] well it "loads" --- build.gradle | 13 ++-- gradle.properties | 8 +- .../replaymod/core/KeyBindingRegistry.java | 3 +- .../java/com/replaymod/core/ReplayMod.java | 9 ++- .../com/replaymod/core/ReplayModBackend.java | 3 +- .../core/mixin/MixinGameRenderer.java | 10 +-- .../replaymod/core/utils/Restrictions.java | 2 +- .../core/versions/LangResourcePack.java | 6 +- .../com/replaymod/core/versions/MCVer.java | 25 ++++-- .../com/replaymod/core/versions/Patterns.java | 7 +- .../recording/ReplayModRecording.java | 15 ++-- .../mixin/MixinNetHandlerPlayClient.java | 6 +- .../recording/packet/PacketListener.java | 44 +++++++---- .../java/com/replaymod/render/blend/Util.java | 2 +- .../render/mixin/Mixin_ForceChunkLoading.java | 12 +-- .../mixin/Mixin_Omnidirectional_Rotation.java | 3 +- .../mixin/Mixin_Stereoscopic_Camera.java | 6 +- .../render/rendering/VideoRenderer.java | 5 +- .../replaymod/replay/FullReplaySender.java | 13 ++-- .../com/replaymod/replay/NoGuiScreenshot.java | 2 +- .../replaymod/replay/QuickReplaySender.java | 3 +- .../com/replaymod/replay/ReplayHandler.java | 38 ++++++++-- .../replaymod/replay/mixin/MixinCamera.java | 4 +- .../preview/PathPreviewRenderer.java | 12 +-- .../gui/container/AbstractGuiScreen.java | 2 +- .../gui/element/AbstractGuiTextField.java | 3 +- .../element/advanced/AbstractGuiTextArea.java | 3 +- .../mixin/Mixin_RenderHudCallback.java | 76 +++++++++---------- .../resources/META-INF/accesstransformer.cfg | 4 + .../{mods.toml => neoforge.mods.toml} | 9 ++- src/main/resources/mixins.jgui.json | 2 +- 31 files changed, 212 insertions(+), 138 deletions(-) create mode 100644 src/main/resources/META-INF/accesstransformer.cfg rename src/main/resources/META-INF/{mods.toml => neoforge.mods.toml} (90%) diff --git a/build.gradle b/build.gradle index f8c13dd..31d948c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'dev.architectury.loom' version '1.4-SNAPSHOT' + id 'dev.architectury.loom' version '1.6-SNAPSHOT' id 'maven-publish' id "com.github.johnrengelman.shadow" version "8.1.1" } @@ -7,8 +7,8 @@ plugins { version = project.mod_version group = project.maven_group -sourceCompatibility = JavaVersion.VERSION_17 -targetCompatibility = JavaVersion.VERSION_17 +sourceCompatibility = JavaVersion.VERSION_21 +targetCompatibility = JavaVersion.VERSION_21 loom { runs { @@ -16,6 +16,9 @@ loom { vmArgs("-Xmx8G", "-XX:+UseZGC") } } + mixin { + useLegacyMixinAp = false + } silentMojangMappingsLicense() } @@ -31,7 +34,7 @@ configurations { processResources { inputs.property "version", project.version archivesBaseName = "reforgedplaymod-${project.minecraft_version}" - filesMatching("META-INF/mods.toml") { + filesMatching("META-INF/neoforge.mods.toml") { expand "version": project.version } } @@ -68,7 +71,7 @@ dependencies { mappings loom.layered() { it.mappings("net.fabricmc:yarn:${project.yarn_mappings}:v2") - it.mappings file("mappings/yarnpatch.tiny") + it.mappings("dev.architectury:yarn-mappings-patch-neoforge:1.20.5+build.3") } // To change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" diff --git a/gradle.properties b/gradle.properties index f42e55f..57e2ba2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,12 +3,12 @@ org.gradle.jvmargs=-Xmx3G # Fabric Properties # check these on https://modmuss50.me/fabric.html -minecraft_version=1.20.4 -yarn_mappings=1.20.4+build.1 +minecraft_version=1.20.6 +yarn_mappings=1.20.6+build.2 loader_version=0.15.0 #Fabric api -fabric_version=0.91.1+1.20.4 +fabric_version=0.91.1+1.20.6 # Mod Properties mod_version=0.1 @@ -17,4 +17,4 @@ archives_base_name=replaymod # Dependencies # check this on https://modmuss50.me/fabric.html loom.platform=neoforge -neoforge_version=20.4.234 \ No newline at end of file +neoforge_version=20.6.100-beta \ No newline at end of file diff --git a/src/main/java/com/replaymod/core/KeyBindingRegistry.java b/src/main/java/com/replaymod/core/KeyBindingRegistry.java index c740ea8..926245a 100644 --- a/src/main/java/com/replaymod/core/KeyBindingRegistry.java +++ b/src/main/java/com/replaymod/core/KeyBindingRegistry.java @@ -23,6 +23,7 @@ import net.minecraft.util.Identifier; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.fml.common.Mod; import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent; @@ -42,7 +43,7 @@ import java.util.function.Consumer; import java.util.function.Supplier; -@Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) +@EventBusSubscriber(modid = MOD_ID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) public class KeyBindingRegistry extends EventRegistrations { private static final String CATEGORY = "replaymod.title"; //#if FABRIC>=1 && MC<11600 diff --git a/src/main/java/com/replaymod/core/ReplayMod.java b/src/main/java/com/replaymod/core/ReplayMod.java index 53cab39..ef91f82 100644 --- a/src/main/java/com/replaymod/core/ReplayMod.java +++ b/src/main/java/com/replaymod/core/ReplayMod.java @@ -19,6 +19,8 @@ import com.replaymod.simplepathing.ReplayModSimplePathing; import net.minecraft.client.MinecraftClient; import net.minecraft.resource.DirectoryResourcePack; +import net.minecraft.resource.ResourcePackInfo; +import net.minecraft.resource.ResourcePackSource; import net.minecraft.text.PlainTextContent; import net.minecraft.text.Style; import net.minecraft.text.Text; @@ -33,6 +35,7 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; @@ -85,7 +88,7 @@ public ReplayMod(ReplayModBackend backend) { // Check Minecraft protocol version for compatibility if (!ProtocolVersion.isRegistered(MCVer.getProtocolVersion()) && !Boolean.parseBoolean(System.getProperty("replaymod.skipversioncheck", "false"))) { - minimalMode = true; + //minimalMode = true; } // Register all RM modules @@ -121,13 +124,13 @@ private static DirectoryResourcePack createJGuiResourcePack() { } } //#if MC>=11903 - return new DirectoryResourcePack(JGUI_RESOURCE_PACK_NAME, folder.toPath(), true) { + return new DirectoryResourcePack(new ResourcePackInfo(JGUI_RESOURCE_PACK_NAME, Text.literal(JGUI_RESOURCE_PACK_NAME), ResourcePackSource.BUILTIN, Optional.empty()), folder.toPath()) { //#else //$$ return new DirectoryResourcePack(folder) { //#endif @Override //#if MC>=11400 - public String getName() { + public String getId() { //#else //$$ public String getPackName() { //#endif diff --git a/src/main/java/com/replaymod/core/ReplayModBackend.java b/src/main/java/com/replaymod/core/ReplayModBackend.java index 03c2db5..24640b1 100644 --- a/src/main/java/com/replaymod/core/ReplayModBackend.java +++ b/src/main/java/com/replaymod/core/ReplayModBackend.java @@ -3,6 +3,7 @@ import net.minecraft.SharedConstants; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.fml.common.Mod; import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; import net.neoforged.fml.event.lifecycle.FMLConstructModEvent; @@ -10,7 +11,7 @@ import static com.replaymod.core.ReplayMod.MOD_ID; -@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, modid = MOD_ID, value = Dist.CLIENT) +@EventBusSubscriber(bus = EventBusSubscriber.Bus.MOD, modid = MOD_ID, value = Dist.CLIENT) @Mod(MOD_ID) public class ReplayModBackend { private final ReplayMod mod = new ReplayMod(this); diff --git a/src/main/java/com/replaymod/core/mixin/MixinGameRenderer.java b/src/main/java/com/replaymod/core/mixin/MixinGameRenderer.java index a7c817a..4bf8dbf 100644 --- a/src/main/java/com/replaymod/core/mixin/MixinGameRenderer.java +++ b/src/main/java/com/replaymod/core/mixin/MixinGameRenderer.java @@ -6,6 +6,7 @@ import net.minecraft.client.render.Camera; import net.minecraft.client.render.GameRenderer; import net.minecraft.client.util.math.MatrixStack; +import org.joml.Matrix4f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -24,22 +25,21 @@ private void postRenderWorld( float partialTicks, long nanoTime, //#if MC>=11500 - MatrixStack matrixStack, //#endif CallbackInfo ci) { //#if MC<11500 //$$ MatrixStack matrixStack = new MatrixStack(); //#endif - PostRenderWorldCallback.EVENT.invoker().postRenderWorld(matrixStack); + PostRenderWorldCallback.EVENT.invoker().postRenderWorld(new MatrixStack()); } @Inject(method = "renderHand", at = @At("HEAD"), cancellable = true) private void preRenderHand( - //#if MC>=11500 - MatrixStack matrixStack, - //#endif Camera camera, + //#if MC>=11500 float partialTicks, + Matrix4f matrixStack, + //#endif CallbackInfo ci) { if (PreRenderHandCallback.EVENT.invoker().preRenderHand()) { ci.cancel(); diff --git a/src/main/java/com/replaymod/core/utils/Restrictions.java b/src/main/java/com/replaymod/core/utils/Restrictions.java index 59f3155..60bb7a9 100644 --- a/src/main/java/com/replaymod/core/utils/Restrictions.java +++ b/src/main/java/com/replaymod/core/utils/Restrictions.java @@ -28,7 +28,7 @@ public class Restrictions { public String handle(CustomPayloadS2CPacket packet) { //#if MC>=12002 PacketByteBuf buffer = new PacketByteBuf(Unpooled.buffer()); - packet.write(buffer); + CustomPayloadS2CPacket.CONFIGURATION_CODEC.encode(buffer, packet); //#elseif MC>=10800 //$$ PacketByteBuf buffer = packet.getData(); //#else diff --git a/src/main/java/com/replaymod/core/versions/LangResourcePack.java b/src/main/java/com/replaymod/core/versions/LangResourcePack.java index e624557..6d4ba3f 100644 --- a/src/main/java/com/replaymod/core/versions/LangResourcePack.java +++ b/src/main/java/com/replaymod/core/versions/LangResourcePack.java @@ -4,7 +4,10 @@ import com.google.gson.Gson; import com.replaymod.core.ReplayMod; import net.minecraft.resource.AbstractFileResourcePack; +import net.minecraft.resource.ResourcePackInfo; +import net.minecraft.resource.ResourcePackSource; import net.minecraft.resource.ResourceType; +import net.minecraft.text.Text; import net.minecraft.util.Identifier; import net.neoforged.fml.loading.LoadingModList; import net.neoforged.fml.loading.moddiscovery.ModFileInfo; @@ -23,6 +26,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.function.Consumer; import java.util.function.Predicate; @@ -65,7 +69,7 @@ public class LangResourcePack extends AbstractFileResourcePack { private final Path basePath; public LangResourcePack() { //#if MC>=11903 - super(NAME, true); + super(new ResourcePackInfo(NAME, Text.literal("NAME"), ResourcePackSource.BUILTIN, Optional.empty())); //#else //$$ super(new File(NAME)); //#endif diff --git a/src/main/java/com/replaymod/core/versions/MCVer.java b/src/main/java/com/replaymod/core/versions/MCVer.java index 39acc46..0273fc7 100644 --- a/src/main/java/com/replaymod/core/versions/MCVer.java +++ b/src/main/java/com/replaymod/core/versions/MCVer.java @@ -11,6 +11,14 @@ import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.render.BufferBuilder; import net.minecraft.network.NetworkState; +import net.minecraft.network.RegistryByteBuf; +import net.minecraft.network.state.ConfigurationStates; +import net.minecraft.network.state.HandshakeStates; +import net.minecraft.network.state.LoginStates; +import net.minecraft.network.state.PlayStateFactories; +import net.minecraft.network.state.QueryStates; +import net.minecraft.registry.DynamicRegistryManager; +import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; import net.minecraft.util.Util; import net.minecraft.util.math.Vec3d; @@ -86,6 +94,7 @@ //$$ import static org.lwjgl.opengl.GL11.*; //#endif +import javax.net.ssl.SSLEngineResult; import java.io.File; import java.net.URI; import java.util.List; @@ -106,19 +115,19 @@ public static int getProtocolVersion() { public static NetworkState asMc(State state) { switch (state) { - case HANDSHAKE: return NetworkState.HANDSHAKING; - case STATUS: return NetworkState.STATUS; - case LOGIN: return NetworkState.LOGIN; + case HANDSHAKE: return HandshakeStates.C2S; + case STATUS: return QueryStates.S2C; + case LOGIN: return LoginStates.S2C; //#if MC>=12002 - case CONFIGURATION: return NetworkState.CONFIGURATION; + case CONFIGURATION: return ConfigurationStates.S2C; //#endif - case PLAY: return NetworkState.PLAY; + case PLAY: return PlayStateFactories.S2C.bind(RegistryByteBuf.makeFactory(DynamicRegistryManager.of(Registries.REGISTRIES))); } throw new IllegalArgumentException("Unexpected value: " + state); } public static State fromMc(NetworkState mcState) { - switch (mcState) { + switch (mcState.id()) { case HANDSHAKING: return State.HANDSHAKE; case STATUS: return State.STATUS; case LOGIN: return State.LOGIN; @@ -398,7 +407,7 @@ public static void openURL(URI url) { public static void pushMatrix() { //#if MC>=11700 - RenderSystem.getModelViewStack().push(); + RenderSystem.getModelViewStack().pushMatrix(); //#else //$$ GlStateManager.pushMatrix(); //#endif @@ -406,7 +415,7 @@ public static void pushMatrix() { public static void popMatrix() { //#if MC>=11700 - RenderSystem.getModelViewStack().pop(); + RenderSystem.getModelViewStack().popMatrix(); RenderSystem.applyModelViewMatrix(); //#else //$$ GlStateManager.popMatrix(); diff --git a/src/main/java/com/replaymod/core/versions/Patterns.java b/src/main/java/com/replaymod/core/versions/Patterns.java index bbeb91a..2ad87f3 100644 --- a/src/main/java/com/replaymod/core/versions/Patterns.java +++ b/src/main/java/com/replaymod/core/versions/Patterns.java @@ -19,6 +19,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.network.NetworkSide; import net.minecraft.network.NetworkState; +import net.minecraft.network.handler.PacketCodecDispatcher; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.s2c.common.CustomPayloadS2CPacket; import net.minecraft.resource.Resource; @@ -575,7 +576,7 @@ private static void GL11_glTranslatef(float x, float y, float z) { @Pattern private static void GL11_glRotatef(float angle, float x, float y, float z) { //#if MC>=11700 - com.mojang.blaze3d.systems.RenderSystem.getModelViewStack().multiply(com.replaymod.core.versions.MCVer.quaternion(angle, new org.joml.Vector3f(x, y, z))); + com.mojang.blaze3d.systems.RenderSystem.getModelViewStack().rotate(com.replaymod.core.versions.MCVer.quaternion(angle, new org.joml.Vector3f(x, y, z))); //#else //$$ GL11.glRotatef(angle, x, y, z); //#endif @@ -916,7 +917,7 @@ public World getWorld(Entity entity) { @Pattern public Object channel(CustomPayloadS2CPacket packet) { //#if MC>=12002 - return packet.payload().id(); + return packet.payload().getId().id(); //#else //$$ return packet.getChannel(); //#endif @@ -926,7 +927,7 @@ public Object channel(CustomPayloadS2CPacket packet) { @Pattern public Integer getPacketId(NetworkState state, NetworkSide side, Packet packet) throws Exception { //#if MC>=12002 - return state.getHandler(side).getId(packet); + return ((PacketCodecDispatcher) state.codec()).typeToIndex.get(packet); //#else //$$ return state.getPacketId(side, packet); //#endif diff --git a/src/main/java/com/replaymod/recording/ReplayModRecording.java b/src/main/java/com/replaymod/recording/ReplayModRecording.java index 1aeeae1..ee98171 100644 --- a/src/main/java/com/replaymod/recording/ReplayModRecording.java +++ b/src/main/java/com/replaymod/recording/ReplayModRecording.java @@ -12,10 +12,13 @@ import io.netty.channel.Channel; import io.netty.util.AttributeKey; import net.minecraft.network.ClientConnection; +import net.minecraft.network.codec.PacketCodec; +import net.minecraft.network.codec.PacketCodecs; +import net.minecraft.network.packet.CustomPayload; import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.fml.common.Mod; -import net.neoforged.neoforge.network.event.RegisterPayloadHandlerEvent; -import net.neoforged.neoforge.network.registration.IPayloadRegistrar; +import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -34,7 +37,7 @@ //$$ import io.netty.channel.ChannelHandler; //#endif -@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, modid = ReplayMod.MOD_ID) +@EventBusSubscriber(bus = EventBusSubscriber.Bus.MOD, modid = ReplayMod.MOD_ID) public class ReplayModRecording implements Module { private static final Logger LOGGER = LogManager.getLogger(); @@ -110,8 +113,8 @@ public ConnectionEventHandler getConnectionEventHandler() { } @SubscribeEvent - public static void registerNetwork(RegisterPayloadHandlerEvent event) { - final IPayloadRegistrar registrar = event.registrar(ReplayMod.MOD_ID).optional(); - registrar.play(Restrictions.PLUGIN_CHANNEL, packetByteBuf -> null, (arg, playPayloadContext) -> {}); + public static void registerNetwork(RegisterPayloadHandlersEvent event) { + final var registrar = event.registrar(ReplayMod.MOD_ID).optional(); + registrar.playToClient(new CustomPayload.Id(Restrictions.PLUGIN_CHANNEL), PacketCodec.ofStatic((buf, value) -> {}, buf -> null), (arg, playPayloadContext) -> {}); } } diff --git a/src/main/java/com/replaymod/recording/mixin/MixinNetHandlerPlayClient.java b/src/main/java/com/replaymod/recording/mixin/MixinNetHandlerPlayClient.java index bacfaf7..cef7a62 100644 --- a/src/main/java/com/replaymod/recording/mixin/MixinNetHandlerPlayClient.java +++ b/src/main/java/com/replaymod/recording/mixin/MixinNetHandlerPlayClient.java @@ -5,7 +5,10 @@ import com.replaymod.replaystudio.lib.viaversion.api.protocol.packet.State; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayNetworkHandler; +import net.minecraft.network.RegistryByteBuf; import net.minecraft.network.packet.s2c.play.PlayerRespawnS2CPacket; +import net.minecraft.registry.DynamicRegistryManager; +import net.minecraft.registry.Registries; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -72,8 +75,7 @@ public void recordOwnJoin(PlayerListS2CPacket packet, CallbackInfo ci) { // to parse it instead. ByteBuf byteBuf = Unpooled.buffer(); try { - packet.write(new PacketByteBuf(byteBuf)); - + PlayerListS2CPacket.CODEC.encode(new RegistryByteBuf(byteBuf, DynamicRegistryManager.of(Registries.REGISTRIES)), packet); byteBuf.readerIndex(0); byte[] array = new byte[byteBuf.readableBytes()]; byteBuf.readBytes(array); diff --git a/src/main/java/com/replaymod/recording/packet/PacketListener.java b/src/main/java/com/replaymod/recording/packet/PacketListener.java index fc1dc29..a0b74c0 100644 --- a/src/main/java/com/replaymod/recording/packet/PacketListener.java +++ b/src/main/java/com/replaymod/recording/packet/PacketListener.java @@ -28,11 +28,23 @@ import io.netty.util.AttributeKey; import net.minecraft.client.MinecraftClient; import net.minecraft.network.ClientConnection; +import net.minecraft.network.NetworkPhase; +import net.minecraft.network.RegistryByteBuf; +import net.minecraft.network.encoding.VarInts; +import net.minecraft.network.handler.DecoderHandler; +import net.minecraft.network.handler.PacketCodecDispatcher; import net.minecraft.network.packet.s2c.common.CustomPayloadS2CPacket; import net.minecraft.network.packet.s2c.common.DisconnectS2CPacket; import net.minecraft.entity.Entity; import net.minecraft.network.NetworkState; import net.minecraft.network.PacketByteBuf; +import net.minecraft.network.state.ConfigurationStates; +import net.minecraft.network.state.HandshakeStates; +import net.minecraft.network.state.LoginStates; +import net.minecraft.network.state.PlayStateFactories; +import net.minecraft.network.state.QueryStates; +import net.minecraft.registry.DynamicRegistryManager; +import net.minecraft.registry.Registries; import net.minecraft.text.PlainTextContent; import net.minecraft.util.crash.CrashReport; import org.apache.commons.io.FilenameUtils; @@ -101,12 +113,12 @@ public class PacketListener extends ChannelInboundHandlerAdapter { //$$ new ResourcePackSendS2CPacket() //#endif ; - private static final int PACKET_ID_RESOURCE_PACK_SEND = getPacketId(NetworkState.PLAY, RESOURCE_PACK_SEND_PACKET); + private static final int PACKET_ID_RESOURCE_PACK_SEND = getPacketId(PlayStateFactories.S2C.bind(RegistryByteBuf.makeFactory(DynamicRegistryManager.of(Registries.REGISTRIES))), RESOURCE_PACK_SEND_PACKET); //#if MC>=12002 - private static final int PACKET_ID_CONFIG_RESOURCE_PACK_SEND = getPacketId(NetworkState.CONFIGURATION, RESOURCE_PACK_SEND_PACKET); + private static final int PACKET_ID_CONFIG_RESOURCE_PACK_SEND = getPacketId(ConfigurationStates.S2C, RESOURCE_PACK_SEND_PACKET); //#endif //#if MC>=11700 - private static final int PACKET_ID_LOGIN_COMPRESSION = getPacketId(NetworkState.LOGIN, new LoginCompressionS2CPacket(0)); + private static final int PACKET_ID_LOGIN_COMPRESSION = getPacketId(LoginStates.S2C, new LoginCompressionS2CPacket(0)); //#else //$$ private static final int PACKET_ID_LOGIN_COMPRESSION = getPacketId(NetworkState.LOGIN, new LoginCompressionS2CPacket()); //#endif @@ -365,7 +377,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception // ourselves to be able to store them //#if MC>=11904 //#if MC>=12002 - PacketBundleHandler bundleHandler = ctx.channel().attr(ClientConnection.CLIENTBOUND_PROTOCOL_KEY).get().getBundler(); + PacketBundleHandler bundleHandler = connectionState.bundleHandler(); //#else //$$ PacketBundleHandler bundleHandler = ctx.channel().attr(PacketBundleHandler.KEY).get().getBundler(NetworkSide.CLIENTBOUND); //#endif @@ -389,9 +401,9 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception } if (packet != null) { - if (connectionState == NetworkState.PLAY && packet.getId() == PACKET_ID_RESOURCE_PACK_SEND + if (connectionState.id() == NetworkPhase.PLAY && packet.getId() == PACKET_ID_RESOURCE_PACK_SEND //#if MC>=12002 - || connectionState == NetworkState.CONFIGURATION && packet.getId() == PACKET_ID_CONFIG_RESOURCE_PACK_SEND + || connectionState.id() == NetworkPhase.CONFIGURATION && packet.getId() == PACKET_ID_CONFIG_RESOURCE_PACK_SEND //#endif ) { ClientConnection connection = ctx.pipeline().get(ClientConnection.class); @@ -411,11 +423,12 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception private NetworkState getConnectionState() { ChannelHandlerContext ctx = context; if (ctx == null) { - return NetworkState.LOGIN; + return LoginStates.S2C; } + return ((DecoderHandler)context.pipeline().get("decoder")).state; //#if MC>=12002 - AttributeKey> key = ClientConnection.CLIENTBOUND_PROTOCOL_KEY; - return ctx.channel().attr(key).get().getState(); + //AttributeKey> key = ClientConnection.CLIENTBOUND_PROTOCOL_KEY; + //return ctx.channel().attr(key).get().getState(); //#else //$$ AttributeKey key = ClientConnection.PROTOCOL_ATTRIBUTE_KEY; //$$ return ctx.channel().attr(key).get(); @@ -424,7 +437,7 @@ private NetworkState getConnectionState() { private static Packet encodeMcPacket(NetworkState connectionState, net.minecraft.network.packet.Packet packet) throws Exception { //#if MC>=10800 - Integer packetId = connectionState.getHandler(NetworkSide.CLIENTBOUND).getId(packet); + Integer packetId = ((PacketCodecDispatcher) connectionState.codec()).typeToIndex.get(packet.getPacketId()); //#else //$$ Integer packetId = (Integer) connectionState.func_150755_b().inverse().get(packet.getClass()); //#endif @@ -433,7 +446,7 @@ private static Packet encodeMcPacket(NetworkState connectionState, net.minecraft } ByteBuf byteBuf = Unpooled.buffer(); try { - packet.write(new PacketByteBuf(byteBuf)); + connectionState.codec().encode(new PacketByteBuf(byteBuf), packet); return new Packet( MCVer.getPacketTypeRegistry(connectionState), packetId, @@ -450,11 +463,12 @@ private static Packet encodeMcPacket(NetworkState connectionState, net.minecraft private static net.minecraft.network.packet.Packet decodeMcPacket(Packet packet) throws IOException, IllegalAccessException, InstantiationException { NetworkState connectionState = asMc(packet.getRegistry().getState()); - int packetId = packet.getId(); + //int packetId = packet.getId();//TODO need to add int? + PacketByteBuf packetBuf = new PacketByteBuf(Unpooled.wrappedBuffer(packet.getBuf().nioBuffer())); //#if MC>=12002 - return connectionState.getHandler(NetworkSide.CLIENTBOUND).createPacket(packetId, packetBuf); + return (net.minecraft.network.packet.Packet) connectionState.codec().decode(packetBuf); //#elseif MC>=11700 //$$ return connectionState.getPacketHandler(NetworkSide.CLIENTBOUND, packetId, packetBuf); //#else @@ -482,7 +496,7 @@ private static Packet decodePacket(NetworkState connectionState, ByteBuf buf) { private static int getPacketId(NetworkState networkState, net.minecraft.network.packet.Packet packet) { try { - return requireNonNull(networkState.getHandler(NetworkSide.CLIENTBOUND).getId(packet)); + return requireNonNull(((PacketCodecDispatcher) networkState.codec()).typeToIndex.get(packet.getPacketId())); } catch (Exception e) { throw new RuntimeException("Failed to determine packet id for " + packet.getClass(), e); } @@ -537,7 +551,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception if (msg instanceof CustomPayloadS2CPacket) { CustomPayloadS2CPacket packet = (CustomPayloadS2CPacket) msg; - if (Restrictions.PLUGIN_CHANNEL.equals(packet.payload().id())) { + if (Restrictions.PLUGIN_CHANNEL.equals(packet.payload().getId().id())) { save(new DisconnectS2CPacket(net.minecraft.text.Text.literal("Please update to view this replay."))); } } diff --git a/src/main/java/com/replaymod/render/blend/Util.java b/src/main/java/com/replaymod/render/blend/Util.java index 0852aa6..45f9b32 100644 --- a/src/main/java/com/replaymod/render/blend/Util.java +++ b/src/main/java/com/replaymod/render/blend/Util.java @@ -184,7 +184,7 @@ public static void insert(ListBase list, CPointer element) throws IOExcept public static String getTileEntityId(BlockEntity tileEntity) { //#if MC>=11800 - NbtCompound nbt = tileEntity.createNbt(); + NbtCompound nbt = tileEntity.createNbt(null); //TODO fix if needed //#else //$$ NbtCompound nbt = new NbtCompound(); //#if MC>=11400 diff --git a/src/main/java/com/replaymod/render/mixin/Mixin_ForceChunkLoading.java b/src/main/java/com/replaymod/render/mixin/Mixin_ForceChunkLoading.java index 4843023..cb1a108 100644 --- a/src/main/java/com/replaymod/render/mixin/Mixin_ForceChunkLoading.java +++ b/src/main/java/com/replaymod/render/mixin/Mixin_ForceChunkLoading.java @@ -35,9 +35,9 @@ public void replayModRender_setHook(ForceChunkLoadingHook hook) { this.replayModRender_hook = hook; } - @Shadow private ChunkBuilder field_45614; + @Shadow private ChunkBuilder chunkBuilder; - @Shadow @Final private ChunkRenderingDataPreparer field_45615; + @Shadow @Final private ChunkRenderingDataPreparer chunkRenderingDataPreparer; @Shadow protected abstract void setupTerrain(Camera par1, Frustum par2, boolean par3, boolean par4); @@ -50,7 +50,7 @@ public void replayModRender_setHook(ForceChunkLoadingHook hook) { @Shadow protected abstract void applyFrustum(Frustum par1); @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;setupTerrain(Lnet/minecraft/client/render/Camera;Lnet/minecraft/client/render/Frustum;ZZ)V")) - private void forceAllChunks(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, CallbackInfo ci) { + private void forceAllChunks(float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci) { if (replayModRender_hook == null) { return; } @@ -60,7 +60,7 @@ private void forceAllChunks(MatrixStack matrices, float tickDelta, long limitTim assert this.client.player != null; - ChunkRenderingDataPreparer renderingData = this.field_45615; + ChunkRenderingDataPreparer renderingData = this.chunkRenderingDataPreparer; ChunkRenderingDataPreparerAccessor renderingDataAcc = (ChunkRenderingDataPreparerAccessor) renderingData; ChunkRendererRegionBuilder chunkRendererRegionBuilder = new ChunkRendererRegionBuilder(); @@ -99,14 +99,14 @@ private void forceAllChunks(MatrixStack matrices, float tickDelta, long limitTim } // MC sometimes schedules invalid chunks when you're outside of loaded chunks (e.g. y > 256) if (builtChunk.shouldBuild()) { - builtChunk.scheduleRebuild(this.field_45614, chunkRendererRegionBuilder); + builtChunk.scheduleRebuild(this.chunkBuilder, chunkRendererRegionBuilder); areWeDoneYet = false; } builtChunk.cancelRebuild(); } // Upload all chunks - if (((ForceChunkLoadingHook.IBlockOnChunkRebuilds) this.field_45614).uploadEverythingBlocking()) { + if (((ForceChunkLoadingHook.IBlockOnChunkRebuilds) this.chunkBuilder).uploadEverythingBlocking()) { areWeDoneYet = false; } diff --git a/src/main/java/com/replaymod/render/mixin/Mixin_Omnidirectional_Rotation.java b/src/main/java/com/replaymod/render/mixin/Mixin_Omnidirectional_Rotation.java index f5c006c..7addd3f 100644 --- a/src/main/java/com/replaymod/render/mixin/Mixin_Omnidirectional_Rotation.java +++ b/src/main/java/com/replaymod/render/mixin/Mixin_Omnidirectional_Rotation.java @@ -43,7 +43,6 @@ private void replayModRender_setupCubicFrameRotation( //#if MC>=11500 float partialTicks, long frameStartNano, - MatrixStack matrixStack, //#endif CallbackInfo ci ) { @@ -79,7 +78,7 @@ private void replayModRender_setupCubicFrameRotation( break; } //#if MC>=11500 - matrixStack.multiply(new org.joml.Quaternionf().fromAxisAngleDeg(new Vector3f(x, y, 0), angle)); + //matrixStack.multiply(new org.joml.Quaternionf().fromAxisAngleDeg(new Vector3f(x, y, 0), angle)); TODO //#else //$$ GL11.glRotatef(angle, x, y, 0); //#endif diff --git a/src/main/java/com/replaymod/render/mixin/Mixin_Stereoscopic_Camera.java b/src/main/java/com/replaymod/render/mixin/Mixin_Stereoscopic_Camera.java index 154b8ad..5d7292b 100644 --- a/src/main/java/com/replaymod/render/mixin/Mixin_Stereoscopic_Camera.java +++ b/src/main/java/com/replaymod/render/mixin/Mixin_Stereoscopic_Camera.java @@ -30,12 +30,12 @@ private void replayModRender_setupStereoscopicProjection(CallbackInfoReturnable< } @Inject(method = "renderWorld", at = @At("HEAD")) - private void replayModRender_setupStereoscopicProjection(float partialTicks, long frameStartNano, MatrixStack matrixStack, CallbackInfo ci) { + private void replayModRender_setupStereoscopicProjection(float partialTicks, long frameStartNano, CallbackInfo ci) { if (replayModRender_getHandler() != null) { if (replayModRender_getHandler().data == StereoscopicOpenGlFrameCapturer.Data.LEFT_EYE) { - matrixStack.translate(0.1, 0, 0); + //matrixStack.translate(0.1, 0, 0); TODO } else if (replayModRender_getHandler().data == StereoscopicOpenGlFrameCapturer.Data.RIGHT_EYE) { - matrixStack.translate(-0.1, 0, 0); + //matrixStack.translate(-0.1, 0, 0); } } } diff --git a/src/main/java/com/replaymod/render/rendering/VideoRenderer.java b/src/main/java/com/replaymod/render/rendering/VideoRenderer.java index eab6470..8b53211 100644 --- a/src/main/java/com/replaymod/render/rendering/VideoRenderer.java +++ b/src/main/java/com/replaymod/render/rendering/VideoRenderer.java @@ -40,6 +40,7 @@ import net.minecraft.sound.SoundCategory; import net.minecraft.client.render.RenderTickCounter; import net.neoforged.fml.loading.LoadingModList; +import org.joml.Matrix4fStack; import org.lwjgl.glfw.GLFW; //#if MC>=12000 @@ -506,8 +507,8 @@ public boolean drawGui() { , VertexSorter.BY_Z //#endif ); - MatrixStack matrixStack = RenderSystem.getModelViewStack(); - matrixStack.loadIdentity(); + Matrix4fStack matrixStack = RenderSystem.getModelViewStack(); + matrixStack.identity(); matrixStack.translate(0, 0, -2000); RenderSystem.applyModelViewMatrix(); DiffuseLighting.enableGuiDepthLighting(); diff --git a/src/main/java/com/replaymod/replay/FullReplaySender.java b/src/main/java/com/replaymod/replay/FullReplaySender.java index 769b6a1..aa7fb38 100644 --- a/src/main/java/com/replaymod/replay/FullReplaySender.java +++ b/src/main/java/com/replaymod/replay/FullReplaySender.java @@ -472,11 +472,11 @@ private Packet deserializePacket(byte[] bytes, ChannelHandlerContext ctx) throws ByteBuf bb = Unpooled.wrappedBuffer(bytes); PacketByteBuf pb = new PacketByteBuf(bb); - int i = pb.readVarInt(); + //int i = pb.readVarInt(); //TODO add integer infront? NetworkState state = asMc(registry.getState()); //#if MC>=12002 - Packet p = state.getHandler(NetworkSide.CLIENTBOUND).createPacket(i, pb, ctx); + Packet p = (Packet) state.codec().decode(pb); //#elseif MC>=11700 //$$ Packet p = state.getPacketHandler(NetworkSide.CLIENTBOUND, i, pb); //#else @@ -582,7 +582,7 @@ protected Packet processPacket(Packet p) throws Exception { if (p instanceof CustomPayloadS2CPacket) { CustomPayloadS2CPacket packet = (CustomPayloadS2CPacket) p; - if (Restrictions.PLUGIN_CHANNEL.equals(packet.payload().id())) { + if (Restrictions.PLUGIN_CHANNEL.equals(packet.payload().getId().id())) { final String unknown = replayHandler.getRestrictions().handle(packet); if (unknown == null) { return null; @@ -611,7 +611,7 @@ protected Packet processPacket(Packet p) throws Exception { } } if (p instanceof DisconnectS2CPacket) { - Text reason = ((DisconnectS2CPacket) p).getReason(); + Text reason = ((DisconnectS2CPacket) p).reason(); String message = reason.getString(); if ("Please update to view this replay.".equals(message)) { // This version of the mod supports replay restrictions so we are allowed @@ -625,7 +625,7 @@ protected Packet processPacket(Packet p) throws Exception { if (p instanceof CustomPayloadS2CPacket) { CustomPayloadS2CPacket packet = (CustomPayloadS2CPacket) p; //#if MC>=11400 - Identifier channelName = packet.payload().id(); + Identifier channelName = packet.payload().getId().id(); //#else //$$ String channelName = packet.getChannelName(); //#endif @@ -699,7 +699,8 @@ protected Packet processPacket(Packet p) throws Exception { packet.reducedDebugInfo(), packet.showDeathScreen(), packet.doLimitedCrafting(), - withSpectatorMode(packet.commonPlayerSpawnInfo()) + withSpectatorMode(packet.commonPlayerSpawnInfo()), + false //#else //#if MC>=11800 //$$ packet.hardcore(), diff --git a/src/main/java/com/replaymod/replay/NoGuiScreenshot.java b/src/main/java/com/replaymod/replay/NoGuiScreenshot.java index fe0e58a..87de4f5 100644 --- a/src/main/java/com/replaymod/replay/NoGuiScreenshot.java +++ b/src/main/java/com/replaymod/replay/NoGuiScreenshot.java @@ -75,7 +75,7 @@ public void run() { float tickDelta = mc.getTickDelta(); //#if MC>=11500 - mc.gameRenderer.renderWorld(tickDelta, System.nanoTime(), new MatrixStack()); + mc.gameRenderer.renderWorld(tickDelta, System.nanoTime()); //#else //#if MC>=11400 //$$ mc.gameRenderer.renderWorld(tickDelta, System.nanoTime()); diff --git a/src/main/java/com/replaymod/replay/QuickReplaySender.java b/src/main/java/com/replaymod/replay/QuickReplaySender.java index 97c23ba..dd2d613 100644 --- a/src/main/java/com/replaymod/replay/QuickReplaySender.java +++ b/src/main/java/com/replaymod/replay/QuickReplaySender.java @@ -87,7 +87,8 @@ protected void dispatch(com.replaymod.replaystudio.protocol.Packet packet) { //$$ Packet mcPacket; //#endif //#if MC>=12002 - mcPacket = state.getHandler(NetworkSide.CLIENTBOUND).createPacket(packet.getId(), packetByteBuf); + //TODO add id back? + mcPacket = (Packet) state.codec().decode(packetByteBuf); //#elseif MC>=11700 //$$ mcPacket = state.getPacketHandler(NetworkSide.CLIENTBOUND, packet.getId(), packetByteBuf); //#elseif MC>=11500 diff --git a/src/main/java/com/replaymod/replay/ReplayHandler.java b/src/main/java/com/replaymod/replay/ReplayHandler.java index 2208cda..5790876 100644 --- a/src/main/java/com/replaymod/replay/ReplayHandler.java +++ b/src/main/java/com/replaymod/replay/ReplayHandler.java @@ -34,6 +34,8 @@ import net.minecraft.client.network.ClientLoginNetworkHandler; import net.minecraft.client.util.Window; import net.minecraft.network.NetworkState; +import net.minecraft.network.listener.ClientLoginPacketListener; +import net.minecraft.network.state.LoginStates; import net.minecraft.util.crash.CrashReport; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; @@ -64,6 +66,7 @@ //#if MC>=11700 import net.minecraft.client.render.DiffuseLighting; +import net.neoforged.neoforge.network.registration.NetworkRegistry; import org.joml.Matrix4f; //#endif @@ -73,6 +76,7 @@ //#if MC>=11500 import com.mojang.blaze3d.systems.RenderSystem; +import org.joml.Matrix4fStack; import org.lwjgl.opengl.GL11; //#endif @@ -326,7 +330,8 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable t) { channel.pipeline().addLast("ReplayModReplay_replaySender", fullReplaySender); //#if MC>=12002 channel.pipeline().addLast("ReplayModReplay_transition", new DummyNetworkStateTransitionHandler()); - channel.pipeline().addLast("bundler", new PacketBundler(ClientConnection.CLIENTBOUND_PROTOCOL_KEY)); + //channel.pipeline().addLast("bundler", new PacketBundler(ClientConnection.CLIENTBOUND_PROTOCOL_KEY)); + //#elseif MC>=11904 //$$ channel.pipeline().addLast("bundler", new PacketBundler(NetworkSide.CLIENTBOUND)); //#endif @@ -336,13 +341,29 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable t) { // 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. //#if MC>=12002 - channel.attr(ClientConnection.CLIENTBOUND_PROTOCOL_KEY).set(NetworkState.LOGIN.getHandler(NetworkSide.CLIENTBOUND)); - channel.attr(ClientConnection.SERVERBOUND_PROTOCOL_KEY).set(NetworkState.LOGIN.getHandler(NetworkSide.SERVERBOUND)); + networkManager.transitionInbound(LoginStates.S2C, new ClientLoginNetworkHandler( + networkManager, + mc, + null + //#if MC>=11903 + , null + , false + , null + //#endif + //#if MC>=11400 + , it -> {} + , null + //#endif + )); + + networkManager.transitionOutbound(LoginStates.C2S); + //channel.attr(ClientConnection.CLIENTBOUND_PROTOCOL_KEY).set(LoginStates.S2C); + //channel.attr(ClientConnection.SERVERBOUND_PROTOCOL_KEY).set(LoginStates.C2S); //#else //$$ networkManager.setState(NetworkState.LOGIN); //#endif - networkManager.setPacketListener(new ClientLoginNetworkHandler( + networkManager.setPacketListener(LoginStates.S2C, new ClientLoginNetworkHandler( networkManager, mc, null @@ -353,6 +374,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable t) { //#endif //#if MC>=11400 , it -> {} + , null //#endif )); @@ -679,8 +701,8 @@ public void doJump(int targetTime, boolean retainCameraPosition) { , VertexSorter.BY_Z //#endif ); - MatrixStack matrixStack = RenderSystem.getModelViewStack(); - matrixStack.loadIdentity(); + Matrix4fStack matrixStack = RenderSystem.getModelViewStack(); + matrixStack.identity(); matrixStack.translate(0, 0, -2000); RenderSystem.applyModelViewMatrix(); DiffuseLighting.enableGuiDepthLighting(); @@ -809,7 +831,7 @@ private static class DummyNetworkStateTransitionHandler extends ChannelDuplexHan @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof Packet packet) { - NetworkStateTransitionHandler.handle(ctx.channel().attr(ClientConnection.CLIENTBOUND_PROTOCOL_KEY), packet); + NetworkStateTransitionHandler.onDecoded(ctx, packet); } super.channelRead(ctx, msg); } @@ -817,7 +839,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (msg instanceof Packet packet) { - NetworkStateTransitionHandler.handle(ctx.channel().attr(ClientConnection.SERVERBOUND_PROTOCOL_KEY), packet); + NetworkStateTransitionHandler.onEncoded(ctx, packet); } super.write(ctx, msg, promise); } diff --git a/src/main/java/com/replaymod/replay/mixin/MixinCamera.java b/src/main/java/com/replaymod/replay/mixin/MixinCamera.java index 226a1df..dde381e 100644 --- a/src/main/java/com/replaymod/replay/mixin/MixinCamera.java +++ b/src/main/java/com/replaymod/replay/mixin/MixinCamera.java @@ -23,10 +23,10 @@ public class MixinCamera { target = "Lnet/minecraft/client/render/Camera;getPitch()F" ) ) - private void applyRoll(float float_1, long long_1, MatrixStack matrixStack, CallbackInfo ci) { + private void applyRoll(float float_1, long long_1, CallbackInfo ci) { Entity entity = this.client.getCameraEntity() == null ? this.client.player : this.client.getCameraEntity(); if (entity instanceof CameraEntity) { - matrixStack.multiply(new org.joml.Quaternionf().fromAxisAngleDeg(new org.joml.Vector3f(0, 0, 1), ((CameraEntity) entity).roll)); + //matrixStack.multiply(new org.joml.Quaternionf().fromAxisAngleDeg(new org.joml.Vector3f(0, 0, 1), ((CameraEntity) entity).roll)); TODO } } } diff --git a/src/main/java/com/replaymod/simplepathing/preview/PathPreviewRenderer.java b/src/main/java/com/replaymod/simplepathing/preview/PathPreviewRenderer.java index e406e80..6308656 100644 --- a/src/main/java/com/replaymod/simplepathing/preview/PathPreviewRenderer.java +++ b/src/main/java/com/replaymod/simplepathing/preview/PathPreviewRenderer.java @@ -108,7 +108,7 @@ private void renderCameraPath(MatrixStack matrixStack) { //#endif //#if MC>=11700 - RenderSystem.getModelViewStack().multiplyPositionMatrix(matrixStack.peek().getPositionMatrix()); + RenderSystem.getModelViewStack().mul(matrixStack.peek().getPositionMatrix()); RenderSystem.applyModelViewMatrix(); //#elseif MC>=11500 //$$ RenderSystem.multMatrix(matrixStack.peek().getModel()); @@ -292,8 +292,8 @@ private void drawPoint(Vector3f view, Vector3f pos, Keyframe keyframe) { Vector3f t = Vector3f.sub(pos, view, null); com.mojang.blaze3d.systems.RenderSystem.getModelViewStack().translate(t.x, t.y, t.z); - com.mojang.blaze3d.systems.RenderSystem.getModelViewStack().multiply(com.replaymod.core.versions.MCVer.quaternion(-mc.getEntityRenderDispatcher().camera.getYaw(), new org.joml.Vector3f(0, 1, 0))); - com.mojang.blaze3d.systems.RenderSystem.getModelViewStack().multiply(com.replaymod.core.versions.MCVer.quaternion(mc.getEntityRenderDispatcher().camera.getPitch(), new org.joml.Vector3f(1, 0, 0))); + com.mojang.blaze3d.systems.RenderSystem.getModelViewStack().rotate(com.replaymod.core.versions.MCVer.quaternion(-mc.getEntityRenderDispatcher().camera.getYaw(), new org.joml.Vector3f(0, 1, 0))); + com.mojang.blaze3d.systems.RenderSystem.getModelViewStack().rotate(com.replaymod.core.versions.MCVer.quaternion(mc.getEntityRenderDispatcher().camera.getPitch(), new org.joml.Vector3f(1, 0, 0))); //#if MC>=11700 RenderSystem.applyModelViewMatrix(); @@ -312,9 +312,9 @@ private void drawCamera(Vector3f view, Vector3f pos, Vector3f rot) { Vector3f t = Vector3f.sub(pos, view, null); com.mojang.blaze3d.systems.RenderSystem.getModelViewStack().translate(t.x, t.y, t.z); - com.mojang.blaze3d.systems.RenderSystem.getModelViewStack().multiply(com.replaymod.core.versions.MCVer.quaternion(-rot.x, new org.joml.Vector3f(0, 1, 0))); - com.mojang.blaze3d.systems.RenderSystem.getModelViewStack().multiply(com.replaymod.core.versions.MCVer.quaternion(rot.y, new org.joml.Vector3f(1, 0, 0))); - com.mojang.blaze3d.systems.RenderSystem.getModelViewStack().multiply(com.replaymod.core.versions.MCVer.quaternion(rot.z, new org.joml.Vector3f(0, 0, 1))); + com.mojang.blaze3d.systems.RenderSystem.getModelViewStack().rotate(com.replaymod.core.versions.MCVer.quaternion(-rot.x, new org.joml.Vector3f(0, 1, 0))); + com.mojang.blaze3d.systems.RenderSystem.getModelViewStack().rotate(com.replaymod.core.versions.MCVer.quaternion(rot.y, new org.joml.Vector3f(1, 0, 0))); + com.mojang.blaze3d.systems.RenderSystem.getModelViewStack().rotate(com.replaymod.core.versions.MCVer.quaternion(rot.z, new org.joml.Vector3f(0, 0, 1))); //draw the position line Tessellator tessellator = Tessellator.getInstance(); diff --git a/src/main/java/de/johni0702/minecraft/gui/container/AbstractGuiScreen.java b/src/main/java/de/johni0702/minecraft/gui/container/AbstractGuiScreen.java index 5405f8a..300a265 100644 --- a/src/main/java/de/johni0702/minecraft/gui/container/AbstractGuiScreen.java +++ b/src/main/java/de/johni0702/minecraft/gui/container/AbstractGuiScreen.java @@ -118,7 +118,7 @@ public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo render break; case DIRT: //#if MC>=12000 - wrapped.renderBackgroundTexture(renderer.getContext()); + wrapped.renderInGameBackground(renderer.getContext()); //#elseif MC>=11904 //$$ wrapped.renderBackgroundTexture(renderer.getMatrixStack()); //#elseif MC>=11600 diff --git a/src/main/java/de/johni0702/minecraft/gui/element/AbstractGuiTextField.java b/src/main/java/de/johni0702/minecraft/gui/element/AbstractGuiTextField.java index e982f2b..1a80c4c 100644 --- a/src/main/java/de/johni0702/minecraft/gui/element/AbstractGuiTextField.java +++ b/src/main/java/de/johni0702/minecraft/gui/element/AbstractGuiTextField.java @@ -168,7 +168,8 @@ public T writeText(String append) { @Override public T writeChar(char c) { //#if MC>=11400 - if (!SharedConstants.isValidChar(c)) { + //if (!SharedConstants.isValidChar(c)) { //TODO + if (true) { //#else //$$ if (!ChatAllowedCharacters.isAllowedCharacter(c)) { //#endif diff --git a/src/main/java/de/johni0702/minecraft/gui/element/advanced/AbstractGuiTextArea.java b/src/main/java/de/johni0702/minecraft/gui/element/advanced/AbstractGuiTextArea.java index 4e77604..63b4ff7 100644 --- a/src/main/java/de/johni0702/minecraft/gui/element/advanced/AbstractGuiTextArea.java +++ b/src/main/java/de/johni0702/minecraft/gui/element/advanced/AbstractGuiTextArea.java @@ -219,7 +219,8 @@ public void writeText(String append) { @Override public void writeChar(char c) { //#if MC>=11400 - if (!SharedConstants.isValidChar(c)) { + //if (!SharedConstants.isValidChar(c)) { + if (true) { //#else //$$ if (!ChatAllowedCharacters.isAllowedCharacter(c)) { //#endif diff --git a/src/main/java/de/johni0702/minecraft/gui/versions/mixin/Mixin_RenderHudCallback.java b/src/main/java/de/johni0702/minecraft/gui/versions/mixin/Mixin_RenderHudCallback.java index 4902d16..1d15ad8 100644 --- a/src/main/java/de/johni0702/minecraft/gui/versions/mixin/Mixin_RenderHudCallback.java +++ b/src/main/java/de/johni0702/minecraft/gui/versions/mixin/Mixin_RenderHudCallback.java @@ -1,38 +1,38 @@ -//#if FABRIC>=1 -package de.johni0702.minecraft.gui.versions.mixin; - -import de.johni0702.minecraft.gui.versions.callbacks.RenderHudCallback; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.hud.InGameHud; -import net.neoforged.neoforge.client.gui.overlay.ExtendedGui; -import net.neoforged.neoforge.client.gui.overlay.VanillaGuiOverlay; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -//#else -//$$ import net.minecraft.client.util.math.MatrixStack; -//#endif - -@Mixin(VanillaGuiOverlay.class) -public class Mixin_RenderHudCallback { - @Inject( - method = "lambda$static$19", - //#if MC>=12002 - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/DebugHud;shouldShowDebugHud()Z") - //#else - //$$ at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/client/option/GameOptions;debugEnabled:Z") - //#endif - ) - //#if MC>=12000 - private static void renderOverlay(ExtendedGui gui, DrawContext stack, float partialTicks, int screenWidth, int screenHeight, CallbackInfo ci) { - //#elseif MC>=11600 - //$$ private void renderOverlay(MatrixStack stack, float partialTicks, CallbackInfo ci) { - //#else - //$$ private void renderOverlay(float partialTicks, CallbackInfo ci) { - //$$ MatrixStack stack = new MatrixStack(); - //#endif - RenderHudCallback.EVENT.invoker().renderHud(stack, partialTicks); - } -} -//#endif +////#if FABRIC>=1 +//package de.johni0702.minecraft.gui.versions.mixin; +// +//import de.johni0702.minecraft.gui.versions.callbacks.RenderHudCallback; +//import net.minecraft.client.gui.DrawContext; +//import net.minecraft.client.gui.hud.InGameHud; +//import net.neoforged.neoforge.client.gui.overlay.ExtendedGui; +//import net.neoforged.neoforge.client.gui.overlay.VanillaGuiOverlay; +//import org.spongepowered.asm.mixin.Mixin; +//import org.spongepowered.asm.mixin.injection.At; +//import org.spongepowered.asm.mixin.injection.Inject; +//import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +////#else +////$$ import net.minecraft.client.util.math.MatrixStack; +////#endif +// +//@Mixin(VanillaGuiOverlay.class) +//public class Mixin_RenderHudCallback { +// @Inject( +// method = "lambda$static$19", +// //#if MC>=12002 +// at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/DebugHud;shouldShowDebugHud()Z") +// //#else +// //$$ at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/client/option/GameOptions;debugEnabled:Z") +// //#endif +// ) +// //#if MC>=12000 +// private static void renderOverlay(ExtendedGui gui, DrawContext stack, float partialTicks, int screenWidth, int screenHeight, CallbackInfo ci) { +// //#elseif MC>=11600 +// //$$ private void renderOverlay(MatrixStack stack, float partialTicks, CallbackInfo ci) { +// //#else +// //$$ private void renderOverlay(float partialTicks, CallbackInfo ci) { +// //$$ MatrixStack stack = new MatrixStack(); +// //#endif +// RenderHudCallback.EVENT.invoker().renderHud(stack, partialTicks); +// } +//} +////#endif diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg new file mode 100644 index 0000000..3db917f --- /dev/null +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -0,0 +1,4 @@ +public net.minecraft.network.codec.IdDispatchCodec toId # toId +public net.minecraft.network.Connection validateListener(Lnet/minecraft/network/ProtocolInfo;Lnet/minecraft/network/PacketListener;)V # validateListener +public net.minecraft.network.Connection packetListener # packetListener +public net.minecraft.network.PacketDecoder protocolInfo # protocolInfo diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/neoforge.mods.toml similarity index 90% rename from src/main/resources/META-INF/mods.toml rename to src/main/resources/META-INF/neoforge.mods.toml index f2f3bc2..5f39020 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/neoforge.mods.toml @@ -1,5 +1,5 @@ modLoader="javafml" -loaderVersion="[1,)" +loaderVersion="[2,)" license="GPL-3.0-or-later" [[mods]] modId="reforgedplaymod" @@ -14,14 +14,14 @@ A Mod which allows you to record, replay and share your Minecraft experience. [[dependencies.reforgedplaymod]] modId = "neoforge" type="required" -versionRange = "[20.4.40-beta,)" +versionRange = "[20.6.1-beta,)" ordering = "NONE" side = "BOTH" [[dependencies.reforgedplaymod]] modId = "minecraft" type="required" -versionRange = "[1.20.4,1.20.5)" +versionRange = "[1.20.5,1.20.7)" ordering = "NONE" side = "BOTH" @@ -55,6 +55,9 @@ config = "mixins.render.replaymod.json" [[mixins]] config = "mixins.replay.replaymod.json" +[[accessTransformers]] +file="META-INF/accesstransformer.cfg" + [[mods]] modId="replaymod" version="${version}" diff --git a/src/main/resources/mixins.jgui.json b/src/main/resources/mixins.jgui.json index 07273c9..a2d6148 100644 --- a/src/main/resources/mixins.jgui.json +++ b/src/main/resources/mixins.jgui.json @@ -11,7 +11,7 @@ "Mixin_PassEventsExt", //#if MC>=11400 //#if MC>=11400 - "Mixin_RenderHudCallback", + //"Mixin_RenderHudCallback", "MixinGameRenderer", "MixinScreen", "MixinMouseListener",