Update to 1.20.6
This commit is contained in:
@@ -36,6 +36,13 @@ import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
//#if MC>=12006
|
||||
//$$ import net.minecraft.resource.ResourcePackInfo;
|
||||
//$$ import net.minecraft.resource.ResourcePackSource;
|
||||
//$$ import net.minecraft.text.Text;
|
||||
//$$ import java.util.Optional;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11900
|
||||
//#else
|
||||
import net.minecraft.client.options.Option;
|
||||
@@ -120,7 +127,9 @@ public class ReplayMod implements Module, Scheduler {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
//#if MC>=11903
|
||||
//#if MC>=12006
|
||||
//$$ return new DirectoryResourcePack(new ResourcePackInfo(JGUI_RESOURCE_PACK_NAME, Text.literal("jGui"), ResourcePackSource.NONE, Optional.empty()), folder.toPath()) {
|
||||
//#elseif MC>=11903
|
||||
//$$ return new DirectoryResourcePack(JGUI_RESOURCE_PACK_NAME, folder.toPath(), true) {
|
||||
//#else
|
||||
return new DirectoryResourcePack(folder) {
|
||||
|
||||
@@ -15,12 +15,18 @@ import com.llamalad7.mixinextras.sugar.Local;
|
||||
|
||||
@Mixin(WorldRenderer.class)
|
||||
public class Mixin_PostRenderWorldCalback {
|
||||
//#if MC>=12005
|
||||
//$$ @Inject(method = "render", at = @At(value = "INVOKE", target = "Lorg/joml/Matrix4fStack;popMatrix()Lorg/joml/Matrix4fStack;"))
|
||||
//$$ private void postRenderWorld(CallbackInfo ci) {
|
||||
//$$ MatrixStack matrixStack = new MatrixStack();
|
||||
//#else
|
||||
@Inject(method = "render", at = @At("RETURN"))
|
||||
//#if MC>=11500
|
||||
private void postRenderWorld(CallbackInfo ci, @Local(argsOnly = true) MatrixStack matrixStack) {
|
||||
//#else
|
||||
//$$ private void postRenderWorld(CallbackInfo ci) {
|
||||
//$$ MatrixStack matrixStack = new MatrixStack();
|
||||
//#endif
|
||||
//#endif
|
||||
PostRenderWorldCallback.EVENT.invoker().postRenderWorld(matrixStack);
|
||||
}
|
||||
|
||||
@@ -10,15 +10,23 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
//#if MC>=12005
|
||||
//$$ import org.joml.Matrix4f;
|
||||
//#else
|
||||
//#endif
|
||||
|
||||
@Mixin(GameRenderer.class)
|
||||
public class Mixin_PreRenderHandCallback {
|
||||
@Inject(method = "renderHand", at = @At("HEAD"), cancellable = true)
|
||||
private void preRenderHand(
|
||||
//#if MC>=11500
|
||||
//#if MC>=11500 && MC<12005
|
||||
MatrixStack matrixStack,
|
||||
//#endif
|
||||
Camera camera,
|
||||
float partialTicks,
|
||||
//#if MC>=12005
|
||||
//$$ Matrix4f matrixStack,
|
||||
//#endif
|
||||
CallbackInfo ci) {
|
||||
if (PreRenderHandCallback.EVENT.invoker().preRenderHand()) {
|
||||
ci.cancel();
|
||||
|
||||
@@ -2,6 +2,12 @@ package com.replaymod.core.utils;
|
||||
|
||||
import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
|
||||
//#if MC>=12006
|
||||
//$$ import net.minecraft.network.codec.PacketCodec;
|
||||
//$$ import net.minecraft.network.packet.CustomPayload;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10904
|
||||
import net.minecraft.util.Identifier;
|
||||
//#endif
|
||||
@@ -26,7 +32,9 @@ public class Restrictions {
|
||||
private boolean onlyRecordingPlayer;
|
||||
|
||||
public String handle(CustomPayloadS2CPacket packet) {
|
||||
//#if MC>=12002
|
||||
//#if MC>=12006
|
||||
//$$ PacketByteBuf buffer = new PacketByteBuf(Unpooled.wrappedBuffer(((Payload) packet.payload()).bytes()));
|
||||
//#elseif MC>=12002
|
||||
//$$ PacketByteBuf buffer = new PacketByteBuf(Unpooled.buffer());
|
||||
//$$ packet.write(buffer);
|
||||
//#elseif MC>=10800
|
||||
@@ -67,4 +75,22 @@ public class Restrictions {
|
||||
public boolean isOnlyRecordingPlayer() {
|
||||
return onlyRecordingPlayer;
|
||||
}
|
||||
|
||||
//#if MC>=12006
|
||||
//$$ public static final CustomPayload.Id<Payload> ID = CustomPayload.id(PLUGIN_CHANNEL.toString());
|
||||
//$$ public static final PacketCodec<? super PacketByteBuf, Payload> CODEC = PacketCodec.ofStatic(
|
||||
//$$ (buf, payload) -> buf.writeBytes(payload.bytes()),
|
||||
//$$ buf -> {
|
||||
//$$ byte[] bytes = new byte[buf.readableBytes()];
|
||||
//$$ buf.readBytes(bytes);
|
||||
//$$ return new Payload(bytes);
|
||||
//$$ }
|
||||
//$$ );
|
||||
//$$ public record Payload(byte[] bytes) implements CustomPayload {
|
||||
//$$ @Override
|
||||
//$$ public Id<? extends CustomPayload> getId() {
|
||||
//$$ return ID;
|
||||
//$$ }
|
||||
//$$ }
|
||||
//#endif
|
||||
}
|
||||
|
||||
@@ -34,6 +34,13 @@ import net.fabricmc.loader.api.ModContainer;
|
||||
//#else
|
||||
//#endif
|
||||
|
||||
//#if MC>=12006
|
||||
//$$ import net.minecraft.resource.ResourcePackInfo;
|
||||
//$$ import net.minecraft.resource.ResourcePackSource;
|
||||
//$$ import net.minecraft.text.Text;
|
||||
//$$ import java.util.Optional;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11903
|
||||
//$$ import java.util.Objects;
|
||||
//$$ import net.minecraft.resource.InputSupplier;
|
||||
@@ -64,7 +71,9 @@ public class LangResourcePack extends AbstractFileResourcePack {
|
||||
|
||||
private final Path basePath;
|
||||
public LangResourcePack() {
|
||||
//#if MC>=11903
|
||||
//#if MC>=12006
|
||||
//$$ super(new ResourcePackInfo(NAME, Text.literal("ReplayMod Translations"), ResourcePackSource.NONE, Optional.empty()));
|
||||
//#elseif MC>=11903
|
||||
//$$ super(NAME, true);
|
||||
//#else
|
||||
super(new File(NAME));
|
||||
|
||||
@@ -397,7 +397,9 @@ public class MCVer {
|
||||
}
|
||||
|
||||
public static void pushMatrix() {
|
||||
//#if MC>=11700
|
||||
//#if MC>=12006
|
||||
//$$ RenderSystem.getModelViewStack().pushMatrix();
|
||||
//#elseif MC>=11700
|
||||
//$$ RenderSystem.getModelViewStack().push();
|
||||
//#else
|
||||
GlStateManager.pushMatrix();
|
||||
@@ -406,7 +408,11 @@ public class MCVer {
|
||||
|
||||
public static void popMatrix() {
|
||||
//#if MC>=11700
|
||||
//#if MC>=12006
|
||||
//$$ RenderSystem.getModelViewStack().popMatrix();
|
||||
//#else
|
||||
//$$ RenderSystem.getModelViewStack().pop();
|
||||
//#endif
|
||||
//$$ RenderSystem.applyModelViewMatrix();
|
||||
//#else
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
@@ -21,6 +21,7 @@ import net.minecraft.network.NetworkSide;
|
||||
import net.minecraft.network.NetworkState;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.DisconnectS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.PlayerListS2CPacket;
|
||||
import net.minecraft.resource.Resource;
|
||||
import net.minecraft.resource.ResourceManager;
|
||||
@@ -576,7 +577,9 @@ class Patterns {
|
||||
|
||||
@Pattern
|
||||
private static void GL11_glRotatef(float angle, float x, float y, float z) {
|
||||
//#if MC>=11700
|
||||
//#if MC>=12006
|
||||
//$$ com.mojang.blaze3d.systems.RenderSystem.getModelViewStack().rotate(com.replaymod.core.versions.MCVer.quaternion(angle, new org.joml.Vector3f(x, y, z)));
|
||||
//#elseif MC>=11700
|
||||
//$$ com.mojang.blaze3d.systems.RenderSystem.getModelViewStack().multiply(com.replaymod.core.versions.MCVer.quaternion(angle, new net.minecraft.util.math.Vec3f(x, y, z)));
|
||||
//#else
|
||||
GL11.glRotatef(angle, x, y, z);
|
||||
@@ -917,7 +920,9 @@ class Patterns {
|
||||
|
||||
@Pattern
|
||||
public Object channel(CustomPayloadS2CPacket packet) {
|
||||
//#if MC>=12002
|
||||
//#if MC>=12006
|
||||
//$$ return packet.payload().getId().id();
|
||||
//#elseif MC>=12002
|
||||
//$$ return packet.payload().id();
|
||||
//#else
|
||||
return packet.getChannel();
|
||||
@@ -925,6 +930,9 @@ class Patterns {
|
||||
}
|
||||
|
||||
//#if MC>=10904
|
||||
//#if MC>=12006
|
||||
//$$ @Pattern public void getPacketId() {}
|
||||
//#else
|
||||
@Pattern
|
||||
public Integer getPacketId(NetworkState state, NetworkSide side, Packet<?> packet) throws Exception {
|
||||
//#if MC>=12002
|
||||
@@ -933,6 +941,7 @@ class Patterns {
|
||||
return state.getPacketId(side, packet);
|
||||
//#endif
|
||||
}
|
||||
//#endif
|
||||
|
||||
@Pattern
|
||||
public int UnloadChunkPacket_getX(UnloadChunkS2CPacket packet) {
|
||||
@@ -983,4 +992,13 @@ class Patterns {
|
||||
return mc.options.debugEnabled;
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
public Text getMessage(DisconnectS2CPacket packet) {
|
||||
//#if MC>=12006
|
||||
//$$ return packet.reason();
|
||||
//#else
|
||||
return packet.getReason();
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@ import net.minecraft.network.ClientConnection;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
//#if MC>=12006
|
||||
//$$ import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
||||
//#endif
|
||||
|
||||
//#if FABRIC>=1
|
||||
//#if MC>=11700
|
||||
//$$ import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
@@ -73,7 +77,11 @@ public class ReplayModRecording implements Module {
|
||||
new GuiHandler(core).register();
|
||||
|
||||
//#if FABRIC>=1
|
||||
//#if MC>=11700
|
||||
//#if MC>=12006
|
||||
//$$ PayloadTypeRegistry.configurationS2C().register(Restrictions.ID, Restrictions.CODEC);
|
||||
//$$ PayloadTypeRegistry.playS2C().register(Restrictions.ID, Restrictions.CODEC);
|
||||
//$$ ClientPlayNetworking.registerGlobalReceiver(Restrictions.ID, (payload, context) -> {});
|
||||
//#elseif MC>=11700
|
||||
//$$ ClientPlayNetworking.registerGlobalReceiver(Restrictions.PLUGIN_CHANNEL, (client, handler, buf, resp) -> {});
|
||||
//#else
|
||||
ClientSidePacketRegistry.INSTANCE.register(Restrictions.PLUGIN_CHANNEL, (packetContext, packetByteBuf) -> {});
|
||||
|
||||
@@ -156,6 +156,11 @@ public class ConnectionEventHandler {
|
||||
|
||||
Channel channel = ((NetworkManagerAccessor) networkManager).getChannel();
|
||||
packetListener = new PacketListener(core, channel, outputPath, replayFile, metaData);
|
||||
|
||||
//#if MC>=12005
|
||||
//$$ channel.pipeline().addBefore("inbound_config", PacketListener.RAW_RECORDER_KEY, packetListener);
|
||||
//$$ channel.pipeline().addAfter("inbound_config", PacketListener.DECODED_RECORDER_KEY, packetListener.new DecodedPacketListener());
|
||||
//#else
|
||||
if (channel.pipeline().get(PacketListener.DECODER_KEY) != null) {
|
||||
// Regular channel, we'll inject our recorder directly before the decoder
|
||||
channel.pipeline().addBefore(PacketListener.DECODER_KEY, PacketListener.RAW_RECORDER_KEY, packetListener);
|
||||
@@ -165,6 +170,7 @@ public class ConnectionEventHandler {
|
||||
channel.pipeline().addFirst(PacketListener.RAW_RECORDER_KEY, packetListener);
|
||||
channel.pipeline().addAfter(PacketListener.RAW_RECORDER_KEY, PacketListener.DECODED_RECORDER_KEY, packetListener.new DecodedPacketListener());
|
||||
}
|
||||
//#endif
|
||||
|
||||
recordingEventHandler = new RecordingEventHandler(packetListener);
|
||||
recordingEventHandler.register();
|
||||
|
||||
@@ -73,7 +73,12 @@ public class RecordingEventHandler extends EventRegistrations {
|
||||
private final PacketListener packetListener;
|
||||
|
||||
private Double lastX, lastY, lastZ;
|
||||
private final List<ItemStack> playerItems = DefaultedList.ofSize(6, ItemStack.EMPTY);
|
||||
//#if MC>=10904
|
||||
private static final int EQUIPMENT_SLOTS = EquipmentSlot.values().length;
|
||||
//#else
|
||||
//$$ private static final int EQUIPMENT_SLOTS = 5;
|
||||
//#endif
|
||||
private final List<ItemStack> playerItems = DefaultedList.ofSize(EQUIPMENT_SLOTS, ItemStack.EMPTY);
|
||||
private int ticksSinceLastCorrection;
|
||||
private boolean wasSleeping;
|
||||
private int lastRiding = -1;
|
||||
@@ -279,7 +284,7 @@ public class RecordingEventHandler extends EventRegistrations {
|
||||
ItemStack stack = player.getEquippedStack(slot);
|
||||
int index = slot.ordinal();
|
||||
//#else
|
||||
//$$ for (int slot = 0; slot < 5; slot++) {
|
||||
//$$ for (int slot = 0; slot < EQUIPMENT_SLOTS; slot++) {
|
||||
//$$ ItemStack stack = player.getEquipmentInSlot(slot);
|
||||
//$$ int index = slot;
|
||||
//#endif
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
// 1.20.6 and above
|
||||
@@ -23,9 +23,11 @@ import de.johni0702.minecraft.gui.container.VanillaGuiScreen;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.util.AttributeKey;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
@@ -41,6 +43,15 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
//#if MC>=12006
|
||||
//$$ import com.replaymod.recording.mixin.DecoderHandlerAccessor;
|
||||
//$$ import net.minecraft.network.NetworkState;
|
||||
//$$ import net.minecraft.network.handler.DecoderHandler;
|
||||
//$$ import net.minecraft.network.handler.NetworkStateTransitions;
|
||||
//$$ import net.minecraft.network.packet.s2c.config.ReadyS2CPacket;
|
||||
//$$ import net.minecraft.network.state.LoginStates;
|
||||
//#endif
|
||||
|
||||
//#if MC>=12002
|
||||
//$$ import net.minecraft.entity.EntityType;
|
||||
//$$ import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket;
|
||||
@@ -307,6 +318,9 @@ 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>=12006
|
||||
//$$ // No longer applies. MC now encodes packets even for the integrated server connection.
|
||||
//#else
|
||||
//#if MC>=11904
|
||||
//#if MC>=12002
|
||||
//$$ PacketBundleHandler bundleHandler = ctx.channel().attr(ClientConnection.CLIENTBOUND_PROTOCOL_KEY).get().getBundler();
|
||||
@@ -330,6 +344,7 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
||||
//#else
|
||||
packet = encodeMcPacket(connectionState, (net.minecraft.network.Packet) msg);
|
||||
//#endif
|
||||
//#endif
|
||||
}
|
||||
|
||||
currentRawPacket = packet;
|
||||
@@ -344,7 +359,13 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
private NetworkState getConnectionState() {
|
||||
//#if MC>=12002
|
||||
//#if MC>=12006
|
||||
//$$ var decoderHandler = (DecoderHandlerAccessor<?>) channel.pipeline().get(DecoderHandler.class);
|
||||
//$$ if (decoderHandler == null) {
|
||||
//$$ return NetworkPhase.LOGIN;
|
||||
//$$ }
|
||||
//$$ return decoderHandler.getState().id();
|
||||
//#elseif MC>=12002
|
||||
//$$ AttributeKey<NetworkState.PacketHandler<?>> key = ClientConnection.CLIENTBOUND_PROTOCOL_KEY;
|
||||
//$$ return channel.attr(key).get().getState();
|
||||
//#else
|
||||
@@ -353,7 +374,25 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
||||
//#endif
|
||||
}
|
||||
|
||||
private static Packet encodeMcPacket(NetworkState connectionState, net.minecraft.network.Packet packet) throws Exception {
|
||||
private Packet encodeMcPacket(NetworkState connectionState, net.minecraft.network.Packet packet) throws Exception {
|
||||
//#if MC>=12006
|
||||
//$$ var byteBuf = Unpooled.buffer();
|
||||
//$$ try {
|
||||
//$$ NetworkState<?> state;
|
||||
//$$ if (connectionState == NetworkPhase.LOGIN) {
|
||||
//$$ // Special case for our initial LoginSuccess packet which we only save after the pipeline has already
|
||||
//$$ // started to transition to the next phase, so we can't just use its DecoderHandler (and luckily we
|
||||
//$$ // also don't need it).
|
||||
//$$ state = LoginStates.S2C;
|
||||
//$$ } else {
|
||||
//$$ state = ((DecoderHandlerAccessor<?>) channel.pipeline().get(DecoderHandler.class)).getState();
|
||||
//$$ }
|
||||
//$$ state.codec().encode(byteBuf, packet);
|
||||
//$$ return decodePacket(state.id(), byteBuf);
|
||||
//$$ } finally {
|
||||
//$$ byteBuf.release();
|
||||
//$$ }
|
||||
//#else
|
||||
//#if MC>=10800
|
||||
Integer packetId = connectionState.getPacketId(NetworkSide.CLIENTBOUND, packet);
|
||||
//#else
|
||||
@@ -377,6 +416,7 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
||||
} finally {
|
||||
byteBuf.release();
|
||||
}
|
||||
//#endif
|
||||
}
|
||||
|
||||
private static Packet decodePacket(NetworkState connectionState, ByteBuf buf) {
|
||||
@@ -434,7 +474,7 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
||||
return resourcePackRecorder;
|
||||
}
|
||||
|
||||
public class DecodedPacketListener extends ChannelInboundHandlerAdapter {
|
||||
public class DecodedPacketListener extends ChannelDuplexHandler {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
|
||||
@@ -482,6 +522,17 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
||||
return;
|
||||
}
|
||||
|
||||
//#if MC>=12006
|
||||
//$$ // Special case: We need to inject another packet before this one, and we can only construct that
|
||||
//$$ // packet on the main thread, so we'll skip saving this packet here and then manually re-add it after
|
||||
//$$ // that other packet has been injected.
|
||||
//$$ // See MixinNetHandlerConfigClient.
|
||||
//$$ if (msg instanceof ReadyS2CPacket) {
|
||||
//$$ super.channelRead(ctx, msg);
|
||||
//$$ return;
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
if (currentRawPacket != null) {
|
||||
save(currentRawPacket);
|
||||
currentRawPacket = null;
|
||||
@@ -489,5 +540,21 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
||||
|
||||
super.channelRead(ctx, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
||||
//#if MC>=12006
|
||||
//$$ if (msg instanceof NetworkStateTransitions.DecoderTransitioner) {
|
||||
//$$ // We need our DecodedPacketListener to stay right behind the decoder, however MC will on network state
|
||||
//$$ // transitions insert the bundler in the middle, so we need to re-position our handler in that case.
|
||||
//$$ msg = ((NetworkStateTransitions.DecoderTransitioner) msg).andThen(context -> {
|
||||
//$$ context.pipeline().remove(this);
|
||||
//$$ context.pipeline().addAfter(DECODER_KEY, DECODED_RECORDER_KEY, new DecodedPacketListener());
|
||||
//$$ });
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
super.write(ctx, msg, promise);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +183,9 @@ public class Util {
|
||||
}
|
||||
|
||||
public static String getTileEntityId(BlockEntity tileEntity) {
|
||||
//#if MC>=12006
|
||||
//$$ return net.minecraft.block.entity.BlockEntityType.getId(tileEntity.getType()).toString();
|
||||
//#else
|
||||
//#if MC>=11800
|
||||
//$$ NbtCompound nbt = tileEntity.createNbt();
|
||||
//#else
|
||||
@@ -194,6 +197,7 @@ public class Util {
|
||||
//#endif
|
||||
//#endif
|
||||
return nbt.getString("id");
|
||||
//#endif
|
||||
}
|
||||
|
||||
public interface IOCallable<R> {
|
||||
|
||||
@@ -112,7 +112,13 @@ public class GuiVideoRenderer extends GuiScreen implements Tickable {
|
||||
size(contentPanel, width - 10, height - 10);
|
||||
}
|
||||
});
|
||||
// FIXME default background doesn't work during rendering because the blur effect relies on the framebuffer
|
||||
//#if MC>=12006
|
||||
//$$ setBackground(Background.NONE);
|
||||
//$$ setBackgroundColor(new de.johni0702.minecraft.gui.utils.lwjgl.Color(32, 32, 32));
|
||||
//#else
|
||||
setBackground(Background.DIRT);
|
||||
//#endif
|
||||
}
|
||||
|
||||
public GuiVideoRenderer(VideoRenderer renderer) {
|
||||
|
||||
@@ -22,7 +22,9 @@ public abstract class Mixin_ChromaKeyColorSky {
|
||||
|
||||
//#if MC>=11800
|
||||
//$$ @Inject(
|
||||
//#if MC>=11802
|
||||
//#if MC>=12005
|
||||
//$$ method = "renderSky(Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;FLnet/minecraft/client/render/Camera;ZLjava/lang/Runnable;)V",
|
||||
//#elseif MC>=11802
|
||||
//$$ method = "renderSky(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/math/Matrix4f;FLnet/minecraft/client/render/Camera;ZLjava/lang/Runnable;)V",
|
||||
//#else
|
||||
//$$ method = "renderSky(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/math/Matrix4f;FLjava/lang/Runnable;)V",
|
||||
|
||||
@@ -11,7 +11,11 @@ import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
public abstract class Mixin_Omnidirectional_Camera implements EntityRendererHandler.IEntityRenderer {
|
||||
private static final String METHOD = "getBasicProjectionMatrix";
|
||||
//#if MC>=11903
|
||||
//#if MC>=12005
|
||||
//$$ private static final String TARGET = "Lorg/joml/Matrix4f;perspective(FFFF)Lorg/joml/Matrix4f;";
|
||||
//#else
|
||||
//$$ private static final String TARGET = "Lorg/joml/Matrix4f;setPerspective(FFFF)Lorg/joml/Matrix4f;";
|
||||
//#endif
|
||||
//$$ private static final boolean TARGET_REMAP = false;
|
||||
//$$ private static final float OMNIDIRECTIONAL_FOV = (float) Math.PI / 2;
|
||||
//#else
|
||||
|
||||
@@ -7,6 +7,11 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
//#if MC>=12005
|
||||
//$$ import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
//$$ import org.joml.Matrix4f;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11500
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
@@ -30,6 +35,10 @@ public abstract class Mixin_Omnidirectional_Rotation {
|
||||
return ((EntityRendererHandler.IEntityRenderer) getMinecraft().gameRenderer).replayModRender_getHandler();
|
||||
}
|
||||
|
||||
//#if MC>=12005
|
||||
//$$ @ModifyExpressionValue(method = "renderWorld", at = @At(value = "INVOKE", target = "Lorg/joml/Matrix4f;rotationXYZ(FFF)Lorg/joml/Matrix4f;"))
|
||||
//$$ private Matrix4f replayModRender_setupCubicFrameRotation(Matrix4f matrix) {
|
||||
//#else
|
||||
//#if MC>=11500
|
||||
@Inject(method = "renderWorld", at = @At("HEAD"))
|
||||
//#else
|
||||
@@ -47,6 +56,7 @@ public abstract class Mixin_Omnidirectional_Rotation {
|
||||
//#endif
|
||||
CallbackInfo ci
|
||||
) {
|
||||
//#endif
|
||||
if (getHandler() != null && getHandler().data instanceof CubicOpenGlFrameCapturer.Data) {
|
||||
CubicOpenGlFrameCapturer.Data data = (CubicOpenGlFrameCapturer.Data) getHandler().data;
|
||||
float angle = 0;
|
||||
@@ -78,7 +88,9 @@ public abstract class Mixin_Omnidirectional_Rotation {
|
||||
x = 1;
|
||||
break;
|
||||
}
|
||||
//#if MC>=11500
|
||||
//#if MC>=12005
|
||||
//$$ matrix.rotateLocal(angle * (float) Math.PI / 180f, x, y, 0);
|
||||
//#elseif MC>=11500
|
||||
matrixStack.multiply(new Vector3f(x, y, 0).getDegreesQuaternion(angle));
|
||||
//#else
|
||||
//$$ GL11.glRotatef(angle, x, y, 0);
|
||||
@@ -96,5 +108,8 @@ public abstract class Mixin_Omnidirectional_Rotation {
|
||||
//#endif
|
||||
//$$ }
|
||||
//#endif
|
||||
//#if MC>=12005
|
||||
//$$ return matrix;
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,11 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
//#if MC>=12005
|
||||
//$$ import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
//$$ import org.joml.Matrix4f;
|
||||
//#endif
|
||||
|
||||
@Mixin(GameRenderer.class)
|
||||
public abstract class Mixin_Stereoscopic_Camera implements EntityRendererHandler.IEntityRenderer {
|
||||
@Inject(method = "getBasicProjectionMatrix", at = @At("RETURN"), cancellable = true)
|
||||
@@ -29,14 +34,30 @@ public abstract class Mixin_Stereoscopic_Camera implements EntityRendererHandler
|
||||
}
|
||||
}
|
||||
|
||||
//#if MC>=12005
|
||||
//$$ @ModifyExpressionValue(method = "renderWorld", at = @At(value = "INVOKE", target = "Lorg/joml/Matrix4f;rotationXYZ(FFF)Lorg/joml/Matrix4f;"))
|
||||
//$$ private Matrix4f replayModRender_setupStereoscopicProjection(Matrix4f matrix) {
|
||||
//#else
|
||||
@Inject(method = "renderWorld", at = @At("HEAD"))
|
||||
private void replayModRender_setupStereoscopicProjection(float partialTicks, long frameStartNano, MatrixStack matrixStack, CallbackInfo ci) {
|
||||
//#endif
|
||||
if (replayModRender_getHandler() != null) {
|
||||
if (replayModRender_getHandler().data == StereoscopicOpenGlFrameCapturer.Data.LEFT_EYE) {
|
||||
matrixStack.translate(0.1, 0, 0);
|
||||
//#if MC>=12005
|
||||
//$$ matrix.translateLocal(0.1f, 0, 0);
|
||||
//#else
|
||||
matrixStack.translate(0.1f, 0, 0);
|
||||
//#endif
|
||||
} else if (replayModRender_getHandler().data == StereoscopicOpenGlFrameCapturer.Data.RIGHT_EYE) {
|
||||
matrixStack.translate(-0.1, 0, 0);
|
||||
//#if MC>=12005
|
||||
//$$ matrix.translateLocal(-0.1f, 0, 0);
|
||||
//#else
|
||||
matrixStack.translate(-0.1f, 0, 0);
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
//#if MC>=12005
|
||||
//$$ return matrix;
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -512,9 +512,14 @@ public class VideoRenderer implements RenderInfo {
|
||||
//$$ , VertexSorter.BY_Z
|
||||
//#endif
|
||||
//$$ );
|
||||
//#if MC>=12006
|
||||
//$$ org.joml.Matrix4fStack matrixStack = RenderSystem.getModelViewStack();
|
||||
//$$ matrixStack.translation(0, 0, -2000);
|
||||
//#else
|
||||
//$$ MatrixStack matrixStack = RenderSystem.getModelViewStack();
|
||||
//$$ matrixStack.loadIdentity();
|
||||
//$$ matrixStack.translate(0, 0, -2000);
|
||||
//#endif
|
||||
//$$ RenderSystem.applyModelViewMatrix();
|
||||
//$$ DiffuseLighting.enableGuiDepthLighting();
|
||||
//#else
|
||||
@@ -558,13 +563,17 @@ public class VideoRenderer implements RenderInfo {
|
||||
int mouseX = (int) mc.mouse.getX() * window.getScaledWidth() / Math.max(window.getWidth(), 1);
|
||||
int mouseY = (int) mc.mouse.getY() * window.getScaledHeight() / Math.max(window.getHeight(), 1);
|
||||
|
||||
//#if MC>=12000
|
||||
//$$ DrawContext drawContext = new DrawContext(mc, mc.getBufferBuilders().getEntityVertexConsumers());
|
||||
//#endif
|
||||
|
||||
if (mc.getOverlay() != null) {
|
||||
Screen orgScreen = mc.currentScreen;
|
||||
try {
|
||||
mc.currentScreen = gui.toMinecraft();
|
||||
mc.getOverlay().render(
|
||||
//#if MC>=12000
|
||||
//$$ new DrawContext(mc, mc.getBufferBuilders().getEntityVertexConsumers()),
|
||||
//$$ drawContext,
|
||||
//#elseif MC>=11600
|
||||
new MatrixStack(),
|
||||
//#endif
|
||||
@@ -582,6 +591,9 @@ public class VideoRenderer implements RenderInfo {
|
||||
//#endif
|
||||
mouseX, mouseY, 0);
|
||||
}
|
||||
//#if MC>=12000
|
||||
//$$ drawContext.draw();
|
||||
//#endif
|
||||
//#else
|
||||
//$$ int mouseX = Mouse.getX() * window.getScaledWidth() / mc.displayWidth;
|
||||
//$$ int mouseY = window.getScaledHeight() - Mouse.getY() * window.getScaledHeight() / mc.displayHeight - 1;
|
||||
|
||||
@@ -675,6 +675,9 @@ public class FullReplaySender extends ChannelInboundHandlerAdapter implements Re
|
||||
//$$ packet.showDeathScreen(),
|
||||
//$$ packet.doLimitedCrafting(),
|
||||
//$$ withSpectatorMode(packet.commonPlayerSpawnInfo())
|
||||
//#if MC>=12006
|
||||
//$$ , packet.enforcesSecureChat()
|
||||
//#endif
|
||||
//#else
|
||||
//#if MC>=11800
|
||||
//$$ packet.hardcore(),
|
||||
|
||||
@@ -74,7 +74,9 @@ public class NoGuiScreenshot {
|
||||
//#endif
|
||||
|
||||
float tickDelta = mc.getTickDelta();
|
||||
//#if MC>=11500
|
||||
//#if MC>=12006
|
||||
//$$ mc.gameRenderer.renderWorld(tickDelta, System.nanoTime());
|
||||
//#elseif MC>=11500
|
||||
mc.gameRenderer.renderWorld(tickDelta, System.nanoTime(), new MatrixStack());
|
||||
//#else
|
||||
//#if MC>=11400
|
||||
|
||||
@@ -46,6 +46,11 @@ import net.minecraft.network.ClientConnection;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
//#if MC>=12006
|
||||
//$$ import net.minecraft.network.handler.NetworkStateTransitions;
|
||||
//$$ import net.minecraft.network.state.LoginStates;
|
||||
//#endif
|
||||
|
||||
//#if MC>=12003
|
||||
//$$ import net.minecraft.client.resource.server.ServerResourcePackManager;
|
||||
//#endif
|
||||
@@ -325,6 +330,10 @@ public class ReplayHandler {
|
||||
quickReplaySender.setChannel(channel);
|
||||
fullReplaySender.setChannel(channel);
|
||||
|
||||
//#if MC>=12006
|
||||
//$$ channel.pipeline().addLast("inbound_config", new NetworkStateTransitions.InboundConfigurer());
|
||||
//$$ channel.pipeline().addLast("outbound_config", new NetworkStateTransitions.OutboundConfigurer());
|
||||
//#else
|
||||
//#if MC>=12002
|
||||
//$$ channel.pipeline().addLast("decoder", new DecoderHandler(ClientConnection.CLIENTBOUND_PROTOCOL_KEY));
|
||||
//$$ channel.pipeline().addLast("encoder", new PacketEncoder(ClientConnection.SERVERBOUND_PROTOCOL_KEY));
|
||||
@@ -337,12 +346,19 @@ public class ReplayHandler {
|
||||
//#elseif MC>=11904
|
||||
//$$ channel.pipeline().addLast("bundler", new PacketBundler(NetworkSide.CLIENTBOUND));
|
||||
//#endif
|
||||
//#endif
|
||||
channel.pipeline().addLast(PACKET_HANDLER_NAME, quickMode ? quickReplaySender : fullReplaySender);
|
||||
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.
|
||||
//#if MC>=12006
|
||||
//$$ networkManager.transitionInbound(LoginStates.S2C, new ClientLoginNetworkHandler(
|
||||
//$$ networkManager, mc, null, null, false, null, it -> {}, null
|
||||
//$$ ));
|
||||
//$$ networkManager.transitionOutbound(LoginStates.C2S);
|
||||
//#else
|
||||
//#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));
|
||||
@@ -363,6 +379,7 @@ public class ReplayHandler {
|
||||
, it -> {}
|
||||
//#endif
|
||||
));
|
||||
//#endif
|
||||
|
||||
//#if MC>=11400
|
||||
((MinecraftAccessor) mc).setConnection(networkManager);
|
||||
@@ -657,7 +674,28 @@ public class ReplayHandler {
|
||||
long diff = targetTime - (replaySender.isHurrying() ? replaySender.getDesiredTimestamp() : replaySender.currentTimeStamp());
|
||||
if (diff != 0) {
|
||||
if (diff > 0 && diff < 5000) { // Small difference and no time travel
|
||||
replaySender.jumpToTime(targetTime);
|
||||
if (replaySender.paused()) {
|
||||
replaySender.setSyncModeAndWait();
|
||||
do {
|
||||
replaySender.sendPacketsTill(targetTime);
|
||||
targetTime += 500;
|
||||
} while (mc.player == null || mc.currentScreen instanceof DownloadingTerrainScreen);
|
||||
replaySender.setAsyncMode(true);
|
||||
|
||||
for (int i = 0; i < Math.min(diff / 50, 3); i++) {
|
||||
//#if MC>=10800 && MC<11400
|
||||
//$$ try {
|
||||
//$$ mc.runTick();
|
||||
//$$ } catch (IOException e) {
|
||||
//$$ e.printStackTrace(); // This should never be thrown but whatever
|
||||
//$$ }
|
||||
//#else
|
||||
mc.tick();
|
||||
//#endif
|
||||
}
|
||||
} else {
|
||||
replaySender.jumpToTime(targetTime);
|
||||
}
|
||||
} else { // We either have to restart the replay or send a significant amount of packets
|
||||
// Render our please-wait-screen
|
||||
GuiScreen guiScreen = new GuiScreen();
|
||||
@@ -696,9 +734,14 @@ public class ReplayHandler {
|
||||
//$$ , VertexSorter.BY_Z
|
||||
//#endif
|
||||
//$$ );
|
||||
//#if MC>=12006
|
||||
//$$ org.joml.Matrix4fStack matrixStack = RenderSystem.getModelViewStack();
|
||||
//$$ matrixStack.translation(0, 0, -2000);
|
||||
//#else
|
||||
//$$ MatrixStack matrixStack = RenderSystem.getModelViewStack();
|
||||
//$$ matrixStack.loadIdentity();
|
||||
//$$ matrixStack.translate(0, 0, -2000);
|
||||
//#endif
|
||||
//$$ RenderSystem.applyModelViewMatrix();
|
||||
//$$ DiffuseLighting.enableGuiDepthLighting();
|
||||
//#else
|
||||
@@ -719,7 +762,9 @@ public class ReplayHandler {
|
||||
|
||||
guiScreen.toMinecraft().init(mc, window.getScaledWidth(), window.getScaledHeight());
|
||||
//#if MC>=12000
|
||||
//$$ guiScreen.toMinecraft().render(new DrawContext(mc, mc.getBufferBuilders().getEntityVertexConsumers()), 0, 0, 0);
|
||||
//$$ DrawContext drawContext = new DrawContext(mc, mc.getBufferBuilders().getEntityVertexConsumers());
|
||||
//$$ guiScreen.toMinecraft().render(drawContext, 0, 0, 0);
|
||||
//$$ drawContext.draw();
|
||||
//#elseif MC>=11600
|
||||
guiScreen.toMinecraft().render(new MatrixStack(), 0, 0, 0);
|
||||
//#else
|
||||
|
||||
@@ -13,9 +13,18 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
//#if MC>=12005
|
||||
//$$ import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
//$$ import org.joml.Matrix4f;
|
||||
//#endif
|
||||
|
||||
@Mixin(GameRenderer.class)
|
||||
public class MixinCamera {
|
||||
@Shadow @Final private MinecraftClient client;
|
||||
//#if MC>=12005
|
||||
//$$ @ModifyExpressionValue(method = "renderWorld", at = @At(value = "INVOKE", target = "Lorg/joml/Matrix4f;rotationXYZ(FFF)Lorg/joml/Matrix4f;"))
|
||||
//$$ private Matrix4f applyRoll(Matrix4f matrix) {
|
||||
//#else
|
||||
@Inject(
|
||||
method = "renderWorld",
|
||||
at = @At(
|
||||
@@ -24,9 +33,17 @@ public class MixinCamera {
|
||||
)
|
||||
)
|
||||
private void applyRoll(float float_1, long long_1, MatrixStack matrixStack, CallbackInfo ci) {
|
||||
//#endif
|
||||
Entity entity = this.client.getCameraEntity() == null ? this.client.player : this.client.getCameraEntity();
|
||||
if (entity instanceof CameraEntity) {
|
||||
//#if MC>=12005
|
||||
//$$ matrix.rotateLocal(((CameraEntity) entity).roll * (float) Math.PI / 180f, 0f, 0f, 1f);
|
||||
//#else
|
||||
matrixStack.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(((CameraEntity) entity).roll));
|
||||
//#endif
|
||||
}
|
||||
//#if MC>=12005
|
||||
//$$ return matrix;
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,11 @@ public class PathPreviewRenderer extends EventRegistrations {
|
||||
//#endif
|
||||
|
||||
//#if MC>=11700
|
||||
//#if MC>=12006
|
||||
//$$ RenderSystem.getModelViewStack().mul(matrixStack.peek().getPositionMatrix());
|
||||
//#else
|
||||
//$$ RenderSystem.getModelViewStack().method_34425(matrixStack.peek().getModel());
|
||||
//#endif
|
||||
//$$ RenderSystem.applyModelViewMatrix();
|
||||
//#elseif MC>=11500
|
||||
RenderSystem.multMatrix(matrixStack.peek().getModel());
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
"client": [
|
||||
"AddServerScreenAccessor",
|
||||
"ClientLoginNetworkHandlerAccessor",
|
||||
//#if MC>=12006
|
||||
//$$ "DecoderHandlerAccessor",
|
||||
//#endif
|
||||
"EntityLivingBaseAccessor",
|
||||
"IntegratedServerAccessor",
|
||||
"NetworkManagerAccessor",
|
||||
@@ -31,6 +34,9 @@
|
||||
//$$ "MixinGuiScreen",
|
||||
//$$ "MixinS26PacketMapChunkBulk",
|
||||
//#endif
|
||||
//#if MC>=12006
|
||||
//$$ "MixinNetHandlerConfigClient",
|
||||
//#endif
|
||||
"MixinNetHandlerLoginClient",
|
||||
"MixinNetHandlerPlayClient",
|
||||
//#if MC<11400
|
||||
|
||||
Reference in New Issue
Block a user