Make use of new @Pattern feature to centralize version-aware code

That is, most of the business code should not be aware that it is being compiled
to multiple versions even when it heavily interacts with MC, preprocessor
statements should be an escape hatch, not the norm.
Similarly, code should not be forced to do `MCVer.getWindow(mc)` instead of the
much more intuitive `mc.getWindow()`, and a new preprocessor (technically remap)
feature makes this possible by defining "search and replace"-like patterns (but
smarter in that they are type-aware) in one or more central places (the
"Patterns.java" files) which then are applied all over the code base.

In a way, this is another step in the automatic back-porting process where
preprocessor statements are used when we cannot yet do something automatically.
Previously we "merely" automatically converted between different mapping, this
new feature now also allows us to automatically perform simple refactoring
tasks like changing field access to a getter+setter (e.g. `mc.getWindow()`), or
changing how a method is called (e.g. `BufferBuilder.begin`), or changing a
method call chain (e.g. `dispatcher.camera.getYaw()`), or most other
search-and-replace-like changes and any combination of those.
The only major limitation is that the replacement itself is not smart, so
arguments must be kept in same order (or be temporarily assigned to local
variables which then can be used in any order).
This commit is contained in:
Jonas Herzig
2021-02-27 17:54:49 +01:00
parent 06a46e6f38
commit cfb9e15b8a
56 changed files with 890 additions and 872 deletions

View File

@@ -30,55 +30,9 @@ The `master` branch is solely to be used for the `version.json` file that contai
used by the clients to check for updates of this mod. used by the clients to check for updates of this mod.
### The Preprocessor ### The Preprocessor
To support multiple Minecraft versions with the ReplayMod, a [JCP](https://github.com/raydac/java-comment-preprocessor)-inspired preprocessor is used: To support multiple Minecraft versions with the ReplayMod, a [JCP](https://github.com/raydac/java-comment-preprocessor)-inspired preprocessor is used.
```java It has by now acquired a lot more sophisticated features to make it as noninvasive as possible.
//#if MC>=11200 Please read the [preprocessor's README](https://github.com/ReplayMod/preprocessor/blob/master/README.md) to understand how it works.
// This is the block for MC >= 1.12.0
category.addDetail(name, callable::call);
//#else
//$$ // This is the block for MC < 1.12.0
//$$ category.setDetail(name, callable::call);
//#endif
```
Any comments starting with `//$$` will automatically be introduced / removed based on the surrounding condition(s).
Normal comments are left untouched. The `//#else` branch is optional.
Conditions can be nested arbitrarily but their indention shall always be equal to the indention of the code at the `//#if` line.
The `//$$` shall be aligned with the inner-most `//#if`.
```java
//#if MC>=10904
public CPacketResourcePackStatus makeStatusPacket(String hash, Action action) {
//#if MC>=11002
return new CPacketResourcePackStatus(action);
//#else
//$$ return new CPacketResourcePackStatus(hash, action);
//#endif
}
//#else
//$$ public C19PacketResourcePackStatus makeStatusPacket(String hash, Action action) {
//$$ return new C19PacketResourcePackStatus(hash, action);
//$$ }
//#endif
```
Code for the more recent MC version shall be placed in the first branch of the if-else-construct.
Version-dependent import statements shall be placed separately from and after all other imports.
Common version dependent code (including the fml and forge event bus) are available as static methods/fields in the `MCVer` class.
The source code in `src/main` is generally for the most recent Minecraft version and is automatically passed through the
preprocessor when any of the other versions are built (gradle projects `:1.8`, `:1.8.9`, etc.).
Do **NOT** edit any of the code in `versions/$MCVERSION/build/` as it is automatically generated and will be overwritten without warning.
You can change the version of the code in `src/main` if you wish to develop/debug with another version of Minecraft:
```bash
./gradle :1.9.4:setCoreVersion # switches all sources in src/main to 1.9.4
```
If you do so, you'll also have to refresh the project in your IDE.
Make sure to switch back to the most recent branch before committing!
Care should also be taken that switching to a different branch and back doesn't introduce any uncommitted changes (e.g. due to different indention, especially in case of nested conditions).
Some files may use the same preprocessor with different keywords.
If required, more file extensions and keywords can be added in the `preprocess` block of the `versions/common.gradle` script.
### Versioning ### Versioning
The ReplayMod uses the versioning scheme outlined [here](http://mcforge.readthedocs.io/en/latest/conventions/versioning/) The ReplayMod uses the versioning scheme outlined [here](http://mcforge.readthedocs.io/en/latest/conventions/versioning/)

View File

@@ -102,6 +102,8 @@ preprocess {
".vert": PreprocessTask.DEFAULT_KEYWORDS, ".vert": PreprocessTask.DEFAULT_KEYWORDS,
".frag": PreprocessTask.DEFAULT_KEYWORDS, ".frag": PreprocessTask.DEFAULT_KEYWORDS,
]) ])
patternAnnotation.set("com.replaymod.gradle.remap.Pattern")
} }
def mcVersionStr = "${(int)(mcVersion/10000)}.${(int)(mcVersion/100)%100}" + (mcVersion%100==0 ? '' : ".${mcVersion%100}") def mcVersionStr = "${(int)(mcVersion/10000)}.${(int)(mcVersion/100)%100}" + (mcVersion%100==0 ? '' : ".${mcVersion%100}")

View File

@@ -3,7 +3,7 @@ import java.io.ByteArrayOutputStream
plugins { plugins {
id("fabric-loom") version "0.5-SNAPSHOT" apply false id("fabric-loom") version "0.5-SNAPSHOT" apply false
id("com.replaymod.preprocess") version "7c4f90e" id("com.replaymod.preprocess") version "3d85a00"
id("com.github.hierynomus.license") version "0.15.0" id("com.github.hierynomus.license") version "0.15.0"
} }

View File

@@ -8,8 +8,6 @@ import net.minecraft.client.MinecraftClient;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import static com.replaymod.core.versions.MCVer.getRenderPartialTicks;
public class ShaderBeginRender extends EventRegistrations { public class ShaderBeginRender extends EventRegistrations {
private final MinecraftClient mc = MinecraftClient.getInstance(); private final MinecraftClient mc = MinecraftClient.getInstance();
@@ -36,7 +34,7 @@ public class ShaderBeginRender extends EventRegistrations {
//#if MC>=11400 //#if MC>=11400
mc.gameRenderer.getCamera(), mc.gameRenderer.getCamera(),
//#endif //#endif
getRenderPartialTicks(), 0); mc.getTickDelta(), 0);
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@@ -7,7 +7,6 @@ import com.replaymod.core.mixin.KeyBindingAccessor;
import de.johni0702.minecraft.gui.utils.EventRegistrations; import de.johni0702.minecraft.gui.utils.EventRegistrations;
import com.replaymod.core.events.KeyBindingEventCallback; import com.replaymod.core.events.KeyBindingEventCallback;
import com.replaymod.core.events.KeyEventCallback; import com.replaymod.core.events.KeyEventCallback;
import com.replaymod.core.versions.MCVer;
import net.minecraft.client.options.KeyBinding; import net.minecraft.client.options.KeyBinding;
import net.minecraft.util.crash.CrashReport; import net.minecraft.util.crash.CrashReport;
import net.minecraft.util.crash.CrashReportSection; import net.minecraft.util.crash.CrashReportSection;
@@ -121,8 +120,8 @@ public class KeyBindingRegistry extends EventRegistrations {
} catch (Throwable cause) { } catch (Throwable cause) {
CrashReport crashReport = CrashReport.create(cause, "Handling Key Binding"); CrashReport crashReport = CrashReport.create(cause, "Handling Key Binding");
CrashReportSection category = crashReport.addElement("Key Binding"); CrashReportSection category = crashReport.addElement("Key Binding");
MCVer.addDetail(category, "Key Binding", () -> binding.name); category.add("Key Binding", () -> binding.name);
MCVer.addDetail(category, "Handler", runnable::toString); category.add("Handler", runnable::toString);
throw new CrashException(crashReport); throw new CrashException(crashReport);
} }
} }
@@ -139,8 +138,8 @@ public class KeyBindingRegistry extends EventRegistrations {
} catch (Throwable cause) { } catch (Throwable cause) {
CrashReport crashReport = CrashReport.create(cause, "Handling Raw Key Binding"); CrashReport crashReport = CrashReport.create(cause, "Handling Raw Key Binding");
CrashReportSection category = crashReport.addElement("Key Binding"); CrashReportSection category = crashReport.addElement("Key Binding");
MCVer.addDetail(category, "Key Code", () -> "" + keyCode); category.add("Key Code", () -> "" + keyCode);
MCVer.addDetail(category, "Handler", handler::toString); category.add("Handler", handler::toString);
throw new CrashException(crashReport); throw new CrashException(crashReport);
} }
} }
@@ -161,7 +160,12 @@ public class KeyBindingRegistry extends EventRegistrations {
} }
public String getBoundKey() { public String getBoundKey() {
return MCVer.getBoundKey(keyBinding); try {
return keyBinding.getBoundKeyLocalizedText().getString();
} catch (ArrayIndexOutOfBoundsException e) {
// Apparently windows likes to press strange keys, see https://www.replaymod.com/forum/thread/55
return "Unknown";
}
} }
public boolean isBound() { public boolean isBound() {

View File

@@ -22,15 +22,15 @@ import com.replaymod.simplepathing.ReplayModSimplePathing;
import de.johni0702.minecraft.gui.container.GuiScreen; import de.johni0702.minecraft.gui.container.GuiScreen;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.options.Option; import net.minecraft.client.options.Option;
import net.minecraft.util.Identifier;
import net.minecraft.resource.DirectoryResourcePack; import net.minecraft.resource.DirectoryResourcePack;
import net.minecraft.text.Text;
import net.minecraft.text.Style;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting; import net.minecraft.util.Formatting;
import org.apache.commons.io.FilenameUtils; import net.minecraft.util.Identifier;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
@@ -355,6 +355,14 @@ public class ReplayMod implements Module, Scheduler {
return backend.getVersion(); return backend.getVersion();
} }
public String getMinecraftVersion() {
return backend.getMinecraftVersion();
}
public boolean isModLoaded(String id) {
return backend.isModLoaded(id);
}
public MinecraftClient getMinecraft() { public MinecraftClient getMinecraft() {
return mc; return mc;
} }

View File

@@ -18,4 +18,12 @@ public class ReplayModBackend implements ClientModInitializer {
.orElseThrow(IllegalStateException::new) .orElseThrow(IllegalStateException::new)
.getMetadata().getVersion().toString(); .getMetadata().getVersion().toString();
} }
public String getMinecraftVersion() {
return mod.getMinecraft().getGame().getVersion().getName();
}
public boolean isModLoaded(String id) {
return FabricLoader.getInstance().isModLoaded(id.toLowerCase());
}
} }

View File

@@ -10,8 +10,6 @@ import net.minecraft.util.Identifier;
//$$ import io.netty.buffer.Unpooled; //$$ import io.netty.buffer.Unpooled;
//#endif //#endif
import static com.replaymod.core.versions.MCVer.readString;
/** /**
* Restrictions set by the server, * Restrictions set by the server,
* @see <a href="https://gist.github.com/Johni0702/2547c463e51f65f312cb">Replay Restrictions Gist</a> * @see <a href="https://gist.github.com/Johni0702/2547c463e51f65f312cb">Replay Restrictions Gist</a>
@@ -34,7 +32,7 @@ public class Restrictions {
//$$ PacketBuffer buffer = new PacketBuffer(Unpooled.wrappedBuffer(packet.func_149168_d())); //$$ PacketBuffer buffer = new PacketBuffer(Unpooled.wrappedBuffer(packet.func_149168_d()));
//#endif //#endif
while (buffer.isReadable()) { while (buffer.isReadable()) {
String name = readString(buffer, 64); String name = buffer.readString(64);
boolean active = buffer.readBoolean(); boolean active = buffer.readBoolean();
// if ("no_xray".equals(name)) { // if ("no_xray".equals(name)) {
// noXray = active; // noXray = active;

View File

@@ -0,0 +1 @@
// 1.7.10 and below

View File

@@ -0,0 +1 @@
// 1.12.2 and below

View File

@@ -1,45 +1,19 @@
package com.replaymod.core.versions; package com.replaymod.core.versions;
import com.replaymod.core.mixin.GuiScreenAccessor; import com.replaymod.core.mixin.GuiScreenAccessor;
import com.replaymod.core.mixin.MinecraftAccessor;
import com.replaymod.render.mixin.MainWindowAccessor;
import com.replaymod.replaystudio.protocol.PacketTypeRegistry; import com.replaymod.replaystudio.protocol.PacketTypeRegistry;
import com.replaymod.replaystudio.us.myles.ViaVersion.api.protocol.ProtocolVersion; import com.replaymod.replaystudio.us.myles.ViaVersion.api.protocol.ProtocolVersion;
import com.replaymod.replaystudio.us.myles.ViaVersion.packets.State; import com.replaymod.replaystudio.us.myles.ViaVersion.packets.State;
import de.johni0702.minecraft.gui.utils.NonNull;
import de.johni0702.minecraft.gui.utils.lwjgl.Dimension;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.options.KeyBinding;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.model.ModelPart;
import net.minecraft.util.crash.CrashReportSection;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util; import net.minecraft.util.Util;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.chunk.WorldChunk;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
//#if MC>=11600 //#if MC>=11600
import net.minecraft.resource.ResourcePackSource; import net.minecraft.resource.ResourcePackSource;
//#endif //#endif
//#if MC>=11500
import net.minecraft.client.model.ModelPart.Cuboid;
import java.util.ArrayList;
//#else
//$$ import net.minecraft.client.model.Box;
//#endif
//#if MC>=11400 //#if MC>=11400
import com.replaymod.core.mixin.AbstractButtonWidgetAccessor; import com.replaymod.render.mixin.MainWindowAccessor;
import net.minecraft.SharedConstants; import net.minecraft.SharedConstants;
import net.minecraft.client.gl.Framebuffer; import net.minecraft.client.gl.Framebuffer;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.ButtonWidget;
@@ -62,20 +36,14 @@ import net.minecraft.text.TranslatableText;
//#if FABRIC>=1 //#if FABRIC>=1
//#else //#else
//$$ import net.minecraft.entity.LivingEntity;
//$$ import net.minecraftforge.client.event.GuiScreenEvent;
//$$ import net.minecraftforge.client.event.RenderGameOverlayEvent;
//$$ import net.minecraftforge.client.event.RenderLivingEvent;
//$$ import net.minecraftforge.common.MinecraftForge; //$$ import net.minecraftforge.common.MinecraftForge;
//$$ import net.minecraftforge.eventbus.api.IEventBus; //$$ import net.minecraftforge.eventbus.api.IEventBus;
//#endif //#endif
//#if MC>=11400 //#if MC>=11400
import net.minecraft.client.util.Window;
import net.minecraft.client.util.InputUtil; import net.minecraft.client.util.InputUtil;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
//#else //#else
//$$ import net.minecraft.client.gui.ScaledResolution;
//$$ import net.minecraft.client.resources.ResourcePackRepository; //$$ import net.minecraft.client.resources.ResourcePackRepository;
//$$ import net.minecraftforge.fml.client.FMLClientHandler; //$$ import net.minecraftforge.fml.client.FMLClientHandler;
//$$ import org.apache.logging.log4j.LogManager; //$$ import org.apache.logging.log4j.LogManager;
@@ -84,28 +52,18 @@ import org.lwjgl.glfw.GLFW;
//$$ import java.io.IOException; //$$ import java.io.IOException;
//#endif //#endif
//#if MC>=11400
import net.minecraft.client.sound.PositionedSoundInstance;
//#else
//$$ import net.minecraft.client.audio.PositionedSoundRecord;
//#endif
//#if MC>=10904 //#if MC>=10904
import com.replaymod.render.blend.mixin.ParticleAccessor; import com.replaymod.render.blend.mixin.ParticleAccessor;
import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.Particle;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
//#endif //#endif
//#if MC>=10809 //#if MC>=10809
import net.minecraft.client.render.VertexFormats;
//#else //#else
//$$ import net.minecraftforge.fml.common.FMLCommonHandler; //$$ import net.minecraftforge.fml.common.FMLCommonHandler;
//#endif //#endif
//#if MC>=10800 //#if MC>=10800
import net.minecraft.client.render.BufferBuilder;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.render.VertexFormat; import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormatElement; import net.minecraft.client.render.VertexFormatElement;
//#if MC<11500 //#if MC<11500
@@ -113,28 +71,17 @@ import net.minecraft.client.render.VertexFormatElement;
//#endif //#endif
//#else //#else
//$$ import com.replaymod.core.mixin.ResourcePackRepositoryAccessor; //$$ import com.replaymod.core.mixin.ResourcePackRepositoryAccessor;
//$$ import com.google.common.util.concurrent.Futures;
//$$ import io.netty.handler.codec.DecoderException; //$$ import io.netty.handler.codec.DecoderException;
//$$ import net.minecraft.client.renderer.entity.RenderManager;
//$$ import net.minecraft.client.resources.FileResourcePack; //$$ import net.minecraft.client.resources.FileResourcePack;
//$$ import net.minecraft.network.PacketBuffer;
//$$ //$$
//$$ import static org.lwjgl.opengl.GL11.*; //$$ import static org.lwjgl.opengl.GL11.*;
//#endif //#endif
//#if FABRIC>=1
import net.fabricmc.loader.api.FabricLoader;
//#else
//#if MC>=11400
//$$ import net.minecraftforge.fml.ModList;
//#else
//$$ import net.minecraftforge.fml.common.Loader;
//#endif
//#endif
import java.io.File; import java.io.File;
import java.net.URI; import java.net.URI;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.concurrent.Callable;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.Optional; import java.util.Optional;
@@ -142,8 +89,6 @@ import java.util.Optional;
* Abstraction over things that have changed between different MC versions. * Abstraction over things that have changed between different MC versions.
*/ */
public class MCVer { public class MCVer {
private static Logger LOGGER = LogManager.getLogger();
//#if FABRIC<=0 //#if FABRIC<=0
//$$ public static IEventBus FORGE_BUS = MinecraftForge.EVENT_BUS; //$$ public static IEventBus FORGE_BUS = MinecraftForge.EVENT_BUS;
//#if MC>=10809 //#if MC>=10809
@@ -153,18 +98,6 @@ public class MCVer {
//#endif //#endif
//#endif //#endif
public static boolean isModLoaded(String id) {
//#if FABRIC>=1
return FabricLoader.getInstance().isModLoaded(id.toLowerCase());
//#else
//#if MC>=11400
//$$ return ModList.get().isLoaded(id.toLowerCase());
//#else
//$$ return Loader.isModLoaded(id);
//#endif
//#endif
}
public static int getProtocolVersion() { public static int getProtocolVersion() {
//#if MC>=11400 //#if MC>=11400
return SharedConstants.getGameVersion().getProtocolVersion(); return SharedConstants.getGameVersion().getProtocolVersion();
@@ -180,38 +113,6 @@ public class MCVer {
); );
} }
public static String getMinecraftVersion() {
//#if MC>=11400
return getMinecraft().getGame().getVersion().getName();
//#else
//$$ return Loader.MC_VERSION;
//#endif
}
public static void addDetail(CrashReportSection category, String name, Callable<String> callable) {
//#if MC>=10904
//#if MC>=11200
category.add(name, callable::call);
//#else
//$$ category.setDetail(name, callable::call);
//#endif
//#else
//$$ category.addCrashSectionCallable(name, callable);
//#endif
}
public static Dimension getMainWindowSize(MinecraftClient mc) {
return new Dimension(
//#if MC>=11400
getWindow(mc).getFramebufferWidth(),
getWindow(mc).getFramebufferHeight()
//#else
//$$ mc.displayWidth,
//$$ mc.displayHeight
//#endif
);
}
public static void resizeMainWindow(MinecraftClient mc, int width, int height) { public static void resizeMainWindow(MinecraftClient mc, int width, int height) {
//#if MC>=11400 //#if MC>=11400
Framebuffer fb = mc.getFramebuffer(); Framebuffer fb = mc.getFramebuffer();
@@ -219,7 +120,7 @@ public class MCVer {
fb.resize(width, height, false); fb.resize(width, height, false);
} }
//noinspection ConstantConditions //noinspection ConstantConditions
MainWindowAccessor mainWindow = (MainWindowAccessor) (Object) getWindow(mc); MainWindowAccessor mainWindow = (MainWindowAccessor) (Object) mc.getWindow();
mainWindow.setFramebufferWidth(width); mainWindow.setFramebufferWidth(width);
mainWindow.setFramebufferHeight(height); mainWindow.setFramebufferHeight(height);
//#if MC>=11500 //#if MC>=11500
@@ -232,263 +133,13 @@ public class MCVer {
//#endif //#endif
} }
public static double Entity_getX(Entity entity) { //#if MC<10800
//#if MC>=11500 //$$ public static String tryReadString(PacketBuffer buffer, int max) {
return entity.getX();
//#else
//$$ return entity.x;
//#endif
}
public static double Entity_getY(Entity entity) {
//#if MC>=11500
return entity.getY();
//#else
//$$ return entity.y;
//#endif
}
public static double Entity_getZ(Entity entity) {
//#if MC>=11500
return entity.getZ();
//#else
//$$ return entity.z;
//#endif
}
public static void Entity_setPos(Entity entity, double x, double y, double z) {
//#if MC>=11500
entity.setPos(x, y, z);
//#else
//$$ entity.x = x;
//$$ entity.y = y;
//$$ entity.z = z;
//#endif
}
//#if MC>=11400
public static void width(AbstractButtonWidget button, int value) {
button.setWidth(value);
}
public static int width(AbstractButtonWidget button) {
return button.getWidth();
}
public static int height(AbstractButtonWidget button) {
return ((AbstractButtonWidgetAccessor) button).getHeight();
}
//#else
//$$ public static void width(GuiButton button, int value) {
//$$ button.width = value;
//$$ }
//$$
//$$ public static int width(GuiButton button) {
//$$ return button.width;
//$$ }
//$$
//$$ public static int height(GuiButton button) {
//$$ return button.height;
//$$ }
//#endif
//#if FABRIC<=0
//#if MC>=11400
//$$ public static void addButton(GuiScreenEvent.InitGuiEvent event, Widget button) {
//$$ event.addWidget(button);
//$$ }
//$$
//$$ public static void removeButton(GuiScreenEvent.InitGuiEvent event, Widget button) {
//$$ event.removeWidget(button);
//$$ }
//$$
//$$ public static List<Widget> getButtonList(GuiScreenEvent.InitGuiEvent event) {
//$$ return event.getWidgetList();
//$$ }
//$$
//$$ public static Widget getButton(GuiScreenEvent.ActionPerformedEvent event) {
//$$ return event.getButton();
//$$ }
//#else
//$$ public static void addButton(GuiScreenEvent.InitGuiEvent event, GuiButton button) {
//#if MC>=11400
//$$ event.addButton(button);
//#else
//$$ getButtonList(event).add(button);
//#endif
//$$ }
//$$
//$$ public static void removeButton(GuiScreenEvent.InitGuiEvent event, GuiButton button) {
//#if MC>=11400
//$$ event.removeButton(button);
//#else
//$$ getButtonList(event).remove(button);
//#endif
//$$ }
//$$
//$$ @SuppressWarnings("unchecked")
//$$ public static List<GuiButton> getButtonList(GuiScreenEvent.InitGuiEvent event) {
//#if MC>=10904
//$$ return event.getButtonList();
//#else
//$$ return event.buttonList;
//#endif
//$$ }
//$$
//$$ public static GuiButton getButton(GuiScreenEvent.ActionPerformedEvent event) {
//#if MC>=10904
//$$ return event.getButton();
//#else
//$$ return event.button;
//#endif
//$$ }
//#endif
//$$
//$$ public static Screen getGui(GuiScreenEvent event) {
//#if MC>=10904
//$$ return event.getGui();
//#else
//$$ return event.gui;
//#endif
//$$ }
//$$
//$$ public static LivingEntity getEntity(RenderLivingEvent event) {
//#if MC>=10904
//$$ return event.getEntity();
//#else
//$$ return event.entity;
//#endif
//$$ }
//#endif
public static String readString(PacketByteBuf buffer, int max) {
//#if MC>=10800
return buffer.readString(max);
//#else
//$$ try { //$$ try {
//$$ return buffer.readStringFromBuffer(max); //$$ return buffer.readStringFromBuffer(max);
//$$ } catch (IOException e) { //$$ } catch (IOException e) {
//$$ throw new DecoderException(e); //$$ throw new DecoderException(e);
//$$ } //$$ }
//#endif
}
//#if FABRIC<=0
//$$ public static RenderGameOverlayEvent.ElementType getType(RenderGameOverlayEvent event) {
//#if MC>=10904
//$$ return event.getType();
//#else
//$$ return event.type;
//#endif
//$$ }
//#endif
//#if MC>=10800
public static Entity getRenderViewEntity(MinecraftClient mc) {
return mc.getCameraEntity();
}
//#else
//$$ public static EntityLivingBase getRenderViewEntity(Minecraft mc) {
//$$ return mc.renderViewEntity;
//$$ }
//#endif
//#if MC>=10800
public static void setRenderViewEntity(MinecraftClient mc, Entity entity) {
mc.setCameraEntity(entity);
}
//#else
//$$ public static void setRenderViewEntity(Minecraft mc, EntityLivingBase entity) {
//$$ mc.renderViewEntity = entity;
//$$ }
//#endif
public static Entity getRiddenEntity(Entity ridden) {
//#if MC>=10904
return ridden.getVehicle();
//#else
//$$ return ridden.ridingEntity;
//#endif
}
public static Iterable<Entity> loadedEntityList(ClientWorld world) {
//#if MC>=11400
return world.getEntities();
//#else
//$$ return world.loadedEntityList;
//#endif
}
@SuppressWarnings("unchecked")
public static Collection<Entity>[] getEntityLists(WorldChunk chunk) {
//#if MC>=10800
return chunk.getEntitySectionArray();
//#else
//$$ return chunk.entityLists;
//#endif
}
@SuppressWarnings("unchecked")
//#if MC>=11500
public static List<Cuboid> cubeList(ModelPart modelRenderer) {
return new ArrayList<>(); // FIXME 1.15
}
//#else
//$$ public static List<Box> cubeList(ModelPart modelRenderer) {
//$$ return modelRenderer.boxes;
//$$ }
//#endif
@SuppressWarnings("unchecked")
public static List<PlayerEntity> playerEntities(World world) {
//#if MC>=11400
return (List) world.getPlayers();
//#else
//$$ return world.playerEntities;
//#endif
}
public static boolean isOnMainThread() {
//#if MC>=11400
return getMinecraft().isOnThread();
//#else
//$$ return getMinecraft().isCallingFromMinecraftThread();
//#endif
}
public static void scheduleOnMainThread(Runnable runnable) {
//#if MC>=11400
getMinecraft().send(runnable);
//#else
//$$ getMinecraft().addScheduledTask(runnable);
//#endif
}
//#if MC>=11400
public static @NonNull Window getWindow(MinecraftClient mc) {
//#if MC>=11500
return mc.getWindow();
//#else
//$$ return mc.window;
//#endif
}
//#else
//$$ public static @NonNull MainWindowAccessor getWindow(Minecraft mc) {
//$$ return (MainWindowAccessor) mc;
//$$ }
//#endif
//#if MC>=11400
public static Window newScaledResolution(MinecraftClient mc) {
return getWindow(mc);
}
//#else
//$$ public static ScaledResolution newScaledResolution(Minecraft mc) {
//#if MC>=10809
//$$ return new ScaledResolution(mc);
//#else
//$$ return new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
//#endif
//$$ } //$$ }
//#endif //#endif
@@ -549,69 +200,6 @@ public class MCVer {
//#endif //#endif
} }
//#if MC>=10800
public static BufferBuilder Tessellator_getBufferBuilder() {
return Tessellator.getInstance().getBuffer();
}
//#else
//$$ public static Tessellator Tessellator_getBufferBuilder() {
//$$ return Tessellator.instance;
//$$ }
//#endif
public static void BufferBuilder_beginPosCol(int mode) {
Tessellator_getBufferBuilder().begin(
mode
//#if MC>=10809
, VertexFormats.POSITION_COLOR
//#endif
);
}
public static void BufferBuilder_addPosCol(double x, double y, double z, int r, int g, int b, int a) {
//#if MC>=10809
Tessellator_getBufferBuilder().vertex(x, y, z).color(r, g, b, a).next();
//#else
//$$ Tessellator_getBufferBuilder().setColorRGBA(r, g, b, a);
//$$ Tessellator_getBufferBuilder().addVertex(x, y, z);
//#endif
}
public static void BufferBuilder_beginPosTex(int mode) {
Tessellator_getBufferBuilder().begin(
mode
//#if MC>=10809
, VertexFormats.POSITION_TEXTURE
//#endif
);
}
public static void BufferBuilder_addPosTex(double x, double y, double z, float u, float v) {
//#if MC>=10809
Tessellator_getBufferBuilder().vertex(x, y, z).texture(u, v).next();
//#else
//$$ Tessellator_getBufferBuilder().addVertexWithUV(x, y, z, u, v);
//#endif
}
public static void BufferBuilder_beginPosTexCol(int mode) {
Tessellator_getBufferBuilder().begin(
mode
//#if MC>=10809
, VertexFormats.POSITION_TEXTURE_COLOR
//#endif
);
}
public static void BufferBuilder_addPosTexCol(double x, double y, double z, float u, float v, int r, int g, int b, int a) {
//#if MC>=10809
Tessellator_getBufferBuilder().vertex(x, y, z).texture(u, v).color(r, g, b, a).next();
//#else
//$$ Tessellator_getBufferBuilder().setColorRGBA(r, g, b, a);
//$$ Tessellator_getBufferBuilder().addVertexWithUV(x, y, z, u, v);
//#endif
}
//#if MC>=10800 //#if MC>=10800
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static List<VertexFormatElement> getElements(VertexFormat vertexFormat) { public static List<VertexFormatElement> getElements(VertexFormat vertexFormat) {
@@ -619,30 +207,16 @@ public class MCVer {
} }
//#endif //#endif
public static Tessellator Tessellator_getInstance() { //#if MC<10800
//#if MC>=10800 //$$ public static RenderManager getRenderManager(@SuppressWarnings("unused") Minecraft mc) {
return Tessellator.getInstance();
//#else
//$$ return Tessellator.instance;
//#endif
}
public static EntityRenderDispatcher getRenderManager() {
//#if MC>=10800
return getMinecraft().getEntityRenderDispatcher();
//#else
//$$ return RenderManager.instance; //$$ return RenderManager.instance;
//$$ }
//#endif //#endif
}
public static MinecraftClient getMinecraft() { public static MinecraftClient getMinecraft() {
return MinecraftClient.getInstance(); return MinecraftClient.getInstance();
} }
public static float getRenderPartialTicks() {
return ((MinecraftAccessor) getMinecraft()).getTimer().tickDelta;
}
public static void addButton( public static void addButton(
Screen screen, Screen screen,
//#if MC>=11400 //#if MC>=11400
@@ -719,26 +293,6 @@ public class MCVer {
//#endif //#endif
} }
public static void bindTexture(Identifier texture) {
//#if MC>=11500
getMinecraft().getTextureManager().bindTexture(texture);
//#else
//#if MC>=11400
//$$ getMinecraft().getTextureManager().bindTexture(texture);
//#else
//$$ getMinecraft().renderEngine.bindTexture(texture);
//#endif
//#endif
}
public static float cos(float val) {
return MathHelper.cos(val);
}
public static float sin(float val) {
return MathHelper.sin(val);
}
//#if MC>=10904 //#if MC>=10904
// TODO: this can be inlined once https://github.com/SpongePowered/Mixin/issues/305 is fixed // TODO: this can be inlined once https://github.com/SpongePowered/Mixin/issues/305 is fixed
public static Vec3d getPosition(Particle particle, float partialTicks) { public static Vec3d getPosition(Particle particle, float partialTicks) {
@@ -781,51 +335,20 @@ public class MCVer {
} }
public static void openURL(URI url) { public static void openURL(URI url) {
//#if MC>=11400
//#if MC>=11400 //#if MC>=11400
Util.getOperatingSystem().open(url); Util.getOperatingSystem().open(url);
//#else //#else
//$$ Util.getOSType().openURI(url);
//#endif
//#else
//$$ try { //$$ try {
//$$ Desktop.getDesktop().browse(url); //$$ Desktop.getDesktop().browse(url);
//$$ } catch (Throwable e) { //$$ } catch (Throwable e) {
//$$ LOGGER.error("Failed to open URL: ", e); //$$ LogManager.getLogger().error("Failed to open URL: ", e);
//$$ } //$$ }
//#endif //#endif
} }
public static String getBoundKey(KeyBinding keyBinding) { //#if MC<10900
try { //$$ public static class SoundEvent {}
//#if MC>=11600
return keyBinding.getBoundKeyLocalizedText().getString();
//#else
//#if MC>=11400
//$$ return keyBinding.getLocalizedName();
//#else
//$$ return Keyboard.getKeyName(keyBinding.getKeyCode());
//#endif //#endif
//#endif
} catch (ArrayIndexOutOfBoundsException e) {
// Apparently windows likes to press strange keys, see https://www.replaymod.com/forum/thread/55
return "Unknown";
}
}
public static void playSound(Identifier sound) {
getMinecraft().getSoundManager().play(
//#if MC>=11400
PositionedSoundInstance.master(new SoundEvent(sound), 1.0F)
//#elseif MC>=10904
//$$ PositionedSoundRecord.getMasterRecord(new SoundEvent(sound), 1.0F)
//#elseif MC>=10800
//$$ PositionedSoundRecord.create(sound, 1.0F)
//#else
//$$ PositionedSoundRecord.createPositionedSoundRecord(sound, 1.0F)
//#endif
);
}
//#if MC>=11400 //#if MC>=11400
private static Boolean hasOptifine; private static Boolean hasOptifine;

View File

@@ -0,0 +1,376 @@
package com.replaymod.core.versions;
import com.replaymod.gradle.remap.Pattern;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.options.KeyBinding;
import net.minecraft.client.texture.TextureManager;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.util.crash.CrashReportSection;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;
import net.minecraft.world.chunk.WorldChunk;
//#if MC>=11400
import net.minecraft.client.gui.widget.AbstractButtonWidget;
import net.minecraft.client.util.Window;
//#else
//$$ import net.minecraft.client.gui.GuiButton;
//#endif
//#if MC>=10904
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.crash.CrashCallable;
//#else
//$$ import java.util.concurrent.Callable;
//#endif
//#if MC>=10809
import net.minecraft.client.render.VertexFormats;
//#else
//#endif
//#if MC>=10800
import net.minecraft.client.render.BufferBuilder;
//#else
//$$ import net.minecraft.entity.EntityLivingBase;
//#endif
import java.util.Collection;
import java.util.List;
class Patterns {
//#if MC>=10904
@Pattern
private static void addCrashCallable(CrashReportSection category, String name, CrashCallable<String> callable) {
//#if MC>=11200
category.add(name, callable);
//#else
//$$ category.setDetail(name, callable);
//#endif
}
//#else
//$$ @Pattern
//$$ private static void addCrashCallable(CrashReportCategory category, String name, Callable<String> callable) {
//$$ category.addCrashSectionCallable(name, callable);
//$$ }
//#endif
@Pattern
private static double Entity_getX(Entity entity) {
//#if MC>=11500
return entity.getX();
//#else
//$$ return entity.x;
//#endif
}
@Pattern
private static double Entity_getY(Entity entity) {
//#if MC>=11500
return entity.getY();
//#else
//$$ return entity.y;
//#endif
}
@Pattern
private static double Entity_getZ(Entity entity) {
//#if MC>=11500
return entity.getZ();
//#else
//$$ return entity.z;
//#endif
}
@Pattern
private static void Entity_setPos(Entity entity, double x, double y, double z) {
//#if MC>=11500
entity.setPos(x, y, z);
//#else
//$$ { net.minecraft.entity.Entity self = entity; self.x = x; self.y = y; self.z = z; }
//#endif
}
//#if MC>=11400
@Pattern
private static void setWidth(AbstractButtonWidget button, int value) {
button.setWidth(value);
}
@Pattern
private static int getWidth(AbstractButtonWidget button) {
return button.getWidth();
}
@Pattern
private static int getHeight(AbstractButtonWidget button) {
//#if MC>=11600
return button.getHeight();
//#else
//$$ return ((com.replaymod.core.mixin.AbstractButtonWidgetAccessor) button).getHeight();
//#endif
}
//#else
//$$ @Pattern
//$$ private static void setWidth(GuiButton button, int value) {
//$$ button.width = value;
//$$ }
//$$
//$$ @Pattern
//$$ private static int getWidth(GuiButton button) {
//$$ return button.width;
//$$ }
//$$
//$$ @Pattern
//$$ private static int getHeight(GuiButton button) {
//$$ return button.height;
//$$ }
//#endif
@Pattern
private static String readString(PacketByteBuf buffer, int max) {
//#if MC>=10800
return buffer.readString(max);
//#else
//$$ return com.replaymod.core.versions.MCVer.tryReadString(buffer, max);
//#endif
}
@Pattern
//#if MC>=10800
private static Entity getRenderViewEntity(MinecraftClient mc) {
return mc.getCameraEntity();
}
//#else
//$$ private static EntityLivingBase getRenderViewEntity(Minecraft mc) {
//$$ return mc.renderViewEntity;
//$$ }
//#endif
@Pattern
//#if MC>=10800
private static void setRenderViewEntity(MinecraftClient mc, Entity entity) {
mc.setCameraEntity(entity);
}
//#else
//$$ private static void setRenderViewEntity(Minecraft mc, EntityLivingBase entity) {
//$$ mc.renderViewEntity = entity;
//$$ }
//#endif
@Pattern
private static Entity getVehicle(Entity passenger) {
//#if MC>=10904
return passenger.getVehicle();
//#else
//$$ return passenger.ridingEntity;
//#endif
}
@Pattern
private static Iterable<Entity> loadedEntityList(ClientWorld world) {
//#if MC>=11400
return world.getEntities();
//#else
//#if MC>=10809
//$$ return world.loadedEntityList;
//#else
//$$ return ((java.util.List<net.minecraft.entity.Entity>) world.loadedEntityList);
//#endif
//#endif
}
@Pattern
private static Collection<Entity>[] getEntitySectionArray(WorldChunk chunk) {
//#if MC>=10800
return chunk.getEntitySectionArray();
//#else
//$$ return chunk.entityLists;
//#endif
}
@Pattern
private static List<? extends PlayerEntity> playerEntities(World world) {
//#if MC>=11400
return world.getPlayers();
//#elseif MC>=10809
//$$ return world.playerEntities;
//#else
//$$ return ((List<? extends net.minecraft.entity.player.EntityPlayer>) world.playerEntities);
//#endif
}
@Pattern
private static boolean isOnMainThread(MinecraftClient mc) {
//#if MC>=11400
return mc.isOnThread();
//#else
//$$ return mc.isCallingFromMinecraftThread();
//#endif
}
@Pattern
private static void scheduleOnMainThread(MinecraftClient mc, Runnable runnable) {
//#if MC>=11400
mc.send(runnable);
//#else
//$$ mc.addScheduledTask(runnable);
//#endif
}
@Pattern
private static Window getWindow(MinecraftClient mc) {
//#if MC>=11500
return mc.getWindow();
//#elseif MC>=11400
//$$ return mc.window;
//#else
//$$ return new com.replaymod.core.versions.Window(mc);
//#endif
}
@Pattern
private static BufferBuilder Tessellator_getBuffer(Tessellator tessellator) {
//#if MC>=10800
return tessellator.getBuffer();
//#else
//$$ return new BufferBuilder(tessellator);
//#endif
}
@Pattern
private static void BufferBuilder_beginPosCol(BufferBuilder buffer, int mode) {
//#if MC>=10809
buffer.begin(mode, VertexFormats.POSITION_COLOR);
//#else
//$$ buffer.startDrawing(mode /* POSITION_COLOR */);
//#endif
}
@Pattern
private static void BufferBuilder_addPosCol(BufferBuilder buffer, double x, double y, double z, int r, int g, int b, int a) {
//#if MC>=10809
buffer.vertex(x, y, z).color(r, g, b, a).next();
//#else
//$$ { WorldRenderer $buffer = buffer; double $x = x; double $y = y; double $z = z; $buffer.setColorRGBA(r, g, b, a); $buffer.addVertex($x, $y, $z); }
//#endif
}
@Pattern
private static void BufferBuilder_beginPosTex(BufferBuilder buffer, int mode) {
//#if MC>=10809
buffer.begin(mode, VertexFormats.POSITION_TEXTURE);
//#else
//$$ buffer.startDrawing(mode /* POSITION_TEXTURE */);
//#endif
}
@Pattern
private static void BufferBuilder_addPosTex(BufferBuilder buffer, double x, double y, double z, float u, float v) {
//#if MC>=10809
buffer.vertex(x, y, z).texture(u, v).next();
//#else
//$$ buffer.addVertexWithUV(x, y, z, u, v);
//#endif
}
@Pattern
private static void BufferBuilder_beginPosTexCol(BufferBuilder buffer, int mode) {
//#if MC>=10809
buffer.begin(mode, VertexFormats.POSITION_TEXTURE_COLOR);
//#else
//$$ buffer.startDrawing(mode /* POSITION_TEXTURE_COLOR */);
//#endif
}
@Pattern
private static void BufferBuilder_addPosTexCol(BufferBuilder buffer, double x, double y, double z, float u, float v, int r, int g, int b, int a) {
//#if MC>=10809
buffer.vertex(x, y, z).texture(u, v).color(r, g, b, a).next();
//#else
//$$ { WorldRenderer $buffer = buffer; double $x = x; double $y = y; double $z = z; float $u = u; float $v = v; $buffer.setColorRGBA(r, g, b, a); $buffer.addVertexWithUV($x, $y, $z, $u, $v); }
//#endif
}
@Pattern
private static Tessellator Tessellator_getInstance() {
//#if MC>=10800
return Tessellator.getInstance();
//#else
//$$ return Tessellator.instance;
//#endif
}
@Pattern
private static EntityRenderDispatcher getEntityRenderDispatcher(MinecraftClient mc) {
//#if MC>=10800
return mc.getEntityRenderDispatcher();
//#else
//$$ return com.replaymod.core.versions.MCVer.getRenderManager(mc);
//#endif
}
@Pattern
private static float getCameraYaw(EntityRenderDispatcher dispatcher) {
//#if MC>=11500
return dispatcher.camera.getYaw();
//#else
//$$ return dispatcher.cameraYaw;
//#endif
}
@Pattern
private static float getCameraPitch(EntityRenderDispatcher dispatcher) {
//#if MC>=11500
return dispatcher.camera.getPitch();
//#else
//$$ return dispatcher.cameraPitch;
//#endif
}
@Pattern
private static float getRenderPartialTicks(MinecraftClient mc) {
//#if MC>=10900
return mc.getTickDelta();
//#else
//$$ return ((com.replaymod.core.mixin.MinecraftAccessor) mc).getTimer().renderPartialTicks;
//#endif
}
@Pattern
private static TextureManager getTextureManager(MinecraftClient mc) {
//#if MC>=11400
return mc.getTextureManager();
//#else
//$$ return mc.renderEngine;
//#endif
}
@Pattern
private static String getBoundKeyName(KeyBinding keyBinding) {
//#if MC>=11600
return keyBinding.getBoundKeyLocalizedText().getString();
//#elseif MC>=11400
//$$ return keyBinding.getLocalizedName();
//#else
//$$ return org.lwjgl.input.Keyboard.getKeyName(keyBinding.getKeyCode());
//#endif
}
@Pattern
private static PositionedSoundInstance master(Identifier sound, float pitch) {
//#if MC>=10900
return PositionedSoundInstance.master(new SoundEvent(sound), pitch);
//#elseif MC>=10800
//$$ return PositionedSoundRecord.create(sound, pitch);
//#else
//$$ return PositionedSoundRecord.createPositionedSoundRecord(sound, pitch);
//#endif
}
}

View File

@@ -0,0 +1 @@
// 1.12.2 and below

View File

@@ -0,0 +1 @@
// 1.12.2 and before

View File

@@ -28,20 +28,20 @@ import static com.replaymod.core.utils.Utils.SSL_SOCKET_FACTORY;
import static com.replaymod.extras.ReplayModExtras.LOGGER; import static com.replaymod.extras.ReplayModExtras.LOGGER;
public class OpenEyeExtra implements Extra { public class OpenEyeExtra implements Extra {
private static final String DOWNLOAD_URL = "https://www.replaymod.com/dl/openeye/" + MCVer.getMinecraftVersion(); private URL url;
private ReplayMod mod; private ReplayMod mod;
@Override @Override
public void register(ReplayMod mod) throws Exception { public void register(ReplayMod mod) throws Exception {
this.mod = mod; this.mod = mod;
this.url = new URL("https://www.replaymod.com/dl/openeye/" + mod.getMinecraftVersion());
boolean isOpenEyeLoaded = MCVer.isModLoaded("OpenEye"); boolean isOpenEyeLoaded = mod.isModLoaded("OpenEye");
if (!isOpenEyeLoaded && mod.getSettingsRegistry().get(Setting.ASK_FOR_OPEN_EYE)) { if (!isOpenEyeLoaded && mod.getSettingsRegistry().get(Setting.ASK_FOR_OPEN_EYE)) {
new Thread(() -> { new Thread(() -> {
try { try {
LOGGER.trace("Checking for OpenEye availability"); LOGGER.trace("Checking for OpenEye availability");
HttpsURLConnection connection = (HttpsURLConnection) new URL(DOWNLOAD_URL).openConnection(); HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setSSLSocketFactory(SSL_SOCKET_FACTORY); connection.setSSLSocketFactory(SSL_SOCKET_FACTORY);
connection.setRequestMethod("HEAD"); connection.setRequestMethod("HEAD");
connection.connect(); connection.connect();
@@ -86,10 +86,10 @@ public class OpenEyeExtra implements Extra {
GuiPopup popup = new GuiPopup(OfferGui.this); GuiPopup popup = new GuiPopup(OfferGui.this);
new Thread(() -> { new Thread(() -> {
try { try {
File targetFile = new File(mod.getMinecraft().runDirectory, "mods/" + MCVer.getMinecraftVersion() + "/OpenEye.jar"); File targetFile = new File(mod.getMinecraft().runDirectory, "mods/" + mod.getMinecraftVersion() + "/OpenEye.jar");
FileUtils.forceMkdir(targetFile.getParentFile()); FileUtils.forceMkdir(targetFile.getParentFile());
HttpsURLConnection connection = (HttpsURLConnection) new URL(DOWNLOAD_URL).openConnection(); HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setSSLSocketFactory(SSL_SOCKET_FACTORY); connection.setSSLSocketFactory(SSL_SOCKET_FACTORY);
ReadableByteChannel in = Channels.newChannel(connection.getInputStream()); ReadableByteChannel in = Channels.newChannel(connection.getInputStream());
FileChannel out = new FileOutputStream(targetFile).getChannel(); FileChannel out = new FileOutputStream(targetFile).getChannel();

View File

@@ -9,10 +9,9 @@ import com.replaymod.render.rendering.Pipelines;
import de.johni0702.minecraft.gui.utils.lwjgl.Dimension; import de.johni0702.minecraft.gui.utils.lwjgl.Dimension;
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension; import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.Window;
import net.minecraft.util.crash.CrashReport; import net.minecraft.util.crash.CrashReport;
import static com.replaymod.core.versions.MCVer.getMainWindowSize;
import static com.replaymod.core.versions.MCVer.getRenderPartialTicks;
import static com.replaymod.core.versions.MCVer.resizeMainWindow; import static com.replaymod.core.versions.MCVer.resizeMainWindow;
public class ScreenshotRenderer implements RenderInfo { public class ScreenshotRenderer implements RenderInfo {
@@ -29,7 +28,9 @@ public class ScreenshotRenderer implements RenderInfo {
public boolean renderScreenshot() throws Throwable { public boolean renderScreenshot() throws Throwable {
try { try {
Dimension sizeBefore = getMainWindowSize(mc); Window window = mc.getWindow();
int widthBefore = window.getFramebufferWidth();
int heightBefore = window.getFramebufferHeight();
boolean hideGUIBefore = mc.options.hudHidden; boolean hideGUIBefore = mc.options.hudHidden;
mc.options.hudHidden = true; mc.options.hudHidden = true;
@@ -46,7 +47,7 @@ public class ScreenshotRenderer implements RenderInfo {
clrg.uninstall(); clrg.uninstall();
mc.options.hudHidden = hideGUIBefore; mc.options.hudHidden = hideGUIBefore;
resizeMainWindow(mc, sizeBefore.getWidth(), sizeBefore.getHeight()); resizeMainWindow(mc, widthBefore, heightBefore);
return true; return true;
} catch (OutOfMemoryError e) { } catch (OutOfMemoryError e) {
e.printStackTrace(); e.printStackTrace();
@@ -75,7 +76,7 @@ public class ScreenshotRenderer implements RenderInfo {
@Override @Override
public float updateForNextFrame() { public float updateForNextFrame() {
framesDone++; framesDone++;
return getRenderPartialTicks(); return mc.getTickDelta();
} }
@Override @Override

View File

@@ -117,7 +117,7 @@ public class PlayerOverview extends EventRegistrations implements Extra {
{ on(PreRenderHandCallback.EVENT, this::shouldHideHand); } { on(PreRenderHandCallback.EVENT, this::shouldHideHand); }
private boolean shouldHideHand() { private boolean shouldHideHand() {
Entity view = getRenderViewEntity(module.getCore().getMinecraft()); Entity view = module.getCore().getMinecraft().getCameraEntity();
return view != null && isHidden(view.getUuid()); return view != null && isHidden(view.getUuid());
} }

View File

@@ -0,0 +1,11 @@
package com.replaymod.gradle.remap;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.METHOD)
public @interface Pattern {
}

View File

@@ -13,7 +13,6 @@ 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.replaymod.core.versions.MCVer.*;
import static com.mojang.blaze3d.platform.GlStateManager.*; import static com.mojang.blaze3d.platform.GlStateManager.*;
/** /**
@@ -44,7 +43,7 @@ public class GuiRecordingOverlay extends EventRegistrations {
stack, stack,
//#endif //#endif
text.toUpperCase(), 30, 18 - (fontRenderer.fontHeight / 2), 0xffffffff); text.toUpperCase(), 30, 18 - (fontRenderer.fontHeight / 2), 0xffffffff);
bindTexture(TEXTURE); mc.getTextureManager().bindTexture(TEXTURE);
enableAlphaTest(); enableAlphaTest();
GuiRenderer renderer = new MinecraftGuiRenderer(stack); GuiRenderer renderer = new MinecraftGuiRenderer(stack);
renderer.drawTexturedRect(10, 10, 58, 20, 16, 16, 16, 16, TEXTURE_SIZE, TEXTURE_SIZE); renderer.drawTexturedRect(10, 10, 58, 20, 16, 16, 16, 16, TEXTURE_SIZE, TEXTURE_SIZE);

View File

@@ -138,7 +138,7 @@ public class ConnectionEventHandler {
metaData.setCustomServerName(serverName); metaData.setCustomServerName(serverName);
metaData.setGenerator("ReplayMod v" + ReplayMod.instance.getVersion()); metaData.setGenerator("ReplayMod v" + ReplayMod.instance.getVersion());
metaData.setDate(System.currentTimeMillis()); metaData.setDate(System.currentTimeMillis());
metaData.setMcVersion(MCVer.getMinecraftVersion()); metaData.setMcVersion(ReplayMod.instance.getMinecraftVersion());
packetListener = new PacketListener(core, outputPath, replayFile, metaData); packetListener = new PacketListener(core, outputPath, replayFile, metaData);
Channel channel = ((NetworkManagerAccessor) networkManager).getChannel(); Channel channel = ((NetworkManagerAccessor) networkManager).getChannel();
channel.pipeline().addBefore(packetHandlerKey, "replay_recorder", packetListener); channel.pipeline().addBefore(packetHandlerKey, "replay_recorder", packetListener);

View File

@@ -7,6 +7,7 @@ import de.johni0702.minecraft.gui.utils.EventRegistrations;
import de.johni0702.minecraft.gui.versions.callbacks.PreTickCallback; import de.johni0702.minecraft.gui.versions.callbacks.PreTickCallback;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.Entity;
import net.minecraft.network.packet.s2c.play.BlockBreakingProgressS2CPacket; import net.minecraft.network.packet.s2c.play.BlockBreakingProgressS2CPacket;
import net.minecraft.network.packet.s2c.play.EntityAnimationS2CPacket; import net.minecraft.network.packet.s2c.play.EntityAnimationS2CPacket;
import net.minecraft.network.packet.s2c.play.EntityAttachS2CPacket; import net.minecraft.network.packet.s2c.play.EntityAttachS2CPacket;
@@ -146,9 +147,9 @@ public class RecordingEventHandler extends EventRegistrations {
boolean force = false; boolean force = false;
if(lastX == null || lastY == null || lastZ == null) { if(lastX == null || lastY == null || lastZ == null) {
force = true; force = true;
lastX = Entity_getX(player); lastX = player.getX();
lastY = Entity_getY(player); lastY = player.getY();
lastZ = Entity_getZ(player); lastZ = player.getZ();
} }
ticksSinceLastCorrection++; ticksSinceLastCorrection++;
@@ -157,13 +158,13 @@ public class RecordingEventHandler extends EventRegistrations {
force = true; force = true;
} }
double dx = Entity_getX(player) - lastX; double dx = player.getX() - lastX;
double dy = Entity_getY(player) - lastY; double dy = player.getY() - lastY;
double dz = Entity_getZ(player) - lastZ; double dz = player.getZ() - lastZ;
lastX = Entity_getX(player); lastX = player.getX();
lastY = Entity_getY(player); lastY = player.getY();
lastZ = Entity_getZ(player); lastZ = player.getZ();
Packet packet; Packet packet;
if (force || Math.abs(dx) > 8.0 || Math.abs(dy) > 8.0 || Math.abs(dz) > 8.0) { if (force || Math.abs(dx) > 8.0 || Math.abs(dy) > 8.0 || Math.abs(dz) > 8.0) {
@@ -309,18 +310,16 @@ public class RecordingEventHandler extends EventRegistrations {
//Leaving Ride //Leaving Ride
if((!player.isRiding() && lastRiding != -1) || Entity vehicle = player.getVehicle();
(player.isRiding() && lastRiding != getRiddenEntity(player).getEntityId())) { int vehicleId = vehicle == null ? -1 : vehicle.getEntityId();
if(!player.isRiding()) { if (lastRiding != vehicleId) {
lastRiding = -1; lastRiding = vehicleId;
} else {
lastRiding = getRiddenEntity(player).getEntityId();
}
packetListener.save(new EntityAttachS2CPacket( packetListener.save(new EntityAttachS2CPacket(
//#if MC<10904 //#if MC<10904
//$$ 0, //$$ 0,
//#endif //#endif
player, getRiddenEntity(player) player,
vehicle
)); ));
} }

View File

@@ -57,7 +57,7 @@ public abstract class MixinNetHandlerPlayClient {
//$$ @Inject(method = "handlePlayerListItem", at=@At("HEAD")) //$$ @Inject(method = "handlePlayerListItem", at=@At("HEAD"))
//#endif //#endif
public void recordOwnJoin(PlayerListS2CPacket packet, CallbackInfo ci) { public void recordOwnJoin(PlayerListS2CPacket packet, CallbackInfo ci) {
if (!MCVer.isOnMainThread()) return; if (!mcStatic.isOnThread()) return;
if (mcStatic.player == null) return; if (mcStatic.player == null) return;
RecordingEventHandler handler = getRecordingEventHandler(); RecordingEventHandler handler = getRecordingEventHandler();

View File

@@ -163,8 +163,8 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
// to happen on the main thread so we can guarantee correct ordering of inbound and inject packets. // to happen on the main thread so we can guarantee correct ordering of inbound and inject packets.
// Otherwise, injected packets may end up further down the packet stream than they were supposed to and other // Otherwise, injected packets may end up further down the packet stream than they were supposed to and other
// inbound packets which may rely on the injected packet would behave incorrectly when played back. // inbound packets which may rely on the injected packet would behave incorrectly when played back.
if (!MCVer.isOnMainThread()) { if (!mc.isOnThread()) {
MCVer.scheduleOnMainThread(() -> save(packet)); mc.send(() -> save(packet));
return; return;
} }
try { try {
@@ -488,15 +488,15 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
} }
public void addMarker(String name, int timestamp) { public void addMarker(String name, int timestamp) {
Entity view = getRenderViewEntity(mc); Entity view = mc.getCameraEntity();
Marker marker = new Marker(); Marker marker = new Marker();
marker.setName(name); marker.setName(name);
marker.setTime(timestamp); marker.setTime(timestamp);
if (view != null) { if (view != null) {
marker.setX(Entity_getX(view)); marker.setX(view.getX());
marker.setY(Entity_getY(view)); marker.setY(view.getY());
marker.setZ(Entity_getZ(view)); marker.setZ(view.getZ());
marker.setYaw(view.yaw); marker.setYaw(view.yaw);
marker.setPitch(view.pitch); marker.setPitch(view.pitch);
} }

View File

@@ -126,8 +126,8 @@ public class FFmpegWriter implements FrameConsumer<BitmapFrame> {
} }
CrashReport report = CrashReport.create(t, "Exporting frame"); CrashReport report = CrashReport.create(t, "Exporting frame");
CrashReportSection exportDetails = report.addElement("Export details"); CrashReportSection exportDetails = report.addElement("Export details");
MCVer.addDetail(exportDetails, "Export command", settings::getExportCommand); exportDetails.add("Export command", settings::getExportCommand);
MCVer.addDetail(exportDetails, "Export args", commandArgs::toString); exportDetails.add("Export args", commandArgs::toString);
MCVer.getMinecraft().setCrashReport(report); MCVer.getMinecraft().setCrashReport(report);
} finally { } finally {
channels.values().forEach(it -> ByteBufferPool.release(it.getByteBuffer())); channels.values().forEach(it -> ByteBufferPool.release(it.getByteBuffer()));

View File

@@ -1,6 +1,5 @@
package com.replaymod.render.blend; package com.replaymod.render.blend;
import com.replaymod.core.versions.MCVer;
import com.replaymod.render.capturer.RenderInfo; import com.replaymod.render.capturer.RenderInfo;
import com.replaymod.render.capturer.WorldRenderer; import com.replaymod.render.capturer.WorldRenderer;
import com.replaymod.render.frame.BitmapFrame; import com.replaymod.render.frame.BitmapFrame;
@@ -8,6 +7,7 @@ import com.replaymod.render.rendering.Channel;
import com.replaymod.render.rendering.FrameCapturer; import com.replaymod.render.rendering.FrameCapturer;
import com.replaymod.render.utils.ByteBufferPool; import com.replaymod.render.utils.ByteBufferPool;
import de.johni0702.minecraft.gui.utils.lwjgl.Dimension; import de.johni0702.minecraft.gui.utils.lwjgl.Dimension;
import net.minecraft.client.MinecraftClient;
import java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.util.Collections;
@@ -37,7 +37,7 @@ public class BlendFrameCapturer implements FrameCapturer<BitmapFrame> {
renderInfo.updateForNextFrame(); renderInfo.updateForNextFrame();
BlendState.getState().preFrame(framesDone); BlendState.getState().preFrame(framesDone);
worldRenderer.renderWorld(MCVer.getRenderPartialTicks(), null); worldRenderer.renderWorld(MinecraftClient.getInstance().getTickDelta(), null);
BlendState.getState().postFrame(framesDone); BlendState.getState().postFrame(framesDone);
BitmapFrame frame = new BitmapFrame(framesDone++, new Dimension(0, 0), 0, ByteBufferPool.allocate(0)); BitmapFrame frame = new BitmapFrame(framesDone++, new Dimension(0, 0), 0, ByteBufferPool.allocate(0));

View File

@@ -9,6 +9,7 @@ import de.johni0702.minecraft.gui.utils.lwjgl.vector.Vector3f;
import net.minecraft.client.render.Tessellator; import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat; import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormatElement; import net.minecraft.client.render.VertexFormatElement;
import net.minecraft.client.render.VertexFormats;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
//#if MC>=11500 //#if MC>=11500
@@ -82,7 +83,7 @@ public class BlendMeshBuilder
if (!wellBehaved) { if (!wellBehaved) {
// In case the calling code finishes with Tessellator.getInstance().draw() // In case the calling code finishes with Tessellator.getInstance().draw()
BufferBuilder_beginPosTexCol(mode); Tessellator.getInstance().getBuffer().begin(mode, VertexFormats.POSITION_TEXTURE_COLOR);
} }
//#if MC>=10809 //#if MC>=10809

View File

@@ -88,7 +88,7 @@ public class BlendState implements Exporter {
} catch (IOException e) { } catch (IOException e) {
CrashReport report = CrashReport.create(e, "Setup of blend exporter"); CrashReport report = CrashReport.create(e, "Setup of blend exporter");
CrashReportSection category = report.addElement("Exporter"); CrashReportSection category = report.addElement("Exporter");
addDetail(category, "Exporter", exporter::toString); category.add("Exporter", exporter::toString);
throw new CrashException(report); throw new CrashException(report);
} }
} }
@@ -102,7 +102,7 @@ public class BlendState implements Exporter {
} catch (IOException e) { } catch (IOException e) {
CrashReport report = CrashReport.create(e, "Tear down of blend exporter"); CrashReport report = CrashReport.create(e, "Tear down of blend exporter");
CrashReportSection category = report.addElement("Exporter"); CrashReportSection category = report.addElement("Exporter");
addDetail(category, "Exporter", exporter::toString); category.add("Exporter", exporter::toString);
throw new CrashException(report); throw new CrashException(report);
} }
} }
@@ -139,8 +139,8 @@ public class BlendState implements Exporter {
} catch (IOException e) { } catch (IOException e) {
CrashReport report = CrashReport.create(e, "Pre frame of blend exporter"); CrashReport report = CrashReport.create(e, "Pre frame of blend exporter");
CrashReportSection category = report.addElement("Exporter"); CrashReportSection category = report.addElement("Exporter");
addDetail(category, "Exporter", exporter::toString); category.add("Exporter", exporter::toString);
addDetail(category, "Frame", () -> String.valueOf(frame)); category.add("Frame", () -> String.valueOf(frame));
throw new CrashException(report); throw new CrashException(report);
} }
} }
@@ -154,8 +154,8 @@ public class BlendState implements Exporter {
} catch (IOException e) { } catch (IOException e) {
CrashReport report = CrashReport.create(e, "Post frame of blend exporter"); CrashReport report = CrashReport.create(e, "Post frame of blend exporter");
CrashReportSection category = report.addElement("Exporter"); CrashReportSection category = report.addElement("Exporter");
addDetail(category, "Exporter", exporter::toString); category.add("Exporter", exporter::toString);
addDetail(category, "Frame", () -> String.valueOf(frame)); category.add("Frame", () -> String.valueOf(frame));
throw new CrashException(report); throw new CrashException(report);
} }
} }

View File

@@ -21,7 +21,6 @@ import net.minecraft.client.model.ModelPart;
import java.io.IOException; import java.io.IOException;
import static com.replaymod.core.versions.MCVer.*;
import static com.replaymod.render.blend.Util.isGlTextureMatrixIdentity; import static com.replaymod.render.blend.Util.isGlTextureMatrixIdentity;
public class ModelRendererExporter implements Exporter { public class ModelRendererExporter implements Exporter {
@@ -86,11 +85,13 @@ public class ModelRendererExporter implements Exporter {
DMesh mesh = new DMesh(); DMesh mesh = new DMesh();
BlendMeshBuilder builder = new BlendMeshBuilder(mesh); BlendMeshBuilder builder = new BlendMeshBuilder(mesh);
//#if MC>=11500 //#if MC>=11500
for (Cuboid box : cubeList(model)) {
// FIXME 1.15 // FIXME 1.15
} //#elseif MC>=10809
//$$ for (Box box : model.boxes) {
//$$ box.render(builder, scale);
//$$ }
//#else //#else
//$$ for (Box box : cubeList(model)) { //$$ for (ModelBox box : (java.util.List<ModelBox>) model.cubeList) {
//$$ box.render(builder, scale); //$$ box.render(builder, scale);
//$$ } //$$ }
//#endif //#endif

View File

@@ -19,7 +19,6 @@ import net.minecraft.util.crash.CrashException;
import java.util.Arrays; import java.util.Arrays;
import java.util.function.Consumer; import java.util.function.Consumer;
import static com.replaymod.core.versions.MCVer.addDetail;
import static com.replaymod.render.ReplayModRender.LOGGER; import static com.replaymod.render.ReplayModRender.LOGGER;
public class GuiExportFailed extends GuiScreen { public class GuiExportFailed extends GuiScreen {
@@ -33,8 +32,8 @@ public class GuiExportFailed extends GuiScreen {
// If they haven't, then this is probably a faulty ffmpeg installation and there's nothing we can do // If they haven't, then this is probably a faulty ffmpeg installation and there's nothing we can do
CrashReport crashReport = CrashReport.create(e, "Exporting video"); CrashReport crashReport = CrashReport.create(e, "Exporting video");
CrashReportSection details = crashReport.addElement("Export details"); CrashReportSection details = crashReport.addElement("Export details");
addDetail(details, "Settings", settings::toString); details.add("Settings", settings::toString);
addDetail(details, "FFmpeg log", e::getLog); details.add("FFmpeg log", e::getLog);
throw new CrashException(crashReport); throw new CrashException(crashReport);
} else { } else {
// If they have, ask them whether it was intentional // If they have, ask them whether it was intentional

View File

@@ -59,7 +59,7 @@ public abstract class MixinCamera {
) { ) {
if (getHandler() != null) { if (getHandler() != null) {
//#if MC<11400 //#if MC<11400
//$$ Entity entity = getRenderViewEntity(getMinecraft()); //$$ Entity entity = getMinecraft().getRenderViewEntity();
//#endif //#endif
orgYaw = entity.yaw; orgYaw = entity.yaw;
orgPitch = entity.pitch; orgPitch = entity.pitch;
@@ -79,7 +79,7 @@ public abstract class MixinCamera {
//#endif //#endif
if (getHandler() != null) { if (getHandler() != null) {
//#if MC<11400 //#if MC<11400
//$$ Entity entity = getRenderViewEntity(getMinecraft()); //$$ Entity entity = getMinecraft().getRenderViewEntity();
//#endif //#endif
RenderSettings settings = getHandler().getSettings(); RenderSettings settings = getHandler().getSettings();
if (settings.isStabilizeYaw()) { if (settings.isStabilizeYaw()) {
@@ -117,7 +117,7 @@ public abstract class MixinCamera {
) { ) {
if (getHandler() != null) { if (getHandler() != null) {
//#if MC<11400 //#if MC<11400
//$$ Entity entity = getRenderViewEntity(getMinecraft()); //$$ Entity entity = getMinecraft().getRenderViewEntity();
//#endif //#endif
entity.yaw = orgYaw; entity.yaw = orgYaw;
entity.pitch = orgPitch; entity.pitch = orgPitch;

View File

@@ -117,7 +117,7 @@ public abstract class MixinEntityRenderer implements EntityRendererHandler.IEnti
} }
//#else //#else
//$$ } else { //$$ } else {
//$$ Entity currentEntity = getRenderViewEntity(MCVer.getMinecraft()); //$$ Entity currentEntity = this.mc.getRenderViewEntity();
//$$ if (currentEntity instanceof EntityPlayer && !(currentEntity instanceof CameraEntity)) { //$$ if (currentEntity instanceof EntityPlayer && !(currentEntity instanceof CameraEntity)) {
//$$ if (renderPass == 2) { // Need to update render pass //$$ if (renderPass == 2) { // Need to update render pass
//$$ renderPass = replayModRender_handler.data == StereoscopicOpenGlFrameCapturer.Data.LEFT_EYE ? 1 : 0; //$$ renderPass = replayModRender_handler.data == StereoscopicOpenGlFrameCapturer.Data.LEFT_EYE ? 1 : 0;

View File

@@ -6,14 +6,9 @@ import com.replaymod.render.capturer.WorldRenderer;
import com.replaymod.render.frame.BitmapFrame; import com.replaymod.render.frame.BitmapFrame;
import com.replaymod.render.processor.GlToAbsoluteDepthProcessor; import com.replaymod.render.processor.GlToAbsoluteDepthProcessor;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.util.crash.CrashReport;
import net.minecraft.util.crash.CrashException; import net.minecraft.util.crash.CrashException;
import net.minecraft.util.crash.CrashReport;
//#if MC>=11400
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
//#else
//$$ import org.lwjgl.opengl.Display;
//#endif
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -23,9 +18,6 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static com.replaymod.core.versions.MCVer.getMinecraft; import static com.replaymod.core.versions.MCVer.getMinecraft;
//#if MC>=11400
import static com.replaymod.core.versions.MCVer.getWindow;
//#endif
public class Pipeline<R extends Frame, P extends Frame> implements Runnable { public class Pipeline<R extends Frame, P extends Frame> implements Runnable {
@@ -72,11 +64,7 @@ public class Pipeline<R extends Frame, P extends Frame> implements Runnable {
MinecraftClient mc = MCVer.getMinecraft(); MinecraftClient mc = MCVer.getMinecraft();
while (!capturer.isDone() && !abort) { while (!capturer.isDone() && !abort) {
//#if MC>=11400 if (GLFW.glfwWindowShouldClose(mc.getWindow().getHandle()) || ((MinecraftAccessor) mc).getCrashReporter() != null) {
if (GLFW.glfwWindowShouldClose(getWindow(mc).getHandle()) || ((MinecraftAccessor) mc).getCrashReporter() != null) {
//#else
//$$ if (Display.isCloseRequested() || ((MinecraftAccessor) mc).getCrashReporter() != null) {
//#endif
processService.shutdown(); processService.shutdown();
return; return;
} }

View File

@@ -30,10 +30,14 @@ import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import com.mojang.blaze3d.platform.GLX; import com.mojang.blaze3d.platform.GLX;
import net.minecraft.client.gl.Framebuffer; import net.minecraft.client.gl.Framebuffer;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.client.util.Window;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.crash.CrashException; import net.minecraft.util.crash.CrashException;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.client.render.RenderTickCounter; import net.minecraft.client.render.RenderTickCounter;
import org.lwjgl.glfw.GLFW;
//#if MC>=11600 //#if MC>=11600
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
@@ -41,20 +45,16 @@ import net.minecraft.client.util.math.MatrixStack;
//#if MC>=11500 //#if MC>=11500
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.util.Window;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
//#endif //#endif
//#if MC>=11400 //#if MC>=11400
import com.replaymod.render.EXRWriter; import com.replaymod.render.EXRWriter;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import org.lwjgl.glfw.GLFW;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
//#else //#else
//$$ import net.minecraft.client.gui.ScaledResolution;
//$$ import org.lwjgl.input.Mouse; //$$ import org.lwjgl.input.Mouse;
//$$ import org.lwjgl.opengl.Display; //$$ import org.lwjgl.opengl.Display;
//$$ import static com.replaymod.core.versions.MCVer.newScaledResolution;
//#endif //#endif
//#if MC>=10800 //#if MC>=10800
@@ -80,6 +80,7 @@ import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT; import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
public class VideoRenderer implements RenderInfo { public class VideoRenderer implements RenderInfo {
private static final Identifier SOUND_RENDER_SUCCESS = new Identifier("replaymod", "render_success");
private final MinecraftClient mc = MCVer.getMinecraft(); private final MinecraftClient mc = MCVer.getMinecraft();
private final RenderSettings settings; private final RenderSettings settings;
private final ReplayHandler replayHandler; private final ReplayHandler replayHandler;
@@ -232,7 +233,7 @@ public class VideoRenderer implements RenderInfo {
@Override @Override
public float updateForNextFrame() { public float updateForNextFrame() {
// because the jGui lib uses Minecraft's displayWidth and displayHeight values, update these temporarily // because the jGui lib uses Minecraft's displayWidth and displayHeight values, update these temporarily
MainWindowAccessor acc = (MainWindowAccessor) (Object) getWindow(mc); MainWindowAccessor acc = (MainWindowAccessor) (Object) mc.getWindow();
int displayWidthBefore = acc.getFramebufferWidth(); int displayWidthBefore = acc.getFramebufferWidth();
int displayHeightBefore = acc.getFramebufferHeight(); int displayHeightBefore = acc.getFramebufferHeight();
acc.setFramebufferWidth(displayWidth); acc.setFramebufferWidth(displayWidth);
@@ -351,10 +352,7 @@ public class VideoRenderer implements RenderInfo {
updateDisplaySize(); updateDisplaySize();
//#if MC<=10809 gui.toMinecraft().init(mc, mc.getWindow().getScaledWidth(), mc.getWindow().getScaledHeight());
//$$ ScaledResolution scaled = newScaledResolution(mc);
//$$ gui.toMinecraft().setWorldAndResolution(mc, scaled.getScaledWidth(), scaled.getScaledHeight());
//#endif
forceChunkLoadingHook = new ForceChunkLoadingHook(mc.worldRenderer); forceChunkLoadingHook = new ForceChunkLoadingHook(mc.worldRenderer);
@@ -401,7 +399,7 @@ public class VideoRenderer implements RenderInfo {
} }
} }
MCVer.playSound(new Identifier("replaymod", "render_success")); mc.getSoundManager().play(PositionedSoundInstance.master(new SoundEvent(SOUND_RENDER_SUCCESS), 1));
try { try {
if (!hasFailed() && ffmpegWriter != null) { if (!hasFailed() && ffmpegWriter != null) {
@@ -464,12 +462,9 @@ public class VideoRenderer implements RenderInfo {
} }
public boolean drawGui() { public boolean drawGui() {
Window window = mc.getWindow();
do { do {
//#if MC>=11400 if (GLFW.glfwWindowShouldClose(window.getHandle()) || ((MinecraftAccessor) mc).getCrashReporter() != null) {
if (GLFW.glfwWindowShouldClose(getWindow(mc).getHandle()) || ((MinecraftAccessor) mc).getCrashReporter() != null) {
//#else
//$$ if (Display.isCloseRequested() || ((MinecraftAccessor) mc).getCrashReporter() != null) {
//#endif
return false; return false;
} }
@@ -497,7 +492,6 @@ public class VideoRenderer implements RenderInfo {
guiFramebuffer.beginWrite(true); guiFramebuffer.beginWrite(true);
//#if MC>=11500 //#if MC>=11500
Window window = getWindow(mc);
RenderSystem.clear(256, MinecraftClient.IS_SYSTEM_MAC); RenderSystem.clear(256, MinecraftClient.IS_SYSTEM_MAC);
RenderSystem.matrixMode(GL11.GL_PROJECTION); RenderSystem.matrixMode(GL11.GL_PROJECTION);
RenderSystem.loadIdentity(); RenderSystem.loadIdentity();
@@ -507,7 +501,7 @@ public class VideoRenderer implements RenderInfo {
RenderSystem.translatef(0, 0, -2000); RenderSystem.translatef(0, 0, -2000);
//#else //#else
//#if MC>=11400 //#if MC>=11400
//$$ getWindow(mc).method_4493( //$$ window.method_4493(
//#if MC>=11400 //#if MC>=11400
//$$ false //$$ false
//#endif //#endif
@@ -517,12 +511,7 @@ public class VideoRenderer implements RenderInfo {
//#endif //#endif
//#endif //#endif
//#if MC>=11400 gui.toMinecraft().init(mc, window.getScaledWidth(), window.getScaledHeight());
gui.toMinecraft().init(mc, getWindow(mc).getScaledWidth(), getWindow(mc).getScaledHeight());
//#else
//$$ ScaledResolution scaled = newScaledResolution(mc);
//$$ gui.toMinecraft().setWorldAndResolution(mc, scaled.getScaledWidth(), scaled.getScaledHeight());
//#endif
// Events are polled on 1.13+ in mainWindow.update which is called later // Events are polled on 1.13+ in mainWindow.update which is called later
//#if MC<11400 //#if MC<11400
@@ -540,8 +529,8 @@ public class VideoRenderer implements RenderInfo {
//#endif //#endif
//#if MC>=11400 //#if MC>=11400
int mouseX = (int) mc.mouse.getX() * getWindow(mc).getScaledWidth() / displayWidth; int mouseX = (int) mc.mouse.getX() * window.getScaledWidth() / displayWidth;
int mouseY = (int) mc.mouse.getY() * getWindow(mc).getScaledHeight() / displayHeight; int mouseY = (int) mc.mouse.getY() * window.getScaledHeight() / displayHeight;
if (mc.overlay != null) { if (mc.overlay != null) {
Screen orgScreen = mc.currentScreen; Screen orgScreen = mc.currentScreen;
@@ -564,8 +553,8 @@ public class VideoRenderer implements RenderInfo {
mouseX, mouseY, 0); mouseX, mouseY, 0);
} }
//#else //#else
//$$ int mouseX = Mouse.getX() * scaled.getScaledWidth() / mc.displayWidth; //$$ int mouseX = Mouse.getX() * window.getScaledWidth() / mc.displayWidth;
//$$ int mouseY = scaled.getScaledHeight() - Mouse.getY() * scaled.getScaledHeight() / mc.displayHeight - 1; //$$ int mouseY = window.getScaledHeight() - Mouse.getY() * window.getScaledHeight() / mc.displayHeight - 1;
//$$ //$$
//$$ gui.toMinecraft().updateScreen(); //$$ gui.toMinecraft().updateScreen();
//$$ gui.toMinecraft().drawScreen(mouseX, mouseY, 0); //$$ gui.toMinecraft().drawScreen(mouseX, mouseY, 0);
@@ -578,10 +567,10 @@ public class VideoRenderer implements RenderInfo {
popMatrix(); popMatrix();
//#if MC>=11500 //#if MC>=11500
getWindow(mc).swapBuffers(); window.swapBuffers();
//#else //#else
//#if MC>=11400 //#if MC>=11400
//$$ getWindow(mc).setFullscreen(false); //$$ window.setFullscreen(false);
//#else //#else
//$$ // if not in high performance mode, update the gui size if screen size changed //$$ // if not in high performance mode, update the gui size if screen size changed
//$$ // otherwise just swap the progress gui to screen //$$ // otherwise just swap the progress gui to screen
@@ -611,13 +600,8 @@ public class VideoRenderer implements RenderInfo {
} }
private boolean displaySizeChanged() { private boolean displaySizeChanged() {
//#if MC>=11400 int realWidth = mc.getWindow().getWidth();
int realWidth = getWindow(mc).getWidth(); int realHeight = mc.getWindow().getHeight();
int realHeight = getWindow(mc).getHeight();
//#else
//$$ int realWidth = Display.getWidth();
//$$ int realHeight = Display.getHeight();
//#endif
if (realWidth == 0 || realHeight == 0) { if (realWidth == 0 || realHeight == 0) {
// These can be zero on Windows if minimized. // These can be zero on Windows if minimized.
// Creating zero-sized framebuffers however will throw an error, so we never want to switch to zero values. // Creating zero-sized framebuffers however will throw an error, so we never want to switch to zero values.
@@ -627,13 +611,8 @@ public class VideoRenderer implements RenderInfo {
} }
private void updateDisplaySize() { private void updateDisplaySize() {
//#if MC>=11400 displayWidth = mc.getWindow().getWidth();
displayWidth = getWindow(mc).getWidth(); displayHeight = mc.getWindow().getHeight();
displayHeight = getWindow(mc).getHeight();
//#else
//$$ displayWidth = Display.getWidth();
//$$ displayHeight = Display.getHeight();
//#endif
} }
public int getFramesDone() { public int getFramesDone() {

View File

@@ -367,7 +367,7 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
// To counteract this, we need to manually update it's position if it hasn't been added // To counteract this, we need to manually update it's position if it hasn't been added
// to any chunk yet. // to any chunk yet.
if (mc.world != null) { if (mc.world != null) {
for (PlayerEntity playerEntity : playerEntities(mc.world)) { for (PlayerEntity playerEntity : mc.world.getPlayers()) {
if (!playerEntity.updateNeeded && playerEntity instanceof OtherClientPlayerEntity) { if (!playerEntity.updateNeeded && playerEntity instanceof OtherClientPlayerEntity) {
playerEntity.tickMovement(); playerEntity.tickMovement();
} }
@@ -417,7 +417,7 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
// Note: Not sure if it's still required but there's this really handy method anyway // Note: Not sure if it's still required but there's this really handy method anyway
world.finishRemovingEntities(); world.finishRemovingEntities();
//#else //#else
//$$ Iterator<Entity> iter = loadedEntityList(world).iterator(); //$$ Iterator<Entity> iter = world.loadedEntityList.iterator();
//$$ while (iter.hasNext()) { //$$ while (iter.hasNext()) {
//$$ Entity entity = iter.next(); //$$ Entity entity = iter.next();
//$$ if (entity.isDead) { //$$ if (entity.isDead) {
@@ -455,10 +455,10 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
} }
} }
}; };
if (MCVer.isOnMainThread()) { if (mc.isOnThread()) {
doLightUpdates.run(); doLightUpdates.run();
} else { } else {
MCVer.scheduleOnMainThread(doLightUpdates); mc.send(doLightUpdates);
} }
} }
//#endif //#endif
@@ -742,8 +742,8 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
//#endif //#endif
if(cent != null) { if(cent != null) {
if(!allowMovement && !((Math.abs(Entity_getX(cent) - ppl.getX()) > TP_DISTANCE_LIMIT) || if(!allowMovement && !((Math.abs(cent.getX() - ppl.getX()) > TP_DISTANCE_LIMIT) ||
(Math.abs(Entity_getZ(cent) - ppl.getZ()) > TP_DISTANCE_LIMIT))) { (Math.abs(cent.getZ() - ppl.getZ()) > TP_DISTANCE_LIMIT))) {
return null; return null;
} else { } else {
allowMovement = false; allowMovement = false;
@@ -754,7 +754,7 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void run() { public void run() {
if (mc.world == null || !isOnMainThread()) { if (mc.world == null || !mc.isOnThread()) {
ReplayMod.instance.runLater(this); ReplayMod.instance.runLater(this);
return; return;
} }
@@ -1171,7 +1171,7 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
//#endif //#endif
List<Entity> entitiesInChunk = new ArrayList<>(); List<Entity> entitiesInChunk = new ArrayList<>();
// Gather all entities in that chunk // Gather all entities in that chunk
for (Collection<Entity> entityList : getEntityLists(chunk)) { for (Collection<Entity> entityList : chunk.getEntitySectionArray()) {
entitiesInChunk.addAll(entityList); entitiesInChunk.addAll(entityList);
} }
for (Entity entity : entitiesInChunk) { for (Entity entity : entitiesInChunk) {
@@ -1189,9 +1189,9 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
// Check whether the entity has left the chunk // Check whether the entity has left the chunk
//#if MC>=11404 //#if MC>=11404
int chunkX = MathHelper.floor(Entity_getX(entity) / 16); int chunkX = MathHelper.floor(entity.getX() / 16);
int chunkY = MathHelper.floor(Entity_getY(entity) / 16); int chunkY = MathHelper.floor(entity.getY() / 16);
int chunkZ = MathHelper.floor(Entity_getZ(entity) / 16); int chunkZ = MathHelper.floor(entity.getZ() / 16);
if (entity.chunkX != chunkX || entity.chunkY != chunkY || entity.chunkZ != chunkZ) { if (entity.chunkX != chunkX || entity.chunkY != chunkY || entity.chunkZ != chunkZ) {
if (entity.updateNeeded) { if (entity.updateNeeded) {
// Entity has left the chunk // Entity has left the chunk

View File

@@ -3,7 +3,6 @@ package com.replaymod.replay;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture; import com.google.common.util.concurrent.SettableFuture;
import com.replaymod.core.ReplayMod; import com.replaymod.core.ReplayMod;
import com.replaymod.core.versions.MCVer;
import de.johni0702.minecraft.gui.versions.Image; import de.johni0702.minecraft.gui.versions.Image;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
@@ -13,10 +12,6 @@ import net.minecraft.client.util.ScreenshotUtils;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
//#endif //#endif
//#if MC>=11400
import static com.replaymod.core.versions.MCVer.getWindow;
//#endif
//#if MC<11400 //#if MC<11400
//$$ import com.google.common.io.Files; //$$ import com.google.common.io.Files;
//$$ import org.apache.commons.io.FileUtils; //$$ import org.apache.commons.io.FileUtils;
@@ -55,11 +50,8 @@ public class NoGuiScreenshot {
return; return;
} }
//#if MC>=11400 int frameWidth = mc.getWindow().getFramebufferWidth();
int frameWidth = getWindow(mc).getFramebufferWidth(), frameHeight = getWindow(mc).getFramebufferHeight(); int frameHeight = mc.getWindow().getFramebufferHeight();
//#else
//$$ int frameWidth = mc.displayWidth, frameHeight = mc.displayHeight;
//#endif
final boolean guiHidden = mc.options.hudHidden; final boolean guiHidden = mc.options.hudHidden;
try { try {
@@ -76,16 +68,17 @@ public class NoGuiScreenshot {
mc.getFramebuffer().beginWrite(true); mc.getFramebuffer().beginWrite(true);
GlStateManager.enableTexture(); GlStateManager.enableTexture();
float tickDelta = mc.getTickDelta();
//#if MC>=11500 //#if MC>=11500
mc.gameRenderer.renderWorld(MCVer.getRenderPartialTicks(), System.nanoTime(), new MatrixStack()); mc.gameRenderer.renderWorld(tickDelta, System.nanoTime(), new MatrixStack());
//#else //#else
//#if MC>=11400 //#if MC>=11400
//$$ mc.gameRenderer.renderWorld(MCVer.getRenderPartialTicks(), System.nanoTime()); //$$ mc.gameRenderer.renderWorld(tickDelta, System.nanoTime());
//#else //#else
//#if MC>=10809 //#if MC>=10809
//$$ mc.entityRenderer.updateCameraAndRender(MCVer.getRenderPartialTicks(), System.nanoTime()); //$$ mc.entityRenderer.updateCameraAndRender(tickDelta, System.nanoTime());
//#else //#else
//$$ mc.entityRenderer.updateCameraAndRender(MCVer.getRenderPartialTicks()); //$$ mc.entityRenderer.updateCameraAndRender(tickDelta);
//#endif //#endif
//#endif //#endif
//#endif //#endif

View File

@@ -31,6 +31,7 @@ import io.netty.channel.embedded.EmbeddedChannel;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.DownloadingTerrainScreen; import net.minecraft.client.gui.screen.DownloadingTerrainScreen;
import net.minecraft.client.network.ClientLoginNetworkHandler; import net.minecraft.client.network.ClientLoginNetworkHandler;
import net.minecraft.client.util.Window;
import net.minecraft.util.crash.CrashReport; import net.minecraft.util.crash.CrashReport;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@@ -50,12 +51,10 @@ import org.lwjgl.opengl.GL11;
//#if MC>=11400 //#if MC>=11400
import com.replaymod.replay.mixin.EntityLivingBaseAccessor; import com.replaymod.replay.mixin.EntityLivingBaseAccessor;
import net.minecraft.client.util.Window;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
//#else //#else
//$$ import com.replaymod.replay.mixin.EntityOtherPlayerMPAccessor; //$$ import com.replaymod.replay.mixin.EntityOtherPlayerMPAccessor;
//$$ import net.minecraft.client.entity.EntityOtherPlayerMP; //$$ import net.minecraft.client.entity.EntityOtherPlayerMP;
//$$ import net.minecraft.client.gui.ScaledResolution;
//$$ import org.lwjgl.opengl.Display; //$$ import org.lwjgl.opengl.Display;
//#endif //#endif
@@ -148,7 +147,7 @@ public class ReplayHandler {
private UUID spectating; private UUID spectating;
public ReplayHandler(ReplayFile replayFile, boolean asyncMode) throws IOException { public ReplayHandler(ReplayFile replayFile, boolean asyncMode) throws IOException {
Preconditions.checkState(isOnMainThread(), "Must be called from Minecraft thread."); Preconditions.checkState(mc.isOnThread(), "Must be called from Minecraft thread.");
this.replayFile = replayFile; this.replayFile = replayFile;
replayDuration = replayFile.getMetaData().getDuration(); replayDuration = replayFile.getMetaData().getDuration();
@@ -171,7 +170,7 @@ public class ReplayHandler {
} }
void restartedReplay() { void restartedReplay() {
Preconditions.checkState(isOnMainThread(), "Must be called from Minecraft thread."); Preconditions.checkState(mc.isOnThread(), "Must be called from Minecraft thread.");
channel.close(); channel.close();
@@ -197,7 +196,7 @@ public class ReplayHandler {
} }
public void endReplay() throws IOException { public void endReplay() throws IOException {
Preconditions.checkState(isOnMainThread(), "Must be called from Minecraft thread."); Preconditions.checkState(mc.isOnThread(), "Must be called from Minecraft thread.");
ReplayClosingCallback.EVENT.invoker().replayClosing(this); ReplayClosingCallback.EVENT.invoker().replayClosing(this);
@@ -246,7 +245,7 @@ public class ReplayHandler {
} }
private void setup() { private void setup() {
Preconditions.checkState(isOnMainThread(), "Must be called from Minecraft thread."); Preconditions.checkState(mc.isOnThread(), "Must be called from Minecraft thread.");
//#if MC>=11100 //#if MC>=11100
mc.inGameHud.getChatHud().clear(false); mc.inGameHud.getChatHud().clear(false);
@@ -403,7 +402,7 @@ public class ReplayHandler {
CameraEntity cam = getCameraEntity(); CameraEntity cam = getCameraEntity();
if (cam != null) { if (cam != null) {
targetCameraPosition = new Location(Entity_getX(cam), Entity_getY(cam), Entity_getZ(cam), cam.yaw, cam.pitch); targetCameraPosition = new Location(cam.getX(), cam.getY(), cam.getZ(), cam.yaw, cam.pitch);
} else { } else {
targetCameraPosition = null; targetCameraPosition = null;
} }
@@ -486,8 +485,8 @@ public class ReplayHandler {
cameraEntity.setCameraController(new SpectatorCameraController(cameraEntity)); cameraEntity.setCameraController(new SpectatorCameraController(cameraEntity));
} }
if (getRenderViewEntity(mc) != e) { if (mc.getCameraEntity() != e) {
setRenderViewEntity(mc, e); mc.setCameraEntity(e);
cameraEntity.setCameraPosRot(e); cameraEntity.setCameraPosRot(e);
} }
} }
@@ -505,7 +504,7 @@ public class ReplayHandler {
* @return {@code true} if the camera is the view entity, {@code false} otherwise * @return {@code true} if the camera is the view entity, {@code false} otherwise
*/ */
public boolean isCameraView() { public boolean isCameraView() {
return mc.player instanceof CameraEntity && mc.player == getRenderViewEntity(mc); return mc.player instanceof CameraEntity && mc.player == mc.getCameraEntity();
} }
/** /**
@@ -539,11 +538,11 @@ public class ReplayHandler {
} }
// Update all entity positions (especially prev/lastTick values) // Update all entity positions (especially prev/lastTick values)
for (Entity entity : loadedEntityList(mc.world)) { for (Entity entity : mc.world.getEntities()) {
skipTeleportInterpolation(entity); skipTeleportInterpolation(entity);
entity.lastRenderX = entity.prevX = Entity_getX(entity); entity.lastRenderX = entity.prevX = entity.getX();
entity.lastRenderY = entity.prevY = Entity_getY(entity); entity.lastRenderY = entity.prevY = entity.getY();
entity.lastRenderZ = entity.prevZ = Entity_getZ(entity); entity.lastRenderZ = entity.prevZ = entity.getZ();
entity.prevYaw = entity.yaw; entity.prevYaw = entity.yaw;
entity.prevPitch = entity.pitch; entity.prevPitch = entity.pitch;
} }
@@ -563,7 +562,7 @@ public class ReplayHandler {
quickReplaySender.sendPacketsTill(targetTime); quickReplaySender.sendPacketsTill(targetTime);
// Immediately apply player teleport interpolation // Immediately apply player teleport interpolation
for (Entity entity : loadedEntityList(mc.world)) { for (Entity entity : mc.world.getEntities()) {
skipTeleportInterpolation(entity); skipTeleportInterpolation(entity);
} }
return; return;
@@ -582,7 +581,7 @@ public class ReplayHandler {
if (retainCameraPosition) { if (retainCameraPosition) {
CameraEntity cam = getCameraEntity(); CameraEntity cam = getCameraEntity();
if (cam != null) { if (cam != null) {
targetCameraPosition = new Location(Entity_getX(cam), Entity_getY(cam), Entity_getZ(cam), targetCameraPosition = new Location(cam.getX(), cam.getY(), cam.getZ(),
cam.yaw, cam.pitch); cam.yaw, cam.pitch);
} else { } else {
targetCameraPosition = null; targetCameraPosition = null;
@@ -612,8 +611,8 @@ public class ReplayHandler {
); );
enableTexture(); enableTexture();
mc.getFramebuffer().beginWrite(true); mc.getFramebuffer().beginWrite(true);
Window window = mc.getWindow();
//#if MC>=11500 //#if MC>=11500
Window window = getWindow(mc);
RenderSystem.clear(256, MinecraftClient.IS_SYSTEM_MAC); RenderSystem.clear(256, MinecraftClient.IS_SYSTEM_MAC);
RenderSystem.matrixMode(GL11.GL_PROJECTION); RenderSystem.matrixMode(GL11.GL_PROJECTION);
RenderSystem.loadIdentity(); RenderSystem.loadIdentity();
@@ -623,23 +622,13 @@ public class ReplayHandler {
RenderSystem.translatef(0, 0, -2000); RenderSystem.translatef(0, 0, -2000);
//#else //#else
//#if MC>=11400 //#if MC>=11400
//$$ getWindow(mc).method_4493(true); //$$ window.method_4493(true);
//#else
//#if MC>=11400
//$$ mc.mainWindow.setupOverlayRendering();
//#else //#else
//$$ mc.entityRenderer.setupOverlayRendering(); //$$ mc.entityRenderer.setupOverlayRendering();
//#endif //#endif
//#endif //#endif
//#endif
//#if MC>=11400 guiScreen.toMinecraft().init(mc, window.getScaledWidth(), window.getScaledHeight());
Window
//#else
//$$ ScaledResolution
//#endif
resolution = newScaledResolution(mc);
guiScreen.toMinecraft().init(mc, resolution.getScaledWidth(), resolution.getScaledHeight());
//#if MC>=11600 //#if MC>=11600
guiScreen.toMinecraft().render(new MatrixStack(), 0, 0, 0); guiScreen.toMinecraft().render(new MatrixStack(), 0, 0, 0);
//#else //#else
@@ -654,18 +643,14 @@ public class ReplayHandler {
mc.getFramebuffer().endWrite(); mc.getFramebuffer().endWrite();
popMatrix(); popMatrix();
pushMatrix(); pushMatrix();
//#if MC>=11400 mc.getFramebuffer().draw(mc.getWindow().getFramebufferWidth(), mc.getWindow().getFramebufferHeight());
mc.getFramebuffer().draw(getWindow(mc).getFramebufferWidth(), getWindow(mc).getFramebufferHeight());
//#else
//$$ mc.getFramebuffer().framebufferRender(mc.displayWidth, mc.displayHeight);
//#endif
popMatrix(); popMatrix();
//#if MC>=11500 //#if MC>=11500
getWindow(mc).swapBuffers(); mc.getWindow().swapBuffers();
//#else //#else
//#if MC>=11400 //#if MC>=11400
//$$ getWindow(mc).setFullscreen(true); //$$ mc.window.setFullscreen(true);
//#else //#else
//$$ Display.update(); //$$ Display.update();
//#endif //#endif
@@ -691,11 +676,11 @@ public class ReplayHandler {
//#else //#else
//$$ .processReceivedPackets(); //$$ .processReceivedPackets();
//#endif //#endif
for (Entity entity : loadedEntityList(mc.world)) { for (Entity entity : mc.world.getEntities()) {
skipTeleportInterpolation(entity); skipTeleportInterpolation(entity);
entity.lastRenderX = entity.prevX = Entity_getX(entity); entity.lastRenderX = entity.prevX = entity.getX();
entity.lastRenderY = entity.prevY = Entity_getY(entity); entity.lastRenderY = entity.prevY = entity.getY();
entity.lastRenderZ = entity.prevZ = Entity_getZ(entity); entity.lastRenderZ = entity.prevZ = entity.getZ();
entity.prevYaw = entity.yaw; entity.prevYaw = entity.yaw;
entity.prevPitch = entity.pitch; entity.prevPitch = entity.pitch;
} }

View File

@@ -32,8 +32,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Optional; import java.util.Optional;
import static com.replaymod.core.versions.MCVer.*;
public class ReplayModReplay implements Module { public class ReplayModReplay implements Module {
{ instance = this; } { instance = this; }
@@ -68,9 +66,9 @@ public class ReplayModReplay implements Module {
if (camera != null) { if (camera != null) {
Marker marker = new Marker(); Marker marker = new Marker();
marker.setTime(replayHandler.getReplaySender().currentTimeStamp()); marker.setTime(replayHandler.getReplaySender().currentTimeStamp());
marker.setX(Entity_getX(camera)); marker.setX(camera.getX());
marker.setY(Entity_getY(camera)); marker.setY(camera.getY());
marker.setZ(Entity_getZ(camera)); marker.setZ(camera.getZ());
marker.setYaw(camera.yaw); marker.setYaw(camera.yaw);
marker.setPitch(camera.pitch); marker.setPitch(camera.pitch);
marker.setRoll(camera.roll); marker.setRoll(camera.roll);

View File

@@ -31,7 +31,6 @@ import net.minecraft.util.math.Box;
//#if FABRIC>=1 //#if FABRIC>=1
//#else //#else
//$$ import com.replaymod.core.versions.MCVer;
//$$ import net.minecraftforge.client.event.EntityViewRenderEvent; //$$ import net.minecraftforge.client.event.EntityViewRenderEvent;
//$$ import net.minecraftforge.client.event.RenderGameOverlayEvent; //$$ import net.minecraftforge.client.event.RenderGameOverlayEvent;
//$$ import net.minecraftforge.common.MinecraftForge; //$$ import net.minecraftforge.common.MinecraftForge;
@@ -185,7 +184,7 @@ public class CameraEntity
* @param z Delta in Z direction * @param z Delta in Z direction
*/ */
public void moveCamera(double x, double y, double z) { public void moveCamera(double x, double y, double z) {
setCameraPosition(Entity_getX(this) + x, Entity_getY(this) + y, Entity_getZ(this) + z); setCameraPosition(this.getX() + x, this.getY() + y, this.getZ() + z);
} }
/** /**
@@ -198,7 +197,7 @@ public class CameraEntity
this.lastRenderX = this.prevX = x; this.lastRenderX = this.prevX = x;
this.lastRenderY = this.prevY = y; this.lastRenderY = this.prevY = y;
this.lastRenderZ = this.prevZ = z; this.lastRenderZ = this.prevZ = z;
Entity_setPos(this, x, y, z); this.setPos(x, y, z);
updateBoundingBox(); updateBoundingBox();
} }
@@ -239,7 +238,7 @@ public class CameraEntity
this.prevZ = to.prevZ; this.prevZ = to.prevZ;
this.prevYaw = to.prevYaw; this.prevYaw = to.prevYaw;
this.prevPitch = to.prevPitch; this.prevPitch = to.prevPitch;
Entity_setPos(this, Entity_getX(to), Entity_getY(to), Entity_getZ(to)); this.setPos(to.getX(), to.getY(), to.getZ());
this.yaw = to.yaw; this.yaw = to.yaw;
this.pitch = to.pitch; this.pitch = to.pitch;
this.lastRenderX = to.lastRenderX; this.lastRenderX = to.lastRenderX;
@@ -258,17 +257,18 @@ public class CameraEntity
//#else //#else
//$$ this.boundingBox.setBB(AxisAlignedBB.getBoundingBox( //$$ this.boundingBox.setBB(AxisAlignedBB.getBoundingBox(
//#endif //#endif
Entity_getX(this) - width / 2, Entity_getY(this), Entity_getZ(this) - width / 2, this.getX() - width / 2, this.getY(), this.getZ() - width / 2,
Entity_getX(this) + width / 2, Entity_getY(this) + height, Entity_getZ(this) + width / 2)); this.getX() + width / 2, this.getY() + height, this.getZ() + width / 2));
} }
@Override @Override
public void tick() { public void tick() {
//#if MC>=10800 //#if MC>=10800
Entity view = getRenderViewEntity(this.client); Entity view =
//#else //#else
//$$ EntityLivingBase view = getRenderViewEntity(this.mc); //$$ EntityLivingBase view =
//#endif //#endif
this.client.getCameraEntity();
if (view != null) { if (view != null) {
// Make sure we're always spectating the right entity // Make sure we're always spectating the right entity
// This is important if the spectated player respawns as their // This is important if the spectated player respawns as their
@@ -284,9 +284,9 @@ public class CameraEntity
} }
view = this.world.getPlayerByUuid(spectating); view = this.world.getPlayerByUuid(spectating);
if (view != null) { if (view != null) {
setRenderViewEntity(this.client, view); this.client.setCameraEntity(view);
} else { } else {
setRenderViewEntity(this.client, this); this.client.setCameraEntity(this);
return; return;
} }
} }
@@ -309,7 +309,7 @@ public class CameraEntity
@Override @Override
public void setRotation(float yaw, float pitch) { public void setRotation(float yaw, float pitch) {
if (getRenderViewEntity(this.client) == this) { if (this.client.getCameraEntity() == this) {
// Only update camera rotation when the camera is the view // Only update camera rotation when the camera is the view
super.setRotation(yaw, pitch); super.setRotation(yaw, pitch);
} }
@@ -357,7 +357,7 @@ public class CameraEntity
} }
private boolean falseUnlessSpectating(Function<Entity, Boolean> property) { private boolean falseUnlessSpectating(Function<Entity, Boolean> property) {
Entity view = getRenderViewEntity(this.client); Entity view = this.client.getCameraEntity();
if (view != null && view != this) { if (view != null && view != this) {
return property.apply(view); return property.apply(view);
} }
@@ -407,7 +407,7 @@ public class CameraEntity
//#if MC>=10800 //#if MC>=10800
@Override @Override
public float getSpeed() { public float getSpeed() {
Entity view = getRenderViewEntity(this.client); Entity view = this.client.getCameraEntity();
if (view != this && view instanceof AbstractClientPlayerEntity) { if (view != this && view instanceof AbstractClientPlayerEntity) {
return ((AbstractClientPlayerEntity) view).getSpeed(); return ((AbstractClientPlayerEntity) view).getSpeed();
} }
@@ -422,7 +422,7 @@ public class CameraEntity
@Override @Override
public boolean isInvisible() { public boolean isInvisible() {
Entity view = getRenderViewEntity(this.client); Entity view = this.client.getCameraEntity();
if (view != this) { if (view != this) {
return view.isInvisible(); return view.isInvisible();
} }
@@ -431,7 +431,7 @@ public class CameraEntity
@Override @Override
public Identifier getSkinTexture() { public Identifier getSkinTexture() {
Entity view = getRenderViewEntity(this.client); Entity view = this.client.getCameraEntity();
if (view != this && view instanceof PlayerEntity) { if (view != this && view instanceof PlayerEntity) {
return Utils.getResourceLocationForPlayerUUID(view.getUuid()); return Utils.getResourceLocationForPlayerUUID(view.getUuid());
} }
@@ -450,7 +450,7 @@ public class CameraEntity
@Override @Override
public boolean isPartVisible(PlayerModelPart modelPart) { public boolean isPartVisible(PlayerModelPart modelPart) {
Entity view = getRenderViewEntity(this.client); Entity view = this.client.getCameraEntity();
if (view != this && view instanceof PlayerEntity) { if (view != this && view instanceof PlayerEntity) {
return ((PlayerEntity) view).isPartVisible(modelPart); return ((PlayerEntity) view).isPartVisible(modelPart);
} }
@@ -460,7 +460,7 @@ public class CameraEntity
@Override @Override
public float getHandSwingProgress(float renderPartialTicks) { public float getHandSwingProgress(float renderPartialTicks) {
Entity view = getRenderViewEntity(this.client); Entity view = this.client.getCameraEntity();
if (view != this && view instanceof PlayerEntity) { if (view != this && view instanceof PlayerEntity) {
return ((PlayerEntity) view).getHandSwingProgress(renderPartialTicks); return ((PlayerEntity) view).getHandSwingProgress(renderPartialTicks);
} }
@@ -705,7 +705,7 @@ public class CameraEntity
{ on(PreRenderHandCallback.EVENT, this::onRenderHand); } { on(PreRenderHandCallback.EVENT, this::onRenderHand); }
private boolean onRenderHand() { private boolean onRenderHand() {
// Unless we are spectating another player, don't render our hand // Unless we are spectating another player, don't render our hand
Entity view = getRenderViewEntity(mc); Entity view = mc.getCameraEntity();
if (view == CameraEntity.this || !(view instanceof PlayerEntity)) { if (view == CameraEntity.this || !(view instanceof PlayerEntity)) {
return true; // cancel hand rendering return true; // cancel hand rendering
} else { } else {
@@ -761,7 +761,7 @@ public class CameraEntity
//#else //#else
//$$ @SubscribeEvent //$$ @SubscribeEvent
//$$ public void preRenderGameOverlay(RenderGameOverlayEvent.Pre event) { //$$ public void preRenderGameOverlay(RenderGameOverlayEvent.Pre event) {
//$$ switch (MCVer.getType(event)) { //$$ switch (event.getType()) {
//$$ case ALL: //$$ case ALL:
//$$ heldItemTooltipsWasTrue = mc.gameSettings.heldItemTooltips; //$$ heldItemTooltipsWasTrue = mc.gameSettings.heldItemTooltips;
//$$ mc.gameSettings.heldItemTooltips = false; //$$ mc.gameSettings.heldItemTooltips = false;
@@ -797,7 +797,7 @@ public class CameraEntity
//$$ //$$
//$$ @SubscribeEvent //$$ @SubscribeEvent
//$$ public void postRenderGameOverlay(RenderGameOverlayEvent.Post event) { //$$ public void postRenderGameOverlay(RenderGameOverlayEvent.Post event) {
//$$ if (MCVer.getType(event) != RenderGameOverlayEvent.ElementType.ALL) return; //$$ if (event.getType() != RenderGameOverlayEvent.ElementType.ALL) return;
//$$ mc.gameSettings.heldItemTooltips = heldItemTooltipsWasTrue; //$$ mc.gameSettings.heldItemTooltips = heldItemTooltipsWasTrue;
//$$ } //$$ }
//#endif //#endif

View File

@@ -1,9 +1,11 @@
package com.replaymod.replay.camera; package com.replaymod.replay.camera;
import de.johni0702.minecraft.gui.utils.lwjgl.vector.Vector3f; import de.johni0702.minecraft.gui.utils.lwjgl.vector.Vector3f;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.options.KeyBinding; import net.minecraft.client.options.KeyBinding;
import static com.replaymod.core.versions.MCVer.*; import static net.minecraft.util.math.MathHelper.cos;
import static net.minecraft.util.math.MathHelper.sin;
// TODO: Marius is responsible for this. Please, someone clean it up. // TODO: Marius is responsible for this. Please, someone clean it up.
public class ClassicCameraController implements CameraController { public class ClassicCameraController implements CameraController {
@@ -32,7 +34,7 @@ public class ClassicCameraController implements CameraController {
public void update(float partialTicksPassed) { public void update(float partialTicksPassed) {
boolean forward = false, backward = false, left = false, right = false, up = false, down = false; boolean forward = false, backward = false, left = false, right = false, up = false, down = false;
speedup = false; speedup = false;
for(KeyBinding kb : getMinecraft().options.keysAll) { for(KeyBinding kb : MinecraftClient.getInstance().options.keysAll) {
if(!kb.isPressed()) continue; if(!kb.isPressed()) continue;
if(kb.getTranslationKey().equals("key.forward")) { if(kb.getTranslationKey().equals("key.forward")) {
forward = true; forward = true;

View File

@@ -52,9 +52,9 @@ public class SpectatorCameraController implements CameraController {
// Always make sure the camera is in the exact same spot as the spectated entity // Always make sure the camera is in the exact same spot as the spectated entity
// This is necessary as some rendering code for the hand doesn't respect the view entity // This is necessary as some rendering code for the hand doesn't respect the view entity
// and always uses mc.thePlayer // and always uses mc.thePlayer
Entity view = getRenderViewEntity(mc); Entity view = mc.getCameraEntity();
if (view != null && view != camera) { if (view != null && view != camera) {
camera.setCameraPosRot(getRenderViewEntity(mc)); camera.setCameraPosRot(mc.getCameraEntity());
// If it's a player, also 'steal' its inventory so the rendering code knows what item to render // If it's a player, also 'steal' its inventory so the rendering code knows what item to render
if (view instanceof PlayerEntity) { if (view instanceof PlayerEntity) {
PlayerEntity viewPlayer = (PlayerEntity) view; PlayerEntity viewPlayer = (PlayerEntity) view;

View File

@@ -113,8 +113,8 @@ public class GuiHandler extends EventRegistrations {
BUTTON_EXIT_REPLAY, BUTTON_EXIT_REPLAY,
b.x, b.x,
b.y, b.y,
width(b), b.getWidth(),
height(b), b.getHeight(),
"replaymod.gui.exit", "replaymod.gui.exit",
this::onButton this::onButton
)); ));
@@ -133,9 +133,9 @@ public class GuiHandler extends EventRegistrations {
//#if MC>=11400 //#if MC>=11400
} else if (id.equals(BUTTON_OPTIONS)) { } else if (id.equals(BUTTON_OPTIONS)) {
//#if MC>=11400 //#if MC>=11400
width(b, 204); b.setWidth(204);
//#else //#else
//$$ width(b, 200); //$$ b.width = 200
//#endif //#endif
//#endif //#endif
} }
@@ -147,7 +147,7 @@ public class GuiHandler extends EventRegistrations {
} }
if (achievements != null && stats != null) { if (achievements != null && stats != null) {
moveAllButtonsInRect(buttonList, moveAllButtonsInRect(buttonList,
achievements.x, stats.x + width(stats), achievements.x, stats.x + stats.getWidth(),
achievements.y, Integer.MAX_VALUE, achievements.y, Integer.MAX_VALUE,
-24); -24);
} }
@@ -185,8 +185,8 @@ public class GuiHandler extends EventRegistrations {
int moveBy int moveBy
) { ) {
buttons.stream() buttons.stream()
.filter(button -> button.x <= xEnd && button.x + width(button) >= xStart) .filter(button -> button.x <= xEnd && button.x + button.getWidth() >= xStart)
.filter(button -> button.y <= yEnd && button.y + height(button) >= yStart) .filter(button -> button.y <= yEnd && button.y + button.getHeight() >= yStart)
.forEach(button -> button.y += moveBy); .forEach(button -> button.y += moveBy);
} }
@@ -261,8 +261,8 @@ public class GuiHandler extends EventRegistrations {
//#else //#else
//$$ @SubscribeEvent //$$ @SubscribeEvent
//$$ public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) { //$$ public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
//$$ GuiScreen guiScreen = getGui(event); //$$ GuiScreen guiScreen = event.getGui();
//$$ GuiButton button = getButton(event); //$$ GuiButton button = event.getButton();
//#endif //#endif
if(!button.active) return; if(!button.active) return;

View File

@@ -49,7 +49,6 @@ import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import static com.replaymod.core.versions.MCVer.*;
import static com.replaymod.replaystudio.pathing.change.RemoveKeyframe.create; import static com.replaymod.replaystudio.pathing.change.RemoveKeyframe.create;
import static com.replaymod.simplepathing.ReplayModSimplePathing.LOGGER; import static com.replaymod.simplepathing.ReplayModSimplePathing.LOGGER;
@@ -674,7 +673,7 @@ public class SPTimeline implements PathingRegistry {
} catch (IOException e) { } catch (IOException e) {
CrashReport crash = CrashReport.create(e, "Serializing interpolator"); CrashReport crash = CrashReport.create(e, "Serializing interpolator");
CrashReportSection category = crash.addElement("Serializing interpolator"); CrashReportSection category = crash.addElement("Serializing interpolator");
addDetail(category, "Interpolator", interpolator::toString); category.add("Interpolator", interpolator::toString);
throw new CrashException(crash); throw new CrashException(crash);
} }
@@ -689,7 +688,7 @@ public class SPTimeline implements PathingRegistry {
} catch (IOException e) { } catch (IOException e) {
CrashReport crash = CrashReport.create(e, "De-serializing interpolator"); CrashReport crash = CrashReport.create(e, "De-serializing interpolator");
CrashReportSection category = crash.addElement("De-serializing interpolator"); CrashReportSection category = crash.addElement("De-serializing interpolator");
addDetail(category, "Interpolator", json::toString); category.add("Interpolator", json::toString);
throw new CrashException(crash); throw new CrashException(crash);
} }
} }

View File

@@ -18,6 +18,9 @@ import com.replaymod.simplepathing.SPTimeline.SPPath;
import de.johni0702.minecraft.gui.GuiRenderer; import de.johni0702.minecraft.gui.GuiRenderer;
import de.johni0702.minecraft.gui.element.advanced.AbstractGuiTimeline; import de.johni0702.minecraft.gui.element.advanced.AbstractGuiTimeline;
import de.johni0702.minecraft.gui.function.Draggable; import de.johni0702.minecraft.gui.function.Draggable;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormats;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import de.johni0702.minecraft.gui.utils.lwjgl.Point; import de.johni0702.minecraft.gui.utils.lwjgl.Point;
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension; import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
@@ -27,10 +30,6 @@ import org.lwjgl.opengl.GL11;
import java.util.Comparator; import java.util.Comparator;
import java.util.Optional; import java.util.Optional;
import static com.replaymod.core.versions.MCVer.BufferBuilder_addPosCol;
import static com.replaymod.core.versions.MCVer.BufferBuilder_beginPosCol;
import static com.replaymod.core.versions.MCVer.Tessellator_getInstance;
public class GuiKeyframeTimeline extends AbstractGuiTimeline<GuiKeyframeTimeline> implements Draggable { public class GuiKeyframeTimeline extends AbstractGuiTimeline<GuiKeyframeTimeline> implements Draggable {
protected static final int KEYFRAME_SIZE = 5; protected static final int KEYFRAME_SIZE = 5;
protected static final int KEYFRAME_TEXTURE_X = 74; protected static final int KEYFRAME_TEXTURE_X = 74;
@@ -142,55 +141,61 @@ public class GuiKeyframeTimeline extends AbstractGuiTimeline<GuiKeyframeTimeline
float positionXKeyframeTimeline = positonX + KEYFRAME_SIZE / 2f; float positionXKeyframeTimeline = positonX + KEYFRAME_SIZE / 2f;
final int color = 0xff0000ff; final int color = 0xff0000ff;
BufferBuilder_beginPosCol(GL11.GL_LINE_STRIP); Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
buffer.begin(GL11.GL_LINE_STRIP, VertexFormats.POSITION_COLOR);
// Start just below the top border of the replay timeline // Start just below the top border of the replay timeline
BufferBuilder_addPosCol( buffer.vertex(
replayTimelineLeft + positionXReplayTimeline, replayTimelineLeft + positionXReplayTimeline,
replayTimelineTop + BORDER_TOP, replayTimelineTop + BORDER_TOP,
0, 0
).color(
color >> 24 & 0xff, color >> 24 & 0xff,
color >> 16 & 0xff, color >> 16 & 0xff,
color >> 8 & 0xff, color >> 8 & 0xff,
color & 0xff color & 0xff
); ).next();
// Draw vertically over the replay timeline, including its bottom border // Draw vertically over the replay timeline, including its bottom border
BufferBuilder_addPosCol( buffer.vertex(
replayTimelineLeft + positionXReplayTimeline, replayTimelineLeft + positionXReplayTimeline,
replayTimelineBottom, replayTimelineBottom,
0, 0
).color(
color >> 24 & 0xff, color >> 24 & 0xff,
color >> 16 & 0xff, color >> 16 & 0xff,
color >> 8 & 0xff, color >> 8 & 0xff,
color & 0xff color & 0xff
); ).next();
// Now for the important part: connecting to the keyframe timeline // Now for the important part: connecting to the keyframe timeline
BufferBuilder_addPosCol( buffer.vertex(
keyframeTimelineLeft + positionXKeyframeTimeline, keyframeTimelineLeft + positionXKeyframeTimeline,
keyframeTimelineTop, keyframeTimelineTop,
0, 0
).color(
color >> 24 & 0xff, color >> 24 & 0xff,
color >> 16 & 0xff, color >> 16 & 0xff,
color >> 8 & 0xff, color >> 8 & 0xff,
color & 0xff color & 0xff
); ).next();
// And finally another vertical bit (the timeline is already crammed enough, so only the border) // And finally another vertical bit (the timeline is already crammed enough, so only the border)
BufferBuilder_addPosCol( buffer.vertex(
keyframeTimelineLeft + positionXKeyframeTimeline, keyframeTimelineLeft + positionXKeyframeTimeline,
keyframeTimelineTop + BORDER_TOP, keyframeTimelineTop + BORDER_TOP,
0, 0
).color(
color >> 24 & 0xff, color >> 24 & 0xff,
color >> 16 & 0xff, color >> 16 & 0xff,
color >> 8 & 0xff, color >> 8 & 0xff,
color & 0xff color & 0xff
); ).next();
GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glEnable(GL11.GL_LINE_SMOOTH);
GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glPushAttrib(GL11.GL_SCISSOR_BIT); GL11.glPushAttrib(GL11.GL_SCISSOR_BIT);
GL11.glDisable(GL11.GL_SCISSOR_TEST); GL11.glDisable(GL11.GL_SCISSOR_TEST);
GL11.glLineWidth(1); GL11.glLineWidth(1);
Tessellator_getInstance().draw(); tessellator.draw();
GL11.glPopAttrib(); GL11.glPopAttrib();
GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_LINE_SMOOTH); GL11.glDisable(GL11.GL_LINE_SMOOTH);

View File

@@ -644,9 +644,9 @@ public class GuiPathing {
CameraEntity camera = replayHandler.getCameraEntity(); CameraEntity camera = replayHandler.getCameraEntity();
int spectatedId = -1; int spectatedId = -1;
if (!replayHandler.isCameraView() && !neverSpectator) { if (!replayHandler.isCameraView() && !neverSpectator) {
spectatedId = getRenderViewEntity(replayHandler.getOverlay().getMinecraft()).getEntityId(); spectatedId = replayHandler.getOverlay().getMinecraft().getCameraEntity().getEntityId();
} }
timeline.addPositionKeyframe(time, Entity_getX(camera), Entity_getY(camera), Entity_getZ(camera), timeline.addPositionKeyframe(time, camera.getX(), camera.getY(), camera.getZ(),
camera.yaw, camera.pitch, camera.roll, spectatedId); camera.yaw, camera.pitch, camera.roll, spectatedId);
mod.setSelected(path, time); mod.setSelected(path, time);
} }

View File

@@ -19,6 +19,9 @@ import com.replaymod.simplepathing.SPTimeline;
import com.replaymod.simplepathing.gui.GuiPathing; import com.replaymod.simplepathing.gui.GuiPathing;
import de.johni0702.minecraft.gui.utils.EventRegistrations; import de.johni0702.minecraft.gui.utils.EventRegistrations;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
@@ -34,7 +37,6 @@ import java.util.Comparator;
import java.util.Optional; import java.util.Optional;
import static com.replaymod.core.ReplayMod.TEXTURE; import static com.replaymod.core.ReplayMod.TEXTURE;
import static com.replaymod.core.versions.MCVer.*;
public class PathPreviewRenderer extends EventRegistrations { public class PathPreviewRenderer extends EventRegistrations {
private static final Identifier CAMERA_HEAD = new Identifier("replaymod", "camera_head.png"); private static final Identifier CAMERA_HEAD = new Identifier("replaymod", "camera_head.png");
@@ -56,7 +58,7 @@ public class PathPreviewRenderer extends EventRegistrations {
private void renderCameraPath(MatrixStack matrixStack) { private void renderCameraPath(MatrixStack matrixStack) {
if (!replayHandler.getReplaySender().isAsyncMode() || mc.options.hudHidden) return; if (!replayHandler.getReplaySender().isAsyncMode() || mc.options.hudHidden) return;
Entity view = getRenderViewEntity(mc); Entity view = mc.getCameraEntity();
if (view == null) return; if (view == null) return;
GuiPathing guiPathing = mod.getGuiPathing(); GuiPathing guiPathing = mod.getGuiPathing();
@@ -75,14 +77,15 @@ public class PathPreviewRenderer extends EventRegistrations {
int renderDistanceSquared = renderDistance * renderDistance; int renderDistanceSquared = renderDistance * renderDistance;
Triple<Double, Double, Double> viewPos = Triple.of( Triple<Double, Double, Double> viewPos = Triple.of(
Entity_getX(view), view.getX(),
view.getY()
//#if MC>=10800 && MC<11500 //#if MC>=10800 && MC<11500
//$$ // Eye height is subtracted to make path appear higher (at eye height) than it actually is (at foot height) //$$ // Eye height is subtracted to make path appear higher (at eye height) than it actually is (at foot height)
//$$ Entity_getY(view) - view.getStandingEyeHeight(), //$$ - view.getStandingEyeHeight(),
//#else //#else
Entity_getY(view), ,
//#endif //#endif
Entity_getZ(view) view.getZ()
); );
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
@@ -212,36 +215,40 @@ public class PathPreviewRenderer extends EventRegistrations {
if (distanceSquared(view, pos1) > renderDistanceSquared) return; if (distanceSquared(view, pos1) > renderDistanceSquared) return;
if (distanceSquared(view, pos2) > renderDistanceSquared) return; if (distanceSquared(view, pos2) > renderDistanceSquared) return;
BufferBuilder_beginPosCol(GL11.GL_LINES); Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
buffer.begin(GL11.GL_LINES, VertexFormats.POSITION_COLOR);
BufferBuilder_addPosCol( buffer.vertex(
pos1.getLeft() - view.getLeft(), pos1.getLeft() - view.getLeft(),
pos1.getMiddle() - view.getMiddle(), pos1.getMiddle() - view.getMiddle(),
pos1.getRight() - view.getRight(), pos1.getRight() - view.getRight()
).color(
color >> 16 & 0xff, color >> 16 & 0xff,
color >> 8 & 0xff, color >> 8 & 0xff,
color & 0xff, color & 0xff,
255 255
); ).next();
BufferBuilder_addPosCol( buffer.vertex(
pos2.getLeft() - view.getLeft(), pos2.getLeft() - view.getLeft(),
pos2.getMiddle() - view.getMiddle(), pos2.getMiddle() - view.getMiddle(),
pos2.getRight() - view.getRight(), pos2.getRight() - view.getRight()
).color(
color >> 16 & 0xff, color >> 16 & 0xff,
color >> 8 & 0xff, color >> 8 & 0xff,
color & 0xff, color & 0xff,
255 255
); ).next();
GL11.glLineWidth(3); GL11.glLineWidth(3);
Tessellator_getInstance().draw(); tessellator.draw();
} }
private void drawPoint(Triple<Double, Double, Double> view, private void drawPoint(Triple<Double, Double, Double> view,
Triple<Double, Double, Double> pos, Triple<Double, Double, Double> pos,
Keyframe keyframe) { Keyframe keyframe) {
MCVer.bindTexture(TEXTURE); mc.getTextureManager().bindTexture(TEXTURE);
float posX = 80f / ReplayMod.TEXTURE_SIZE; float posX = 80f / ReplayMod.TEXTURE_SIZE;
float posY = 0f; float posY = 0f;
@@ -260,12 +267,14 @@ public class PathPreviewRenderer extends EventRegistrations {
float maxX = 0.5f; float maxX = 0.5f;
float maxY = 0.5f; float maxY = 0.5f;
BufferBuilder_beginPosTex(GL11.GL_QUADS); Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_TEXTURE);
BufferBuilder_addPosTex(minX, minY, 0, posX + size, posY + size); buffer.vertex(minX, minY, 0).texture(posX + size, posY + size).next();
BufferBuilder_addPosTex(minX, maxY, 0, posX + size, posY); buffer.vertex(minX, maxY, 0).texture(posX + size, posY).next();
BufferBuilder_addPosTex(maxX, maxY, 0, posX, posY); buffer.vertex(maxX, maxY, 0).texture(posX, posY).next();
BufferBuilder_addPosTex(maxX, minY, 0, posX, posY + size); buffer.vertex(maxX, minY, 0).texture(posX, posY + size).next();
GL11.glPushMatrix(); GL11.glPushMatrix();
@@ -275,15 +284,10 @@ public class PathPreviewRenderer extends EventRegistrations {
pos.getRight() - view.getRight() pos.getRight() - view.getRight()
); );
GL11.glNormal3f(0, 1, 0); GL11.glNormal3f(0, 1, 0);
//#if MC>=11500 GL11.glRotatef(-mc.getEntityRenderDispatcher().camera.getYaw(), 0, 1, 0);
GL11.glRotatef(-getRenderManager().camera.getYaw(), 0, 1, 0); GL11.glRotatef(mc.getEntityRenderDispatcher().camera.getPitch(), 1, 0, 0);
GL11.glRotatef(getRenderManager().camera.getPitch(), 1, 0, 0);
//#else
//$$ GL11.glRotatef(-getRenderManager().cameraYaw, 0, 1, 0);
//$$ GL11.glRotatef(getRenderManager().cameraPitch, 1, 0, 0);
//#endif
Tessellator_getInstance().draw(); tessellator.draw();
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
@@ -292,7 +296,7 @@ public class PathPreviewRenderer extends EventRegistrations {
Triple<Double, Double, Double> pos, Triple<Double, Double, Double> pos,
Triple<Float, Float, Float> rot) { Triple<Float, Float, Float> rot) {
MCVer.bindTexture(CAMERA_HEAD); mc.getTextureManager().bindTexture(CAMERA_HEAD);
GL11.glPushMatrix(); GL11.glPushMatrix();
@@ -308,12 +312,14 @@ public class PathPreviewRenderer extends EventRegistrations {
//draw the position line //draw the position line
GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_2D);
BufferBuilder_beginPosCol(GL11.GL_LINES); Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
buffer.begin(GL11.GL_LINES, VertexFormats.POSITION_COLOR);
BufferBuilder_addPosCol(0, 0, 0, 0, 255, 0, 170); buffer.vertex(0, 0, 0).color(0, 255, 0, 170).next();
BufferBuilder_addPosCol(0, 0, 2, 0, 255, 0, 170); buffer.vertex(0, 0, 2).color(0, 255, 0, 170).next();
Tessellator_getInstance().draw(); tessellator.draw();
// draw camera cube // draw camera cube
GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_TEXTURE_2D);
@@ -322,45 +328,45 @@ public class PathPreviewRenderer extends EventRegistrations {
double r = -cubeSize/2; double r = -cubeSize/2;
BufferBuilder_beginPosTexCol(GL11.GL_QUADS); buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
//back //back
BufferBuilder_addPosTexCol(r, r + cubeSize, r, 3 * 8 / 64f, 8 / 64f, 255, 255, 255, 200); buffer.vertex(r, r + cubeSize, r).texture(3 * 8 / 64f, 8 / 64f).color(255, 255, 255, 200).next();
BufferBuilder_addPosTexCol(r + cubeSize, r + cubeSize, r, 4*8/64f, 8/64f, 255, 255, 255, 200); buffer.vertex(r + cubeSize, r + cubeSize, r).texture(4*8/64f, 8/64f).color(255, 255, 255, 200).next();
BufferBuilder_addPosTexCol(r + cubeSize, r, r, 4*8/64f, 2*8/64f, 255, 255, 255, 200); buffer.vertex(r + cubeSize, r, r).texture(4*8/64f, 2*8/64f).color(255, 255, 255, 200).next();
BufferBuilder_addPosTexCol(r, r, r, 3*8/64f, 2*8/64f, 255, 255, 255, 200); buffer.vertex(r, r, r).texture(3*8/64f, 2*8/64f).color(255, 255, 255, 200).next();
//front //front
BufferBuilder_addPosTexCol(r + cubeSize, r, r + cubeSize, 2 * 8 / 64f, 2*8/64f, 255, 255, 255, 200); buffer.vertex(r + cubeSize, r, r + cubeSize).texture(2 * 8 / 64f, 2*8/64f).color(255, 255, 255, 200).next();
BufferBuilder_addPosTexCol(r + cubeSize, r + cubeSize, r + cubeSize, 2 * 8 / 64f, 8/64f, 255, 255, 255, 200); buffer.vertex(r + cubeSize, r + cubeSize, r + cubeSize).texture(2 * 8 / 64f, 8/64f).color(255, 255, 255, 200).next();
BufferBuilder_addPosTexCol(r, r + cubeSize, r + cubeSize, 8 / 64f, 8 / 64f, 255, 255, 255, 200); buffer.vertex(r, r + cubeSize, r + cubeSize).texture(8 / 64f, 8 / 64f).color(255, 255, 255, 200).next();
BufferBuilder_addPosTexCol(r, r, r + cubeSize, 8 / 64f, 2*8/64f, 255, 255, 255, 200); buffer.vertex(r, r, r + cubeSize).texture(8 / 64f, 2*8/64f).color(255, 255, 255, 200).next();
//left //left
BufferBuilder_addPosTexCol(r + cubeSize, r + cubeSize, r, 0, 8/64f, 255, 255, 255, 200); buffer.vertex(r + cubeSize, r + cubeSize, r).texture(0, 8/64f).color(255, 255, 255, 200).next();
BufferBuilder_addPosTexCol(r + cubeSize, r + cubeSize, r + cubeSize, 8/64f, 8/64f, 255, 255, 255, 200); buffer.vertex(r + cubeSize, r + cubeSize, r + cubeSize).texture(8/64f, 8/64f).color(255, 255, 255, 200).next();
BufferBuilder_addPosTexCol(r + cubeSize, r, r + cubeSize, 8/64f, 2*8/64f, 255, 255, 255, 200); buffer.vertex(r + cubeSize, r, r + cubeSize).texture(8/64f, 2*8/64f).color(255, 255, 255, 200).next();
BufferBuilder_addPosTexCol(r+cubeSize, r, r, 0, 2*8/64f, 255, 255, 255, 200); buffer.vertex(r+cubeSize, r, r).texture(0, 2*8/64f).color(255, 255, 255, 200).next();
//right //right
BufferBuilder_addPosTexCol(r, r + cubeSize, r + cubeSize, 2*8/64f, 8/64f, 255, 255, 255, 200); buffer.vertex(r, r + cubeSize, r + cubeSize).texture(2*8/64f, 8/64f).color(255, 255, 255, 200).next();
BufferBuilder_addPosTexCol(r, r + cubeSize, r, 3*8/64f, 8/64f, 255, 255, 255, 200); buffer.vertex(r, r + cubeSize, r).texture(3*8/64f, 8/64f).color(255, 255, 255, 200).next();
BufferBuilder_addPosTexCol(r, r, r, 3*8/64f, 2*8/64f, 255, 255, 255, 200); buffer.vertex(r, r, r).texture(3*8/64f, 2*8/64f).color(255, 255, 255, 200).next();
BufferBuilder_addPosTexCol(r, r, r + cubeSize, 2 * 8 / 64f, 2 * 8 / 64f, 255, 255, 255, 200); buffer.vertex(r, r, r + cubeSize).texture(2 * 8 / 64f, 2 * 8 / 64f).color(255, 255, 255, 200).next();
//bottom //bottom
BufferBuilder_addPosTexCol(r + cubeSize, r, r, 3*8/64f, 0, 255, 255, 255, 200); buffer.vertex(r + cubeSize, r, r).texture(3*8/64f, 0).color(255, 255, 255, 200).next();
BufferBuilder_addPosTexCol(r + cubeSize, r, r + cubeSize, 3*8/64f, 8/64f, 255, 255, 255, 200); buffer.vertex(r + cubeSize, r, r + cubeSize).texture(3*8/64f, 8/64f).color(255, 255, 255, 200).next();
BufferBuilder_addPosTexCol(r, r, r + cubeSize, 2*8/64f, 8/64f, 255, 255, 255, 200); buffer.vertex(r, r, r + cubeSize).texture(2*8/64f, 8/64f).color(255, 255, 255, 200).next();
BufferBuilder_addPosTexCol(r, r, r, 2 * 8 / 64f, 0, 255, 255, 255, 200); buffer.vertex(r, r, r).texture(2 * 8 / 64f, 0).color(255, 255, 255, 200).next();
//top //top
BufferBuilder_addPosTexCol(r, r + cubeSize, r, 8/64f, 0, 255, 255, 255, 200); buffer.vertex(r, r + cubeSize, r).texture(8/64f, 0).color(255, 255, 255, 200).next();
BufferBuilder_addPosTexCol(r, r + cubeSize, r + cubeSize, 8/64f, 8/64f, 255, 255, 255, 200); buffer.vertex(r, r + cubeSize, r + cubeSize).texture(8/64f, 8/64f).color(255, 255, 255, 200).next();
BufferBuilder_addPosTexCol(r + cubeSize, r + cubeSize, r + cubeSize, 2*8/64f, 8/64f, 255, 255, 255, 200); buffer.vertex(r + cubeSize, r + cubeSize, r + cubeSize).texture(2*8/64f, 8/64f).color(255, 255, 255, 200).next();
BufferBuilder_addPosTexCol(r + cubeSize, r + cubeSize, r, 2 * 8 / 64f, 0, 255, 255, 255, 200); buffer.vertex(r + cubeSize, r + cubeSize, r).texture(2 * 8 / 64f, 0).color(255, 255, 255, 200).next();
Tessellator_getInstance().draw(); tessellator.draw();
GL11.glPopMatrix(); GL11.glPopMatrix();
} }

View File

@@ -1,5 +1,6 @@
package com.replaymod.compat.oranges17animations; package com.replaymod.compat.oranges17animations;
import com.replaymod.core.ReplayMod;
import com.replaymod.replay.camera.CameraEntity; import com.replaymod.replay.camera.CameraEntity;
import de.johni0702.minecraft.gui.utils.EventRegistrations; import de.johni0702.minecraft.gui.utils.EventRegistrations;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@@ -7,8 +8,6 @@ import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import static com.replaymod.core.versions.MCVer.*;
/** /**
* Orange seems to have copied vast parts of the RendererLivingEntity into their ArmorAnimation class which cancels the RenderLivingEvent.Pre and calls its own code instead. * Orange seems to have copied vast parts of the RendererLivingEntity into their ArmorAnimation class which cancels the RenderLivingEvent.Pre and calls its own code instead.
* This breaks our mixin which assures that, even though the camera is in spectator mode, it cannot see invisible entities. * This breaks our mixin which assures that, even though the camera is in spectator mode, it cannot see invisible entities.
@@ -17,12 +16,12 @@ import static com.replaymod.core.versions.MCVer.*;
*/ */
public class HideInvisibleEntities extends EventRegistrations { public class HideInvisibleEntities extends EventRegistrations {
private final Minecraft mc = Minecraft.getMinecraft(); private final Minecraft mc = Minecraft.getMinecraft();
private final boolean modLoaded = isModLoaded("animations"); private final boolean modLoaded = ReplayMod.instance.isModLoaded("animations");
@SubscribeEvent(priority = EventPriority.HIGH) @SubscribeEvent(priority = EventPriority.HIGH)
public void preRenderLiving(RenderLivingEvent.Pre event) { public void preRenderLiving(RenderLivingEvent.Pre event) {
if (modLoaded) { if (modLoaded) {
if (mc.player instanceof CameraEntity && getEntity(event).isInvisible()) { if (mc.player instanceof CameraEntity && event.getEntity().isInvisible()) {
event.setCanceled(true); event.setCanceled(true);
} }
} }

View File

@@ -61,6 +61,14 @@ public class ReplayModBackend {
return Loader.instance().getIndexedModList().get(MOD_ID).getVersion(); return Loader.instance().getIndexedModList().get(MOD_ID).getVersion();
} }
public String getMinecraftVersion() {
return Loader.MC_VERSION;
}
public boolean isModLoaded(String id) {
return Loader.isModLoaded(id);
}
static { // Note: even preInit is too late and we'd have to issue another resource reload static { // Note: even preInit is too late and we'd have to issue another resource reload
List<IResourcePack> defaultResourcePacks = ((MinecraftAccessor) getMinecraft()).getDefaultResourcePacks(); List<IResourcePack> defaultResourcePacks = ((MinecraftAccessor) getMinecraft()).getDefaultResourcePacks();

View File

@@ -0,0 +1,9 @@
package com.replaymod.core.versions;
import org.lwjgl.opengl.Display;
public class GLFW {
public static boolean glfwWindowShouldClose(@SuppressWarnings("unused") long handle) {
return Display.isCloseRequested();
}
}

View File

@@ -0,0 +1,69 @@
package com.replaymod.core.versions;
import com.replaymod.render.mixin.MainWindowAccessor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import org.lwjgl.opengl.Display;
public class Window implements MainWindowAccessor {
private final Minecraft mc;
private ScaledResolution scaledResolution;
public Window(Minecraft mc) {
this.mc = mc;
}
@Override
public int getFramebufferWidth() {
return mc.displayWidth;
}
@Override
public void setFramebufferWidth(int value) {
mc.displayWidth = value;
}
@Override
public int getFramebufferHeight() {
return mc.displayHeight;
}
@Override
public void setFramebufferHeight(int value) {
mc.displayHeight = value;
}
public long getHandle() {
return 0;
}
public int getWidth() {
return Display.getWidth();
}
public int getHeight() {
return Display.getHeight();
}
private ScaledResolution scaledResolution() {
ScaledResolution scaledResolution = this.scaledResolution;
if (scaledResolution == null) {
//#if MC>=10809
scaledResolution = new ScaledResolution(mc);
//#else
//$$ scaledResolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
//#endif
this.scaledResolution = scaledResolution;
}
return scaledResolution;
}
public int getScaledWidth() {
return scaledResolution().getScaledWidth();
}
public int getScaledHeight() {
return scaledResolution().getScaledWidth();
}
}

View File

@@ -55,7 +55,7 @@ public class EventsAdapter extends EventRegistrations {
@SubscribeEvent @SubscribeEvent
public void preRenderGameOverlay(RenderGameOverlayEvent.Pre event) { public void preRenderGameOverlay(RenderGameOverlayEvent.Pre event) {
Boolean result = null; Boolean result = null;
switch (MCVer.getType(event)) { switch (event.getType()) {
case CROSSHAIRS: case CROSSHAIRS:
result = RenderSpectatorCrosshairCallback.EVENT.invoker().shouldRenderSpectatorCrosshair(); result = RenderSpectatorCrosshairCallback.EVENT.invoker().shouldRenderSpectatorCrosshair();
break; break;

View File

@@ -0,0 +1,47 @@
package com.replaymod.core.versions.forge;
import com.replaymod.gradle.remap.Pattern;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.EntityLivingBase;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderLivingEvent;
class Patterns {
@Pattern
private static GuiButton getButton(GuiScreenEvent.ActionPerformedEvent event) {
//#if MC>=10904
return event.getButton();
//#else
//$$ return event.button;
//#endif
}
@Pattern
private static GuiScreen getGui(GuiScreenEvent event) {
//#if MC>=10904
return event.getGui();
//#else
//$$ return event.gui;
//#endif
}
@Pattern
private static EntityLivingBase getEntity(RenderLivingEvent event) {
//#if MC>=10904
return event.getEntity();
//#else
//$$ return event.entity;
//#endif
}
@Pattern
private static RenderGameOverlayEvent.ElementType getType(RenderGameOverlayEvent event) {
//#if MC>=10904
return event.getType();
//#else
//$$ return event.type;
//#endif
}
}

View File

@@ -16,6 +16,9 @@ net.minecraft.network.play.server.SPacketEntity.Move net.minecraft.network.play.
net.minecraftforge.fml.network.NetworkRegistry net.minecraftforge.fml.common.network.NetworkRegistry net.minecraftforge.fml.network.NetworkRegistry net.minecraftforge.fml.common.network.NetworkRegistry
net.minecraft.client.particle.ParticleManager queue queueEntityFX net.minecraft.client.particle.ParticleManager queue queueEntityFX
org.apache.maven.artifact.versioning.ComparableVersion net.minecraftforge.fml.common.versioning.ComparableVersion org.apache.maven.artifact.versioning.ComparableVersion net.minecraftforge.fml.common.versioning.ComparableVersion
org.lwjgl.glfw.GLFW com.replaymod.core.versions.GLFW
net.minecraft.client.MainWindow com.replaymod.core.versions.Window
net.minecraft.client.audio.SimpleSound net.minecraft.client.audio.PositionedSoundRecord
net.minecraft.resources.FolderPack getInputStream() getInputStreamByName() net.minecraft.resources.FolderPack getInputStream() getInputStreamByName()
net.minecraft.client.gui.GuiYesNoCallback confirmResult() confirmClicked() net.minecraft.client.gui.GuiYesNoCallback confirmResult() confirmClicked()

View File

@@ -1,5 +1,6 @@
package com.replaymod.core; package com.replaymod.core;
import net.minecraft.client.Minecraft;
import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.ModList;
import static com.replaymod.core.ReplayMod.MOD_ID; import static com.replaymod.core.ReplayMod.MOD_ID;
@@ -8,4 +9,12 @@ public class ReplayModBackend {
public String getVersion() { public String getVersion() {
return ModList.get().getModContainerById(MOD_ID).get().getModInfo().getVersion().toString(); return ModList.get().getModContainerById(MOD_ID).get().getModInfo().getVersion().toString();
} }
public String getMinecraftVersion() {
return Minecraft.getInstance().getMinecraftGame().getVersion().getName();
}
public boolean isModLoaded(String id) {
return ModList.get().isLoaded(id.toLowerCase());
}
} }

View File

@@ -0,0 +1,30 @@
package com.replaymod.core.versions;
import net.minecraft.client.renderer.Tessellator;
public class BufferBuilder {
private final Tessellator inner;
public BufferBuilder(Tessellator inner) {
this.inner = inner;
}
public void startDrawing(int glQuads) {
inner.startDrawing(glQuads);
}
public void addVertexWithUV(double x, double y, double z, float u, float v) {
inner.addVertexWithUV(x, y, z, u, v);
}
public void setColorRGBA(int r, int g, int b, int a) {
inner.setColorRGBA(r, g, b, a);
}
public void addVertex(double x, double y, double z) {
inner.addVertex(x, y, z);
}
public static class VertexFormats {}
}

View File

@@ -36,3 +36,5 @@ net.minecraft.client.renderer.tileentity.TileEntityEndPortalRenderer net.minecra
net.minecraft.network.play.server.S3FPacketCustomPayload getChannelName() func_149169_c() net.minecraft.network.play.server.S3FPacketCustomPayload getChannelName() func_149169_c()
net.minecraft.network.play.server.S01PacketJoinGame getEntityId() func_149197_c() net.minecraft.network.play.server.S01PacketJoinGame getEntityId() func_149197_c()
net.minecraft.client.network.NetHandlerLoginClient networkManager field_147393_d net.minecraft.client.network.NetHandlerLoginClient networkManager field_147393_d
net.minecraft.client.renderer.WorldRenderer com.replaymod.core.versions.BufferBuilder
net.minecraft.client.renderer.vertex.DefaultVertexFormats com.replaymod.core.versions.BufferBuilder.VertexFormats

View File

@@ -20,6 +20,7 @@ net.minecraft.network.play.server.SPacketSpawnMob dataManager field_149043_l
net.minecraft.network.play.server.SPacketSpawnMob getDataManagerEntries() func_149027_c() net.minecraft.network.play.server.SPacketSpawnMob getDataManagerEntries() func_149027_c()
net.minecraft.network.play.server.SPacketSpawnPlayer getDataManagerEntries() func_148944_c() net.minecraft.network.play.server.SPacketSpawnPlayer getDataManagerEntries() func_148944_c()
net.minecraft.client.multiplayer.ServerList saveSingleServer() func_147414_b() net.minecraft.client.multiplayer.ServerList saveSingleServer() func_147414_b()
net.minecraft.util.SoundEvent com.replaymod.core.versions.MCVer.SoundEvent
net.minecraft.network.play.server.SPacketJoinGame net.minecraft.network.play.server.S01PacketJoinGame net.minecraft.network.play.server.SPacketJoinGame net.minecraft.network.play.server.S01PacketJoinGame
net.minecraft.network.play.server.SPacketChat net.minecraft.network.play.server.S02PacketChat net.minecraft.network.play.server.SPacketChat net.minecraft.network.play.server.S02PacketChat