Compare commits
18 Commits
1.11-2.0.0
...
1.8-2.0.0-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ffeb010d5 | ||
|
|
c122d30065 | ||
|
|
27fd25ae84 | ||
|
|
db6b0ff5a6 | ||
|
|
d61d0ac670 | ||
|
|
f7460f9bf5 | ||
|
|
bdbffd5c33 | ||
|
|
5cbfd2884e | ||
|
|
6095aef3d1 | ||
|
|
64898ce288 | ||
|
|
70e3e54038 | ||
|
|
3f2b3d62f7 | ||
|
|
d2def94fc1 | ||
|
|
2c64030459 | ||
|
|
4deb374a7f | ||
|
|
5302bcaed4 | ||
|
|
057edccf26 | ||
|
|
cd16211309 |
@@ -7,7 +7,7 @@ pipeline:
|
|||||||
commands:
|
commands:
|
||||||
- curl --fail --create-dirs -o $HOME/.gradle/init.d/mirror.gradle https://maven.johni0702.de/config/gradle
|
- curl --fail --create-dirs -o $HOME/.gradle/init.d/mirror.gradle https://maven.johni0702.de/config/gradle
|
||||||
- curl --fail --create-dirs -o $HOME/.m2/settings.xml https://maven.johni0702.de/config/maven
|
- curl --fail --create-dirs -o $HOME/.m2/settings.xml https://maven.johni0702.de/config/maven
|
||||||
- JAVA_OPTS=-Xmx1516M ./gradlew setupDecompWorkspace
|
- ./gradlew setupCIWorkspace
|
||||||
- ./gradlew :build
|
- ./gradlew :build
|
||||||
archive:
|
archive:
|
||||||
image: plugins/s3
|
image: plugins/s3
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
eyJhbGciOiJIUzI1NiJ9.cGlwZWxpbmU6CiAgY2xvbmU6CiAgICBpbWFnZTogcGx1Z2lucy9naXQKICAgIHRhZ3M6IHRydWUKICBidWlsZDoKICAgIGltYWdlOiBtYXZlbjozLjMuOS1qZGstOAogICAgY29tbWFuZHM6CiAgICAgIC0gY3VybCAtLWZhaWwgLS1jcmVhdGUtZGlycyAtbyAkSE9NRS8uZ3JhZGxlL2luaXQuZC9taXJyb3IuZ3JhZGxlIGh0dHBzOi8vbWF2ZW4uam9obmkwNzAyLmRlL2NvbmZpZy9ncmFkbGUKICAgICAgLSBjdXJsIC0tZmFpbCAtLWNyZWF0ZS1kaXJzIC1vICRIT01FLy5tMi9zZXR0aW5ncy54bWwgaHR0cHM6Ly9tYXZlbi5qb2huaTA3MDIuZGUvY29uZmlnL21hdmVuCiAgICAgIC0gSkFWQV9PUFRTPS1YbXgxNTE2TSAuL2dyYWRsZXcgc2V0dXBEZWNvbXBXb3Jrc3BhY2UKICAgICAgLSAuL2dyYWRsZXcgOmJ1aWxkCiAgYXJjaGl2ZToKICAgIGltYWdlOiBwbHVnaW5zL3MzCiAgICBhY2w6IHB1YmxpYy1yZWFkCiAgICByZWdpb246ICJ1cy1lYXN0LTEiCiAgICBidWNrZXQ6ICJyZXBsYXltb2QiCiAgICBwYXRoX3N0eWxlOiB0cnVlCiAgICBzb3VyY2U6IGJ1aWxkL2xpYnMvKgogICAgc3RyaXBfcHJlZml4OiBidWlsZC9saWJzLwogICAgdGFyZ2V0OiAvCg.nzPW0_TpMIjnFZZ5Ci439QDKlaDo1a3DCH-VCYUgpx8
|
eyJhbGciOiJIUzI1NiJ9.cGlwZWxpbmU6CiAgY2xvbmU6CiAgICBpbWFnZTogcGx1Z2lucy9naXQKICAgIHRhZ3M6IHRydWUKICBidWlsZDoKICAgIGltYWdlOiBtYXZlbjozLjMuOS1qZGstOAogICAgY29tbWFuZHM6CiAgICAgIC0gY3VybCAtLWZhaWwgLS1jcmVhdGUtZGlycyAtbyAkSE9NRS8uZ3JhZGxlL2luaXQuZC9taXJyb3IuZ3JhZGxlIGh0dHBzOi8vbWF2ZW4uam9obmkwNzAyLmRlL2NvbmZpZy9ncmFkbGUKICAgICAgLSBjdXJsIC0tZmFpbCAtLWNyZWF0ZS1kaXJzIC1vICRIT01FLy5tMi9zZXR0aW5ncy54bWwgaHR0cHM6Ly9tYXZlbi5qb2huaTA3MDIuZGUvY29uZmlnL21hdmVuCiAgICAgIC0gLi9ncmFkbGV3IHNldHVwQ0lXb3Jrc3BhY2UKICAgICAgLSAuL2dyYWRsZXcgOmJ1aWxkCiAgYXJjaGl2ZToKICAgIGltYWdlOiBwbHVnaW5zL3MzCiAgICBhY2w6IHB1YmxpYy1yZWFkCiAgICByZWdpb246ICJ1cy1lYXN0LTEiCiAgICBidWNrZXQ6ICJyZXBsYXltb2QiCiAgICBwYXRoX3N0eWxlOiB0cnVlCiAgICBzb3VyY2U6IGJ1aWxkL2xpYnMvKgogICAgc3RyaXBfcHJlZml4OiBidWlsZC9saWJzLwogICAgdGFyZ2V0OiAvCg.riE6lhwfdNUhI7LO2SxEKFOjzjaX40ne7Ae9gyP75KE
|
||||||
Submodule ReplayStudio updated: 1c794f3fd5...c615476693
@@ -19,8 +19,8 @@ buildscript {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT'
|
||||||
classpath 'org.spongepowered:mixingradle:0.4-SNAPSHOT'
|
classpath 'org.spongepowered:mixingradle:0.3-SNAPSHOT'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,9 +36,9 @@ archivesBaseName = "replaymod"
|
|||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
coreMod = 'com.replaymod.core.LoadingPlugin'
|
coreMod = 'com.replaymod.core.LoadingPlugin'
|
||||||
version = '1.11-13.19.1.2188'
|
version = '1.8-11.14.4.1563'
|
||||||
runDir = "eclipse"
|
runDir = "eclipse"
|
||||||
mappings = "snapshot_20161111"
|
mappings = "snapshot_nodoc_20141130"
|
||||||
replace '@MOD_VERSION@', project.version
|
replace '@MOD_VERSION@', project.version
|
||||||
replace '@MC_VERSION@', project.minecraft.version
|
replace '@MC_VERSION@', project.minecraft.version
|
||||||
}
|
}
|
||||||
@@ -138,7 +138,6 @@ jar {
|
|||||||
manifest {
|
manifest {
|
||||||
attributes 'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
|
attributes 'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
|
||||||
'TweakOrder': '0',
|
'TweakOrder': '0',
|
||||||
'FMLCorePluginContainsFMLMod': 'true',
|
|
||||||
'FMLAT': 'replaymod_at.cfg'
|
'FMLAT': 'replaymod_at.cfg'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ Please use [Optifine](https://optifine.net/) instead.
|
|||||||
|
|
||||||
### Custom Main Menu [custom-main-menu]
|
### Custom Main Menu [custom-main-menu]
|
||||||
The [Custom Main Menu](https://mods.curse.com/mc-mods/minecraft/226406-custom-main-menu) mod is often used in mod packs to customize their Main Menu with a button layout fitting the background image, links to their website / bug tracker and similar.
|
The [Custom Main Menu](https://mods.curse.com/mc-mods/minecraft/226406-custom-main-menu) mod is often used in mod packs to customize their Main Menu with a button layout fitting the background image, links to their website / bug tracker and similar.
|
||||||
If you are familiar with it, the button ids for the Replay Mod are: **17890234** (text: `replaymod.gui.replayviewer`), **17890235** (text: `replaymod.gui.replayviewer`) and **17890236** (text: `replaymod.gui.replaycenter`)
|
If you are familiar with it, the button ids for the Replay Mod are: **17890234** (text: `replaymod.gui.replayviewer`), **17890237** (text: `replaymod.gui.replayeditor`) and **17890236** (text: `replaymod.gui.replaycenter`)
|
||||||
|
|
||||||
Due to the nature of this Custom Main Menu mod, buttons added to the Main Menu by 3rd party mods like the **Replay Mod** will not show up by default.
|
Due to the nature of this Custom Main Menu mod, buttons added to the Main Menu by 3rd party mods like the **Replay Mod** will not show up by default.
|
||||||
Thus, to access the Replay Viewer/Editor/Center, you need to manually configure the position for those buttons.
|
Thus, to access the Replay Viewer/Editor/Center, you need to manually configure the position for those buttons.
|
||||||
|
|||||||
2
jGui
2
jGui
Submodule jGui updated: 33c65436f0...a77d2f3f50
@@ -2,7 +2,7 @@ package com.replaymod.compat;
|
|||||||
|
|
||||||
import com.replaymod.compat.optifine.DisableFastRender;
|
import com.replaymod.compat.optifine.DisableFastRender;
|
||||||
import com.replaymod.compat.shaders.ShaderBeginRender;
|
import com.replaymod.compat.shaders.ShaderBeginRender;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.EventBus;
|
import net.minecraftforge.fml.common.eventhandler.EventBus;
|
||||||
@@ -16,7 +16,7 @@ public class ReplayModCompat {
|
|||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void init(FMLInitializationEvent event) {
|
public void init(FMLInitializationEvent event) {
|
||||||
EventBus bus = MinecraftForge.EVENT_BUS;
|
EventBus bus = FMLCommonHandler.instance().bus();
|
||||||
bus.register(new ShaderBeginRender());
|
bus.register(new ShaderBeginRender());
|
||||||
bus.register(new DisableFastRender());
|
bus.register(new DisableFastRender());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class KeyBindingRegistry {
|
public class KeyBindingRegistry {
|
||||||
private Map<String, KeyBinding> keyBindings = new HashMap<String, KeyBinding>();
|
private Map<String, KeyBinding> keyBindings = new HashMap<String, KeyBinding>();
|
||||||
@@ -85,7 +86,7 @@ public class KeyBindingRegistry {
|
|||||||
CrashReport crashReport = CrashReport.makeCrashReport(cause, "Handling Key Binding");
|
CrashReport crashReport = CrashReport.makeCrashReport(cause, "Handling Key Binding");
|
||||||
CrashReportCategory category = crashReport.makeCategory("Key Binding");
|
CrashReportCategory category = crashReport.makeCategory("Key Binding");
|
||||||
category.addCrashSection("Key Binding", keyBinding);
|
category.addCrashSection("Key Binding", keyBinding);
|
||||||
category.setDetail("Handler", runnable::toString);
|
category.addCrashSectionCallable("Handler", runnable::toString);
|
||||||
throw new ReportedException(crashReport);
|
throw new ReportedException(crashReport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,7 +101,12 @@ public class KeyBindingRegistry {
|
|||||||
CrashReport crashReport = CrashReport.makeCrashReport(cause, "Handling Raw Key Binding");
|
CrashReport crashReport = CrashReport.makeCrashReport(cause, "Handling Raw Key Binding");
|
||||||
CrashReportCategory category = crashReport.makeCategory("Key Binding");
|
CrashReportCategory category = crashReport.makeCategory("Key Binding");
|
||||||
category.addCrashSection("Key Code", keyCode);
|
category.addCrashSection("Key Code", keyCode);
|
||||||
category.setDetail("Handler", runnable::toString);
|
category.addCrashSectionCallable("Handler", new Callable() {
|
||||||
|
@Override
|
||||||
|
public Object call() throws Exception {
|
||||||
|
return runnable;
|
||||||
|
}
|
||||||
|
});
|
||||||
throw new ReportedException(crashReport);
|
throw new ReportedException(crashReport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import net.minecraftforge.fml.relauncher.CoreModManager;
|
|||||||
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
|
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.spongepowered.asm.launch.MixinBootstrap;
|
import org.spongepowered.asm.launch.MixinBootstrap;
|
||||||
import org.spongepowered.asm.mixin.Mixins;
|
import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
@@ -16,10 +16,10 @@ public class LoadingPlugin implements IFMLLoadingPlugin {
|
|||||||
|
|
||||||
public LoadingPlugin() {
|
public LoadingPlugin() {
|
||||||
MixinBootstrap.init();
|
MixinBootstrap.init();
|
||||||
Mixins.addConfiguration("mixins.recording.replaymod.json");
|
MixinEnvironment.getDefaultEnvironment().addConfiguration("mixins.recording.replaymod.json");
|
||||||
Mixins.addConfiguration("mixins.render.replaymod.json");
|
MixinEnvironment.getDefaultEnvironment().addConfiguration("mixins.render.replaymod.json");
|
||||||
Mixins.addConfiguration("mixins.replay.replaymod.json");
|
MixinEnvironment.getDefaultEnvironment().addConfiguration("mixins.replay.replaymod.json");
|
||||||
Mixins.addConfiguration("mixins.compat.shaders.replaymod.json");
|
MixinEnvironment.getDefaultEnvironment().addConfiguration("mixins.compat.shaders.replaymod.json");
|
||||||
|
|
||||||
CodeSource codeSource = getClass().getProtectionDomain().getCodeSource();
|
CodeSource codeSource = getClass().getProtectionDomain().getCodeSource();
|
||||||
if (codeSource != null) {
|
if (codeSource != null) {
|
||||||
@@ -29,7 +29,7 @@ public class LoadingPlugin implements IFMLLoadingPlugin {
|
|||||||
if (file.isFile()) {
|
if (file.isFile()) {
|
||||||
// This forces forge to reexamine the jar file for FML mods
|
// This forces forge to reexamine the jar file for FML mods
|
||||||
// Should eventually be handled by Mixin itself, maybe?
|
// Should eventually be handled by Mixin itself, maybe?
|
||||||
CoreModManager.getIgnoredMods().remove(file.getName());
|
CoreModManager.getLoadedCoremods().remove(file.getName());
|
||||||
}
|
}
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.replaymod.core.gui.GuiReplaySettings;
|
|||||||
import com.replaymod.core.gui.RestoreReplayGui;
|
import com.replaymod.core.gui.RestoreReplayGui;
|
||||||
import com.replaymod.core.handler.MainMenuHandler;
|
import com.replaymod.core.handler.MainMenuHandler;
|
||||||
import com.replaymod.core.utils.OpenGLUtils;
|
import com.replaymod.core.utils.OpenGLUtils;
|
||||||
|
import com.replaymod.render.utils.SoundHandler;
|
||||||
import com.replaymod.replaystudio.util.I18n;
|
import com.replaymod.replaystudio.util.I18n;
|
||||||
import de.johni0702.minecraft.gui.container.GuiScreen;
|
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -13,11 +14,10 @@ import net.minecraft.client.Minecraft;
|
|||||||
import net.minecraft.client.settings.GameSettings;
|
import net.minecraft.client.settings.GameSettings;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
import net.minecraft.crash.CrashReportCategory;
|
import net.minecraft.crash.CrashReportCategory;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.*;
|
||||||
import net.minecraft.util.text.*;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||||
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraftforge.fml.common.Loader;
|
import net.minecraftforge.fml.common.Loader;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||||
@@ -31,6 +31,7 @@ import org.apache.commons.io.FileUtils;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Queue;
|
||||||
|
|
||||||
@Mod(modid = ReplayMod.MOD_ID,
|
@Mod(modid = ReplayMod.MOD_ID,
|
||||||
useMetadata = true,
|
useMetadata = true,
|
||||||
@@ -67,6 +68,8 @@ public class ReplayMod {
|
|||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static Configuration config;
|
public static Configuration config;
|
||||||
|
@Deprecated
|
||||||
|
public static SoundHandler soundHandler = new SoundHandler();
|
||||||
|
|
||||||
private final KeyBindingRegistry keyBindingRegistry = new KeyBindingRegistry();
|
private final KeyBindingRegistry keyBindingRegistry = new KeyBindingRegistry();
|
||||||
private final SettingsRegistry settingsRegistry = new SettingsRegistry();
|
private final SettingsRegistry settingsRegistry = new SettingsRegistry();
|
||||||
@@ -109,7 +112,7 @@ public class ReplayMod {
|
|||||||
|
|
||||||
new MainMenuHandler().register();
|
new MainMenuHandler().register();
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(keyBindingRegistry);
|
FMLCommonHandler.instance().bus().register(keyBindingRegistry);
|
||||||
|
|
||||||
getKeyBindingRegistry().registerKeyBinding("replaymod.input.settings", 0, () -> {
|
getKeyBindingRegistry().registerKeyBinding("replaymod.input.settings", 0, () -> {
|
||||||
new GuiReplaySettings(null, settingsRegistry).display();
|
new GuiReplaySettings(null, settingsRegistry).display();
|
||||||
@@ -123,7 +126,150 @@ public class ReplayMod {
|
|||||||
if(!FMLClientHandler.instance().hasOptifine())
|
if(!FMLClientHandler.instance().hasOptifine())
|
||||||
GameSettings.Options.RENDER_DISTANCE.setValueMax(64f);
|
GameSettings.Options.RENDER_DISTANCE.setValueMax(64f);
|
||||||
|
|
||||||
testIfMoeshAndExitMinecraft();
|
if (System.getProperty("replaymod.render.file") != null) {
|
||||||
|
final File file = new File(System.getProperty("replaymod.render.file"));
|
||||||
|
if (!file.exists()) {
|
||||||
|
throw new IOException("File \"" + file.getPath() + "\" not found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
final String path = System.getProperty("replaymod.render.path");
|
||||||
|
String type = System.getProperty("replaymod.render.type");
|
||||||
|
String bitrate = System.getProperty("replaymod.render.bitrate");
|
||||||
|
String fps = System.getProperty("replaymod.render.fps");
|
||||||
|
String waitForChunks = System.getProperty("replaymod.render.waitforchunks");
|
||||||
|
String linearMovement = System.getProperty("replaymod.render.linearmovement");
|
||||||
|
String skyColor = System.getProperty("replaymod.render.skycolor");
|
||||||
|
String width = System.getProperty("replaymod.render.width");
|
||||||
|
String height = System.getProperty("replaymod.render.height");
|
||||||
|
String exportCommand = System.getProperty("replaymod.render.exportcommand");
|
||||||
|
String exportCommandArgs = System.getProperty("replaymod.render.exportcommandargs");
|
||||||
|
/*
|
||||||
|
final RenderOptions options = new RenderOptions();
|
||||||
|
if (bitrate != null) {
|
||||||
|
options.setBitrate(bitrate);
|
||||||
|
}
|
||||||
|
if (fps != null) {
|
||||||
|
options.setFps(Integer.parseInt(fps));
|
||||||
|
}
|
||||||
|
if (waitForChunks != null) {
|
||||||
|
options.setWaitForChunks(Boolean.parseBoolean(waitForChunks));
|
||||||
|
}
|
||||||
|
if (linearMovement != null) {
|
||||||
|
options.setLinearMovement(Boolean.parseBoolean(linearMovement));
|
||||||
|
}
|
||||||
|
if (skyColor != null) {
|
||||||
|
if (skyColor.startsWith("0x")) {
|
||||||
|
options.setSkyColor(Integer.parseInt(skyColor.substring(2), 16));
|
||||||
|
} else {
|
||||||
|
options.setSkyColor(Integer.parseInt(skyColor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (width != null) {
|
||||||
|
options.setWidth(Integer.parseInt(width));
|
||||||
|
}
|
||||||
|
if (height != null) {
|
||||||
|
options.setHeight(Integer.parseInt(height));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exportCommand != null) {
|
||||||
|
options.setExportCommand(exportCommand);
|
||||||
|
}
|
||||||
|
if (exportCommandArgs != null) {
|
||||||
|
options.setExportCommandArgs(exportCommandArgs);
|
||||||
|
} else {
|
||||||
|
options.setExportCommandArgs(EncodingPreset.MP4DEFAULT.getCommandLineArgs());
|
||||||
|
}
|
||||||
|
|
||||||
|
options.setOutputFile(new File(String.valueOf(System.currentTimeMillis())));
|
||||||
|
|
||||||
|
Pipelines.Preset pipelinePreset = Pipelines.Preset.DEFAULT;
|
||||||
|
if (type != null) {
|
||||||
|
String[] parts = type.split(":");
|
||||||
|
type = parts[0].toUpperCase();
|
||||||
|
if ("NORMAL".equals(type) || "DEFAULT".equals(type)) {
|
||||||
|
pipelinePreset = Pipelines.Preset.DEFAULT;
|
||||||
|
} else if ("STEREO".equals(type) || "STEREOSCOPIC".equals(type)) {
|
||||||
|
pipelinePreset = Pipelines.Preset.STEREOSCOPIC;
|
||||||
|
} else if ("CUBIC".equals(type)) {
|
||||||
|
if (parts.length < 2) {
|
||||||
|
throw new IllegalArgumentException("Cubic renderer requires boolean for whether it's stable.");
|
||||||
|
}
|
||||||
|
pipelinePreset = Pipelines.Preset.CUBIC;
|
||||||
|
} else if ("EQUIRECTANGULAR".equals(type)) {
|
||||||
|
if (parts.length < 2) {
|
||||||
|
throw new IllegalArgumentException("Equirectangular renderer requires boolean for whether it's stable.");
|
||||||
|
}
|
||||||
|
pipelinePreset = Pipelines.Preset.EQUIRECTANGULAR;
|
||||||
|
} else if ("ODS".equals(type)) {
|
||||||
|
if (parts.length < 2) {
|
||||||
|
throw new IllegalArgumentException("ODS renderer requires boolean for whether it's stable.");
|
||||||
|
}
|
||||||
|
pipelinePreset = Pipelines.Preset.ODS;
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Unknown type: " + parts[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
options.setMode(pipelinePreset);
|
||||||
|
*/
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Queue<ListenableFutureTask> tasks = mc.scheduledTasks;
|
||||||
|
synchronized (mc.scheduledTasks) {
|
||||||
|
tasks.add(ListenableFutureTask.create(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
String renderDistance = System.getProperty("replaymod.render.mc.renderdistance");
|
||||||
|
String clouds = System.getProperty("replaymod.render.mc.clouds");
|
||||||
|
if (renderDistance != null) {
|
||||||
|
mc.gameSettings.renderDistanceChunks = Integer.parseInt(renderDistance);
|
||||||
|
}
|
||||||
|
if (clouds != null) {
|
||||||
|
mc.gameSettings.clouds = Boolean.parseBoolean(clouds);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Loading replay...");
|
||||||
|
// TODO
|
||||||
|
// try {
|
||||||
|
// ReplayHandler.startReplay(file, false);
|
||||||
|
// } catch (Throwable t) {
|
||||||
|
// t.printStackTrace();
|
||||||
|
// FMLCommonHandler.instance().exitJava(1, false);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// int index = 0;
|
||||||
|
// if (path != null) {
|
||||||
|
// for (KeyframeSet set : ReplayHandler.getKeyframeRepository()) {
|
||||||
|
// if (set.getName().equals(path)) {
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// index++;
|
||||||
|
// }
|
||||||
|
// if (index >= ReplayHandler.getKeyframeRepository().length) {
|
||||||
|
// throw new IllegalArgumentException("No path named \"" + path + "\".");
|
||||||
|
// }
|
||||||
|
// } else if (ReplayHandler.getKeyframeRepository().length == 0) {
|
||||||
|
// throw new IllegalArgumentException("Replay file has no paths defined.");
|
||||||
|
// }
|
||||||
|
// ReplayHandler.useKeyframePresetFromRepository(index);
|
||||||
|
//
|
||||||
|
// System.out.println("Rendering started...");
|
||||||
|
// try {
|
||||||
|
// ReplayProcess.startReplayProcess(options, true);
|
||||||
|
// } catch (Throwable t) {
|
||||||
|
// t.printStackTrace();
|
||||||
|
// FMLCommonHandler.instance().exitJava(1, false);
|
||||||
|
// }
|
||||||
|
// if (mc.hasCrashed) {
|
||||||
|
// System.out.println(mc.crashReporter.getCompleteReport());
|
||||||
|
// }
|
||||||
|
// System.out.println("Rendering done. Shutting down...");
|
||||||
|
// mc.shutdown();
|
||||||
|
}
|
||||||
|
}, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
testIfMoeshAndExitMinecraft();
|
||||||
|
}
|
||||||
|
|
||||||
runLater(() -> {
|
runLater(() -> {
|
||||||
// Cleanup deleted corrupted replays
|
// Cleanup deleted corrupted replays
|
||||||
@@ -160,8 +306,10 @@ public class ReplayMod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void runLater(Runnable runnable) {
|
public void runLater(Runnable runnable) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Queue<ListenableFutureTask> tasks = mc.scheduledTasks;
|
||||||
synchronized (mc.scheduledTasks) {
|
synchronized (mc.scheduledTasks) {
|
||||||
mc.scheduledTasks.add(ListenableFutureTask.create(runnable, null));
|
tasks.add(ListenableFutureTask.create(runnable, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,13 +338,13 @@ public class ReplayMod {
|
|||||||
private void printToChat(boolean warning, String message, Object... args) {
|
private void printToChat(boolean warning, String message, Object... args) {
|
||||||
if (getSettingsRegistry().get(Setting.NOTIFICATIONS)) {
|
if (getSettingsRegistry().get(Setting.NOTIFICATIONS)) {
|
||||||
// Some nostalgia: "§8[§6Replay Mod§8]§r Your message goes here"
|
// Some nostalgia: "§8[§6Replay Mod§8]§r Your message goes here"
|
||||||
Style coloredDarkGray = new Style().setColor(TextFormatting.DARK_GRAY);
|
ChatStyle coloredDarkGray = new ChatStyle().setColor(EnumChatFormatting.DARK_GRAY);
|
||||||
Style coloredGold = new Style().setColor(TextFormatting.GOLD);
|
ChatStyle coloredGold = new ChatStyle().setColor(EnumChatFormatting.GOLD);
|
||||||
ITextComponent text = new TextComponentString("[").setStyle(coloredDarkGray)
|
IChatComponent text = new ChatComponentText("[").setChatStyle(coloredDarkGray)
|
||||||
.appendSibling(new TextComponentTranslation("replaymod.title").setStyle(coloredGold))
|
.appendSibling(new ChatComponentTranslation("replaymod.title").setChatStyle(coloredGold))
|
||||||
.appendSibling(new TextComponentString("] "))
|
.appendSibling(new ChatComponentText("] "))
|
||||||
.appendSibling(new TextComponentTranslation(message, args).setStyle(new Style()
|
.appendSibling(new ChatComponentTranslation(message, args).setChatStyle(new ChatStyle()
|
||||||
.setColor(warning ? TextFormatting.RED : TextFormatting.DARK_GREEN)));
|
.setColor(warning ? EnumChatFormatting.RED : EnumChatFormatting.DARK_GREEN)));
|
||||||
// Send message to chat GUI
|
// Send message to chat GUI
|
||||||
// The ingame GUI is initialized at startup, therefore this is possible before the client is connected
|
// The ingame GUI is initialized at startup, therefore this is possible before the client is connected
|
||||||
mc.ingameGUI.getChatGUI().printChatMessage(text);
|
mc.ingameGUI.getChatGUI().printChatMessage(text);
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package com.replaymod.core;
|
|||||||
|
|
||||||
import com.replaymod.core.events.SettingsChangedEvent;
|
import com.replaymod.core.events.SettingsChangedEvent;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
@@ -83,7 +83,7 @@ public class SettingsRegistry {
|
|||||||
throw new IllegalArgumentException("Default type " + key.getDefault().getClass() + " not supported.");
|
throw new IllegalArgumentException("Default type " + key.getDefault().getClass() + " not supported.");
|
||||||
}
|
}
|
||||||
settings.put(key, value);
|
settings.put(key, value);
|
||||||
MinecraftForge.EVENT_BUS.post(new SettingsChangedEvent(this, key));
|
FMLCommonHandler.instance().bus().post(new SettingsChangedEvent(this, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.replaymod.core.gui;
|
|||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import com.replaymod.replaystudio.PacketData;
|
import com.replaymod.replaystudio.PacketData;
|
||||||
import com.replaymod.replaystudio.io.ReplayInputStream;
|
import com.replaymod.replaystudio.io.ReplayInputStream;
|
||||||
|
import com.replaymod.replaystudio.io.ReplayOutputStream;
|
||||||
import com.replaymod.replaystudio.replay.ReplayFile;
|
import com.replaymod.replaystudio.replay.ReplayFile;
|
||||||
import com.replaymod.replaystudio.replay.ReplayMetaData;
|
import com.replaymod.replaystudio.replay.ReplayMetaData;
|
||||||
import com.replaymod.replaystudio.replay.ZipReplayFile;
|
import com.replaymod.replaystudio.replay.ZipReplayFile;
|
||||||
@@ -45,15 +46,19 @@ public class RestoreReplayGui extends AbstractGuiScreen<RestoreReplayGui> {
|
|||||||
ReplayMetaData metaData = replayFile.getMetaData();
|
ReplayMetaData metaData = replayFile.getMetaData();
|
||||||
if (metaData != null && metaData.getDuration() == 0) {
|
if (metaData != null && metaData.getDuration() == 0) {
|
||||||
// Try to restore replay duration
|
// Try to restore replay duration
|
||||||
try (ReplayInputStream in = replayFile.getPacketData()) {
|
// We need to re-write the packet data in case there are any incomplete packets dangling at the end
|
||||||
|
try (ReplayInputStream in = replayFile.getPacketData();
|
||||||
|
ReplayOutputStream out = replayFile.writePacketData()) {
|
||||||
PacketData last = null;
|
PacketData last = null;
|
||||||
while ((last = in.readPacket()) != null) {
|
while ((last = in.readPacket()) != null) {
|
||||||
metaData.setDuration((int) last.getTime());
|
metaData.setDuration((int) last.getTime());
|
||||||
|
out.write(last);
|
||||||
}
|
}
|
||||||
replayFile.writeMetaData(metaData);
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
|
// Write back the actual duration
|
||||||
|
replayFile.writeMetaData(metaData);
|
||||||
}
|
}
|
||||||
replayFile.save();
|
replayFile.save();
|
||||||
replayFile.close();
|
replayFile.close();
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import net.minecraftforge.client.event.GuiScreenEvent;
|
|||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves certain buttons on the main menu upwards so we can inject our own.
|
* Moves certain buttons on the main menu upwards so we can inject our own.
|
||||||
*/
|
*/
|
||||||
@@ -16,12 +18,14 @@ public class MainMenuHandler {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onInit(GuiScreenEvent.InitGuiEvent.Post event) {
|
public void onInit(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||||
if (event.getGui() instanceof GuiMainMenu) {
|
if (event.gui instanceof GuiMainMenu) {
|
||||||
for (GuiButton button : event.getButtonList()) {
|
@SuppressWarnings("unchecked")
|
||||||
|
List<GuiButton> buttonList = event.buttonList;
|
||||||
|
for (GuiButton button : buttonList) {
|
||||||
// Buttons that aren't in a rectangle directly above our space don't need moving
|
// Buttons that aren't in a rectangle directly above our space don't need moving
|
||||||
if (button.xPosition + button.width < event.getGui().width / 2 - 100
|
if (button.xPosition + button.width < event.gui.width / 2 - 100
|
||||||
|| button.xPosition > event.getGui().width / 2 + 100
|
|| button.xPosition > event.gui.width / 2 + 100
|
||||||
|| button.yPosition > event.getGui().height / 4 + 10 + 4 * 24) continue;
|
|| button.yPosition > event.gui.height / 4 + 10 + 4 * 24) continue;
|
||||||
// Move button up to make space for two rows of buttons
|
// Move button up to make space for two rows of buttons
|
||||||
// and then move back down by 10 to compensate for the space to the exit button that was already there
|
// and then move back down by 10 to compensate for the space to the exit button that was already there
|
||||||
button.yPosition -= 2 * 24 - 10;
|
button.yPosition -= 2 * 24 - 10;
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ package com.replaymod.core.utils;
|
|||||||
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
import net.minecraft.client.renderer.VertexBuffer;
|
import net.minecraft.client.renderer.WorldRenderer;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
|
||||||
import org.lwjgl.BufferUtils;
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
@@ -35,14 +34,14 @@ public class OpenGLUtils {
|
|||||||
float f5 = 1.0F / textureHeight;
|
float f5 = 1.0F / textureHeight;
|
||||||
|
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
VertexBuffer vertexBuffer = tessellator.getBuffer();
|
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
||||||
GlStateManager.translate(x+(width/2), y+(width/2), 0);
|
GlStateManager.translate(x+(width/2), y+(width/2), 0);
|
||||||
GlStateManager.rotate(rotation, 0, 0, 1);
|
GlStateManager.rotate(rotation, 0, 0, 1);
|
||||||
vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
worldrenderer.startDrawingQuads();
|
||||||
vertexBuffer.pos(-width / 2, height / 2, 0.0D).tex((double) (u * f4), (double) ((v + (float) height) * f5)).endVertex();
|
worldrenderer.addVertexWithUV(-width / 2, height / 2, 0.0D, (double) (u * f4), (double) ((v + (float) height) * f5));
|
||||||
vertexBuffer.pos(width/2, height/2, 0.0D).tex((double)((u + (float)width) * f4), (double)((v + (float)height) * f5)).endVertex();
|
worldrenderer.addVertexWithUV(width/2, height/2, 0.0D, (double)((u + (float)width) * f4), (double)((v + (float)height) * f5));
|
||||||
vertexBuffer.pos(width/2, -height/2, 0.0D).tex((double)((u + (float)width) * f4), (double)(v * f5)).endVertex();
|
worldrenderer.addVertexWithUV(width/2, -height/2, 0.0D, (double)((u + (float)width) * f4), (double)(v * f5));
|
||||||
vertexBuffer.pos(-width/2, -height/2, 0.0D).tex((double)(u * f4), (double)(v * f5)).endVertex();
|
worldrenderer.addVertexWithUV(-width/2, -height/2, 0.0D, (double)(u * f4), (double)(v * f5));
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
|
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.replaymod.core.utils;
|
package com.replaymod.core.utils;
|
||||||
|
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraft.network.play.server.SPacketCustomPayload;
|
import net.minecraft.network.play.server.S3FPacketCustomPayload;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restrictions set by the server,
|
* Restrictions set by the server,
|
||||||
@@ -14,7 +14,7 @@ public class Restrictions {
|
|||||||
private boolean onlyFirstPerson;
|
private boolean onlyFirstPerson;
|
||||||
private boolean onlyRecordingPlayer;
|
private boolean onlyRecordingPlayer;
|
||||||
|
|
||||||
public String handle(SPacketCustomPayload packet) {
|
public String handle(S3FPacketCustomPayload packet) {
|
||||||
PacketBuffer buffer = packet.getBufferData();
|
PacketBuffer buffer = packet.getBufferData();
|
||||||
while (buffer.isReadable()) {
|
while (buffer.isReadable()) {
|
||||||
String name = buffer.readStringFromBuffer(64);
|
String name = buffer.readStringFromBuffer(64);
|
||||||
|
|||||||
@@ -27,8 +27,20 @@ import org.lwjgl.util.ReadableDimension;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.net.ssl.SSLContext;
|
||||||
|
import javax.net.ssl.SSLSocketFactory;
|
||||||
|
import javax.net.ssl.TrustManagerFactory;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.security.KeyManagementException;
|
||||||
|
import java.security.KeyStore;
|
||||||
|
import java.security.KeyStoreException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.cert.Certificate;
|
||||||
|
import java.security.cert.CertificateException;
|
||||||
|
import java.security.cert.CertificateFactory;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -51,6 +63,42 @@ public class Utils {
|
|||||||
DEFAULT_THUMBNAIL = thumbnail;
|
DEFAULT_THUMBNAIL = thumbnail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Neither the root certificate of LetsEncrypt nor the root that cross-signed it is included in the default
|
||||||
|
* Java keystore prior to 8u101.
|
||||||
|
* Therefore whenever a connection to the replaymod.com site is made, this SSLContext has to be used instead.
|
||||||
|
* It has been constructed to include the necessary root certificates.
|
||||||
|
* @see #SSL_SOCKET_FACTORY
|
||||||
|
*/
|
||||||
|
public static final SSLContext SSL_CONTEXT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see #SSL_CONTEXT
|
||||||
|
*/
|
||||||
|
public static final SSLSocketFactory SSL_SOCKET_FACTORY;
|
||||||
|
|
||||||
|
static {
|
||||||
|
// Largely from https://community.letsencrypt.org/t/134/37
|
||||||
|
try (InputStream in = Utils.class.getResourceAsStream("/dst_root_ca_x3.pem")){
|
||||||
|
Certificate certificate = CertificateFactory.getInstance("X.509").generateCertificate(in);
|
||||||
|
|
||||||
|
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||||
|
keyStore.load(null, null);
|
||||||
|
keyStore.setCertificateEntry("1", certificate);
|
||||||
|
|
||||||
|
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||||
|
trustManagerFactory.init(keyStore);
|
||||||
|
|
||||||
|
SSLContext ctx = SSLContext.getInstance("TLS");
|
||||||
|
ctx.init(null, trustManagerFactory.getTrustManagers(), null);
|
||||||
|
SSL_CONTEXT = ctx;
|
||||||
|
SSL_SOCKET_FACTORY = ctx.getSocketFactory();
|
||||||
|
} catch (IOException | CertificateException | KeyStoreException | NoSuchAlgorithmException | KeyManagementException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String convertSecondsToShortString(int seconds) {
|
public static String convertSecondsToShortString(int seconds) {
|
||||||
int hours = seconds/(60*60);
|
int hours = seconds/(60*60);
|
||||||
int min = seconds/60 - hours*60;
|
int min = seconds/60 - hours*60;
|
||||||
@@ -87,7 +135,7 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ResourceLocation getResourceLocationForPlayerUUID(UUID uuid) {
|
public static ResourceLocation getResourceLocationForPlayerUUID(UUID uuid) {
|
||||||
NetworkPlayerInfo info = getMinecraft().getConnection().getPlayerInfo(uuid);
|
NetworkPlayerInfo info = getMinecraft().getNetHandler().getPlayerInfo(uuid);
|
||||||
ResourceLocation skinLocation;
|
ResourceLocation skinLocation;
|
||||||
if (info != null && info.hasLocationSkin()) {
|
if (info != null && info.hasLocationSkin()) {
|
||||||
skinLocation = info.getLocationSkin();
|
skinLocation = info.getLocationSkin();
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class WrappedTimer extends Timer {
|
|||||||
to.elapsedPartialTicks = from.elapsedPartialTicks;
|
to.elapsedPartialTicks = from.elapsedPartialTicks;
|
||||||
to.lastSyncSysClock = from.lastSyncSysClock;
|
to.lastSyncSysClock = from.lastSyncSysClock;
|
||||||
to.lastSyncHRClock = from.lastSyncHRClock;
|
to.lastSyncHRClock = from.lastSyncHRClock;
|
||||||
to.counter = from.counter;
|
to.field_74285_i = from.field_74285_i;
|
||||||
to.timeSyncAdjustment = from.timeSyncAdjustment;
|
to.timeSyncAdjustment = from.timeSyncAdjustment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.replaymod.editor.gui;
|
package com.replaymod.editor.gui;
|
||||||
|
|
||||||
|
import com.google.common.io.Files;
|
||||||
import com.google.common.util.concurrent.FutureCallback;
|
import com.google.common.util.concurrent.FutureCallback;
|
||||||
import com.google.common.util.concurrent.Futures;
|
import com.google.common.util.concurrent.Futures;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
@@ -34,6 +35,7 @@ import de.johni0702.minecraft.gui.popup.GuiInfoPopup;
|
|||||||
import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
||||||
import de.johni0702.minecraft.gui.utils.Colors;
|
import de.johni0702.minecraft.gui.utils.Colors;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.lwjgl.util.ReadableDimension;
|
import org.lwjgl.util.ReadableDimension;
|
||||||
|
|
||||||
@@ -119,10 +121,21 @@ public class GuiReplayEditor extends GuiScreen {
|
|||||||
public void save(File inputFile, PacketStream.FilterInfo...filters) {
|
public void save(File inputFile, PacketStream.FilterInfo...filters) {
|
||||||
save(FilenameUtils.getBaseName(inputFile.getName()), (outputFile) -> {
|
save(FilenameUtils.getBaseName(inputFile.getName()), (outputFile) -> {
|
||||||
Studio studio = new ReplayStudio();
|
Studio studio = new ReplayStudio();
|
||||||
try (ReplayFile outputReplay = new ZipReplayFile(studio, inputFile, outputFile);
|
File tmpDir = null;
|
||||||
ReplayOutputStream out = outputReplay.writePacketData()) {
|
try {
|
||||||
// The input replay file MUST be closed before saving the output file
|
File actualOutputFile = outputFile;
|
||||||
try (ReplayFile inputReplay = new ZipReplayFile(studio, inputFile);
|
if (outputFile.getCanonicalPath().equals(inputFile.getCanonicalPath())) {
|
||||||
|
// Input and output files are identical. Due to the way the ZipReplayFile stores its temporary
|
||||||
|
// data, the same replay file must not be opened twice for writing (tmp files will be deleted once
|
||||||
|
// either one is closed or, on Windows, will throw an exception when deleted).
|
||||||
|
tmpDir = Files.createTempDir();
|
||||||
|
outputFile = new File(tmpDir, "replay.mcpr");
|
||||||
|
LOGGER.debug("Output file is identical to input file, using temporary output file {} instead",
|
||||||
|
outputFile);
|
||||||
|
}
|
||||||
|
try (ReplayFile outputReplay = new ZipReplayFile(studio, inputFile, outputFile);
|
||||||
|
ReplayOutputStream out = outputReplay.writePacketData();
|
||||||
|
ReplayFile inputReplay = new ZipReplayFile(studio, inputFile);
|
||||||
ReplayInputStream in = inputReplay.getPacketData()) {
|
ReplayInputStream in = inputReplay.getPacketData()) {
|
||||||
ReplayMetaData metaData = inputReplay.getMetaData();
|
ReplayMetaData metaData = inputReplay.getMetaData();
|
||||||
PacketStream stream = studio.createReplayStream(in, true);
|
PacketStream stream = studio.createReplayStream(in, true);
|
||||||
@@ -154,11 +167,21 @@ public class GuiReplayEditor extends GuiScreen {
|
|||||||
// Update duration of new replay
|
// Update duration of new replay
|
||||||
metaData.setDuration((int) lastTimestamp);
|
metaData.setDuration((int) lastTimestamp);
|
||||||
outputReplay.writeMetaData(metaData);
|
outputReplay.writeMetaData(metaData);
|
||||||
|
|
||||||
|
out.close();
|
||||||
|
outputReplay.save();
|
||||||
|
}
|
||||||
|
if (outputFile != actualOutputFile) {
|
||||||
|
LOGGER.debug("Moving temporary output file {} to {}");
|
||||||
|
FileUtils.forceDelete(actualOutputFile);
|
||||||
|
FileUtils.moveFile(outputFile, actualOutputFile);
|
||||||
}
|
}
|
||||||
out.close();
|
|
||||||
outputReplay.save();
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
if (tmpDir != null && !FileUtils.deleteQuietly(tmpDir)) {
|
||||||
|
LOGGER.warn("Failed to delete temporary directory {}", tmpDir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ import static com.replaymod.editor.ReplayModEditor.LOGGER;
|
|||||||
import static java.util.Optional.ofNullable;
|
import static java.util.Optional.ofNullable;
|
||||||
|
|
||||||
public class GuiTrimPanel extends GuiPanel {
|
public class GuiTrimPanel extends GuiPanel {
|
||||||
|
private static GuiNumberField newGuiNumberField() {
|
||||||
|
return new GuiNumberField().setMaxLength(2).setSize(20, 20).setValidateOnFocusChange(true);
|
||||||
|
}
|
||||||
|
|
||||||
// Special value indicating no replay files were found
|
// Special value indicating no replay files were found
|
||||||
private static final File NO_REPLAY = new File(".");
|
private static final File NO_REPLAY = new File(".");
|
||||||
// Special value for the initial "Select Marker Keyframe" entry
|
// Special value for the initial "Select Marker Keyframe" entry
|
||||||
@@ -50,16 +54,16 @@ public class GuiTrimPanel extends GuiPanel {
|
|||||||
.setMinSize(new Dimension(200, 20)).onSelection(i -> updateSelectedReplay())
|
.setMinSize(new Dimension(200, 20)).onSelection(i -> updateSelectedReplay())
|
||||||
.setToString(f -> f == NO_REPLAY ? "" : FilenameUtils.getBaseName(f.getName()));
|
.setToString(f -> f == NO_REPLAY ? "" : FilenameUtils.getBaseName(f.getName()));
|
||||||
|
|
||||||
public final GuiNumberField startHour = new GuiNumberField().setSize(20, 20).setMaxLength(2);
|
public final GuiNumberField startHour = newGuiNumberField();
|
||||||
public final GuiNumberField startMin = new GuiNumberField().setSize(20, 20).setMaxLength(2);
|
public final GuiNumberField startMin = newGuiNumberField();
|
||||||
public final GuiNumberField startSec = new GuiNumberField().setSize(20, 20).setMaxLength(2);
|
public final GuiNumberField startSec = newGuiNumberField();
|
||||||
public final GuiNumberField startMilli = new GuiNumberField().setSize(40, 20).setMaxLength(4);
|
public final GuiNumberField startMilli = newGuiNumberField().setSize(40, 20).setMaxLength(4);
|
||||||
public final GuiDropdownMenu<Marker> startMarker = new GuiDropdownMenu<>();
|
public final GuiDropdownMenu<Marker> startMarker = new GuiDropdownMenu<>();
|
||||||
|
|
||||||
public final GuiNumberField endHour = new GuiNumberField().setSize(20, 20).setMaxLength(2);
|
public final GuiNumberField endHour = newGuiNumberField();
|
||||||
public final GuiNumberField endMin = new GuiNumberField().setSize(20, 20).setMaxLength(2);
|
public final GuiNumberField endMin = newGuiNumberField();
|
||||||
public final GuiNumberField endSec = new GuiNumberField().setSize(20, 20).setMaxLength(2);
|
public final GuiNumberField endSec = newGuiNumberField();
|
||||||
public final GuiNumberField endMilli = new GuiNumberField().setSize(40, 20).setMaxLength(4);
|
public final GuiNumberField endMilli = newGuiNumberField().setSize(40, 20).setMaxLength(4);
|
||||||
public final GuiDropdownMenu<Marker> endMarker = new GuiDropdownMenu<>();
|
public final GuiDropdownMenu<Marker> endMarker = new GuiDropdownMenu<>();
|
||||||
|
|
||||||
public final GuiPanel timePanel = new GuiPanel(this)
|
public final GuiPanel timePanel = new GuiPanel(this)
|
||||||
|
|||||||
@@ -8,8 +8,11 @@ import net.minecraft.client.gui.GuiMainMenu;
|
|||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class GuiHandler {
|
public class GuiHandler {
|
||||||
private static final int BUTTON_REPLAY_EDITOR = 17890237;
|
private static final int BUTTON_REPLAY_EDITOR = 17890237;
|
||||||
|
|
||||||
@@ -20,28 +23,31 @@ public class GuiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void register() {
|
public void register() {
|
||||||
|
FMLCommonHandler.instance().bus().register(this);
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
||||||
if (!(event.getGui() instanceof GuiMainMenu)) {
|
if (!(event.gui instanceof GuiMainMenu)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiButton button = new GuiButton(BUTTON_REPLAY_EDITOR, event.getGui().width / 2 + 2,
|
@SuppressWarnings("unchecked")
|
||||||
event.getGui().height / 4 + 10 + 3 * 24, I18n.format("replaymod.gui.replayeditor"));
|
List<GuiButton> buttonList = event.buttonList;
|
||||||
|
GuiButton button = new GuiButton(BUTTON_REPLAY_EDITOR, event.gui.width / 2 + 2,
|
||||||
|
event.gui.height / 4 + 10 + 3 * 24, I18n.format("replaymod.gui.replayeditor"));
|
||||||
button.width = button.width / 2 - 2;
|
button.width = button.width / 2 - 2;
|
||||||
event.getButtonList().add(button);
|
buttonList.add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
||||||
if(!event.getButton().enabled) return;
|
if(!event.button.enabled) return;
|
||||||
|
|
||||||
if (event.getGui() instanceof GuiMainMenu) {
|
if (event.gui instanceof GuiMainMenu) {
|
||||||
if (event.getButton().id == BUTTON_REPLAY_EDITOR) {
|
if (event.button.id == BUTTON_REPLAY_EDITOR) {
|
||||||
new GuiReplayEditor(GuiScreen.wrap(event.getGui()), mod.getCore()).display();
|
new GuiReplayEditor(GuiScreen.wrap(event.gui), mod.getCore()).display();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import de.johni0702.minecraft.gui.element.GuiImage;
|
|||||||
import de.johni0702.minecraft.gui.element.IGuiImage;
|
import de.johni0702.minecraft.gui.element.IGuiImage;
|
||||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||||
import net.minecraft.client.settings.GameSettings;
|
import net.minecraft.client.settings.GameSettings;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
@@ -40,7 +40,7 @@ public class FullBrightness implements Extra {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
FMLCommonHandler.instance().bus().register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import de.johni0702.minecraft.gui.layout.GridLayout;
|
|||||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||||
import de.johni0702.minecraft.gui.layout.LayoutData;
|
import de.johni0702.minecraft.gui.layout.LayoutData;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.util.Dimension;
|
import org.lwjgl.util.Dimension;
|
||||||
@@ -35,7 +35,7 @@ public class HotkeyButtons implements Extra {
|
|||||||
public void register(ReplayMod mod) throws Exception {
|
public void register(ReplayMod mod) throws Exception {
|
||||||
this.mod = mod;
|
this.mod = mod;
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
FMLCommonHandler.instance().bus().register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.resources.IResourcePack;
|
import net.minecraft.client.resources.IResourcePack;
|
||||||
import net.minecraft.client.resources.data.IMetadataSection;
|
import net.minecraft.client.resources.data.IMetadataSection;
|
||||||
import net.minecraft.client.resources.data.MetadataSerializer;
|
import net.minecraft.client.resources.data.IMetadataSerializer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import org.apache.commons.lang3.StringEscapeUtils;
|
import org.apache.commons.lang3.StringEscapeUtils;
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ public class LocalizationExtra implements Extra {
|
|||||||
availableLanguages.put(langcode, prop);
|
availableLanguages.put(langcode, prop);
|
||||||
return true;
|
return true;
|
||||||
} catch (ApiException e) {
|
} catch (ApiException e) {
|
||||||
if (e.getError().getId() != 16) { // This language has not been translated
|
if (e.getError() == null || e.getError().getId() != 16) { // This language has not been translated
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} catch(ConnectException ce) {
|
} catch(ConnectException ce) {
|
||||||
@@ -95,12 +95,12 @@ public class LocalizationExtra implements Extra {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getResourceDomains() {
|
public Set getResourceDomains() {
|
||||||
return ImmutableSet.of("minecraft", "replaymod");
|
return ImmutableSet.of("minecraft", "replaymod");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends IMetadataSection> T getPackMetadata(MetadataSerializer metadataSerializer, String metadataSectionName) throws IOException {
|
public IMetadataSection getPackMetadata(IMetadataSerializer p_135058_1_, String p_135058_2_) throws IOException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import de.johni0702.minecraft.gui.utils.Colors;
|
|||||||
import net.minecraftforge.fml.common.Loader;
|
import net.minecraftforge.fml.common.Loader;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -24,8 +25,10 @@ import java.nio.channels.Channels;
|
|||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
import java.nio.channels.ReadableByteChannel;
|
import java.nio.channels.ReadableByteChannel;
|
||||||
|
|
||||||
|
import static com.replaymod.core.utils.Utils.SSL_SOCKET_FACTORY;
|
||||||
|
|
||||||
public class OpenEyeExtra implements Extra {
|
public class OpenEyeExtra implements Extra {
|
||||||
private static final String DOWNLOAD_URL = "http://www.replaymod.com/dl/openeye/" + Loader.MC_VERSION;
|
private static final String DOWNLOAD_URL = "https://www.replaymod.com/dl/openeye/" + Loader.MC_VERSION;
|
||||||
private static final Setting<Boolean> ASK_FOR_OPEN_EYE = new Setting<>("advanced", "askForOpenEye", null, true);
|
private static final Setting<Boolean> ASK_FOR_OPEN_EYE = new Setting<>("advanced", "askForOpenEye", null, true);
|
||||||
|
|
||||||
private ReplayMod mod;
|
private ReplayMod mod;
|
||||||
@@ -69,7 +72,9 @@ public class OpenEyeExtra implements Extra {
|
|||||||
File targetFile = new File("mods/" + Loader.MC_VERSION, "OpenEye.jar");
|
File targetFile = new File("mods/" + Loader.MC_VERSION, "OpenEye.jar");
|
||||||
FileUtils.forceMkdir(targetFile.getParentFile());
|
FileUtils.forceMkdir(targetFile.getParentFile());
|
||||||
|
|
||||||
ReadableByteChannel in = Channels.newChannel(new URL(DOWNLOAD_URL).openStream());
|
HttpsURLConnection connection = (HttpsURLConnection) new URL(DOWNLOAD_URL).openConnection();
|
||||||
|
connection.setSSLSocketFactory(SSL_SOCKET_FACTORY);
|
||||||
|
ReadableByteChannel in = Channels.newChannel(connection.getInputStream());
|
||||||
FileChannel out = new FileOutputStream(targetFile).getChannel();
|
FileChannel out = new FileOutputStream(targetFile).getChannel();
|
||||||
out.transferFrom(in, 0, Long.MAX_VALUE);
|
out.transferFrom(in, 0, Long.MAX_VALUE);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
|||||||
@@ -11,8 +11,11 @@ import com.replaymod.replay.events.ReplayCloseEvent;
|
|||||||
import com.replaymod.replay.events.ReplayOpenEvent;
|
import com.replaymod.replay.events.ReplayOpenEvent;
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraftforge.client.event.RenderHandEvent;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
@@ -55,6 +58,7 @@ public class PlayerOverview implements Extra {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
FMLCommonHandler.instance().bus().register(this);
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
|
||||||
RenderManager renderManager = mod.getMinecraft().getRenderManager();
|
RenderManager renderManager = mod.getMinecraft().getRenderManager();
|
||||||
@@ -92,6 +96,14 @@ public class PlayerOverview implements Extra {
|
|||||||
hiddenPlayers.clear();
|
hiddenPlayers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void oRenderHand(RenderHandEvent event) {
|
||||||
|
Entity view = module.getCore().getMinecraft().getRenderViewEntity();
|
||||||
|
if (view != null && isHidden(view.getUniqueID())) {
|
||||||
|
event.setCanceled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isSavingEnabled() {
|
public boolean isSavingEnabled() {
|
||||||
return savingEnabled;
|
return savingEnabled;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ import de.johni0702.minecraft.gui.utils.Colors;
|
|||||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EnumPlayerModelParts;
|
import net.minecraft.entity.player.EnumPlayerModelParts;
|
||||||
import net.minecraft.init.MobEffects;
|
import net.minecraft.potion.Potion;
|
||||||
import net.minecraft.init.SoundEvents;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import org.lwjgl.util.Dimension;
|
import org.lwjgl.util.Dimension;
|
||||||
import org.lwjgl.util.ReadableDimension;
|
import org.lwjgl.util.ReadableDimension;
|
||||||
@@ -41,14 +40,14 @@ public class PlayerOverviewGui extends GuiScreen implements Closeable {
|
|||||||
public final GuiCheckbox checkAll = new GuiCheckbox(contentPanel){
|
public final GuiCheckbox checkAll = new GuiCheckbox(contentPanel){
|
||||||
@Override
|
@Override
|
||||||
public void onClick() {
|
public void onClick() {
|
||||||
getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(BUTTON_SOUND, 1.0F));
|
||||||
playersScrollable.forEach(IGuiCheckbox.class).setChecked(true);
|
playersScrollable.forEach(IGuiCheckbox.class).setChecked(true);
|
||||||
}
|
}
|
||||||
}.setLabel("").setChecked(true);
|
}.setLabel("").setChecked(true);
|
||||||
public final GuiCheckbox uncheckAll = new GuiCheckbox(contentPanel){
|
public final GuiCheckbox uncheckAll = new GuiCheckbox(contentPanel){
|
||||||
@Override
|
@Override
|
||||||
public void onClick() {
|
public void onClick() {
|
||||||
getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(BUTTON_SOUND, 1.0F));
|
||||||
playersScrollable.forEach(IGuiCheckbox.class).setChecked(false);
|
playersScrollable.forEach(IGuiCheckbox.class).setChecked(false);
|
||||||
}
|
}
|
||||||
}.setLabel("").setChecked(false);
|
}.setLabel("").setChecked(false);
|
||||||
@@ -91,7 +90,7 @@ public class PlayerOverviewGui extends GuiScreen implements Closeable {
|
|||||||
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
|
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
|
||||||
renderer.bindTexture(texture);
|
renderer.bindTexture(texture);
|
||||||
renderer.drawTexturedRect(0, 0, 8, 8, 16, 16, 8, 8, 64, 64);
|
renderer.drawTexturedRect(0, 0, 8, 8, 16, 16, 8, 8, 64, 64);
|
||||||
if (p.isWearing(EnumPlayerModelParts.HAT)) {
|
if (p.func_175148_a(EnumPlayerModelParts.HAT)) {
|
||||||
renderer.drawTexturedRect(0, 0, 40, 8, size.getWidth(), size.getHeight(), 8, 8, 64, 64);
|
renderer.drawTexturedRect(0, 0, 40, 8, size.getWidth(), size.getHeight(), 8, 8, 64, 64);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -140,7 +139,7 @@ public class PlayerOverviewGui extends GuiScreen implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isSpectator(EntityPlayer e) {
|
private static boolean isSpectator(EntityPlayer e) {
|
||||||
return e.isInvisible() && e.getActivePotionEffect(MobEffects.INVISIBILITY) == null;
|
return e.isInvisible() && e.getActivePotionEffect(Potion.invisibility) == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class PlayerComparator implements Comparator<EntityPlayer> {
|
private static final class PlayerComparator implements Comparator<EntityPlayer> {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.replaymod.extras.playeroverview;
|
package com.replaymod.extras.playeroverview;
|
||||||
|
|
||||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
|
||||||
import net.minecraft.client.renderer.culling.ICamera;
|
import net.minecraft.client.renderer.culling.ICamera;
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
|
||||||
public class PlayerRenderHook extends RenderPlayer {
|
public class PlayerRenderHook extends RenderPlayer {
|
||||||
private final PlayerOverview extra;
|
private final PlayerOverview extra;
|
||||||
@@ -14,7 +14,7 @@ public class PlayerRenderHook extends RenderPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldRender(AbstractClientPlayer entity, ICamera camera, double camX, double camY, double camZ) {
|
public boolean shouldRender(Entity entity, ICamera camera, double camX, double camY, double camZ) {
|
||||||
return !extra.isHidden(entity.getUniqueID()) && super.shouldRender(entity, camera, camX, camY, camZ);
|
return !extra.isHidden(entity.getUniqueID()) && super.shouldRender(entity, camera, camX, camY, camZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ public class YoutubeUpload implements Extra {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onGuiOpen(GuiScreenEvent.InitGuiEvent.Post event) {
|
public void onGuiOpen(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||||
if (GuiScreen.from(event.getGui()) instanceof GuiRenderingDone) {
|
if (GuiScreen.from(event.gui) instanceof GuiRenderingDone) {
|
||||||
GuiRenderingDone gui = (GuiRenderingDone) GuiScreen.from(event.getGui());
|
GuiRenderingDone gui = (GuiRenderingDone) GuiScreen.from(event.gui);
|
||||||
// Check if there already is a youtube button
|
// Check if there already is a youtube button
|
||||||
if (gui.actionsPanel.getChildren().stream().anyMatch(it -> it instanceof YoutubeButton)) {
|
if (gui.actionsPanel.getChildren().stream().anyMatch(it -> it instanceof YoutubeButton)) {
|
||||||
return; // Button already added
|
return; // Button already added
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import com.replaymod.replaystudio.replay.ReplayFile;
|
|||||||
import com.replaymod.replaystudio.replay.ZipReplayFile;
|
import com.replaymod.replaystudio.replay.ZipReplayFile;
|
||||||
import com.replaymod.replaystudio.studio.ReplayStudio;
|
import com.replaymod.replaystudio.studio.ReplayStudio;
|
||||||
import de.johni0702.minecraft.gui.container.GuiScreen;
|
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||||
@@ -74,7 +74,7 @@ public class ReplayModOnline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
new GuiHandler(this).register();
|
new GuiHandler(this).register();
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
FMLCommonHandler.instance().bus().register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
|
|||||||
@@ -15,13 +15,19 @@ import org.apache.commons.io.FileUtils;
|
|||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.*;
|
import java.io.BufferedInputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import static com.replaymod.core.utils.Utils.SSL_SOCKET_FACTORY;
|
||||||
|
|
||||||
public class ApiClient {
|
public class ApiClient {
|
||||||
|
|
||||||
private static final Minecraft mc = Minecraft.getMinecraft();
|
private static final Minecraft mc = Minecraft.getMinecraft();
|
||||||
@@ -130,7 +136,11 @@ public class ApiClient {
|
|||||||
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.get_thumbnail);
|
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.get_thumbnail);
|
||||||
builder.put("id", file);
|
builder.put("id", file);
|
||||||
URL url = new URL(builder.toString());
|
URL url = new URL(builder.toString());
|
||||||
return ImageIO.read(url);
|
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||||
|
connection.setSSLSocketFactory(SSL_SOCKET_FACTORY);
|
||||||
|
try (InputStream in = connection.getInputStream()) {
|
||||||
|
return ImageIO.read(in);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean cancelDownload = false;
|
private boolean cancelDownload = false;
|
||||||
@@ -143,7 +153,8 @@ public class ApiClient {
|
|||||||
builder.put("id", file);
|
builder.put("id", file);
|
||||||
String url = builder.toString();
|
String url = builder.toString();
|
||||||
URL website = new URL(url);
|
URL website = new URL(url);
|
||||||
HttpURLConnection con = (HttpURLConnection) website.openConnection();
|
HttpsURLConnection con = (HttpsURLConnection) website.openConnection();
|
||||||
|
con.setSSLSocketFactory(SSL_SOCKET_FACTORY);
|
||||||
|
|
||||||
int fileSize = con.getContentLength();
|
int fileSize = con.getContentLength();
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,14 @@ import com.google.gson.JsonParser;
|
|||||||
import com.replaymod.online.api.replay.holders.ApiError;
|
import com.replaymod.online.api.replay.holders.ApiError;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.replaymod.core.utils.Utils.SSL_SOCKET_FACTORY;
|
||||||
|
|
||||||
public class SimpleApiClient {
|
public class SimpleApiClient {
|
||||||
|
|
||||||
private static final JsonParser jsonParser = new JsonParser();
|
private static final JsonParser jsonParser = new JsonParser();
|
||||||
@@ -72,10 +74,11 @@ public class SimpleApiClient {
|
|||||||
// read response
|
// read response
|
||||||
String responseContent = null;
|
String responseContent = null;
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
HttpURLConnection httpUrlConnection = null;
|
HttpsURLConnection httpUrlConnection = null;
|
||||||
try {
|
try {
|
||||||
URL url = new URL(urlString);
|
URL url = new URL(urlString);
|
||||||
httpUrlConnection = (HttpURLConnection) url.openConnection();
|
httpUrlConnection = (HttpsURLConnection) url.openConnection();
|
||||||
|
httpUrlConnection.setSSLSocketFactory(SSL_SOCKET_FACTORY);
|
||||||
|
|
||||||
httpUrlConnection.setRequestMethod("GET");
|
httpUrlConnection.setRequestMethod("GET");
|
||||||
|
|
||||||
|
|||||||
@@ -9,16 +9,18 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import static com.replaymod.core.utils.Utils.SSL_SOCKET_FACTORY;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class FileUploader {
|
public class FileUploader {
|
||||||
private static final Gson gson = new Gson();
|
private static final Gson gson = new Gson();
|
||||||
@@ -48,7 +50,8 @@ public class FileUploader {
|
|||||||
postData += "&name=" + URLEncoder.encode(filename, "UTF-8");
|
postData += "&name=" + URLEncoder.encode(filename, "UTF-8");
|
||||||
|
|
||||||
String url = ReplayModApiMethods.upload_file + postData;
|
String url = ReplayModApiMethods.upload_file + postData;
|
||||||
HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection();
|
HttpsURLConnection con = (HttpsURLConnection) new URL(url).openConnection();
|
||||||
|
con.setSSLSocketFactory(SSL_SOCKET_FACTORY);
|
||||||
con.setUseCaches(false);
|
con.setUseCaches(false);
|
||||||
con.setDoOutput(true);
|
con.setDoOutput(true);
|
||||||
con.setRequestMethod("POST");
|
con.setRequestMethod("POST");
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package com.replaymod.online.api.replay;
|
|||||||
|
|
||||||
public class ReplayModApiMethods {
|
public class ReplayModApiMethods {
|
||||||
|
|
||||||
public static final String REPLAYMOD_BASE_URL = "http://ReplayMod.com/api/";
|
public static final String REPLAYMOD_BASE_URL = "https://ReplayMod.com/api/";
|
||||||
|
|
||||||
public static final String register = REPLAYMOD_BASE_URL+"register";
|
public static final String register = REPLAYMOD_BASE_URL+"register";
|
||||||
public static final String check_authkey = REPLAYMOD_BASE_URL+"check_authkey";
|
public static final String check_authkey = REPLAYMOD_BASE_URL+"check_authkey";
|
||||||
|
|||||||
@@ -2,10 +2,7 @@ package com.replaymod.online.api.replay.holders;
|
|||||||
|
|
||||||
public enum MinecraftVersion {
|
public enum MinecraftVersion {
|
||||||
|
|
||||||
MC_1_8("Minecraft 1.8", "1.8"),
|
MC_1_8("Minecraft 1.8", "1.8");
|
||||||
MC_1_9_4("Minecraft 1.9.4", "1.9.4"),
|
|
||||||
MC_1_10_2("Minecraft 1.10.2", "1.10.2"),
|
|
||||||
MC_1_11("Minecraft 1.11", "1.11");
|
|
||||||
|
|
||||||
private String niceName, apiName;
|
private String niceName, apiName;
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,11 @@ import net.minecraft.client.gui.GuiMainMenu;
|
|||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class GuiHandler {
|
public class GuiHandler {
|
||||||
private static final int BUTTON_REPLAY_CENTER = 17890236;
|
private static final int BUTTON_REPLAY_CENTER = 17890236;
|
||||||
@@ -28,23 +30,26 @@ public class GuiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void register() {
|
public void register() {
|
||||||
|
FMLCommonHandler.instance().bus().register(this);
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
||||||
if (!(event.getGui() instanceof GuiMainMenu)) {
|
if (!(event.gui instanceof GuiMainMenu)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiButton button = new GuiButton(BUTTON_REPLAY_CENTER, event.getGui().width / 2 - 100,
|
@SuppressWarnings("unchecked")
|
||||||
event.getGui().height / 4 + 10 + 4 * 24, I18n.format("replaymod.gui.replaycenter"));
|
List<GuiButton> buttonList = event.buttonList;
|
||||||
event.getButtonList().add(button);
|
GuiButton button = new GuiButton(BUTTON_REPLAY_CENTER, event.gui.width / 2 - 100,
|
||||||
|
event.gui.height / 4 + 10 + 4 * 24, I18n.format("replaymod.gui.replaycenter"));
|
||||||
|
buttonList.add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void injectIntoReplayViewer(GuiScreenEvent.InitGuiEvent.Post event) {
|
public void injectIntoReplayViewer(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||||
AbstractGuiScreen guiScreen = GuiScreen.from(event.getGui());
|
AbstractGuiScreen guiScreen = GuiScreen.from(event.gui);
|
||||||
if (!(guiScreen instanceof GuiReplayViewer)) {
|
if (!(guiScreen instanceof GuiReplayViewer)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -70,15 +75,15 @@ public class GuiHandler {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
||||||
if(!event.getButton().enabled) return;
|
if(!event.button.enabled) return;
|
||||||
|
|
||||||
if (event.getGui() instanceof GuiMainMenu) {
|
if (event.gui instanceof GuiMainMenu) {
|
||||||
if (event.getButton().id == BUTTON_REPLAY_CENTER) {
|
if (event.button.id == BUTTON_REPLAY_CENTER) {
|
||||||
GuiReplayCenter replayCenter = new GuiReplayCenter(mod);
|
GuiReplayCenter replayCenter = new GuiReplayCenter(mod);
|
||||||
if (mod.isLoggedIn()) {
|
if (mod.isLoggedIn()) {
|
||||||
replayCenter.display();
|
replayCenter.display();
|
||||||
} else {
|
} else {
|
||||||
new GuiLoginPrompt(mod.getApiClient(), GuiScreen.wrap(event.getGui()), replayCenter, true).display();
|
new GuiLoginPrompt(mod.getApiClient(), GuiScreen.wrap(event.gui), replayCenter, true).display();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import com.replaymod.replaystudio.pathing.path.Keyframe;
|
|||||||
import com.replaymod.replaystudio.pathing.path.Path;
|
import com.replaymod.replaystudio.pathing.path.Path;
|
||||||
import com.replaymod.replaystudio.pathing.path.Timeline;
|
import com.replaymod.replaystudio.pathing.path.Timeline;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -65,7 +65,7 @@ public abstract class AbstractTimelinePlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
replayHandler.getReplaySender().setSyncModeAndWait();
|
replayHandler.getReplaySender().setSyncModeAndWait();
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
FMLCommonHandler.instance().bus().register(this);
|
||||||
lastTime = 0;
|
lastTime = 0;
|
||||||
mc.timer = new ReplayTimer(mc.timer);
|
mc.timer = new ReplayTimer(mc.timer);
|
||||||
mc.timer.timerSpeed = 1;
|
mc.timer.timerSpeed = 1;
|
||||||
@@ -87,7 +87,7 @@ public abstract class AbstractTimelinePlayer {
|
|||||||
mc.timer = ((ReplayTimer) mc.timer).getWrapped();
|
mc.timer = ((ReplayTimer) mc.timer).getWrapped();
|
||||||
replayHandler.getReplaySender().setReplaySpeed(0);
|
replayHandler.getReplaySender().setReplaySpeed(0);
|
||||||
replayHandler.getReplaySender().setAsyncMode(true);
|
replayHandler.getReplaySender().setAsyncMode(true);
|
||||||
MinecraftForge.EVENT_BUS.unregister(this);
|
FMLCommonHandler.instance().bus().unregister(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long time = getTimePassed();
|
long time = getTimePassed();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package com.replaymod.pathing.player;
|
|||||||
|
|
||||||
import com.replaymod.core.utils.WrappedTimer;
|
import com.replaymod.core.utils.WrappedTimer;
|
||||||
import net.minecraft.util.Timer;
|
import net.minecraft.util.Timer;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,7 +20,7 @@ public class ReplayTimer extends WrappedTimer {
|
|||||||
copy(this, state); // Save our current state
|
copy(this, state); // Save our current state
|
||||||
super.updateTimer(); // Update current state
|
super.updateTimer(); // Update current state
|
||||||
copy(state, this); // Restore our old state
|
copy(state, this); // Restore our old state
|
||||||
MinecraftForge.EVENT_BUS.post(new UpdatedEvent());
|
FMLCommonHandler.instance().bus().post(new UpdatedEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Timer getWrapped() {
|
public Timer getWrapped() {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import com.replaymod.core.ReplayMod;
|
|||||||
import com.replaymod.core.utils.Restrictions;
|
import com.replaymod.core.utils.Restrictions;
|
||||||
import com.replaymod.recording.handler.ConnectionEventHandler;
|
import com.replaymod.recording.handler.ConnectionEventHandler;
|
||||||
import com.replaymod.recording.packet.PacketListener;
|
import com.replaymod.recording.packet.PacketListener;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
@@ -51,7 +51,7 @@ public class ReplayModRecording {
|
|||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void init(FMLInitializationEvent event) {
|
public void init(FMLInitializationEvent event) {
|
||||||
EventBus bus = MinecraftForge.EVENT_BUS;
|
EventBus bus = FMLCommonHandler.instance().bus();
|
||||||
bus.register(connectionEventHandler = new ConnectionEventHandler(logger, core));
|
bus.register(connectionEventHandler = new ConnectionEventHandler(logger, core));
|
||||||
|
|
||||||
NetworkRegistry.INSTANCE.newSimpleChannel(Restrictions.PLUGIN_CHANNEL);
|
NetworkRegistry.INSTANCE.newSimpleChannel(Restrictions.PLUGIN_CHANNEL);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class GuiRecordingOverlay {
|
|||||||
*/
|
*/
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void renderRecordingIndicator(RenderGameOverlayEvent.Post event) {
|
public void renderRecordingIndicator(RenderGameOverlayEvent.Post event) {
|
||||||
if (event.getType() != RenderGameOverlayEvent.ElementType.ALL) return;
|
if (event.type != RenderGameOverlayEvent.ElementType.ALL) return;
|
||||||
if (settingsRegistry.get(Setting.INDICATOR)) {
|
if (settingsRegistry.get(Setting.INDICATOR)) {
|
||||||
FontRenderer fontRenderer = mc.fontRendererObj;
|
FontRenderer fontRenderer = mc.fontRendererObj;
|
||||||
fontRenderer.drawString(I18n.format("replaymod.gui.recording").toUpperCase(), 30, 18 - (fontRenderer.FONT_HEIGHT / 2), 0xffffffff);
|
fontRenderer.drawString(I18n.format("replaymod.gui.recording").toUpperCase(), 30, 18 - (fontRenderer.FONT_HEIGHT / 2), 0xffffffff);
|
||||||
|
|||||||
@@ -66,9 +66,6 @@ public class ConnectionEventHandler {
|
|||||||
worldName = mc.getIntegratedServer().getWorldName();
|
worldName = mc.getIntegratedServer().getWorldName();
|
||||||
} else if (Minecraft.getMinecraft().getCurrentServerData() != null) {
|
} else if (Minecraft.getMinecraft().getCurrentServerData() != null) {
|
||||||
worldName = Minecraft.getMinecraft().getCurrentServerData().serverIP;
|
worldName = Minecraft.getMinecraft().getCurrentServerData().serverIP;
|
||||||
} else if (Minecraft.getMinecraft().isConnectedToRealms()) {
|
|
||||||
// we can't access the server name without tapping too deep in the Realms Library
|
|
||||||
worldName = "A Realms Server";
|
|
||||||
} else {
|
} else {
|
||||||
logger.info("Recording not started as the world is neither local nor remote (probably a replay).");
|
logger.info("Recording not started as the world is neither local nor remote (probably a replay).");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,22 +1,24 @@
|
|||||||
package com.replaymod.recording.handler;
|
package com.replaymod.recording.handler;
|
||||||
|
|
||||||
import com.replaymod.recording.packet.PacketListener;
|
import com.replaymod.recording.packet.PacketListener;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.Unpooled;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.EntityLiving;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
import net.minecraft.network.datasync.EntityDataManager;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraft.network.play.server.*;
|
import net.minecraft.network.play.server.*;
|
||||||
|
import net.minecraft.network.play.server.S14PacketEntity.S17PacketEntityLookMove;
|
||||||
import net.minecraft.server.integrated.IntegratedServer;
|
import net.minecraft.server.integrated.IntegratedServer;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.SoundCategory;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.util.SoundEvent;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.entity.minecart.MinecartInteractEvent;
|
import net.minecraftforge.event.entity.minecart.MinecartInteractEvent;
|
||||||
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent;
|
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent;
|
||||||
|
import net.minecraftforge.event.entity.player.PlayerUseItemEvent;
|
||||||
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemPickupEvent;
|
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemPickupEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
@@ -30,24 +32,24 @@ public class RecordingEventHandler {
|
|||||||
private final PacketListener packetListener;
|
private final PacketListener packetListener;
|
||||||
|
|
||||||
private Double lastX, lastY, lastZ;
|
private Double lastX, lastY, lastZ;
|
||||||
private ItemStack[] playerItems = new ItemStack[6];
|
private ItemStack[] playerItems = new ItemStack[5];
|
||||||
private int ticksSinceLastCorrection;
|
private int ticksSinceLastCorrection;
|
||||||
private boolean wasSleeping;
|
private boolean wasSleeping;
|
||||||
private int lastRiding = -1;
|
private int lastRiding = -1;
|
||||||
private Integer rotationYawHeadBefore;
|
private Integer rotationYawHeadBefore;
|
||||||
private boolean wasHandActive;
|
|
||||||
private EnumHand lastActiveHand;
|
|
||||||
|
|
||||||
public RecordingEventHandler(PacketListener packetListener) {
|
public RecordingEventHandler(PacketListener packetListener) {
|
||||||
this.packetListener = packetListener;
|
this.packetListener = packetListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register() {
|
public void register() {
|
||||||
|
FMLCommonHandler.instance().bus().register(this);
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
((RecordingEventSender) mc.renderGlobal).setRecordingEventHandler(this);
|
((RecordingEventSender) mc.renderGlobal).setRecordingEventHandler(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unregister() {
|
public void unregister() {
|
||||||
|
FMLCommonHandler.instance().bus().unregister(this);
|
||||||
MinecraftForge.EVENT_BUS.unregister(this);
|
MinecraftForge.EVENT_BUS.unregister(this);
|
||||||
RecordingEventSender recordingEventSender = ((RecordingEventSender) mc.renderGlobal);
|
RecordingEventSender recordingEventSender = ((RecordingEventSender) mc.renderGlobal);
|
||||||
if (recordingEventSender.getRecordingEventHandler() == this) {
|
if (recordingEventSender.getRecordingEventHandler() == this) {
|
||||||
@@ -57,7 +59,7 @@ public class RecordingEventHandler {
|
|||||||
|
|
||||||
public void onPlayerJoin() {
|
public void onPlayerJoin() {
|
||||||
try {
|
try {
|
||||||
packetListener.save(new SPacketSpawnPlayer(mc.thePlayer));
|
packetListener.save(spawnPlayer(mc.thePlayer));
|
||||||
} catch(Exception e1) {
|
} catch(Exception e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -65,28 +67,39 @@ public class RecordingEventHandler {
|
|||||||
|
|
||||||
public void onPlayerRespawn() {
|
public void onPlayerRespawn() {
|
||||||
try {
|
try {
|
||||||
packetListener.save(new SPacketSpawnPlayer(mc.thePlayer));
|
packetListener.save(spawnPlayer(mc.thePlayer));
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClientSound(SoundEvent sound, SoundCategory category,
|
private S0CPacketSpawnPlayer spawnPlayer(EntityPlayer player) {
|
||||||
double x, double y, double z, float volume, float pitch) {
|
|
||||||
try {
|
try {
|
||||||
// Send to all other players in ServerWorldEventHandler#playSoundToAllNearExcept
|
S0CPacketSpawnPlayer packet = new S0CPacketSpawnPlayer();
|
||||||
packetListener.save(new SPacketSoundEffect(sound, category, x, y, z, volume, pitch));
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onClientEffect(int type, BlockPos pos, int data) {
|
ByteBuf bb = Unpooled.buffer();
|
||||||
try {
|
PacketBuffer pb = new PacketBuffer(bb);
|
||||||
// Send to all other players in ServerWorldEventHandler#playEvent
|
|
||||||
packetListener.save(new SPacketEffect(type, pos, data, false));
|
pb.writeVarIntToBuffer(player.getEntityId());
|
||||||
|
pb.writeUuid(EntityPlayer.getUUID(player.getGameProfile()));
|
||||||
|
|
||||||
|
pb.writeInt(MathHelper.floor_double(player.posX * 32.0D));
|
||||||
|
pb.writeInt(MathHelper.floor_double(player.posY * 32.0D));
|
||||||
|
pb.writeInt(MathHelper.floor_double(player.posZ * 32.0D));
|
||||||
|
pb.writeByte((byte) ((int) (player.rotationYaw * 256.0F / 360.0F)));
|
||||||
|
pb.writeByte((byte) ((int) (player.rotationPitch * 256.0F / 360.0F)));
|
||||||
|
|
||||||
|
ItemStack itemstack = player.inventory.getCurrentItem();
|
||||||
|
pb.writeShort(itemstack == null ? 0 : Item.getIdFromItem(itemstack.getItem()));
|
||||||
|
|
||||||
|
player.getDataWatcher().writeTo(pb);
|
||||||
|
|
||||||
|
packet.readPacketData(pb);
|
||||||
|
|
||||||
|
return packet;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,14 +131,19 @@ public class RecordingEventHandler {
|
|||||||
lastZ = e.player.posZ;
|
lastZ = e.player.posZ;
|
||||||
|
|
||||||
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) > 4.0 || Math.abs(dy) > 4.0 || Math.abs(dz) > 4.0) {
|
||||||
packet = new SPacketEntityTeleport(e.player);
|
int x = MathHelper.floor_double(e.player.posX * 32.0D);
|
||||||
|
int y = MathHelper.floor_double(e.player.posY * 32.0D);
|
||||||
|
int z = MathHelper.floor_double(e.player.posZ * 32.0D);
|
||||||
|
byte yaw = (byte) ((int) (e.player.rotationYaw * 256.0F / 360.0F));
|
||||||
|
byte pitch = (byte) ((int) (e.player.rotationPitch * 256.0F / 360.0F));
|
||||||
|
packet = new S18PacketEntityTeleport(e.player.getEntityId(), x, y, z, yaw, pitch, e.player.onGround);
|
||||||
} else {
|
} else {
|
||||||
byte newYaw = (byte) ((int) (e.player.rotationYaw * 256.0F / 360.0F));
|
byte newYaw = (byte) ((int) (e.player.rotationYaw * 256.0F / 360.0F));
|
||||||
byte newPitch = (byte) ((int) (e.player.rotationPitch * 256.0F / 360.0F));
|
byte newPitch = (byte) ((int) (e.player.rotationPitch * 256.0F / 360.0F));
|
||||||
|
|
||||||
packet = new SPacketEntity.S17PacketEntityLookMove(e.player.getEntityId(),
|
packet = new S17PacketEntityLookMove(e.player.getEntityId(),
|
||||||
(short) Math.round(dx * 4096), (short) Math.round(dy * 4096), (short) Math.round(dz * 4096),
|
(byte) Math.round(dx * 32), (byte) Math.round(dy * 32), (byte) Math.round(dz * 32),
|
||||||
newYaw, newPitch, e.player.onGround);
|
newYaw, newPitch, e.player.onGround);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,16 +153,37 @@ public class RecordingEventHandler {
|
|||||||
int rotationYawHead = ((int)(e.player.rotationYawHead * 256.0F / 360.0F));
|
int rotationYawHead = ((int)(e.player.rotationYawHead * 256.0F / 360.0F));
|
||||||
|
|
||||||
if(!Objects.equals(rotationYawHead, rotationYawHeadBefore)) {
|
if(!Objects.equals(rotationYawHead, rotationYawHeadBefore)) {
|
||||||
packetListener.save(new SPacketEntityHeadLook(e.player, (byte) rotationYawHead));
|
S19PacketEntityHeadLook head = new S19PacketEntityHeadLook();
|
||||||
|
ByteBuf bb1 = Unpooled.buffer();
|
||||||
|
PacketBuffer pb1 = new PacketBuffer(bb1);
|
||||||
|
|
||||||
|
pb1.writeVarIntToBuffer(e.player.getEntityId());
|
||||||
|
pb1.writeByte(rotationYawHead);
|
||||||
|
|
||||||
|
head.readPacketData(pb1);
|
||||||
|
|
||||||
|
packetListener.save(head);
|
||||||
|
|
||||||
rotationYawHeadBefore = rotationYawHead;
|
rotationYawHeadBefore = rotationYawHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
packetListener.save(new SPacketEntityVelocity(e.player.getEntityId(), e.player.motionX, e.player.motionY, e.player.motionZ));
|
S12PacketEntityVelocity vel = new S12PacketEntityVelocity(e.player.getEntityId(), e.player.motionX, e.player.motionY, e.player.motionZ);
|
||||||
|
packetListener.save(vel);
|
||||||
|
|
||||||
//Animation Packets
|
//Animation Packets
|
||||||
//Swing Animation
|
//Swing Animation
|
||||||
if (e.player.isSwingInProgress && e.player.swingProgressInt == -1) {
|
if(e.player.swingProgressInt == 1) {
|
||||||
packetListener.save(new SPacketAnimation(e.player, e.player.swingingHand == EnumHand.MAIN_HAND ? 0 : 3));
|
S0BPacketAnimation pac = new S0BPacketAnimation();
|
||||||
|
|
||||||
|
ByteBuf bb = Unpooled.buffer();
|
||||||
|
PacketBuffer pb = new PacketBuffer(bb);
|
||||||
|
|
||||||
|
pb.writeVarIntToBuffer(e.player.getEntityId());
|
||||||
|
pb.writeByte(0);
|
||||||
|
|
||||||
|
pac.readPacketData(pb);
|
||||||
|
|
||||||
|
packetListener.save(pac);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -168,62 +207,75 @@ public class RecordingEventHandler {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//Inventory Handling
|
//Inventory Handling
|
||||||
if (playerItems[0] != mc.thePlayer.getHeldItem(EnumHand.MAIN_HAND)) {
|
if(playerItems[0] != mc.thePlayer.getHeldItem()) {
|
||||||
playerItems[0] = mc.thePlayer.getHeldItem(EnumHand.MAIN_HAND);
|
playerItems[0] = mc.thePlayer.getHeldItem();
|
||||||
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.MAINHAND, playerItems[0]));
|
S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 0, playerItems[0]);
|
||||||
|
packetListener.save(pee);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerItems[1] != mc.thePlayer.getHeldItem(EnumHand.OFF_HAND)) {
|
if(playerItems[1] != mc.thePlayer.inventory.armorInventory[0]) {
|
||||||
playerItems[1] = mc.thePlayer.getHeldItem(EnumHand.OFF_HAND);
|
playerItems[1] = mc.thePlayer.inventory.armorInventory[0];
|
||||||
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.OFFHAND, playerItems[1]));
|
S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 1, playerItems[1]);
|
||||||
|
packetListener.save(pee);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerItems[2] != mc.thePlayer.getItemStackFromSlot(EntityEquipmentSlot.FEET)) {
|
if(playerItems[2] != mc.thePlayer.inventory.armorInventory[1]) {
|
||||||
playerItems[2] = mc.thePlayer.getItemStackFromSlot(EntityEquipmentSlot.FEET);
|
playerItems[2] = mc.thePlayer.inventory.armorInventory[1];
|
||||||
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.FEET, playerItems[2]));
|
S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 2, playerItems[2]);
|
||||||
|
packetListener.save(pee);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerItems[3] != mc.thePlayer.getItemStackFromSlot(EntityEquipmentSlot.LEGS)) {
|
if(playerItems[3] != mc.thePlayer.inventory.armorInventory[2]) {
|
||||||
playerItems[3] = mc.thePlayer.getItemStackFromSlot(EntityEquipmentSlot.LEGS);
|
playerItems[3] = mc.thePlayer.inventory.armorInventory[2];
|
||||||
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.LEGS, playerItems[3]));
|
S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 3, playerItems[3]);
|
||||||
|
packetListener.save(pee);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerItems[4] != mc.thePlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST)) {
|
if(playerItems[4] != mc.thePlayer.inventory.armorInventory[3]) {
|
||||||
playerItems[4] = mc.thePlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
playerItems[4] = mc.thePlayer.inventory.armorInventory[3];
|
||||||
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.CHEST, playerItems[4]));
|
S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 4, playerItems[4]);
|
||||||
}
|
packetListener.save(pee);
|
||||||
|
|
||||||
if (playerItems[5] != mc.thePlayer.getItemStackFromSlot(EntityEquipmentSlot.HEAD)) {
|
|
||||||
playerItems[5] = mc.thePlayer.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
|
|
||||||
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.HEAD, playerItems[5]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Leaving Ride
|
//Leaving Ride
|
||||||
|
|
||||||
if((!mc.thePlayer.isRiding() && lastRiding != -1) ||
|
if((!mc.thePlayer.isRiding() && lastRiding != -1) ||
|
||||||
(mc.thePlayer.isRiding() && lastRiding != mc.thePlayer.getRidingEntity().getEntityId())) {
|
(mc.thePlayer.isRiding() && lastRiding != mc.thePlayer.ridingEntity.getEntityId())) {
|
||||||
if(!mc.thePlayer.isRiding()) {
|
if(!mc.thePlayer.isRiding()) {
|
||||||
lastRiding = -1;
|
lastRiding = -1;
|
||||||
} else {
|
} else {
|
||||||
lastRiding = mc.thePlayer.getRidingEntity().getEntityId();
|
lastRiding = mc.thePlayer.ridingEntity.getEntityId();
|
||||||
}
|
}
|
||||||
packetListener.save(new SPacketEntityAttach(e.player, e.player.getRidingEntity()));
|
|
||||||
|
S1BPacketEntityAttach pea = new S1BPacketEntityAttach();
|
||||||
|
|
||||||
|
ByteBuf buf = Unpooled.buffer();
|
||||||
|
PacketBuffer pbuf = new PacketBuffer(buf);
|
||||||
|
|
||||||
|
pbuf.writeInt(e.player.getEntityId());
|
||||||
|
pbuf.writeInt(lastRiding);
|
||||||
|
pbuf.writeBoolean(false);
|
||||||
|
|
||||||
|
pea.readPacketData(pbuf);
|
||||||
|
|
||||||
|
packetListener.save(pea);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Sleeping
|
//Sleeping
|
||||||
if(!mc.thePlayer.isPlayerSleeping() && wasSleeping) {
|
if(!mc.thePlayer.isPlayerSleeping() && wasSleeping) {
|
||||||
packetListener.save(new SPacketAnimation(e.player, 2));
|
S0BPacketAnimation pac = new S0BPacketAnimation();
|
||||||
wasSleeping = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Active hand (e.g. eating, drinking, blocking)
|
ByteBuf bb = Unpooled.buffer();
|
||||||
if (mc.thePlayer.isHandActive() ^ wasHandActive || mc.thePlayer.getActiveHand() != lastActiveHand) {
|
PacketBuffer pb = new PacketBuffer(bb);
|
||||||
wasHandActive = mc.thePlayer.isHandActive();
|
|
||||||
lastActiveHand = mc.thePlayer.getActiveHand();
|
pb.writeVarIntToBuffer(e.player.getEntityId());
|
||||||
EntityDataManager dataManager = new EntityDataManager(null);
|
pb.writeByte(2);
|
||||||
int state = (wasHandActive ? 1 : 0) | (lastActiveHand == EnumHand.OFF_HAND ? 2 : 0);
|
|
||||||
dataManager.register(EntityLiving.HAND_STATES, (byte) state);
|
pac.readPacketData(pb);
|
||||||
packetListener.save(new SPacketEntityMetadata(mc.thePlayer.getEntityId(), dataManager, true));
|
|
||||||
|
packetListener.save(pac);
|
||||||
|
|
||||||
|
wasSleeping = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch(Exception e1) {
|
} catch(Exception e1) {
|
||||||
@@ -234,8 +286,27 @@ public class RecordingEventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onPickupItem(ItemPickupEvent event) {
|
public void onPickupItem(ItemPickupEvent event) {
|
||||||
try {
|
try {
|
||||||
packetListener.save(new SPacketCollectItem(event.pickedUp.getEntityId(), event.player.getEntityId(),
|
packetListener.save(new S0DPacketCollectItem(event.pickedUp.getEntityId(), event.player.getEntityId()));
|
||||||
event.pickedUp.getEntityItem().getMaxStackSize()));
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onStartEating(PlayerUseItemEvent.Start event) {
|
||||||
|
try {
|
||||||
|
if(!event.entityPlayer.isEating()) return;
|
||||||
|
S0BPacketAnimation packet = new S0BPacketAnimation();
|
||||||
|
|
||||||
|
ByteBuf bb = Unpooled.buffer();
|
||||||
|
PacketBuffer pb = new PacketBuffer(bb);
|
||||||
|
|
||||||
|
pb.writeVarIntToBuffer(event.entityPlayer.getEntityId());
|
||||||
|
pb.writeByte(3);
|
||||||
|
|
||||||
|
packet.readPacketData(pb);
|
||||||
|
|
||||||
|
packetListener.save(packet);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -244,11 +315,21 @@ public class RecordingEventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onSleep(PlayerSleepInBedEvent event) {
|
public void onSleep(PlayerSleepInBedEvent event) {
|
||||||
try {
|
try {
|
||||||
if (event.getEntityPlayer() != mc.thePlayer) {
|
if(event.entityPlayer != mc.thePlayer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packetListener.save(new SPacketUseBed(event.getEntityPlayer(), event.getPos()));
|
S0APacketUseBed pub = new S0APacketUseBed();
|
||||||
|
|
||||||
|
ByteBuf buf = Unpooled.buffer();
|
||||||
|
PacketBuffer pbuf = new PacketBuffer(buf);
|
||||||
|
|
||||||
|
pbuf.writeVarIntToBuffer(event.entityPlayer.getEntityId());
|
||||||
|
pbuf.writeBlockPos(event.pos);
|
||||||
|
|
||||||
|
pub.readPacketData(pbuf);
|
||||||
|
|
||||||
|
packetListener.save(pub);
|
||||||
|
|
||||||
wasSleeping = true;
|
wasSleeping = true;
|
||||||
|
|
||||||
@@ -260,13 +341,24 @@ public class RecordingEventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void enterMinecart(MinecartInteractEvent event) {
|
public void enterMinecart(MinecartInteractEvent event) {
|
||||||
try {
|
try {
|
||||||
if(event.getEntity() != mc.thePlayer) {
|
if(event.player != mc.thePlayer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packetListener.save(new SPacketEntityAttach(event.getPlayer(), event.getMinecart()));
|
S1BPacketEntityAttach pea = new S1BPacketEntityAttach();
|
||||||
|
|
||||||
lastRiding = event.getMinecart().getEntityId();
|
ByteBuf buf = Unpooled.buffer();
|
||||||
|
PacketBuffer pbuf = new PacketBuffer(buf);
|
||||||
|
|
||||||
|
pbuf.writeInt(event.player.getEntityId());
|
||||||
|
pbuf.writeInt(event.minecart.getEntityId());
|
||||||
|
pbuf.writeBoolean(false);
|
||||||
|
|
||||||
|
pea.readPacketData(pbuf);
|
||||||
|
|
||||||
|
packetListener.save(pea);
|
||||||
|
|
||||||
|
lastRiding = event.minecart.getEntityId();
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -275,7 +367,7 @@ public class RecordingEventHandler {
|
|||||||
public void onBlockBreakAnim(int breakerId, BlockPos pos, int progress) {
|
public void onBlockBreakAnim(int breakerId, BlockPos pos, int progress) {
|
||||||
EntityPlayer thePlayer = mc.thePlayer;
|
EntityPlayer thePlayer = mc.thePlayer;
|
||||||
if (thePlayer != null && breakerId == thePlayer.getEntityId()) {
|
if (thePlayer != null && breakerId == thePlayer.getEntityId()) {
|
||||||
packetListener.save(new SPacketBlockBreakAnim(breakerId, pos, progress));
|
packetListener.save(new S25PacketBlockBreakAnim(breakerId, pos, progress));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,14 +4,15 @@ import com.replaymod.recording.handler.RecordingEventHandler;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||||
import net.minecraft.network.play.server.SPacketPlayerListItem;
|
import net.minecraft.network.play.server.S07PacketRespawn;
|
||||||
import net.minecraft.network.play.server.SPacketRespawn;
|
import net.minecraft.network.play.server.S38PacketPlayerListItem;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -36,16 +37,18 @@ public abstract class MixinNetHandlerPlayClient {
|
|||||||
* @param ci Callback info
|
* @param ci Callback info
|
||||||
*/
|
*/
|
||||||
@Inject(method = "handlePlayerListItem", at=@At("HEAD"))
|
@Inject(method = "handlePlayerListItem", at=@At("HEAD"))
|
||||||
public void recordOwnJoin(SPacketPlayerListItem packet, CallbackInfo ci) {
|
public void recordOwnJoin(S38PacketPlayerListItem packet, CallbackInfo ci) {
|
||||||
if (gameController.thePlayer == null) return;
|
if (gameController.thePlayer == null) return;
|
||||||
|
|
||||||
RecordingEventHandler handler = getRecordingEventHandler();
|
RecordingEventHandler handler = getRecordingEventHandler();
|
||||||
if (handler != null && packet.getAction() == SPacketPlayerListItem.Action.ADD_PLAYER) {
|
if (handler != null && packet.func_179768_b() == S38PacketPlayerListItem.Action.ADD_PLAYER) {
|
||||||
for (SPacketPlayerListItem.AddPlayerData data : packet.getEntries()) {
|
@SuppressWarnings("unchecked")
|
||||||
if (data.getProfile() == null || data.getProfile().getId() == null) continue;
|
List<S38PacketPlayerListItem.AddPlayerData> dataList = packet.func_179767_a();
|
||||||
|
for (S38PacketPlayerListItem.AddPlayerData data : dataList) {
|
||||||
|
if (data.func_179962_a() == null || data.func_179962_a().getId() == null) continue;
|
||||||
// Only add spawn packet for our own player and only if he isn't known yet
|
// Only add spawn packet for our own player and only if he isn't known yet
|
||||||
if (data.getProfile().getId().equals(Minecraft.getMinecraft().thePlayer.getGameProfile().getId())
|
if (data.func_179962_a().getId().equals(Minecraft.getMinecraft().thePlayer.getGameProfile().getId())
|
||||||
&& !playerInfoMap.containsKey(data.getProfile().getId())) {
|
&& !playerInfoMap.containsKey(data.func_179962_a().getId())) {
|
||||||
handler.onPlayerJoin();
|
handler.onPlayerJoin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,12 +58,12 @@ public abstract class MixinNetHandlerPlayClient {
|
|||||||
/**
|
/**
|
||||||
* Record the own player entity respawning.
|
* Record the own player entity respawning.
|
||||||
* We cannot use the {@link net.minecraftforge.event.entity.EntityJoinWorldEvent} because that would also include
|
* We cannot use the {@link net.minecraftforge.event.entity.EntityJoinWorldEvent} because that would also include
|
||||||
* the first spawn which is already handled by {@link #recordOwnJoin(SPacketPlayerListItem, CallbackInfo)}.
|
* the first spawn which is already handled by {@link #recordOwnJoin(S38PacketPlayerListItem, CallbackInfo)}.
|
||||||
* @param packet The packet
|
* @param packet The packet
|
||||||
* @param ci Callback info
|
* @param ci Callback info
|
||||||
*/
|
*/
|
||||||
@Inject(method = "handleRespawn", at=@At("RETURN"))
|
@Inject(method = "handleRespawn", at=@At("RETURN"))
|
||||||
public void recordOwnRespawn(SPacketRespawn packet, CallbackInfo ci) {
|
public void recordOwnRespawn(S07PacketRespawn packet, CallbackInfo ci) {
|
||||||
RecordingEventHandler handler = getRecordingEventHandler();
|
RecordingEventHandler handler = getRecordingEventHandler();
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
handler.onPlayerRespawn();
|
handler.onPlayerRespawn();
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
package com.replaymod.recording.mixin;
|
|
||||||
|
|
||||||
import com.replaymod.recording.handler.RecordingEventHandler;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
|
|
||||||
@Mixin(PlayerControllerMP.class)
|
|
||||||
public abstract class MixinPlayerControllerMP implements RecordingEventHandler.RecordingEventSender {
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
private Minecraft mc;
|
|
||||||
|
|
||||||
// Redirects the call to playEvent without the initial player argument to the method with that argument
|
|
||||||
// The new method will then play it and (if applicable) record it. (See MixinWorldClient)
|
|
||||||
// This is necessary for the block break event (particles and sound) to be recorded. Otherwise it looks like the
|
|
||||||
// event was emitted because of a packet (player will be null) and not as it actually was (by the player).
|
|
||||||
@Redirect(method = "onPlayerDestroyBlock", at = @At(value = "INVOKE",
|
|
||||||
target = "Lnet/minecraft/world/World;playEvent(ILnet/minecraft/util/math/BlockPos;I)V"))
|
|
||||||
public void replayModRecording_playEvent_fixed(World world, int type, BlockPos pos, int data) {
|
|
||||||
world.playEvent(mc.thePlayer, type, pos, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@ package com.replaymod.recording.mixin;
|
|||||||
|
|
||||||
import com.replaymod.recording.handler.RecordingEventHandler;
|
import com.replaymod.recording.handler.RecordingEventHandler;
|
||||||
import net.minecraft.client.renderer.RenderGlobal;
|
import net.minecraft.client.renderer.RenderGlobal;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.BlockPos;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
package com.replaymod.recording.mixin;
|
|
||||||
|
|
||||||
import com.replaymod.recording.handler.RecordingEventHandler;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.profiler.Profiler;
|
|
||||||
import net.minecraft.util.SoundCategory;
|
|
||||||
import net.minecraft.util.SoundEvent;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraft.world.WorldProvider;
|
|
||||||
import net.minecraft.world.storage.ISaveHandler;
|
|
||||||
import net.minecraft.world.storage.WorldInfo;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
@Mixin(WorldClient.class)
|
|
||||||
public abstract class MixinWorldClient extends World implements RecordingEventHandler.RecordingEventSender {
|
|
||||||
@Shadow
|
|
||||||
private Minecraft mc;
|
|
||||||
|
|
||||||
protected MixinWorldClient(ISaveHandler saveHandlerIn, WorldInfo info, WorldProvider providerIn, Profiler profilerIn, boolean client) {
|
|
||||||
super(saveHandlerIn, info, providerIn, profilerIn, client);
|
|
||||||
}
|
|
||||||
|
|
||||||
private RecordingEventHandler replayModRecording_getRecordingEventHandler() {
|
|
||||||
return ((RecordingEventHandler.RecordingEventSender) mc.renderGlobal).getRecordingEventHandler();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sounds that are emitted by thePlayer no longer take the long way over the server
|
|
||||||
// but are instead played directly by the client. The server only sends these sounds to
|
|
||||||
// other clients so we have to record them manually.
|
|
||||||
// E.g. Block place sounds
|
|
||||||
@Inject(method = "playSound", at = @At("HEAD"))
|
|
||||||
public void replayModRecording_recordClientSound(EntityPlayer player, double x, double y, double z, SoundEvent sound, SoundCategory category,
|
|
||||||
float volume, float pitch, CallbackInfo ci) {
|
|
||||||
if (player == mc.thePlayer) {
|
|
||||||
RecordingEventHandler handler = replayModRecording_getRecordingEventHandler();
|
|
||||||
if (handler != null) {
|
|
||||||
handler.onClientSound(sound, category, x, y, z, volume, pitch);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Same goes for level events (also called effects). E.g. door open, block break, etc.
|
|
||||||
// These are handled in the World class, so we override the method in WorldClient and add our special handling.
|
|
||||||
@Override
|
|
||||||
public void playEvent(EntityPlayer player, int type, BlockPos pos, int data) {
|
|
||||||
if (player == mc.thePlayer) {
|
|
||||||
// We caused this event, the server won't send it to us
|
|
||||||
RecordingEventHandler handler = replayModRecording_getRecordingEventHandler();
|
|
||||||
if (handler != null) {
|
|
||||||
handler.onClientEffect(type, pos, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
super.playEvent(player, type, pos, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,24 +9,21 @@ import io.netty.buffer.Unpooled;
|
|||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.entity.DataWatcher;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.network.EnumConnectionState;
|
import net.minecraft.network.EnumConnectionState;
|
||||||
import net.minecraft.network.EnumPacketDirection;
|
import net.minecraft.network.EnumPacketDirection;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraft.network.datasync.EntityDataManager;
|
|
||||||
import net.minecraft.network.play.server.*;
|
import net.minecraft.network.play.server.*;
|
||||||
import net.minecraft.util.text.TextComponentString;
|
import net.minecraft.util.ChatComponentText;
|
||||||
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
|
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -87,8 +84,8 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
|||||||
|
|
||||||
public void save(Packet packet) {
|
public void save(Packet packet) {
|
||||||
try {
|
try {
|
||||||
if(packet instanceof SPacketSpawnPlayer) {
|
if(packet instanceof S0CPacketSpawnPlayer) {
|
||||||
UUID uuid = ((SPacketSpawnPlayer) packet).getUniqueId();
|
UUID uuid = ((S0CPacketSpawnPlayer) packet).func_179819_c();
|
||||||
Set<String> uuids = new HashSet<>(Arrays.asList(metaData.getPlayers()));
|
Set<String> uuids = new HashSet<>(Arrays.asList(metaData.getPlayers()));
|
||||||
uuids.add(uuid.toString());
|
uuids.add(uuid.toString());
|
||||||
metaData.setPlayers(uuids.toArray(new String[uuids.size()]));
|
metaData.setPlayers(uuids.toArray(new String[uuids.size()]));
|
||||||
@@ -154,16 +151,16 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
|||||||
try {
|
try {
|
||||||
Packet packet = (Packet) msg;
|
Packet packet = (Packet) msg;
|
||||||
|
|
||||||
if(packet instanceof SPacketCollectItem) {
|
if(packet instanceof S0DPacketCollectItem) {
|
||||||
if(mc.thePlayer != null ||
|
if(mc.thePlayer != null ||
|
||||||
((SPacketCollectItem) packet).getEntityID() == mc.thePlayer.getEntityId()) {
|
((S0DPacketCollectItem) packet).func_149353_d() == mc.thePlayer.getEntityId()) {
|
||||||
super.channelRead(ctx, msg);
|
super.channelRead(ctx, msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packet instanceof SPacketResourcePackSend) {
|
if (packet instanceof S48PacketResourcePackSend) {
|
||||||
save(resourcePackRecorder.handleResourcePack((SPacketResourcePackSend) packet));
|
save(resourcePackRecorder.handleResourcePack((S48PacketResourcePackSend) packet));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,10 +173,10 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
|||||||
|
|
||||||
save(packet);
|
save(packet);
|
||||||
|
|
||||||
if (packet instanceof SPacketCustomPayload) {
|
if (packet instanceof S3FPacketCustomPayload) {
|
||||||
SPacketCustomPayload p = (SPacketCustomPayload) packet;
|
S3FPacketCustomPayload p = (S3FPacketCustomPayload) packet;
|
||||||
if (Restrictions.PLUGIN_CHANNEL.equals(p.getChannelName())) {
|
if (Restrictions.PLUGIN_CHANNEL.equals(p.getChannelName())) {
|
||||||
packet = new SPacketDisconnect(new TextComponentString("Please update to view this replay."));
|
packet = new S40PacketDisconnect(new ChatComponentText("Please update to view this replay."));
|
||||||
save(packet);
|
save(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,31 +189,27 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
|||||||
super.channelRead(ctx, msg);
|
super.channelRead(ctx, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> void DataManager_set(EntityDataManager dataManager, EntityDataManager.DataEntry<T> entry) {
|
|
||||||
dataManager.register(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private byte[] getPacketData(Packet packet) throws IOException {
|
private byte[] getPacketData(Packet packet) throws IOException {
|
||||||
if (packet instanceof SPacketSpawnMob) {
|
if(packet instanceof S0FPacketSpawnMob) {
|
||||||
SPacketSpawnMob p = (SPacketSpawnMob) packet;
|
S0FPacketSpawnMob p = (S0FPacketSpawnMob) packet;
|
||||||
if (p.dataManager == null) {
|
if (p.field_149043_l == null) {
|
||||||
p.dataManager = new EntityDataManager(null);
|
p.field_149043_l = new DataWatcher(null);
|
||||||
if (p.getDataManagerEntries() != null) {
|
if(p.func_149027_c() != null) {
|
||||||
for (EntityDataManager.DataEntry<?> entry : p.getDataManagerEntries()) {
|
for(DataWatcher.WatchableObject wo : (List<DataWatcher.WatchableObject>) p.func_149027_c()) {
|
||||||
DataManager_set(p.dataManager, entry);
|
p.field_149043_l.addObject(wo.getDataValueId(), wo.getObject());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packet instanceof SPacketSpawnPlayer) {
|
if(packet instanceof S0CPacketSpawnPlayer) {
|
||||||
SPacketSpawnPlayer p = (SPacketSpawnPlayer) packet;
|
S0CPacketSpawnPlayer p = (S0CPacketSpawnPlayer) packet;
|
||||||
if (p.watcher == null) {
|
if (p.field_148960_i == null) {
|
||||||
p.watcher = new EntityDataManager(null);
|
p.field_148960_i = new DataWatcher(null);
|
||||||
if (p.getDataManagerEntries() != null) {
|
if(p.func_148944_c() != null) {
|
||||||
for (EntityDataManager.DataEntry<?> entry : p.getDataManagerEntries()) {
|
for(DataWatcher.WatchableObject wo : (List<DataWatcher.WatchableObject>) p.func_148944_c()) {
|
||||||
DataManager_set(p.watcher, entry);
|
p.field_148960_i.addObject(wo.getDataValueId(), wo.getObject());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,14 +9,15 @@ import com.replaymod.replaystudio.replay.ReplayFile;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiScreenWorking;
|
import net.minecraft.client.gui.GuiScreenWorking;
|
||||||
import net.minecraft.client.gui.GuiYesNo;
|
import net.minecraft.client.gui.GuiYesNo;
|
||||||
|
import net.minecraft.client.gui.GuiYesNoCallback;
|
||||||
import net.minecraft.client.multiplayer.ServerData;
|
import net.minecraft.client.multiplayer.ServerData;
|
||||||
import net.minecraft.client.multiplayer.ServerList;
|
import net.minecraft.client.multiplayer.ServerList;
|
||||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.client.resources.ResourcePackRepository;
|
import net.minecraft.client.resources.ResourcePackRepository;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraft.network.play.client.CPacketResourcePackStatus;
|
import net.minecraft.network.play.client.C19PacketResourcePackStatus;
|
||||||
import net.minecraft.network.play.server.SPacketResourcePackSend;
|
import net.minecraft.network.play.server.S48PacketResourcePackSend;
|
||||||
import net.minecraft.util.HttpUtil;
|
import net.minecraft.util.HttpUtil;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
@@ -26,6 +27,7 @@ import javax.annotation.Nonnull;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,6 +54,9 @@ public class ResourcePackRecorder {
|
|||||||
boolean doWrite = false; // Whether we are the first and have to write it
|
boolean doWrite = false; // Whether we are the first and have to write it
|
||||||
synchronized (replayFile) { // Need to read, modify and write the resource pack index atomically
|
synchronized (replayFile) { // Need to read, modify and write the resource pack index atomically
|
||||||
Map<Integer, String> index = replayFile.getResourcePackIndex();
|
Map<Integer, String> index = replayFile.getResourcePackIndex();
|
||||||
|
if (index == null) {
|
||||||
|
index = new HashMap<>();
|
||||||
|
}
|
||||||
if (!index.containsValue(hash)) {
|
if (!index.containsValue(hash)) {
|
||||||
// Hash is unknown, we have to write the resource pack ourselves
|
// Hash is unknown, we have to write the resource pack ourselves
|
||||||
doWrite = true;
|
doWrite = true;
|
||||||
@@ -70,12 +75,12 @@ public class ResourcePackRecorder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized SPacketResourcePackSend handleResourcePack(SPacketResourcePackSend packet) {
|
public synchronized S48PacketResourcePackSend handleResourcePack(S48PacketResourcePackSend packet) {
|
||||||
final int requestId = nextRequestId++;
|
final int requestId = nextRequestId++;
|
||||||
final NetHandlerPlayClient netHandler = mc.getConnection();
|
final NetHandlerPlayClient netHandler = mc.getNetHandler();
|
||||||
final NetworkManager netManager = netHandler.getNetworkManager();
|
final NetworkManager netManager = netHandler.getNetworkManager();
|
||||||
final String url = packet.getURL();
|
final String url = packet.func_179783_a();
|
||||||
final String hash = packet.getHash();
|
final String hash = packet.func_179784_b();
|
||||||
|
|
||||||
if (url.startsWith("level://")) {
|
if (url.startsWith("level://")) {
|
||||||
String levelName = url.substring("level://".length());
|
String levelName = url.substring("level://".length());
|
||||||
@@ -83,60 +88,65 @@ public class ResourcePackRecorder {
|
|||||||
final File levelDir = new File(savesDir, levelName);
|
final File levelDir = new File(savesDir, levelName);
|
||||||
|
|
||||||
if (levelDir.isFile()) {
|
if (levelDir.isFile()) {
|
||||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.ACCEPTED));
|
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.ACCEPTED));
|
||||||
Futures.addCallback(mc.getResourcePackRepository().setResourcePackInstance(levelDir), new FutureCallback<Object>() {
|
Futures.addCallback(mc.getResourcePackRepository().func_177319_a(levelDir), new FutureCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Object result) {
|
public void onSuccess(Object result) {
|
||||||
recordResourcePack(levelDir, requestId);
|
recordResourcePack(levelDir, requestId);
|
||||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.SUCCESSFULLY_LOADED));
|
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.SUCCESSFULLY_LOADED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@Nonnull Throwable throwable) {
|
public void onFailure(@Nonnull Throwable throwable) {
|
||||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final ServerData serverData = mc.getCurrentServerData();
|
final ServerData serverData = mc.getCurrentServerData();
|
||||||
if (serverData != null && serverData.getResourceMode() == ServerData.ServerResourceMode.ENABLED) {
|
if (serverData != null && serverData.getResourceMode() == ServerData.ServerResourceMode.ENABLED) {
|
||||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.ACCEPTED));
|
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.ACCEPTED));
|
||||||
downloadResourcePackFuture(requestId, url, hash);
|
downloadResourcePackFuture(requestId, url, hash);
|
||||||
} else if (serverData != null && serverData.getResourceMode() != ServerData.ServerResourceMode.PROMPT) {
|
} else if (serverData != null && serverData.getResourceMode() != ServerData.ServerResourceMode.PROMPT) {
|
||||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.DECLINED));
|
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.DECLINED));
|
||||||
} else {
|
} else {
|
||||||
mc.addScheduledTask(() -> mc.displayGuiScreen(new GuiYesNo((result, id) -> {
|
// Lambdas MUST NOT be used with methods that need re-obfuscation in FG prior to 2.2 (will result in AbstractMethodError)
|
||||||
if (serverData != null) {
|
//noinspection Convert2Lambda
|
||||||
serverData.setResourceMode(result ? ServerData.ServerResourceMode.ENABLED : ServerData.ServerResourceMode.DISABLED);
|
mc.addScheduledTask(() -> mc.displayGuiScreen(new GuiYesNo(new GuiYesNoCallback() {
|
||||||
}
|
@Override
|
||||||
if (result) {
|
public void confirmClicked(boolean result, int id) {
|
||||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.ACCEPTED));
|
if (serverData != null) {
|
||||||
downloadResourcePackFuture(requestId, url, hash);
|
serverData.setResourceMode(result ? ServerData.ServerResourceMode.ENABLED : ServerData.ServerResourceMode.DISABLED);
|
||||||
} else {
|
}
|
||||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.DECLINED));
|
if (result) {
|
||||||
}
|
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.ACCEPTED));
|
||||||
|
ResourcePackRecorder.this.downloadResourcePackFuture(requestId, url, hash);
|
||||||
|
} else {
|
||||||
|
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.DECLINED));
|
||||||
|
}
|
||||||
|
|
||||||
ServerList.saveSingleServer(serverData);
|
ServerList.func_147414_b(serverData);
|
||||||
mc.displayGuiScreen(null);
|
mc.displayGuiScreen(null);
|
||||||
|
}
|
||||||
}, I18n.format("multiplayer.texturePrompt.line1"), I18n.format("multiplayer.texturePrompt.line2"), 0)));
|
}, I18n.format("multiplayer.texturePrompt.line1"), I18n.format("multiplayer.texturePrompt.line2"), 0)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new SPacketResourcePackSend("replay://" + requestId, "");
|
return new S48PacketResourcePackSend("replay://" + requestId, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadResourcePackFuture(int requestId, String url, final String hash) {
|
private void downloadResourcePackFuture(int requestId, String url, final String hash) {
|
||||||
Futures.addCallback(downloadResourcePack(requestId, url, hash), new FutureCallback() {
|
Futures.addCallback(downloadResourcePack(requestId, url, hash), new FutureCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Object result) {
|
public void onSuccess(Object result) {
|
||||||
mc.getConnection().sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.SUCCESSFULLY_LOADED));
|
mc.getNetHandler().addToSendQueue(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.SUCCESSFULLY_LOADED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@Nonnull Throwable throwable) {
|
public void onFailure(@Nonnull Throwable throwable) {
|
||||||
mc.getConnection().sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
mc.getNetHandler().addToSendQueue(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -161,16 +171,16 @@ public class ResourcePackRecorder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final File file = new File(repo.dirServerResourcepacks, fileName);
|
final File file = new File(repo.dirServerResourcepacks, fileName);
|
||||||
repo.lock.lock();
|
repo.field_177321_h.lock();
|
||||||
try {
|
try {
|
||||||
repo.clearResourcePack();
|
repo.func_148529_f();
|
||||||
|
|
||||||
if (file.exists() && hash.length() == 40) {
|
if (file.exists() && hash.length() == 40) {
|
||||||
try {
|
try {
|
||||||
String fileHash = Hashing.sha1().hashBytes(Files.toByteArray(file)).toString();
|
String fileHash = Hashing.sha1().hashBytes(Files.toByteArray(file)).toString();
|
||||||
if (fileHash.equals(hash)) {
|
if (fileHash.equals(hash)) {
|
||||||
recordResourcePack(file, requestId);
|
recordResourcePack(file, requestId);
|
||||||
return repo.setResourcePackInstance(file);
|
return repo.func_177319_a(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.warn("File " + file + " had wrong hash (expected " + hash + ", found " + fileHash + "). Deleting it.");
|
logger.warn("File " + file + " had wrong hash (expected " + hash + ", found " + fileHash + "). Deleting it.");
|
||||||
@@ -186,13 +196,13 @@ public class ResourcePackRecorder {
|
|||||||
|
|
||||||
Futures.getUnchecked(mc.addScheduledTask(() -> mc.displayGuiScreen(guiScreen)));
|
Futures.getUnchecked(mc.addScheduledTask(() -> mc.displayGuiScreen(guiScreen)));
|
||||||
|
|
||||||
Map<String, String> sessionInfo = ResourcePackRepository.getDownloadHeaders();
|
Map sessionInfo = Minecraft.getSessionInfo();
|
||||||
repo.downloadingPacks = HttpUtil.downloadResourcePack(file, url, sessionInfo, 50 * 1024 * 1024, guiScreen, mc.getProxy());
|
repo.field_177322_i = HttpUtil.func_180192_a(file, url, sessionInfo, 50 * 1024 * 1024, guiScreen, mc.getProxy());
|
||||||
Futures.addCallback(repo.downloadingPacks, new FutureCallback<Object>() {
|
Futures.addCallback(repo.field_177322_i, new FutureCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Object value) {
|
public void onSuccess(Object value) {
|
||||||
recordResourcePack(file, requestId);
|
recordResourcePack(file, requestId);
|
||||||
repo.setResourcePackInstance(file);
|
repo.func_177319_a(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -200,9 +210,9 @@ public class ResourcePackRecorder {
|
|||||||
throwable.printStackTrace();
|
throwable.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return repo.downloadingPacks;
|
return repo.field_177322_i;
|
||||||
} finally {
|
} finally {
|
||||||
repo.lock.unlock();
|
repo.field_177321_h.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import com.replaymod.render.utils.RenderJob;
|
|||||||
import com.replaymod.replay.events.ReplayCloseEvent;
|
import com.replaymod.replay.events.ReplayCloseEvent;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
import net.minecraft.util.ReportedException;
|
import net.minecraft.util.ReportedException;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
@@ -45,7 +45,7 @@ public class ReplayModRender {
|
|||||||
core = ReplayMod.instance;
|
core = ReplayMod.instance;
|
||||||
configuration = new Configuration(event.getSuggestedConfigurationFile());
|
configuration = new Configuration(event.getSuggestedConfigurationFile());
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
FMLCommonHandler.instance().bus().register(this);
|
||||||
|
|
||||||
core.getSettingsRegistry().register(Setting.class);
|
core.getSettingsRegistry().register(Setting.class);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,9 +75,9 @@ public class ODSFrameCapturer implements FrameCapturer<ODSOpenGlFrame> {
|
|||||||
linkState(1, "lightMapEnabled");
|
linkState(1, "lightMapEnabled");
|
||||||
linkState(2, "hurtTextureEnabled");
|
linkState(2, "hurtTextureEnabled");
|
||||||
final Program.Uniform uniform = shaderProgram.getUniformVariable("fogEnabled");
|
final Program.Uniform uniform = shaderProgram.getUniformVariable("fogEnabled");
|
||||||
previousFogState = GlStateManager.fogState.fog;
|
previousFogState = GlStateManager.fogState.field_179049_a;
|
||||||
uniform.set(previousFogState.currentState);
|
uniform.set(previousFogState.currentState);
|
||||||
GlStateManager.fogState.fog = new BooleanState(previousFogState.capability) {
|
GlStateManager.fogState.field_179049_a = new BooleanState(previousFogState.capability) {
|
||||||
@Override
|
@Override
|
||||||
public void setState(boolean state) {
|
public void setState(boolean state) {
|
||||||
super.setState(state);
|
super.setState(state);
|
||||||
@@ -135,7 +135,7 @@ public class ODSFrameCapturer implements FrameCapturer<ODSOpenGlFrame> {
|
|||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
GlStateManager.textureState[i].texture2DState = previousStates[i];
|
GlStateManager.textureState[i].texture2DState = previousStates[i];
|
||||||
}
|
}
|
||||||
GlStateManager.fogState.fog = previousFogState;
|
GlStateManager.fogState.field_179049_a = previousFogState;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CubicStereoFrameCapturer extends CubicPboOpenGlFrameCapturer {
|
private class CubicStereoFrameCapturer extends CubicPboOpenGlFrameCapturer {
|
||||||
|
|||||||
@@ -80,8 +80,8 @@ public class GuiRenderSettings extends GuiScreen implements Closeable {
|
|||||||
}
|
}
|
||||||
}).setMinSize(new Dimension(0, 20)).setValues(RenderSettings.EncodingPreset.values());
|
}).setMinSize(new Dimension(0, 20)).setValues(RenderSettings.EncodingPreset.values());
|
||||||
|
|
||||||
public final GuiNumberField videoWidth = new GuiNumberField().setSize(50, 20).setMinValue(1);
|
public final GuiNumberField videoWidth = new GuiNumberField().setSize(50, 20).setMinValue(1).setValidateOnFocusChange(true);
|
||||||
public final GuiNumberField videoHeight = new GuiNumberField().setSize(50, 20).setMinValue(1);
|
public final GuiNumberField videoHeight = new GuiNumberField().setSize(50, 20).setMinValue(1).setValidateOnFocusChange(true);
|
||||||
public final GuiSlider frameRateSlider = new GuiSlider().onValueChanged(new Runnable() {
|
public final GuiSlider frameRateSlider = new GuiSlider().onValueChanged(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -93,7 +93,7 @@ public class GuiRenderSettings extends GuiScreen implements Closeable {
|
|||||||
.setLayout(new HorizontalLayout(HorizontalLayout.Alignment.RIGHT).setSpacing(2))
|
.setLayout(new HorizontalLayout(HorizontalLayout.Alignment.RIGHT).setSpacing(2))
|
||||||
.addElements(new HorizontalLayout.Data(0.5), videoWidth, new GuiLabel().setText("*"), videoHeight);
|
.addElements(new HorizontalLayout.Data(0.5), videoWidth, new GuiLabel().setText("*"), videoHeight);
|
||||||
|
|
||||||
public final GuiNumberField bitRateField = new GuiNumberField().setValue(10).setSize(50, 20);
|
public final GuiNumberField bitRateField = new GuiNumberField().setValue(10).setSize(50, 20).setValidateOnFocusChange(true);
|
||||||
public final GuiDropdownMenu<String> bitRateUnit = new GuiDropdownMenu<String>()
|
public final GuiDropdownMenu<String> bitRateUnit = new GuiDropdownMenu<String>()
|
||||||
.setSize(50, 20).setValues("bps", "kbps", "mbps").setSelected("mbps");
|
.setSize(50, 20).setValues("bps", "kbps", "mbps").setSelected("mbps");
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,13 @@ import net.minecraft.client.renderer.chunk.RenderChunk;
|
|||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.concurrent.PriorityBlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
|
|
||||||
public class ChunkLoadingRenderGlobal {
|
public class ChunkLoadingRenderGlobal {
|
||||||
|
|
||||||
private final RenderGlobal hooked;
|
private final RenderGlobal hooked;
|
||||||
private final ChunkRenderDispatcher renderDispatcher;
|
private final ChunkRenderDispatcher renderDispatcher;
|
||||||
private final JailingQueue<ChunkCompileTaskGenerator> workerJailingQueue;
|
private final JailingQueue<?> workerJailingQueue;
|
||||||
private final CustomChunkRenderWorker renderWorker;
|
private final CustomChunkRenderWorker renderWorker;
|
||||||
private int frame;
|
private int frame;
|
||||||
|
|
||||||
@@ -27,10 +27,10 @@ public class ChunkLoadingRenderGlobal {
|
|||||||
this.renderWorker = new CustomChunkRenderWorker(renderDispatcher, new RegionRenderCacheBuilder());
|
this.renderWorker = new CustomChunkRenderWorker(renderDispatcher, new RegionRenderCacheBuilder());
|
||||||
|
|
||||||
int workerThreads = renderDispatcher.listThreadedWorkers.size();
|
int workerThreads = renderDispatcher.listThreadedWorkers.size();
|
||||||
PriorityBlockingQueue<ChunkCompileTaskGenerator> queueChunkUpdates = renderDispatcher.queueChunkUpdates;
|
BlockingQueue<Object> queueChunkUpdates = renderDispatcher.queueChunkUpdates;
|
||||||
workerJailingQueue = new JailingQueue<>(queueChunkUpdates);
|
workerJailingQueue = new JailingQueue<>(queueChunkUpdates);
|
||||||
renderDispatcher.queueChunkUpdates = workerJailingQueue;
|
renderDispatcher.queueChunkUpdates = workerJailingQueue;
|
||||||
ChunkCompileTaskGenerator element = new ChunkCompileTaskGenerator(null, null, 0);
|
ChunkCompileTaskGenerator element = new ChunkCompileTaskGenerator(null, null);
|
||||||
element.finish();
|
element.finish();
|
||||||
for (int i = 0; i < workerThreads; i++) {
|
for (int i = 0; i < workerThreads; i++) {
|
||||||
queueChunkUpdates.add(element);
|
queueChunkUpdates.add(element);
|
||||||
@@ -51,6 +51,7 @@ public class ChunkLoadingRenderGlobal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void updateChunks() {
|
public void updateChunks() {
|
||||||
while (renderDispatcher.runChunkUploads(0)) {
|
while (renderDispatcher.runChunkUploads(0)) {
|
||||||
hooked.displayListEntitiesDirty = true;
|
hooked.displayListEntitiesDirty = true;
|
||||||
@@ -58,7 +59,7 @@ public class ChunkLoadingRenderGlobal {
|
|||||||
|
|
||||||
while (!renderDispatcher.queueChunkUpdates.isEmpty()) {
|
while (!renderDispatcher.queueChunkUpdates.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
renderWorker.processTask(renderDispatcher.queueChunkUpdates.poll());
|
renderWorker.processTask((ChunkCompileTaskGenerator) renderDispatcher.queueChunkUpdates.poll());
|
||||||
} catch (InterruptedException ignored) { }
|
} catch (InterruptedException ignored) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +69,7 @@ public class ChunkLoadingRenderGlobal {
|
|||||||
|
|
||||||
renderDispatcher.updateChunkNow(renderchunk);
|
renderDispatcher.updateChunkNow(renderchunk);
|
||||||
|
|
||||||
renderchunk.clearNeedsUpdate();
|
renderchunk.setNeedsUpdate(false);
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.replaymod.render.mixin;
|
||||||
|
|
||||||
|
import com.replaymod.render.hooks.EntityRendererHandler;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.particle.EffectRenderer;
|
||||||
|
import net.minecraft.client.particle.EntityFX;
|
||||||
|
import net.minecraft.client.renderer.WorldRenderer;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
@Mixin(EffectRenderer.class)
|
||||||
|
public abstract class MixinEffectRenderer {
|
||||||
|
@Redirect(method = "renderParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/EntityFX;func_180434_a(Lnet/minecraft/client/renderer/WorldRenderer;Lnet/minecraft/entity/Entity;FFFFFF)V"))
|
||||||
|
private void renderNormalParticle(EntityFX fx, WorldRenderer worldRenderer, Entity view, float partialTicks,
|
||||||
|
float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||||
|
renderParticle(fx, worldRenderer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "renderLitParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/EntityFX;func_180434_a(Lnet/minecraft/client/renderer/WorldRenderer;Lnet/minecraft/entity/Entity;FFFFFF)V"))
|
||||||
|
private void renderLitParticle(EntityFX fx, WorldRenderer worldRenderer, Entity view, float partialTicks,
|
||||||
|
float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||||
|
renderParticle(fx, worldRenderer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderParticle(EntityFX fx, WorldRenderer worldRenderer, Entity view, float partialTicks,
|
||||||
|
float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||||
|
EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) Minecraft.getMinecraft().entityRenderer).replayModRender_getHandler();
|
||||||
|
if (handler != null && handler.omnidirectional) {
|
||||||
|
// Align all particles towards the camera
|
||||||
|
double dx = fx.prevPosX + (fx.posX - fx.prevPosX) * partialTicks - view.posX;
|
||||||
|
double dy = fx.prevPosY + (fx.posY - fx.prevPosY) * partialTicks - view.posY;
|
||||||
|
double dz = fx.prevPosZ + (fx.posZ - fx.prevPosZ) * partialTicks - view.posZ;
|
||||||
|
double pitch = -Math.atan2(dy, Math.sqrt(dx * dx + dz * dz));
|
||||||
|
double yaw = -Math.atan2(dx, dz);
|
||||||
|
|
||||||
|
rotX = (float) Math.cos(yaw);
|
||||||
|
rotZ = (float) Math.sin(yaw);
|
||||||
|
rotXZ = (float) Math.cos(pitch);
|
||||||
|
|
||||||
|
rotYZ = (float) (-rotZ * Math.sin(pitch));
|
||||||
|
rotXY = (float) (rotX * Math.sin(pitch));
|
||||||
|
}
|
||||||
|
fx.func_180434_a(worldRenderer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ import net.minecraft.client.renderer.RenderGlobal;
|
|||||||
import net.minecraft.client.settings.GameSettings;
|
import net.minecraft.client.settings.GameSettings;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
import org.lwjgl.util.ReadableColor;
|
import org.lwjgl.util.ReadableColor;
|
||||||
import org.lwjgl.util.glu.Project;
|
import org.lwjgl.util.glu.Project;
|
||||||
@@ -118,10 +118,10 @@ public abstract class MixinEntityRenderer implements EntityRendererHandler.IEnti
|
|||||||
@Shadow
|
@Shadow
|
||||||
public abstract void renderHand(float partialTicks, int renderPass);
|
public abstract void renderHand(float partialTicks, int renderPass);
|
||||||
|
|
||||||
@Redirect(method = "renderWorldPass", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderGlobal;drawSelectionBox(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/util/math/RayTraceResult;IF)V"))
|
@Redirect(method = "renderWorldPass", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderGlobal;drawSelectionBox(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/util/MovingObjectPosition;IF)V"))
|
||||||
private void replayModRender_drawSelectionBox(RenderGlobal instance, EntityPlayer player, RayTraceResult rtr, int alwaysZero, float partialTicks) {
|
private void replayModRender_drawSelectionBox(RenderGlobal instance, EntityPlayer player, MovingObjectPosition mop, int alwaysZero, float partialTicks) {
|
||||||
if (replayModRender_handler == null) {
|
if (replayModRender_handler == null) {
|
||||||
instance.drawSelectionBox(player, rtr, alwaysZero, partialTicks);
|
instance.drawSelectionBox(player, mop, alwaysZero, partialTicks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
package com.replaymod.render.mixin;
|
|
||||||
|
|
||||||
import com.replaymod.render.hooks.EntityRendererHandler;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.particle.Particle;
|
|
||||||
import net.minecraft.client.particle.ParticleManager;
|
|
||||||
import net.minecraft.client.renderer.VertexBuffer;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
|
|
||||||
@Mixin(ParticleManager.class)
|
|
||||||
public abstract class MixinParticleManager {
|
|
||||||
@Redirect(method = "renderParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/Particle;renderParticle(Lnet/minecraft/client/renderer/VertexBuffer;Lnet/minecraft/entity/Entity;FFFFFF)V"))
|
|
||||||
private void renderNormalParticle(Particle particle, VertexBuffer vertexBuffer, Entity view, float partialTicks,
|
|
||||||
float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
|
||||||
renderParticle(particle, vertexBuffer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "renderLitParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/Particle;renderParticle(Lnet/minecraft/client/renderer/VertexBuffer;Lnet/minecraft/entity/Entity;FFFFFF)V"))
|
|
||||||
private void renderLitParticle(Particle particle, VertexBuffer vertexBuffer, Entity view, float partialTicks,
|
|
||||||
float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
|
||||||
renderParticle(particle, vertexBuffer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderParticle(Particle particle, VertexBuffer vertexBuffer, Entity view, float partialTicks,
|
|
||||||
float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
|
||||||
EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) Minecraft.getMinecraft().entityRenderer).replayModRender_getHandler();
|
|
||||||
if (handler != null && handler.omnidirectional) {
|
|
||||||
// Align all particles towards the camera
|
|
||||||
double dx = particle.prevPosX + (particle.posX - particle.prevPosX) * partialTicks - view.posX;
|
|
||||||
double dy = particle.prevPosY + (particle.posY - particle.prevPosY) * partialTicks - view.posY;
|
|
||||||
double dz = particle.prevPosZ + (particle.posZ - particle.prevPosZ) * partialTicks - view.posZ;
|
|
||||||
double pitch = -Math.atan2(dy, Math.sqrt(dx * dx + dz * dz));
|
|
||||||
double yaw = -Math.atan2(dx, dz);
|
|
||||||
|
|
||||||
rotX = (float) Math.cos(yaw);
|
|
||||||
rotZ = (float) Math.sin(yaw);
|
|
||||||
rotXZ = (float) Math.cos(pitch);
|
|
||||||
|
|
||||||
rotYZ = (float) (-rotZ * Math.sin(pitch));
|
|
||||||
rotXY = (float) (rotX * Math.sin(pitch));
|
|
||||||
}
|
|
||||||
particle.renderParticle(vertexBuffer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,14 +7,15 @@ import net.minecraft.entity.Entity;
|
|||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
@Mixin(Render.class)
|
@Mixin(Render.class)
|
||||||
public abstract class MixinRender {
|
public abstract class MixinRender {
|
||||||
@Inject(method = "renderLivingLabel", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "canRenderName", at = @At("HEAD"), cancellable = true)
|
||||||
private void replayModRender_areAllNamesHidden(Entity entityIn, String str, double x, double y, double z, int maxDistance, CallbackInfo ci) {
|
private void replayModRender_areAllNamesHidden(Entity entity, CallbackInfoReturnable<Boolean> ci) {
|
||||||
EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) Minecraft.getMinecraft().entityRenderer).replayModRender_getHandler();
|
EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) Minecraft.getMinecraft().entityRenderer).replayModRender_getHandler();
|
||||||
if (handler != null && !handler.getSettings().isRenderNameTags()) {
|
if (handler != null && !handler.getSettings().isRenderNameTags()) {
|
||||||
|
ci.setReturnValue(false);
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,16 @@ package com.replaymod.render.mixin;
|
|||||||
import com.replaymod.render.hooks.ChunkLoadingRenderGlobal;
|
import com.replaymod.render.hooks.ChunkLoadingRenderGlobal;
|
||||||
import net.minecraft.client.renderer.RenderGlobal;
|
import net.minecraft.client.renderer.RenderGlobal;
|
||||||
import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher;
|
import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher;
|
||||||
|
import net.minecraft.client.renderer.chunk.RenderChunk;
|
||||||
import net.minecraft.client.renderer.culling.ICamera;
|
import net.minecraft.client.renderer.culling.ICamera;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
@Mixin(RenderGlobal.class)
|
@Mixin(RenderGlobal.class)
|
||||||
public abstract class MixinRenderGlobal {
|
public abstract class MixinRenderGlobal {
|
||||||
@@ -34,8 +37,6 @@ public abstract class MixinRenderGlobal {
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
setupTerrain(viewEntity, partialTicks, camera, replayModRender_hook.nextFrameId(), playerSpectator);
|
setupTerrain(viewEntity, partialTicks, camera, replayModRender_hook.nextFrameId(), playerSpectator);
|
||||||
|
|
||||||
replayModRender_hook.updateChunks();
|
|
||||||
} while (displayListEntitiesDirty);
|
} while (displayListEntitiesDirty);
|
||||||
|
|
||||||
displayListEntitiesDirty = true;
|
displayListEntitiesDirty = true;
|
||||||
@@ -45,6 +46,13 @@ public abstract class MixinRenderGlobal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "isPositionInRenderChunk", at = @At("HEAD"), cancellable = true)
|
||||||
|
public void replayModRender_isPositionInRenderChunk(BlockPos pos, RenderChunk chunk, CallbackInfoReturnable<Boolean> ci) {
|
||||||
|
if (replayModRender_hook != null) {
|
||||||
|
ci.setReturnValue(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "updateChunks", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "updateChunks", at = @At("HEAD"), cancellable = true)
|
||||||
public void replayModRender_updateChunks(long finishTimeNano, CallbackInfo ci) {
|
public void replayModRender_updateChunks(long finishTimeNano, CallbackInfo ci) {
|
||||||
if (replayModRender_hook != null) {
|
if (replayModRender_hook != null) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
|||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
@Mixin(RenderManager.class)
|
@Mixin(RenderManager.class)
|
||||||
public abstract class MixinRenderManager {
|
public abstract class MixinRenderManager {
|
||||||
@@ -19,7 +19,7 @@ public abstract class MixinRenderManager {
|
|||||||
private float playerViewY;
|
private float playerViewY;
|
||||||
|
|
||||||
@Inject(method = "doRenderEntity", at = @At("HEAD"))
|
@Inject(method = "doRenderEntity", at = @At("HEAD"))
|
||||||
private void replayModRender_reorientForCubicRendering(Entity entity, double dx, double dy, double dz, float iDoNotKnow, float partialTicks, boolean iDoNotCare, CallbackInfo ci) {
|
private void replayModRender_reorientForCubicRendering(Entity entity, double dx, double dy, double dz, float iDoNotKnow, float partialTicks, boolean iDoNotCare, CallbackInfoReturnable ci) {
|
||||||
EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) Minecraft.getMinecraft().entityRenderer).replayModRender_getHandler();
|
EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) Minecraft.getMinecraft().entityRenderer).replayModRender_getHandler();
|
||||||
if (handler != null && handler.omnidirectional) {
|
if (handler != null && handler.omnidirectional) {
|
||||||
double pitch = -Math.atan2(dy, Math.sqrt(dx * dx + dz * dz));
|
double pitch = -Math.atan2(dy, Math.sqrt(dx * dx + dz * dz));
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.replaymod.render.mixin;
|
||||||
|
|
||||||
|
import com.replaymod.render.hooks.EntityRendererHandler;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.entity.RendererLivingEntity;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@Mixin(RendererLivingEntity.class)
|
||||||
|
public abstract class MixinRendererLivingEntity {
|
||||||
|
@Inject(method = "canRenderName", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void replayModRender_areAllNamesHidden(EntityLivingBase entity, CallbackInfoReturnable<Boolean> ci) {
|
||||||
|
EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) Minecraft.getMinecraft().entityRenderer).replayModRender_getHandler();
|
||||||
|
if (handler != null && !handler.getSettings().isRenderNameTags()) {
|
||||||
|
ci.setReturnValue(false); //this calls the cancel method
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.replaymod.render.rendering;
|
package com.replaymod.render.rendering;
|
||||||
|
|
||||||
|
import com.replaymod.core.ReplayMod;
|
||||||
import com.replaymod.pathing.player.AbstractTimelinePlayer;
|
import com.replaymod.pathing.player.AbstractTimelinePlayer;
|
||||||
import com.replaymod.pathing.player.ReplayTimer;
|
import com.replaymod.pathing.player.ReplayTimer;
|
||||||
import com.replaymod.pathing.properties.TimestampProperty;
|
import com.replaymod.pathing.properties.TimestampProperty;
|
||||||
@@ -13,18 +14,17 @@ import com.replaymod.render.gui.GuiRenderingDone;
|
|||||||
import com.replaymod.render.gui.GuiVideoRenderer;
|
import com.replaymod.render.gui.GuiVideoRenderer;
|
||||||
import com.replaymod.render.hooks.ChunkLoadingRenderGlobal;
|
import com.replaymod.render.hooks.ChunkLoadingRenderGlobal;
|
||||||
import com.replaymod.render.metadata.MetadataInjector;
|
import com.replaymod.render.metadata.MetadataInjector;
|
||||||
import com.replaymod.render.utils.SoundHandler;
|
|
||||||
import com.replaymod.replay.ReplayHandler;
|
import com.replaymod.replay.ReplayHandler;
|
||||||
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
||||||
import com.replaymod.replaystudio.pathing.path.Path;
|
import com.replaymod.replaystudio.pathing.path.Path;
|
||||||
import com.replaymod.replaystudio.pathing.path.Timeline;
|
import com.replaymod.replaystudio.pathing.path.Timeline;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.audio.SoundCategory;
|
||||||
import net.minecraft.client.gui.ScaledResolution;
|
import net.minecraft.client.gui.ScaledResolution;
|
||||||
import net.minecraft.client.renderer.OpenGlHelper;
|
import net.minecraft.client.renderer.OpenGlHelper;
|
||||||
import net.minecraft.client.shader.Framebuffer;
|
import net.minecraft.client.shader.Framebuffer;
|
||||||
import net.minecraft.util.SoundCategory;
|
|
||||||
import net.minecraft.util.Timer;
|
import net.minecraft.util.Timer;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import org.lwjgl.input.Mouse;
|
import org.lwjgl.input.Mouse;
|
||||||
import org.lwjgl.opengl.Display;
|
import org.lwjgl.opengl.Display;
|
||||||
import org.lwjgl.util.Dimension;
|
import org.lwjgl.util.Dimension;
|
||||||
@@ -54,7 +54,7 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
private int fps;
|
private int fps;
|
||||||
private boolean mouseWasGrabbed;
|
private boolean mouseWasGrabbed;
|
||||||
private boolean debugInfoWasShown;
|
private boolean debugInfoWasShown;
|
||||||
private Map<SoundCategory, Float> originalSoundLevels;
|
private Map originalSoundLevels;
|
||||||
|
|
||||||
private TimelinePlayer timelinePlayer;
|
private TimelinePlayer timelinePlayer;
|
||||||
private Future<Void> timelinePlayerFuture;
|
private Future<Void> timelinePlayerFuture;
|
||||||
@@ -90,7 +90,7 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
* @return {@code true} if rendering was successful, {@code false} if the user aborted rendering (or the window was closed)
|
* @return {@code true} if rendering was successful, {@code false} if the user aborted rendering (or the window was closed)
|
||||||
*/
|
*/
|
||||||
public boolean renderVideo() {
|
public boolean renderVideo() {
|
||||||
MinecraftForge.EVENT_BUS.post(new ReplayRenderEvent.Pre(this));
|
FMLCommonHandler.instance().bus().post(new ReplayRenderEvent.Pre(this));
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
|
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.post(new ReplayRenderEvent.Post(this));
|
FMLCommonHandler.instance().bus().post(new ReplayRenderEvent.Post(this));
|
||||||
|
|
||||||
return !cancelled;
|
return !cancelled;
|
||||||
}
|
}
|
||||||
@@ -196,9 +196,9 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
for (SoundCategory category : SoundCategory.values()) {
|
for (SoundCategory category : SoundCategory.values()) {
|
||||||
mutedSounds.put(category, 0f);
|
mutedSounds.put(category, 0f);
|
||||||
}
|
}
|
||||||
originalSoundLevels = mc.gameSettings.soundLevels;
|
originalSoundLevels = mc.gameSettings.mapSoundLevels;
|
||||||
mutedSounds.put(SoundCategory.MASTER, originalSoundLevels.get(SoundCategory.MASTER));
|
mutedSounds.put(SoundCategory.MASTER, (Float) originalSoundLevels.get(SoundCategory.MASTER));
|
||||||
mc.gameSettings.soundLevels = mutedSounds;
|
mc.gameSettings.mapSoundLevels = mutedSounds;
|
||||||
|
|
||||||
fps = settings.getFramesPerSecond();
|
fps = settings.getFramesPerSecond();
|
||||||
|
|
||||||
@@ -219,6 +219,9 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
|
|
||||||
updateDisplaySize();
|
updateDisplaySize();
|
||||||
|
|
||||||
|
ScaledResolution scaled = new ScaledResolution(mc, displayWidth, displayHeight);
|
||||||
|
gui.toMinecraft().setWorldAndResolution(mc, scaled.getScaledWidth(), scaled.getScaledHeight());
|
||||||
|
|
||||||
chunkLoadingRenderGlobal = new ChunkLoadingRenderGlobal(mc.renderGlobal);
|
chunkLoadingRenderGlobal = new ChunkLoadingRenderGlobal(mc.renderGlobal);
|
||||||
|
|
||||||
// Set up our own framebuffer to render the GUI to
|
// Set up our own framebuffer to render the GUI to
|
||||||
@@ -239,13 +242,13 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
if (mouseWasGrabbed) {
|
if (mouseWasGrabbed) {
|
||||||
mc.mouseHelper.grabMouseCursor();
|
mc.mouseHelper.grabMouseCursor();
|
||||||
}
|
}
|
||||||
mc.gameSettings.soundLevels = originalSoundLevels;
|
mc.gameSettings.mapSoundLevels = originalSoundLevels;
|
||||||
mc.displayGuiScreen(null);
|
mc.displayGuiScreen(null);
|
||||||
if (chunkLoadingRenderGlobal != null) {
|
if (chunkLoadingRenderGlobal != null) {
|
||||||
chunkLoadingRenderGlobal.uninstall();
|
chunkLoadingRenderGlobal.uninstall();
|
||||||
}
|
}
|
||||||
|
|
||||||
new SoundHandler().playRenderSuccessSound();
|
ReplayMod.soundHandler.playRenderSuccessSound();
|
||||||
|
|
||||||
new GuiRenderingDone(ReplayModRender.instance, videoWriter.getVideoFile(), totalFrames, settings).display();
|
new GuiRenderingDone(ReplayModRender.instance, videoWriter.getVideoFile(), totalFrames, settings).display();
|
||||||
|
|
||||||
@@ -283,7 +286,7 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
|
|
||||||
mc.entityRenderer.setupOverlayRendering();
|
mc.entityRenderer.setupOverlayRendering();
|
||||||
|
|
||||||
ScaledResolution scaled = new ScaledResolution(mc);
|
ScaledResolution scaled = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||||
gui.toMinecraft().setWorldAndResolution(mc, scaled.getScaledWidth(), scaled.getScaledHeight());
|
gui.toMinecraft().setWorldAndResolution(mc, scaled.getScaledWidth(), scaled.getScaledHeight());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -2,18 +2,15 @@ package com.replaymod.render.utils;
|
|||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.PriorityBlockingQueue;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class JailingQueue<T> extends PriorityBlockingQueue<T> {
|
public class JailingQueue<T> extends AbstractQueue<T> implements BlockingQueue<T> {
|
||||||
private final PriorityBlockingQueue<T> delegate;
|
private final BlockingQueue<T> delegate;
|
||||||
private final Set<Thread> jailed = new HashSet<Thread>();
|
private final Set<Thread> jailed = new HashSet<Thread>();
|
||||||
|
|
||||||
public JailingQueue(PriorityBlockingQueue<T> delegate) {
|
public JailingQueue(BlockingQueue<T> delegate) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,13 +59,13 @@ public class JailingQueue<T> extends PriorityBlockingQueue<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void put(T t) {
|
public void put(T t) throws InterruptedException {
|
||||||
tryAccess();
|
tryAccess();
|
||||||
delegate.put(t);
|
delegate.put(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean offer(T t, long timeout, TimeUnit unit) {
|
public boolean offer(T t, long timeout, TimeUnit unit) throws InterruptedException {
|
||||||
tryAccess();
|
tryAccess();
|
||||||
return delegate.offer(t, timeout, unit);
|
return delegate.offer(t, timeout, unit);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,11 +143,10 @@ public class InputReplayTimer extends WrappedTimer {
|
|||||||
|
|
||||||
// Following are a ton of vanilla keyboard shortcuts, some are removed as they're useless in the
|
// Following are a ton of vanilla keyboard shortcuts, some are removed as they're useless in the
|
||||||
// replay viewer as of now
|
// replay viewer as of now
|
||||||
// TODO Update maybe add new key bindings
|
|
||||||
// TODO: Translate magic values to Keyboard.KEY_ constants
|
// TODO: Translate magic values to Keyboard.KEY_ constants
|
||||||
|
|
||||||
if (key == 32 && Keyboard.isKeyDown(61) && mc.ingameGUI != null) {
|
if (key == 32 && Keyboard.isKeyDown(61) && mc.ingameGUI != null) {
|
||||||
mc.ingameGUI.getChatGUI().clearChatMessages(false);
|
mc.ingameGUI.getChatGUI().clearChatMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == 31 && Keyboard.isKeyDown(61)) {
|
if (key == 31 && Keyboard.isKeyDown(61)) {
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import javax.imageio.ImageIO;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.concurrent.FutureTask;
|
||||||
|
|
||||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
@Getter
|
@Getter
|
||||||
@@ -43,7 +45,7 @@ public class NoGuiScreenshot {
|
|||||||
mc.getFramebuffer().bindFramebuffer(true);
|
mc.getFramebuffer().bindFramebuffer(true);
|
||||||
GlStateManager.enableTexture2D();
|
GlStateManager.enableTexture2D();
|
||||||
|
|
||||||
mc.entityRenderer.updateCameraAndRender(mc.timer.renderPartialTicks, System.nanoTime());
|
mc.entityRenderer.updateCameraAndRender(mc.timer.renderPartialTicks);
|
||||||
|
|
||||||
mc.getFramebuffer().unbindFramebuffer();
|
mc.getFramebuffer().unbindFramebuffer();
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
@@ -99,7 +101,9 @@ public class NoGuiScreenshot {
|
|||||||
// of the game loop. We cannot use the addScheduledTask method as it'll run the task if called
|
// of the game loop. We cannot use the addScheduledTask method as it'll run the task if called
|
||||||
// from the minecraft thread which is exactly what we want to avoid.
|
// from the minecraft thread which is exactly what we want to avoid.
|
||||||
synchronized (mc.scheduledTasks) {
|
synchronized (mc.scheduledTasks) {
|
||||||
mc.scheduledTasks.add(ListenableFutureTask.create(runnable, null));
|
@SuppressWarnings("unchecked")
|
||||||
|
Queue<FutureTask> queue = mc.scheduledTasks;
|
||||||
|
queue.add(ListenableFutureTask.create(runnable, null));
|
||||||
}
|
}
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import net.minecraft.entity.Entity;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.network.EnumPacketDirection;
|
import net.minecraft.network.EnumPacketDirection;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||||
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher;
|
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher;
|
||||||
import org.lwjgl.opengl.Display;
|
import org.lwjgl.opengl.Display;
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ public class ReplayHandler {
|
|||||||
Preconditions.checkState(mc.isCallingFromMinecraftThread(), "Must be called from Minecraft thread.");
|
Preconditions.checkState(mc.isCallingFromMinecraftThread(), "Must be called from Minecraft thread.");
|
||||||
this.replayFile = replayFile;
|
this.replayFile = replayFile;
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.post(new ReplayOpenEvent.Pre(this));
|
FMLCommonHandler.instance().bus().post(new ReplayOpenEvent.Pre(this));
|
||||||
|
|
||||||
markers = new ArrayList<>(replayFile.getMarkers().or(Collections.emptySet()));
|
markers = new ArrayList<>(replayFile.getMarkers().or(Collections.emptySet()));
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ public class ReplayHandler {
|
|||||||
overlay = new GuiReplayOverlay(this);
|
overlay = new GuiReplayOverlay(this);
|
||||||
overlay.setVisible(true);
|
overlay.setVisible(true);
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.post(new ReplayOpenEvent.Post(this));
|
FMLCommonHandler.instance().bus().post(new ReplayOpenEvent.Post(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void restartedReplay() {
|
void restartedReplay() {
|
||||||
@@ -101,7 +101,7 @@ public class ReplayHandler {
|
|||||||
public void endReplay() throws IOException {
|
public void endReplay() throws IOException {
|
||||||
Preconditions.checkState(mc.isCallingFromMinecraftThread(), "Must be called from Minecraft thread.");
|
Preconditions.checkState(mc.isCallingFromMinecraftThread(), "Must be called from Minecraft thread.");
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.post(new ReplayCloseEvent.Pre(this));
|
FMLCommonHandler.instance().bus().post(new ReplayCloseEvent.Pre(this));
|
||||||
|
|
||||||
replaySender.terminateReplay();
|
replaySender.terminateReplay();
|
||||||
|
|
||||||
@@ -124,11 +124,11 @@ public class ReplayHandler {
|
|||||||
|
|
||||||
ReplayModReplay.instance.replayHandler = null;
|
ReplayModReplay.instance.replayHandler = null;
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.post(new ReplayCloseEvent.Post(this));
|
FMLCommonHandler.instance().bus().post(new ReplayCloseEvent.Post(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setup() {
|
private void setup() {
|
||||||
mc.ingameGUI.getChatGUI().clearChatMessages(true);
|
mc.ingameGUI.getChatGUI().clearChatMessages();
|
||||||
|
|
||||||
NetworkManager networkManager = new NetworkManager(EnumPacketDirection.CLIENTBOUND) {
|
NetworkManager networkManager = new NetworkManager(EnumPacketDirection.CLIENTBOUND) {
|
||||||
@Override
|
@Override
|
||||||
@@ -311,7 +311,7 @@ public class ReplayHandler {
|
|||||||
mc.getFramebuffer().bindFramebuffer(true);
|
mc.getFramebuffer().bindFramebuffer(true);
|
||||||
mc.entityRenderer.setupOverlayRendering();
|
mc.entityRenderer.setupOverlayRendering();
|
||||||
|
|
||||||
ScaledResolution resolution = new ScaledResolution(mc);
|
ScaledResolution resolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||||
guiScreen.setWorldAndResolution(mc, resolution.getScaledWidth(), resolution.getScaledHeight());
|
guiScreen.setWorldAndResolution(mc, resolution.getScaledWidth(), resolution.getScaledHeight());
|
||||||
guiScreen.drawScreen(0, 0, 0);
|
guiScreen.drawScreen(0, 0, 0);
|
||||||
|
|
||||||
@@ -328,8 +328,10 @@ public class ReplayHandler {
|
|||||||
replaySender.setAsyncMode(true);
|
replaySender.setAsyncMode(true);
|
||||||
replaySender.setReplaySpeed(0);
|
replaySender.setReplaySpeed(0);
|
||||||
|
|
||||||
mc.getConnection().getNetworkManager().processReceivedPackets();
|
mc.getNetHandler().getNetworkManager().processReceivedPackets();
|
||||||
for (Entity entity : mc.theWorld.loadedEntityList) {
|
@SuppressWarnings("unchecked")
|
||||||
|
List<Entity> entities = (List<Entity>) mc.theWorld.loadedEntityList;
|
||||||
|
for (Entity entity : entities) {
|
||||||
if (entity instanceof EntityOtherPlayerMP) {
|
if (entity instanceof EntityOtherPlayerMP) {
|
||||||
EntityOtherPlayerMP e = (EntityOtherPlayerMP) entity;
|
EntityOtherPlayerMP e = (EntityOtherPlayerMP) entity;
|
||||||
e.setPosition(e.otherPlayerMPX, e.otherPlayerMPY, e.otherPlayerMPZ);
|
e.setPosition(e.otherPlayerMPX, e.otherPlayerMPY, e.otherPlayerMPZ);
|
||||||
|
|||||||
@@ -12,22 +12,17 @@ import io.netty.channel.ChannelHandler.Sharable;
|
|||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.EntityOtherPlayerMP;
|
|
||||||
import net.minecraft.client.gui.GuiDownloadTerrain;
|
import net.minecraft.client.gui.GuiDownloadTerrain;
|
||||||
import net.minecraft.client.gui.GuiErrorScreen;
|
import net.minecraft.client.gui.GuiErrorScreen;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.network.*;
|
import net.minecraft.network.*;
|
||||||
import net.minecraft.network.play.server.*;
|
import net.minecraft.network.play.server.*;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.IChatComponent;
|
||||||
import net.minecraft.world.EnumDifficulty;
|
import net.minecraft.world.EnumDifficulty;
|
||||||
import net.minecraft.world.GameType;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.WorldSettings.GameType;
|
||||||
import net.minecraft.world.WorldType;
|
import net.minecraft.world.WorldType;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
@@ -44,22 +39,30 @@ import java.util.concurrent.Callable;
|
|||||||
*/
|
*/
|
||||||
@Sharable
|
@Sharable
|
||||||
public class ReplaySender extends ChannelInboundHandlerAdapter {
|
public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Previously packets for the client player were inserted using one fixed entity id (this one).
|
||||||
|
* This is no longer the case however to provide backwards compatibility, we have to convert
|
||||||
|
* these old packets to use the normal entity id.
|
||||||
|
* Need to punch someone? -> CrushedPixel
|
||||||
|
*/
|
||||||
|
public static final int LEGACY_ENTITY_ID = Integer.MIN_VALUE + 9001;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These packets are ignored completely during replay.
|
* These packets are ignored completely during replay.
|
||||||
*/
|
*/
|
||||||
private static final List<Class> BAD_PACKETS = Arrays.<Class>asList(
|
private static final List<Class> BAD_PACKETS = Arrays.<Class>asList(
|
||||||
// TODO Update possibly more?
|
S06PacketUpdateHealth.class,
|
||||||
SPacketUpdateHealth.class,
|
S2DPacketOpenWindow.class,
|
||||||
SPacketOpenWindow.class,
|
S2EPacketCloseWindow.class,
|
||||||
SPacketCloseWindow.class,
|
S2FPacketSetSlot.class,
|
||||||
SPacketSetSlot.class,
|
S30PacketWindowItems.class,
|
||||||
SPacketWindowItems.class,
|
S36PacketSignEditorOpen.class,
|
||||||
SPacketSignEditorOpen.class,
|
S37PacketStatistics.class,
|
||||||
SPacketStatistics.class,
|
S1FPacketSetExperience.class,
|
||||||
SPacketSetExperience.class,
|
S43PacketCamera.class,
|
||||||
SPacketCamera.class,
|
S39PacketPlayerAbilities.class,
|
||||||
SPacketPlayerAbilities.class,
|
S45PacketTitle.class);
|
||||||
SPacketTitle.class);
|
|
||||||
|
|
||||||
private static int TP_DISTANCE_LIMIT = 128;
|
private static int TP_DISTANCE_LIMIT = 128;
|
||||||
|
|
||||||
@@ -168,8 +171,6 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
this.asyncMode = asyncMode;
|
this.asyncMode = asyncMode;
|
||||||
this.replayLength = file.getMetaData().getDuration();
|
this.replayLength = file.getMetaData().getDuration();
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
|
||||||
|
|
||||||
if (asyncMode) {
|
if (asyncMode) {
|
||||||
new Thread(asyncSender, "replaymod-async-sender").start();
|
new Thread(asyncSender, "replaymod-async-sender").start();
|
||||||
}
|
}
|
||||||
@@ -238,7 +239,6 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
*/
|
*/
|
||||||
public void terminateReplay() {
|
public void terminateReplay() {
|
||||||
terminate = true;
|
terminate = true;
|
||||||
MinecraftForge.EVENT_BUS.unregister(this);
|
|
||||||
try {
|
try {
|
||||||
channelInactive(ctx);
|
channelInactive(ctx);
|
||||||
ctx.channel().pipeline().close();
|
ctx.channel().pipeline().close();
|
||||||
@@ -247,25 +247,6 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onWorldTick(TickEvent.ClientTickEvent event) {
|
|
||||||
// Unfortunately the WorldTickEvent doesn't seem to be emitted on the CLIENT side
|
|
||||||
if (event.phase != TickEvent.Phase.START) return;
|
|
||||||
|
|
||||||
// Spawning a player into an empty chunk (which we might do with the recording player)
|
|
||||||
// prevents it from being moved by teleport packets (it essentially gets stuck) because
|
|
||||||
// Entity#addedToChunk is not set and it is therefore not updated every tick.
|
|
||||||
// To counteract this, we need to manually update it's position if it hasn't been added
|
|
||||||
// to any chunk yet.
|
|
||||||
if (mc.theWorld != null) {
|
|
||||||
for (EntityPlayer playerEntity : mc.theWorld.playerEntities) {
|
|
||||||
if (!playerEntity.addedToChunk && playerEntity instanceof EntityOtherPlayerMP) {
|
|
||||||
playerEntity.onLivingUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelRead(ChannelHandlerContext ctx, Object msg)
|
public void channelRead(ChannelHandlerContext ctx, Object msg)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
@@ -293,21 +274,21 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
// Therefore we have to remove all loaded, dead entities manually if we are in sync mode.
|
// Therefore we have to remove all loaded, dead entities manually if we are in sync mode.
|
||||||
// We do this after every SpawnX packet and after the destroy entities packet.
|
// We do this after every SpawnX packet and after the destroy entities packet.
|
||||||
if (!asyncMode && mc.theWorld != null) {
|
if (!asyncMode && mc.theWorld != null) {
|
||||||
if (p instanceof SPacketSpawnPlayer
|
if (p instanceof S0CPacketSpawnPlayer
|
||||||
|| p instanceof SPacketSpawnObject
|
|| p instanceof S0EPacketSpawnObject
|
||||||
|| p instanceof SPacketSpawnMob
|
|| p instanceof S0FPacketSpawnMob
|
||||||
|| p instanceof SPacketSpawnGlobalEntity
|
|| p instanceof S2CPacketSpawnGlobalEntity
|
||||||
|| p instanceof SPacketSpawnPainting
|
|| p instanceof S10PacketSpawnPainting
|
||||||
|| p instanceof SPacketSpawnExperienceOrb
|
|| p instanceof S11PacketSpawnExperienceOrb
|
||||||
|| p instanceof SPacketDestroyEntities) {
|
|| p instanceof S13PacketDestroyEntities) {
|
||||||
World world = mc.theWorld;
|
World world = mc.theWorld;
|
||||||
for (int i = 0; i < world.loadedEntityList.size(); ++i) {
|
for (int i = 0; i < world.loadedEntityList.size(); ++i) {
|
||||||
Entity entity = world.loadedEntityList.get(i);
|
Entity entity = (Entity) world.loadedEntityList.get(i);
|
||||||
if (entity.isDead) {
|
if (entity.isDead) {
|
||||||
int chunkX = entity.chunkCoordX;
|
int chunkX = entity.chunkCoordX;
|
||||||
int chunkY = entity.chunkCoordZ;
|
int chunkY = entity.chunkCoordZ;
|
||||||
|
|
||||||
if (entity.addedToChunk && world.getChunkProvider().getLoadedChunk(chunkX, chunkY) != null) {
|
if (entity.addedToChunk && world.getChunkProvider().chunkExists(chunkX, chunkY)) {
|
||||||
world.getChunkFromChunkCoords(chunkX, chunkY).removeEntity(entity);
|
world.getChunkFromChunkCoords(chunkX, chunkY).removeEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,8 +326,8 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
* @return The processed packet or {@code null} if no packet shall be sent
|
* @return The processed packet or {@code null} if no packet shall be sent
|
||||||
*/
|
*/
|
||||||
protected Packet processPacket(Packet p) throws Exception {
|
protected Packet processPacket(Packet p) throws Exception {
|
||||||
if (p instanceof SPacketCustomPayload) {
|
if (p instanceof S3FPacketCustomPayload) {
|
||||||
SPacketCustomPayload packet = (SPacketCustomPayload) p;
|
S3FPacketCustomPayload packet = (S3FPacketCustomPayload) p;
|
||||||
if (Restrictions.PLUGIN_CHANNEL.equals(packet.getChannelName())) {
|
if (Restrictions.PLUGIN_CHANNEL.equals(packet.getChannelName())) {
|
||||||
final String unknown = replayHandler.getRestrictions().handle(packet);
|
final String unknown = replayHandler.getRestrictions().handle(packet);
|
||||||
if (unknown == null) {
|
if (unknown == null) {
|
||||||
@@ -372,8 +353,8 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (p instanceof SPacketDisconnect) {
|
if (p instanceof S40PacketDisconnect) {
|
||||||
ITextComponent reason = ((SPacketDisconnect) p).getReason();
|
IChatComponent reason = ((S40PacketDisconnect) p).func_149165_c();
|
||||||
if ("Please update to view this replay.".equals(reason.getUnformattedText())) {
|
if ("Please update to view this replay.".equals(reason.getUnformattedText())) {
|
||||||
// This version of the mod supports replay restrictions so we are allowed
|
// This version of the mod supports replay restrictions so we are allowed
|
||||||
// to remove this packet.
|
// to remove this packet.
|
||||||
@@ -383,9 +364,11 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
|
|
||||||
if(BAD_PACKETS.contains(p.getClass())) return null;
|
if(BAD_PACKETS.contains(p.getClass())) return null;
|
||||||
|
|
||||||
if(p instanceof SPacketResourcePackSend) {
|
convertLegacyEntityIds(p);
|
||||||
SPacketResourcePackSend packet = (SPacketResourcePackSend) p;
|
|
||||||
String url = packet.getURL();
|
if(p instanceof S48PacketResourcePackSend) {
|
||||||
|
S48PacketResourcePackSend packet = (S48PacketResourcePackSend) p;
|
||||||
|
String url = packet.func_179783_a();
|
||||||
if (url.startsWith("replay://")) {
|
if (url.startsWith("replay://")) {
|
||||||
int id = Integer.parseInt(url.substring("replay://".length()));
|
int id = Integer.parseInt(url.substring("replay://".length()));
|
||||||
Map<Integer, String> index = replayFile.getResourcePackIndex();
|
Map<Integer, String> index = replayFile.getResourcePackIndex();
|
||||||
@@ -396,17 +379,17 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
IOUtils.copy(replayFile.getResourcePack(hash).get(), new FileOutputStream(file));
|
IOUtils.copy(replayFile.getResourcePack(hash).get(), new FileOutputStream(file));
|
||||||
}
|
}
|
||||||
mc.getResourcePackRepository().setResourcePackInstance(file);
|
mc.getResourcePackRepository().func_177319_a(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p instanceof SPacketJoinGame) {
|
if(p instanceof S01PacketJoinGame) {
|
||||||
SPacketJoinGame packet = (SPacketJoinGame) p;
|
S01PacketJoinGame packet = (S01PacketJoinGame) p;
|
||||||
allowMovement = true;
|
allowMovement = true;
|
||||||
int entId = packet.getPlayerId();
|
int entId = packet.getEntityId();
|
||||||
actualID = entId;
|
actualID = entId;
|
||||||
entId = -1789435; // Camera entity id should be negative which is an invalid id and can't be used by servers
|
entId = -1789435; // Camera entity id should be negative which is an invalid id and can't be used by servers
|
||||||
int dimension = packet.getDimension();
|
int dimension = packet.getDimension();
|
||||||
@@ -414,21 +397,21 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
int maxPlayers = packet.getMaxPlayers();
|
int maxPlayers = packet.getMaxPlayers();
|
||||||
WorldType worldType = packet.getWorldType();
|
WorldType worldType = packet.getWorldType();
|
||||||
|
|
||||||
p = new SPacketJoinGame(entId, GameType.SPECTATOR, false, dimension,
|
p = new S01PacketJoinGame(entId, GameType.SPECTATOR, false, dimension,
|
||||||
difficulty, maxPlayers, worldType, false);
|
difficulty, maxPlayers, worldType, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p instanceof SPacketRespawn) {
|
if(p instanceof S07PacketRespawn) {
|
||||||
SPacketRespawn respawn = (SPacketRespawn) p;
|
S07PacketRespawn respawn = (S07PacketRespawn) p;
|
||||||
p = new SPacketRespawn(respawn.getDimensionID(),
|
p = new S07PacketRespawn(respawn.func_149082_c(),
|
||||||
respawn.getDifficulty(), respawn.getWorldType(), GameType.SPECTATOR);
|
respawn.func_149081_d(), respawn.func_149080_f(), GameType.SPECTATOR);
|
||||||
|
|
||||||
allowMovement = true;
|
allowMovement = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p instanceof SPacketPlayerPosLook) {
|
if(p instanceof S08PacketPlayerPosLook) {
|
||||||
if(!hasWorldLoaded) hasWorldLoaded = true;
|
if(!hasWorldLoaded) hasWorldLoaded = true;
|
||||||
final SPacketPlayerPosLook ppl = (SPacketPlayerPosLook) p;
|
final S08PacketPlayerPosLook ppl = (S08PacketPlayerPosLook) p;
|
||||||
|
|
||||||
if (mc.currentScreen instanceof GuiDownloadTerrain) {
|
if (mc.currentScreen instanceof GuiDownloadTerrain) {
|
||||||
// Close the world loading screen manually in case we swallow the packet
|
// Close the world loading screen manually in case we swallow the packet
|
||||||
@@ -439,17 +422,17 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
|
|
||||||
CameraEntity cent = replayHandler.getCameraEntity();
|
CameraEntity cent = replayHandler.getCameraEntity();
|
||||||
|
|
||||||
for (SPacketPlayerPosLook.EnumFlags relative : ppl.getFlags()) {
|
for (Object relative : ppl.func_179834_f()) {
|
||||||
if (relative == SPacketPlayerPosLook.EnumFlags.X
|
if (relative == S08PacketPlayerPosLook.EnumFlags.X
|
||||||
|| relative == SPacketPlayerPosLook.EnumFlags.Y
|
|| relative == S08PacketPlayerPosLook.EnumFlags.Y
|
||||||
|| relative == SPacketPlayerPosLook.EnumFlags.Z) {
|
|| relative == S08PacketPlayerPosLook.EnumFlags.Z) {
|
||||||
return null; // At least one of the coordinates is relative, so we don't care
|
return null; // At least one of the coordinates is relative, so we don't care
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cent != null) {
|
if(cent != null) {
|
||||||
if(!allowMovement && !((Math.abs(cent.posX - ppl.getX()) > TP_DISTANCE_LIMIT) ||
|
if(!allowMovement && !((Math.abs(cent.posX - ppl.func_148932_c()) > TP_DISTANCE_LIMIT) ||
|
||||||
(Math.abs(cent.posZ - ppl.getZ()) > TP_DISTANCE_LIMIT))) {
|
(Math.abs(cent.posZ - ppl.func_148933_e()) > TP_DISTANCE_LIMIT))) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
allowMovement = false;
|
allowMovement = false;
|
||||||
@@ -468,15 +451,15 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CameraEntity cent = replayHandler.getCameraEntity();
|
CameraEntity cent = replayHandler.getCameraEntity();
|
||||||
cent.setCameraPosition(ppl.getX(), ppl.getY(), ppl.getZ());
|
cent.setCameraPosition(ppl.func_148932_c(), ppl.func_148928_d(), ppl.func_148933_e());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}.call();
|
}.call();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p instanceof SPacketChangeGameState) {
|
if(p instanceof S2BPacketChangeGameState) {
|
||||||
SPacketChangeGameState pg = (SPacketChangeGameState)p;
|
S2BPacketChangeGameState pg = (S2BPacketChangeGameState)p;
|
||||||
int reason = pg.getGameState();
|
int reason = pg.func_149138_c();
|
||||||
|
|
||||||
// only allow the following packets:
|
// only allow the following packets:
|
||||||
// 1 - End raining
|
// 1 - End raining
|
||||||
@@ -490,7 +473,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p instanceof SPacketChat) {
|
if (p instanceof S02PacketChat) {
|
||||||
if (!ReplayModReplay.instance.getCore().getSettingsRegistry().get(Setting.SHOW_CHAT)) {
|
if (!ReplayModReplay.instance.getCore().getSettingsRegistry().get(Setting.SHOW_CHAT)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -503,7 +486,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
ctx.attr(NetworkManager.PROTOCOL_ATTRIBUTE_KEY).set(EnumConnectionState.PLAY);
|
ctx.attr(NetworkManager.attrKeyConnectionState).set(EnumConnectionState.PLAY);
|
||||||
super.channelActive(ctx);
|
super.channelActive(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -708,11 +691,11 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
protected Packet processPacketAsync(Packet p) {
|
protected Packet processPacketAsync(Packet p) {
|
||||||
//If hurrying, ignore some packets, except for short durations
|
//If hurrying, ignore some packets, except for short durations
|
||||||
if(desiredTimeStamp - lastTimeStamp > 1000) {
|
if(desiredTimeStamp - lastTimeStamp > 1000) {
|
||||||
if(p instanceof SPacketParticles) return null;
|
if(p instanceof S2APacketParticles) return null;
|
||||||
|
|
||||||
if(p instanceof SPacketSpawnObject) {
|
if(p instanceof S0EPacketSpawnObject) {
|
||||||
SPacketSpawnObject pso = (SPacketSpawnObject)p;
|
S0EPacketSpawnObject pso = (S0EPacketSpawnObject)p;
|
||||||
int type = pso.getType();
|
int type = pso.func_148993_l();
|
||||||
if(type == 76) { // Firework rocket
|
if(type == 76) { // Firework rocket
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -798,6 +781,68 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
return p; // During synchronous playback everything is sent normally
|
return p; // During synchronous playback everything is sent normally
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is necessary to convert packets from old replays to new replays.
|
||||||
|
* @param packet The packet to be transformed.
|
||||||
|
* @see #LEGACY_ENTITY_ID
|
||||||
|
*/
|
||||||
|
private void convertLegacyEntityIds(Packet packet) {
|
||||||
|
if (packet instanceof S0CPacketSpawnPlayer) {
|
||||||
|
S0CPacketSpawnPlayer p = (S0CPacketSpawnPlayer) packet;
|
||||||
|
if (p.field_148957_a == LEGACY_ENTITY_ID) {
|
||||||
|
p.field_148957_a = actualID;
|
||||||
|
}
|
||||||
|
} else if (packet instanceof S18PacketEntityTeleport) {
|
||||||
|
S18PacketEntityTeleport p = (S18PacketEntityTeleport) packet;
|
||||||
|
if (p.field_149458_a == LEGACY_ENTITY_ID) {
|
||||||
|
p.field_149458_a = actualID;
|
||||||
|
}
|
||||||
|
} else if (packet instanceof S14PacketEntity.S17PacketEntityLookMove) {
|
||||||
|
S14PacketEntity.S17PacketEntityLookMove p = (S14PacketEntity.S17PacketEntityLookMove) packet;
|
||||||
|
if (p.field_149074_a == LEGACY_ENTITY_ID) {
|
||||||
|
p.field_149074_a = actualID;
|
||||||
|
}
|
||||||
|
} else if (packet instanceof S19PacketEntityHeadLook) {
|
||||||
|
S19PacketEntityHeadLook p = (S19PacketEntityHeadLook) packet;
|
||||||
|
if (p.field_149384_a == LEGACY_ENTITY_ID) {
|
||||||
|
p.field_149384_a = actualID;
|
||||||
|
}
|
||||||
|
} else if (packet instanceof S12PacketEntityVelocity) {
|
||||||
|
S12PacketEntityVelocity p = (S12PacketEntityVelocity) packet;
|
||||||
|
if (p.field_149417_a == LEGACY_ENTITY_ID) {
|
||||||
|
p.field_149417_a = actualID;
|
||||||
|
}
|
||||||
|
} else if (packet instanceof S0BPacketAnimation) {
|
||||||
|
S0BPacketAnimation p = (S0BPacketAnimation) packet;
|
||||||
|
if (p.entityId == LEGACY_ENTITY_ID) {
|
||||||
|
p.entityId = actualID;
|
||||||
|
}
|
||||||
|
} else if (packet instanceof S04PacketEntityEquipment) {
|
||||||
|
S04PacketEntityEquipment p = (S04PacketEntityEquipment) packet;
|
||||||
|
if (p.field_149394_a == LEGACY_ENTITY_ID) {
|
||||||
|
p.field_149394_a = actualID;
|
||||||
|
}
|
||||||
|
} else if (packet instanceof S1BPacketEntityAttach) {
|
||||||
|
S1BPacketEntityAttach p = (S1BPacketEntityAttach) packet;
|
||||||
|
if (p.field_149408_a == LEGACY_ENTITY_ID) {
|
||||||
|
p.field_149408_a = actualID;
|
||||||
|
}
|
||||||
|
if (p.field_149406_b == LEGACY_ENTITY_ID) {
|
||||||
|
p.field_149406_b = actualID;
|
||||||
|
}
|
||||||
|
} else if (packet instanceof S0DPacketCollectItem) {
|
||||||
|
S0DPacketCollectItem p = (S0DPacketCollectItem) packet;
|
||||||
|
if (p.field_149356_b == LEGACY_ENTITY_ID) {
|
||||||
|
p.field_149356_b = actualID;
|
||||||
|
}
|
||||||
|
} else if (packet instanceof S13PacketDestroyEntities) {
|
||||||
|
S13PacketDestroyEntities p = (S13PacketDestroyEntities) packet;
|
||||||
|
if (p.field_149100_a.length == 1 && p.field_149100_a[0] == LEGACY_ENTITY_ID) {
|
||||||
|
p.field_149100_a[0] = actualID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static final class PacketData {
|
private static final class PacketData {
|
||||||
private final int timestamp;
|
private final int timestamp;
|
||||||
private final byte[] bytes;
|
private final byte[] bytes;
|
||||||
|
|||||||
@@ -18,17 +18,16 @@ import net.minecraft.entity.Entity;
|
|||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.entity.item.EntityItemFrame;
|
import net.minecraft.entity.item.EntityItemFrame;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
import net.minecraft.stats.StatFileWriter;
|
||||||
import net.minecraft.stats.StatisticsManager;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
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.client.event.RenderHandEvent;
|
import net.minecraftforge.client.event.RenderHandEvent;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
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 net.minecraftforge.fml.common.gameevent.TickEvent;
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
@@ -66,8 +65,9 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
*/
|
*/
|
||||||
private final EventHandler eventHandler = new EventHandler();
|
private final EventHandler eventHandler = new EventHandler();
|
||||||
|
|
||||||
public CameraEntity(Minecraft mcIn, World worldIn, NetHandlerPlayClient netHandlerPlayClient, StatisticsManager statisticsManager) {
|
public CameraEntity(Minecraft mcIn, World worldIn, NetHandlerPlayClient netHandlerPlayClient, StatFileWriter statFileWriter) {
|
||||||
super(mcIn, worldIn, netHandlerPlayClient, statisticsManager);
|
super(mcIn, worldIn, netHandlerPlayClient, statFileWriter);
|
||||||
|
FMLCommonHandler.instance().bus().register(eventHandler);
|
||||||
MinecraftForge.EVENT_BUS.register(eventHandler);
|
MinecraftForge.EVENT_BUS.register(eventHandler);
|
||||||
if (ReplayModReplay.instance.getReplayHandler().getSpectatedUUID() == null) {
|
if (ReplayModReplay.instance.getReplayHandler().getSpectatedUUID() == null) {
|
||||||
cameraController = ReplayModReplay.instance.createCameraController(this);
|
cameraController = ReplayModReplay.instance.createCameraController(this);
|
||||||
@@ -252,6 +252,15 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInvisible() {
|
||||||
|
Entity view = mc.getRenderViewEntity();
|
||||||
|
if (view != this) {
|
||||||
|
return view.isInvisible();
|
||||||
|
}
|
||||||
|
return super.isInvisible();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation getLocationSkin() {
|
public ResourceLocation getLocationSkin() {
|
||||||
Entity view = mc.getRenderViewEntity();
|
Entity view = mc.getRenderViewEntity();
|
||||||
@@ -280,49 +289,12 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getCooldownPeriod() {
|
public MovingObjectPosition rayTrace(double p_174822_1_, float p_174822_3_) {
|
||||||
Entity view = mc.getRenderViewEntity();
|
MovingObjectPosition pos = super.rayTrace(p_174822_1_, 1f);
|
||||||
if (view != this && view instanceof EntityPlayer) {
|
|
||||||
return ((EntityPlayer) view).getCooldownPeriod();
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getCooledAttackStrength(float adjustTicks) {
|
|
||||||
Entity view = mc.getRenderViewEntity();
|
|
||||||
if (view != this && view instanceof EntityPlayer) {
|
|
||||||
return ((EntityPlayer) view).getCooledAttackStrength(adjustTicks);
|
|
||||||
}
|
|
||||||
// Default to 1 as to not render the cooldown indicator (renders for < 1)
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumHand getActiveHand() {
|
|
||||||
Entity view = mc.getRenderViewEntity();
|
|
||||||
if (view != this && view instanceof EntityPlayer) {
|
|
||||||
return ((EntityPlayer) view).getActiveHand();
|
|
||||||
}
|
|
||||||
return super.getActiveHand();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isHandActive() {
|
|
||||||
Entity view = mc.getRenderViewEntity();
|
|
||||||
if (view != this && view instanceof EntityPlayer) {
|
|
||||||
return ((EntityPlayer) view).isHandActive();
|
|
||||||
}
|
|
||||||
return super.isHandActive();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RayTraceResult rayTrace(double p_174822_1_, float p_174822_3_) {
|
|
||||||
RayTraceResult pos = super.rayTrace(p_174822_1_, 1f);
|
|
||||||
|
|
||||||
// Make sure we can never look at blocks (-> no outline)
|
// Make sure we can never look at blocks (-> no outline)
|
||||||
if(pos != null && pos.typeOfHit == RayTraceResult.Type.BLOCK) {
|
if(pos != null && pos.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||||
pos.typeOfHit = RayTraceResult.Type.MISS;
|
pos.typeOfHit = MovingObjectPosition.MovingObjectType.MISS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
@@ -337,6 +309,7 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
@Override
|
@Override
|
||||||
public void setDead() {
|
public void setDead() {
|
||||||
super.setDead();
|
super.setDead();
|
||||||
|
FMLCommonHandler.instance().bus().unregister(eventHandler);
|
||||||
MinecraftForge.EVENT_BUS.unregister(eventHandler);
|
MinecraftForge.EVENT_BUS.unregister(eventHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -394,13 +367,9 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void preCrosshairRender(RenderGameOverlayEvent.Pre event) {
|
public void preCrosshairRender(RenderGameOverlayEvent.Pre event) {
|
||||||
// The crosshair should only render if targeted entity can actually be spectated
|
// The crosshair should only render if targeted entity can actually be spectated
|
||||||
if (event.getType() == RenderGameOverlayEvent.ElementType.CROSSHAIRS) {
|
if (event.type == RenderGameOverlayEvent.ElementType.CROSSHAIRS) {
|
||||||
event.setCanceled(!canSpectate(mc.pointedEntity));
|
event.setCanceled(!canSpectate(mc.pointedEntity));
|
||||||
}
|
}
|
||||||
// Hotbar should never be rendered
|
|
||||||
if (event.getType() == RenderGameOverlayEvent.ElementType.HOTBAR) {
|
|
||||||
event.setCanceled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
@@ -431,13 +400,10 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
if (lastHandRendered != player) {
|
if (lastHandRendered != player) {
|
||||||
lastHandRendered = player;
|
lastHandRendered = player;
|
||||||
|
|
||||||
mc.entityRenderer.itemRenderer.prevEquippedProgressMainHand = 1;
|
mc.entityRenderer.itemRenderer.prevEquippedProgress = 1;
|
||||||
mc.entityRenderer.itemRenderer.prevEquippedProgressOffHand = 1;
|
mc.entityRenderer.itemRenderer.equippedProgress = 1;
|
||||||
mc.entityRenderer.itemRenderer.equippedProgressMainHand = 1;
|
mc.entityRenderer.itemRenderer.itemToRender = player.inventory.getCurrentItem();
|
||||||
mc.entityRenderer.itemRenderer.equippedProgressOffHand = 1;
|
mc.entityRenderer.itemRenderer.equippedItemSlot = player.inventory.currentItem;
|
||||||
mc.entityRenderer.itemRenderer.itemStackMainHand = player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND);
|
|
||||||
mc.entityRenderer.itemRenderer.itemStackOffHand = player.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND);
|
|
||||||
|
|
||||||
|
|
||||||
mc.thePlayer.renderArmYaw = mc.thePlayer.prevRenderArmYaw = player.rotationYaw;
|
mc.thePlayer.renderArmYaw = mc.thePlayer.prevRenderArmYaw = player.rotationYaw;
|
||||||
mc.thePlayer.renderArmPitch = mc.thePlayer.prevRenderArmPitch = player.rotationPitch;
|
mc.thePlayer.renderArmPitch = mc.thePlayer.prevRenderArmPitch = player.rotationPitch;
|
||||||
@@ -448,7 +414,7 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onEntityViewRenderEvent(EntityViewRenderEvent.CameraSetup event) {
|
public void onEntityViewRenderEvent(EntityViewRenderEvent.CameraSetup event) {
|
||||||
if (mc.getRenderViewEntity() == CameraEntity.this) {
|
if (mc.getRenderViewEntity() == CameraEntity.this) {
|
||||||
event.setRoll(roll);
|
event.roll = roll;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package com.replaymod.replay.camera;
|
|||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.Vec3;
|
||||||
import org.lwjgl.Sys;
|
import org.lwjgl.Sys;
|
||||||
|
|
||||||
// TODO: Marius is responsible for this. Please, someone clean it up.
|
// TODO: Marius is responsible for this. Please, someone clean it up.
|
||||||
@@ -18,8 +18,8 @@ public class ClassicCameraController implements CameraController {
|
|||||||
private double THRESHOLD = MAX_SPEED / 20;
|
private double THRESHOLD = MAX_SPEED / 20;
|
||||||
private double DECAY = MAX_SPEED/3;
|
private double DECAY = MAX_SPEED/3;
|
||||||
|
|
||||||
private Vec3d direction;
|
private Vec3 direction;
|
||||||
private Vec3d dirBefore;
|
private Vec3 dirBefore;
|
||||||
private double motion;
|
private double motion;
|
||||||
private long lastCall = Sys.getTime();
|
private long lastCall = Sys.getTime();
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ public class ClassicCameraController implements CameraController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3d movement = direction.normalize();
|
Vec3 movement = direction.normalize();
|
||||||
double factor = motion * (frac / 1000D);
|
double factor = motion * (frac / 1000D);
|
||||||
|
|
||||||
camera.moveCamera(movement.xCoord * factor, movement.yCoord * factor, movement.zCoord * factor);
|
camera.moveCamera(movement.xCoord * factor, movement.yCoord * factor, movement.zCoord * factor);
|
||||||
@@ -158,7 +158,7 @@ public class ClassicCameraController implements CameraController {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3d dbf = direction;
|
Vec3 dbf = direction;
|
||||||
|
|
||||||
if(dirBefore != null) {
|
if(dirBefore != null) {
|
||||||
direction = dirBefore.normalize().add(direction);
|
direction = dirBefore.normalize().add(direction);
|
||||||
@@ -169,12 +169,12 @@ public class ClassicCameraController implements CameraController {
|
|||||||
updateMovement();
|
updateMovement();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vec3d getVectorForRotation(float pitch, float yaw) {
|
private Vec3 getVectorForRotation(float pitch, float yaw) {
|
||||||
float f2 = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI);
|
float f2 = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI);
|
||||||
float f3 = MathHelper.sin(-yaw * 0.017453292F - (float)Math.PI);
|
float f3 = MathHelper.sin(-yaw * 0.017453292F - (float)Math.PI);
|
||||||
float f4 = -MathHelper.cos(-pitch * 0.017453292F);
|
float f4 = -MathHelper.cos(-pitch * 0.017453292F);
|
||||||
float f5 = MathHelper.sin(-pitch * 0.017453292F);
|
float f5 = MathHelper.sin(-pitch * 0.017453292F);
|
||||||
return new Vec3d((double)(f3 * f4), (double)f5, (double)(f2 * f4));
|
return new Vec3((double)(f3 * f4), (double)f5, (double)(f2 * f4));
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum MoveDirection {
|
public enum MoveDirection {
|
||||||
|
|||||||
@@ -41,9 +41,8 @@ public class SpectatorCameraController implements CameraController {
|
|||||||
if (view instanceof EntityPlayer) {
|
if (view instanceof EntityPlayer) {
|
||||||
EntityPlayer viewPlayer = (EntityPlayer) view;
|
EntityPlayer viewPlayer = (EntityPlayer) view;
|
||||||
camera.inventory = viewPlayer.inventory;
|
camera.inventory = viewPlayer.inventory;
|
||||||
camera.itemStackMainHand = viewPlayer.itemStackMainHand;
|
camera.itemInUse = viewPlayer.itemInUse;
|
||||||
camera.swingingHand = viewPlayer.swingingHand;
|
camera.itemInUseCount = viewPlayer.itemInUseCount;
|
||||||
camera.activeItemStackUseCount = viewPlayer.activeItemStackUseCount;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ import org.lwjgl.input.Keyboard;
|
|||||||
import org.lwjgl.util.ReadablePoint;
|
import org.lwjgl.util.ReadablePoint;
|
||||||
|
|
||||||
public class GuiEditMarkerPopup extends AbstractGuiPopup<GuiEditMarkerPopup> implements Typeable {
|
public class GuiEditMarkerPopup extends AbstractGuiPopup<GuiEditMarkerPopup> implements Typeable {
|
||||||
|
private static GuiNumberField newGuiNumberField() {
|
||||||
|
return new GuiNumberField().setSize(150, 20).setValidateOnFocusChange(true);
|
||||||
|
}
|
||||||
|
|
||||||
private final ReplayHandler replayHandler;
|
private final ReplayHandler replayHandler;
|
||||||
private final Marker marker;
|
private final Marker marker;
|
||||||
|
|
||||||
@@ -23,15 +27,15 @@ public class GuiEditMarkerPopup extends AbstractGuiPopup<GuiEditMarkerPopup> imp
|
|||||||
|
|
||||||
public final GuiTextField nameField = new GuiTextField().setSize(150, 20);
|
public final GuiTextField nameField = new GuiTextField().setSize(150, 20);
|
||||||
// TODO: Replace with a min/sec/msec field
|
// TODO: Replace with a min/sec/msec field
|
||||||
public final GuiNumberField timeField = new GuiNumberField().setSize(150, 20).setPrecision(0);
|
public final GuiNumberField timeField = newGuiNumberField().setPrecision(0);
|
||||||
|
|
||||||
public final GuiNumberField xField = new GuiNumberField().setSize(150, 20).setPrecision(10);
|
public final GuiNumberField xField = newGuiNumberField().setPrecision(10);
|
||||||
public final GuiNumberField yField = new GuiNumberField().setSize(150, 20).setPrecision(10);
|
public final GuiNumberField yField = newGuiNumberField().setPrecision(10);
|
||||||
public final GuiNumberField zField = new GuiNumberField().setSize(150, 20).setPrecision(10);
|
public final GuiNumberField zField = newGuiNumberField().setPrecision(10);
|
||||||
|
|
||||||
public final GuiNumberField yawField = new GuiNumberField().setSize(150, 20).setPrecision(5);
|
public final GuiNumberField yawField = newGuiNumberField().setPrecision(5);
|
||||||
public final GuiNumberField pitchField = new GuiNumberField().setSize(150, 20).setPrecision(5);
|
public final GuiNumberField pitchField = newGuiNumberField().setPrecision(5);
|
||||||
public final GuiNumberField rollField = new GuiNumberField().setSize(150, 20).setPrecision(5);
|
public final GuiNumberField rollField = newGuiNumberField().setPrecision(5);
|
||||||
|
|
||||||
public final GuiPanel inputs = GuiPanel.builder()
|
public final GuiPanel inputs = GuiPanel.builder()
|
||||||
.layout(new GridLayout().setColumns(2).setSpacingX(7).setSpacingY(3))
|
.layout(new GridLayout().setColumns(2).setSpacingX(7).setSpacingY(3))
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ package com.replaymod.replay.gui.overlay;
|
|||||||
|
|
||||||
import com.replaymod.core.ReplayMod;
|
import com.replaymod.core.ReplayMod;
|
||||||
import com.replaymod.replay.ReplayHandler;
|
import com.replaymod.replay.ReplayHandler;
|
||||||
import com.replaymod.replaystudio.data.Marker;
|
|
||||||
import com.replaymod.replaystudio.util.Location;
|
import com.replaymod.replaystudio.util.Location;
|
||||||
import de.johni0702.minecraft.gui.GuiRenderer;
|
import de.johni0702.minecraft.gui.GuiRenderer;
|
||||||
import de.johni0702.minecraft.gui.RenderInfo;
|
import de.johni0702.minecraft.gui.RenderInfo;
|
||||||
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 com.replaymod.replaystudio.data.Marker;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import org.lwjgl.util.Point;
|
import org.lwjgl.util.Point;
|
||||||
import org.lwjgl.util.ReadableDimension;
|
import org.lwjgl.util.ReadableDimension;
|
||||||
import org.lwjgl.util.ReadablePoint;
|
import org.lwjgl.util.ReadablePoint;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import de.johni0702.minecraft.gui.layout.CustomLayout;
|
|||||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.client.settings.GameSettings;
|
import net.minecraft.client.settings.GameSettings;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
@@ -138,9 +138,9 @@ public class GuiReplayOverlay extends AbstractGuiOverlay<GuiReplayOverlay> {
|
|||||||
public void setVisible(boolean visible) {
|
public void setVisible(boolean visible) {
|
||||||
if (isVisible() != visible) {
|
if (isVisible() != visible) {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
FMLCommonHandler.instance().bus().register(this);
|
||||||
} else {
|
} else {
|
||||||
MinecraftForge.EVENT_BUS.unregister(this);
|
FMLCommonHandler.instance().bus().unregister(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.setVisible(visible);
|
super.setVisible(visible);
|
||||||
|
|||||||
@@ -9,10 +9,12 @@ import net.minecraft.client.gui.GuiMainMenu;
|
|||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class GuiHandler {
|
public class GuiHandler {
|
||||||
private static final int BUTTON_EXIT_SERVER = 1;
|
private static final int BUTTON_EXIT_SERVER = 1;
|
||||||
@@ -33,12 +35,13 @@ public class GuiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void register() {
|
public void register() {
|
||||||
|
FMLCommonHandler.instance().bus().register(this);
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void injectIntoIngameMenu(GuiScreenEvent.InitGuiEvent.Post event) {
|
public void injectIntoIngameMenu(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||||
if (!(event.getGui() instanceof GuiIngameMenu)) {
|
if (!(event.gui instanceof GuiIngameMenu)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +49,9 @@ public class GuiHandler {
|
|||||||
// Pause replay when menu is opened
|
// Pause replay when menu is opened
|
||||||
mod.getReplayHandler().getReplaySender().setReplaySpeed(0);
|
mod.getReplayHandler().getReplaySender().setReplaySpeed(0);
|
||||||
|
|
||||||
for(GuiButton b : new ArrayList<>(event.getButtonList())) {
|
@SuppressWarnings("unchecked")
|
||||||
|
List<GuiButton> buttonList = event.buttonList;
|
||||||
|
for(GuiButton b : new ArrayList<>(buttonList)) {
|
||||||
switch (b.id) {
|
switch (b.id) {
|
||||||
// Replace "Exit Server" button with "Exit Replay" button
|
// Replace "Exit Server" button with "Exit Replay" button
|
||||||
case BUTTON_EXIT_SERVER:
|
case BUTTON_EXIT_SERVER:
|
||||||
@@ -57,7 +62,7 @@ public class GuiHandler {
|
|||||||
case BUTTON_ACHIEVEMENTS:
|
case BUTTON_ACHIEVEMENTS:
|
||||||
case BUTTON_STATS:
|
case BUTTON_STATS:
|
||||||
case BUTTON_OPEN_TO_LAN:
|
case BUTTON_OPEN_TO_LAN:
|
||||||
event.getButtonList().remove(b);
|
buttonList.remove(b);
|
||||||
}
|
}
|
||||||
// Move all buttons except the "Return to game" button upwards
|
// Move all buttons except the "Return to game" button upwards
|
||||||
if (b.id != BUTTON_RETURN_TO_GAME) {
|
if (b.id != BUTTON_RETURN_TO_GAME) {
|
||||||
@@ -69,29 +74,31 @@ public class GuiHandler {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
||||||
if (!(event.getGui() instanceof GuiMainMenu)) {
|
if (!(event.gui instanceof GuiMainMenu)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiButton button = new GuiButton(BUTTON_REPLAY_VIEWER, event.getGui().width / 2 - 100,
|
@SuppressWarnings("unchecked")
|
||||||
event.getGui().height / 4 + 10 + 3 * 24, I18n.format("replaymod.gui.replayviewer"));
|
List<GuiButton> buttonList = event.buttonList;
|
||||||
|
GuiButton button = new GuiButton(BUTTON_REPLAY_VIEWER, event.gui.width / 2 - 100,
|
||||||
|
event.gui.height / 4 + 10 + 3 * 24, I18n.format("replaymod.gui.replayviewer"));
|
||||||
button.width = button.width / 2 - 2;
|
button.width = button.width / 2 - 2;
|
||||||
event.getButtonList().add(button);
|
buttonList.add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
||||||
if(!event.getButton().enabled) return;
|
if(!event.button.enabled) return;
|
||||||
|
|
||||||
if (event.getGui() instanceof GuiMainMenu) {
|
if (event.gui instanceof GuiMainMenu) {
|
||||||
if (event.getButton().id == BUTTON_REPLAY_VIEWER) {
|
if (event.button.id == BUTTON_REPLAY_VIEWER) {
|
||||||
new GuiReplayViewer(mod).display();
|
new GuiReplayViewer(mod).display();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getGui() instanceof GuiIngameMenu && mod.getReplayHandler() != null) {
|
if (event.gui instanceof GuiIngameMenu && mod.getReplayHandler() != null) {
|
||||||
if (event.getButton().id == BUTTON_EXIT_REPLAY) {
|
if (event.button.id == BUTTON_EXIT_REPLAY) {
|
||||||
event.getButton().enabled = false;
|
event.button.enabled = false;
|
||||||
mc.displayGuiScreen(new GuiMainMenu());
|
mc.displayGuiScreen(new GuiMainMenu());
|
||||||
try {
|
try {
|
||||||
mod.getReplayHandler().endReplay();
|
mod.getReplayHandler().endReplay();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package com.replaymod.replay.mixin;
|
|||||||
|
|
||||||
import com.replaymod.replay.camera.CameraEntity;
|
import com.replaymod.replay.camera.CameraEntity;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.entity.RenderArmorStand;
|
import net.minecraft.client.renderer.entity.ArmorStandRenderer;
|
||||||
import net.minecraft.entity.item.EntityArmorStand;
|
import net.minecraft.entity.item.EntityArmorStand;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -10,9 +10,9 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
@Mixin(RenderArmorStand.class)
|
@Mixin(ArmorStandRenderer.class)
|
||||||
public abstract class MixinRenderArmorStand {
|
public abstract class MixinArmorStandRenderer {
|
||||||
@Inject(method = "canRenderName", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "func_177099_b", at = @At("HEAD"), cancellable = true)
|
||||||
private void replayModReplay_canRenderInvisibleName(EntityArmorStand entity, CallbackInfoReturnable<Boolean> ci) {
|
private void replayModReplay_canRenderInvisibleName(EntityArmorStand entity, CallbackInfoReturnable<Boolean> ci) {
|
||||||
EntityPlayer thePlayer = Minecraft.getMinecraft().thePlayer;
|
EntityPlayer thePlayer = Minecraft.getMinecraft().thePlayer;
|
||||||
if (thePlayer instanceof CameraEntity && entity.isInvisible()) {
|
if (thePlayer instanceof CameraEntity && entity.isInvisible()) {
|
||||||
@@ -12,12 +12,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
@Mixin(GuiSpectator.class)
|
@Mixin(GuiSpectator.class)
|
||||||
public abstract class MixinGuiSpectator {
|
public abstract class MixinGuiSpectator {
|
||||||
@Shadow
|
@Shadow
|
||||||
private Minecraft mc;
|
private Minecraft field_175268_g;
|
||||||
|
|
||||||
@Inject(method = "onHotbarSelected", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "func_175260_a", at = @At("HEAD"), cancellable = true)
|
||||||
public void isInReplay(int i, CallbackInfo ci) {
|
public void isInReplay(int i, CallbackInfo ci) {
|
||||||
// Prevent spectator gui from opening while in a replay
|
// Prevent spectator gui from opening while in a replay
|
||||||
if (mc.thePlayer instanceof CameraEntity) {
|
if (field_175268_g.thePlayer instanceof CameraEntity) {
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
package com.replaymod.replay.mixin;
|
|
||||||
|
|
||||||
import net.minecraft.client.particle.Particle;
|
|
||||||
import net.minecraft.client.particle.ParticleManager;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
import java.util.Queue;
|
|
||||||
|
|
||||||
@Mixin(ParticleManager.class)
|
|
||||||
public abstract class MixinParticleManager {
|
|
||||||
@Shadow
|
|
||||||
private Queue<Particle> queueEntityFX;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method additionally clears the queue of particles to be added when the world is changed.
|
|
||||||
* Otherwise particles from the previous world might show up in this one if they were spawned after
|
|
||||||
* the last tick in the previous world.
|
|
||||||
*
|
|
||||||
* @param world The new world
|
|
||||||
* @param ci Callback info
|
|
||||||
*/
|
|
||||||
@Inject(method = "clearEffects", at = @At("HEAD"))
|
|
||||||
public void replayModReplay_clearParticleQueue(World world, CallbackInfo ci) {
|
|
||||||
queueEntityFX.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
package com.replaymod.replay.mixin;
|
package com.replaymod.replay.mixin;
|
||||||
|
|
||||||
import com.replaymod.replay.ReplayModReplay;
|
|
||||||
import com.replaymod.replay.camera.CameraEntity;
|
import com.replaymod.replay.camera.CameraEntity;
|
||||||
|
import com.replaymod.replay.ReplayModReplay;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||||
import net.minecraft.stats.StatisticsManager;
|
import net.minecraft.stats.StatFileWriter;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
@@ -21,12 +21,12 @@ public abstract class MixinPlayerControllerMP {
|
|||||||
private Minecraft mc;
|
private Minecraft mc;
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
private NetHandlerPlayClient connection;
|
private NetHandlerPlayClient netClientHandler;
|
||||||
|
|
||||||
@Inject(method = "createClientPlayer", at=@At("HEAD"), cancellable = true)
|
@Inject(method = "func_178892_a", at=@At("HEAD"), cancellable = true)
|
||||||
private void replayModReplay_createReplayCamera(World worldIn, StatisticsManager statisticsManager, CallbackInfoReturnable<EntityPlayerSP> ci) {
|
private void replayModReplay_createReplayCamera(World worldIn, StatFileWriter statFileWriter, CallbackInfoReturnable<EntityPlayerSP> ci) {
|
||||||
if (ReplayModReplay.instance.getReplayHandler() != null) {
|
if (ReplayModReplay.instance.getReplayHandler() != null) {
|
||||||
ci.setReturnValue(new CameraEntity(mc, worldIn, connection, statisticsManager));
|
ci.setReturnValue(new CameraEntity(mc, worldIn, netClientHandler, statFileWriter));
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ public abstract class MixinRenderArrow extends Render {
|
|||||||
super(renderManager);
|
super(renderManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldRender(Entity entity, ICamera camera, double camX, double camY, double camZ) {
|
public boolean shouldRender(Entity entity, ICamera camera, double camX, double camY, double camZ) {
|
||||||
// Force arrows to always render, otherwise they stop rendering when you get close to them
|
// Force arrows to always render, otherwise they stop rendering when you get close to them
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.replaymod.replay.mixin;
|
|||||||
import com.replaymod.replay.ReplayHandler;
|
import com.replaymod.replay.ReplayHandler;
|
||||||
import com.replaymod.replay.ReplayModReplay;
|
import com.replaymod.replay.ReplayModReplay;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.RenderItem;
|
import net.minecraft.client.renderer.entity.RenderItem;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package com.replaymod.replay.mixin;
|
|||||||
|
|
||||||
import com.replaymod.replay.camera.CameraEntity;
|
import com.replaymod.replay.camera.CameraEntity;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.entity.RenderLivingBase;
|
import net.minecraft.client.renderer.entity.RendererLivingEntity;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -11,8 +11,8 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
@Mixin(RenderLivingBase.class)
|
@Mixin(RendererLivingEntity.class)
|
||||||
public abstract class MixinRenderLivingBase {
|
public abstract class MixinRendererLivingEntity {
|
||||||
@Inject(method = "canRenderName", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "canRenderName", at = @At("HEAD"), cancellable = true)
|
||||||
private void replayModReplay_canRenderInvisibleName(EntityLivingBase entity, CallbackInfoReturnable<Boolean> ci) {
|
private void replayModReplay_canRenderInvisibleName(EntityLivingBase entity, CallbackInfoReturnable<Boolean> ci) {
|
||||||
EntityPlayer thePlayer = Minecraft.getMinecraft().thePlayer;
|
EntityPlayer thePlayer = Minecraft.getMinecraft().thePlayer;
|
||||||
@@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
|||||||
|
|
||||||
@Mixin(TileEntityEndPortalRenderer.class)
|
@Mixin(TileEntityEndPortalRenderer.class)
|
||||||
public class MixinTileEntityEndPortalRenderer {
|
public class MixinTileEntityEndPortalRenderer {
|
||||||
@Redirect(method = "renderTileEntityAt", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getSystemTime()J"))
|
@Redirect(method = "func_180544_a", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getSystemTime()J"))
|
||||||
private long replayModReplay_getEnchantmentTime() {
|
private long replayModReplay_getEnchantmentTime() {
|
||||||
ReplayHandler replayHandler = ReplayModReplay.instance.getReplayHandler();
|
ReplayHandler replayHandler = ReplayModReplay.instance.getReplayHandler();
|
||||||
if (replayHandler != null) {
|
if (replayHandler != null) {
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import net.minecraft.client.renderer.RenderGlobal;
|
|||||||
import net.minecraft.client.renderer.ViewFrustum;
|
import net.minecraft.client.renderer.ViewFrustum;
|
||||||
import net.minecraft.client.renderer.chunk.IRenderChunkFactory;
|
import net.minecraft.client.renderer.chunk.IRenderChunkFactory;
|
||||||
import net.minecraft.client.renderer.chunk.RenderChunk;
|
import net.minecraft.client.renderer.chunk.RenderChunk;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
@@ -31,7 +31,7 @@ public abstract class MixinViewFrustum {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instead of calling {@link RenderChunk#setPosition(int, int, int)} we recreate the render chunk
|
* Instead of calling {@link RenderChunk#setPosition(BlockPos)} we recreate the render chunk
|
||||||
* which seems to solve the problem that chunks are invisible when you leave an area and return
|
* which seems to solve the problem that chunks are invisible when you leave an area and return
|
||||||
* to it.
|
* to it.
|
||||||
* Any better fixes are welcome.
|
* Any better fixes are welcome.
|
||||||
@@ -48,18 +48,17 @@ public abstract class MixinViewFrustum {
|
|||||||
int k = this.countChunksX * 16;
|
int k = this.countChunksX * 16;
|
||||||
|
|
||||||
for (int l = 0; l < this.countChunksX; ++l) {
|
for (int l = 0; l < this.countChunksX; ++l) {
|
||||||
int i1 = this.getBaseCoordinate(i, k, l);
|
int i1 = this.func_178157_a(i, k, l);
|
||||||
for (int j1 = 0; j1 < this.countChunksZ; ++j1) {
|
for (int j1 = 0; j1 < this.countChunksZ; ++j1) {
|
||||||
int k1 = this.getBaseCoordinate(j, k, j1);
|
int k1 = this.func_178157_a(j, k, j1);
|
||||||
for (int l1 = 0; l1 < this.countChunksY; ++l1) {
|
for (int l1 = 0; l1 < this.countChunksY; ++l1) {
|
||||||
int i2 = l1 * 16;
|
int i2 = l1 * 16;
|
||||||
RenderChunk renderchunk = this.renderChunks[(j1 * this.countChunksY + l1) * this.countChunksX + l];
|
RenderChunk renderchunk = this.renderChunks[(j1 * this.countChunksY + l1) * this.countChunksX + l];
|
||||||
BlockPos blockpos = new BlockPos(i1, i2, k1);
|
BlockPos blockpos = new BlockPos(i1, i2, k1);
|
||||||
if (!blockpos.equals(renderchunk.getPosition())) {
|
if (!blockpos.equals(renderchunk.getPosition())) {
|
||||||
// Recreate render chunk instead of setting its position
|
// Recreate render chunk instead of setting its position
|
||||||
(renderChunks[(j1 * this.countChunksY + l1) * this.countChunksX + l] =
|
renderChunks[(j1 * this.countChunksY + l1) * this.countChunksX + l] =
|
||||||
renderChunkFactory.create(world, renderGlobal, 0)
|
renderChunkFactory.makeRenderChunk(world, renderGlobal, blockpos, 0);
|
||||||
).setPosition(blockpos.getX(), blockpos.getY(), blockpos.getZ());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,5 +66,5 @@ public abstract class MixinViewFrustum {
|
|||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Shadow abstract int getBaseCoordinate(int p_178157_1_, int p_178157_2_, int p_178157_3_);
|
@Shadow abstract int func_178157_a(int p_178157_1_, int p_178157_2_, int p_178157_3_);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.replaymod.simplepathing;
|
||||||
|
|
||||||
|
import com.replaymod.replaystudio.pathing.interpolation.CatmullRomSplineInterpolator;
|
||||||
|
import com.replaymod.replaystudio.pathing.interpolation.CubicSplineInterpolator;
|
||||||
|
import com.replaymod.replaystudio.pathing.interpolation.Interpolator;
|
||||||
|
import com.replaymod.replaystudio.pathing.interpolation.LinearInterpolator;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum InterpolatorType {
|
||||||
|
DEFAULT("default", null, null),
|
||||||
|
CATMULL_ROM("catmullrom", CatmullRomSplineInterpolator.class, () -> new CatmullRomSplineInterpolator(0.5)),
|
||||||
|
CUBIC("cubic", CubicSplineInterpolator.class, CubicSplineInterpolator::new),
|
||||||
|
LINEAR("linear", LinearInterpolator.class, LinearInterpolator::new);
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private String localizationKey;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private Class<? extends Interpolator> interpolatorClass;
|
||||||
|
|
||||||
|
private Supplier<Interpolator> interpolatorConstructor;
|
||||||
|
|
||||||
|
public String getI18nName() {
|
||||||
|
return String.format("replaymod.gui.editkeyframe.interpolator.%1$s.name", localizationKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getI18nDescription() {
|
||||||
|
return String.format("replaymod.gui.editkeyframe.interpolator.%1$s.desc", localizationKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static InterpolatorType fromString(String string) {
|
||||||
|
for (InterpolatorType t : values()) {
|
||||||
|
if (t.getI18nName().equals(string)) return t;
|
||||||
|
}
|
||||||
|
return CATMULL_ROM; //the default
|
||||||
|
}
|
||||||
|
|
||||||
|
public static InterpolatorType fromClass(Class<? extends Interpolator> cls) {
|
||||||
|
for (InterpolatorType type : values()) {
|
||||||
|
if (cls.equals(type.getInterpolatorClass())) {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Interpolator newInstance() {
|
||||||
|
return interpolatorConstructor.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,36 +1,25 @@
|
|||||||
package com.replaymod.simplepathing;
|
package com.replaymod.simplepathing;
|
||||||
|
|
||||||
import com.google.gson.stream.JsonReader;
|
|
||||||
import com.google.gson.stream.JsonWriter;
|
|
||||||
import com.replaymod.core.ReplayMod;
|
import com.replaymod.core.ReplayMod;
|
||||||
import com.replaymod.core.events.SettingsChangedEvent;
|
import com.replaymod.core.events.SettingsChangedEvent;
|
||||||
import com.replaymod.pathing.properties.CameraProperties;
|
|
||||||
import com.replaymod.pathing.properties.SpectatorProperty;
|
|
||||||
import com.replaymod.pathing.properties.TimestampProperty;
|
|
||||||
import com.replaymod.replay.events.ReplayCloseEvent;
|
import com.replaymod.replay.events.ReplayCloseEvent;
|
||||||
import com.replaymod.replay.events.ReplayOpenEvent;
|
import com.replaymod.replay.events.ReplayOpenEvent;
|
||||||
import com.replaymod.replaystudio.pathing.PathingRegistry;
|
|
||||||
import com.replaymod.replaystudio.pathing.impl.TimelineImpl;
|
|
||||||
import com.replaymod.replaystudio.pathing.interpolation.CubicSplineInterpolator;
|
|
||||||
import com.replaymod.replaystudio.pathing.interpolation.Interpolator;
|
|
||||||
import com.replaymod.replaystudio.pathing.interpolation.LinearInterpolator;
|
|
||||||
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
||||||
import com.replaymod.replaystudio.pathing.path.Timeline;
|
import com.replaymod.simplepathing.SPTimeline.SPPath;
|
||||||
import com.replaymod.simplepathing.gui.GuiPathing;
|
import com.replaymod.simplepathing.gui.GuiPathing;
|
||||||
import com.replaymod.simplepathing.preview.PathPreview;
|
import com.replaymod.simplepathing.preview.PathPreview;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import lombok.Getter;
|
||||||
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Mod(modid = ReplayModSimplePathing.MOD_ID,
|
@Mod(modid = ReplayModSimplePathing.MOD_ID,
|
||||||
version = "@MOD_VERSION@",
|
version = "@MOD_VERSION@",
|
||||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||||
useMetadata = true)
|
useMetadata = true)
|
||||||
public class ReplayModSimplePathing implements PathingRegistry {
|
public class ReplayModSimplePathing {
|
||||||
public static final String MOD_ID = "replaymod-simplepathing";
|
public static final String MOD_ID = "replaymod-simplepathing";
|
||||||
|
|
||||||
private ReplayMod core;
|
private ReplayMod core;
|
||||||
@@ -46,7 +35,7 @@ public class ReplayModSimplePathing implements PathingRegistry {
|
|||||||
|
|
||||||
core.getSettingsRegistry().register(Setting.class);
|
core.getSettingsRegistry().register(Setting.class);
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
FMLCommonHandler.instance().bus().register(this);
|
||||||
|
|
||||||
PathPreview pathPreview = new PathPreview(this);
|
PathPreview pathPreview = new PathPreview(this);
|
||||||
pathPreview.register();
|
pathPreview.register();
|
||||||
@@ -54,84 +43,60 @@ public class ReplayModSimplePathing implements PathingRegistry {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void postReplayOpen(ReplayOpenEvent.Post event) {
|
public void postReplayOpen(ReplayOpenEvent.Post event) {
|
||||||
|
currentTimeline = new SPTimeline();
|
||||||
guiPathing = new GuiPathing(core, this, event.getReplayHandler());
|
guiPathing = new GuiPathing(core, this, event.getReplayHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onReplayClose(ReplayCloseEvent.Post event) {
|
public void onReplayClose(ReplayCloseEvent.Post event) {
|
||||||
|
currentTimeline = null;
|
||||||
guiPathing = null;
|
guiPathing = null;
|
||||||
currentTimeline = createTimeline();
|
selectedPath = null;
|
||||||
currentTimeline.createPath();
|
|
||||||
currentTimeline.createPath();
|
|
||||||
selectedKeyframe = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onSettingsChanged(SettingsChangedEvent event) {
|
public void onSettingsChanged(SettingsChangedEvent event) {
|
||||||
if (event.getKey() == Setting.LINEAR_INTERPOLATION) {
|
if (event.getKey() == Setting.DEFAULT_INTERPOLATION) {
|
||||||
if (currentTimeline != null && guiPathing != null) {
|
if (currentTimeline != null && guiPathing != null) {
|
||||||
currentTimeline.applyChange(guiPathing.updateInterpolators());
|
updateDefaultInterpolatorType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Timeline currentTimeline = createTimeline(); { currentTimeline.createPath(); currentTimeline.createPath(); }
|
private SPTimeline currentTimeline;
|
||||||
private Keyframe selectedKeyframe;
|
|
||||||
|
|
||||||
public Keyframe getSelectedKeyframe() {
|
@Getter
|
||||||
return selectedKeyframe;
|
private SPPath selectedPath;
|
||||||
|
@Getter
|
||||||
|
private long selectedTime;
|
||||||
|
|
||||||
|
public boolean isSelected(Keyframe keyframe) {
|
||||||
|
return selectedPath != null && currentTimeline.getKeyframe(selectedPath, selectedTime) == keyframe;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelectedKeyframe(Keyframe selected) {
|
public void setSelected(SPPath path, long time) {
|
||||||
this.selectedKeyframe = selected;
|
selectedPath = path;
|
||||||
|
selectedTime = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentTimeline(Timeline currentTimeline) {
|
public void setCurrentTimeline(SPTimeline newTimeline) {
|
||||||
if (this.currentTimeline != currentTimeline) {
|
selectedPath = null;
|
||||||
selectedKeyframe = null;
|
currentTimeline = newTimeline;
|
||||||
}
|
|
||||||
this.currentTimeline = currentTimeline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Timeline getCurrentTimeline() {
|
public void clearCurrentTimeline() {
|
||||||
|
setCurrentTimeline(new SPTimeline());
|
||||||
|
updateDefaultInterpolatorType();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SPTimeline getCurrentTimeline() {
|
||||||
return currentTimeline;
|
return currentTimeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void updateDefaultInterpolatorType() {
|
||||||
public Timeline createTimeline() {
|
InterpolatorType newDefaultType =
|
||||||
Timeline timeline = new TimelineImpl();
|
InterpolatorType.fromString(core.getSettingsRegistry().get(Setting.DEFAULT_INTERPOLATION));
|
||||||
|
currentTimeline.setDefaultInterpolatorType(newDefaultType);
|
||||||
timeline.registerProperty(TimestampProperty.PROPERTY);
|
|
||||||
timeline.registerProperty(CameraProperties.POSITION);
|
|
||||||
timeline.registerProperty(CameraProperties.ROTATION);
|
|
||||||
timeline.registerProperty(SpectatorProperty.PROPERTY);
|
|
||||||
|
|
||||||
return timeline;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void serializeInterpolator(JsonWriter writer, Interpolator interpolator) throws IOException {
|
|
||||||
if (interpolator instanceof LinearInterpolator) {
|
|
||||||
writer.value("linear");
|
|
||||||
} else if (interpolator instanceof CubicSplineInterpolator) {
|
|
||||||
writer.value("cubic-spline");
|
|
||||||
} else {
|
|
||||||
throw new IOException("Unknown interpolator type: " + interpolator);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Interpolator deserializeInterpolator(JsonReader reader) throws IOException {
|
|
||||||
String type = reader.nextString();
|
|
||||||
switch (type) {
|
|
||||||
case "linear":
|
|
||||||
return new LinearInterpolator();
|
|
||||||
case "cubic-spline":
|
|
||||||
return new CubicSplineInterpolator();
|
|
||||||
default:
|
|
||||||
throw new IOException("Unknown interpolation type: " + type);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReplayMod getCore() {
|
public ReplayMod getCore() {
|
||||||
|
|||||||
669
src/main/java/com/replaymod/simplepathing/SPTimeline.java
Normal file
669
src/main/java/com/replaymod/simplepathing/SPTimeline.java
Normal file
@@ -0,0 +1,669 @@
|
|||||||
|
package com.replaymod.simplepathing;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import com.replaymod.pathing.properties.CameraProperties;
|
||||||
|
import com.replaymod.pathing.properties.SpectatorProperty;
|
||||||
|
import com.replaymod.pathing.properties.TimestampProperty;
|
||||||
|
import com.replaymod.replaystudio.pathing.PathingRegistry;
|
||||||
|
import com.replaymod.replaystudio.pathing.change.AddKeyframe;
|
||||||
|
import com.replaymod.replaystudio.pathing.change.Change;
|
||||||
|
import com.replaymod.replaystudio.pathing.change.CombinedChange;
|
||||||
|
import com.replaymod.replaystudio.pathing.change.SetInterpolator;
|
||||||
|
import com.replaymod.replaystudio.pathing.change.UpdateKeyframeProperties;
|
||||||
|
import com.replaymod.replaystudio.pathing.impl.TimelineImpl;
|
||||||
|
import com.replaymod.replaystudio.pathing.interpolation.CatmullRomSplineInterpolator;
|
||||||
|
import com.replaymod.replaystudio.pathing.interpolation.CubicSplineInterpolator;
|
||||||
|
import com.replaymod.replaystudio.pathing.interpolation.Interpolator;
|
||||||
|
import com.replaymod.replaystudio.pathing.interpolation.LinearInterpolator;
|
||||||
|
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
||||||
|
import com.replaymod.replaystudio.pathing.path.Path;
|
||||||
|
import com.replaymod.replaystudio.pathing.path.PathSegment;
|
||||||
|
import com.replaymod.replaystudio.pathing.path.Timeline;
|
||||||
|
import com.replaymod.replaystudio.pathing.property.Property;
|
||||||
|
import com.replaymod.replaystudio.util.EntityPositionTracker;
|
||||||
|
import com.replaymod.replaystudio.util.Location;
|
||||||
|
import com.replaymod.simplepathing.properties.ExplicitInterpolationProperty;
|
||||||
|
import lombok.Getter;
|
||||||
|
import net.minecraft.crash.CrashReport;
|
||||||
|
import net.minecraft.crash.CrashReportCategory;
|
||||||
|
import net.minecraft.util.ReportedException;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
import org.apache.commons.lang3.Validate;
|
||||||
|
import org.apache.commons.lang3.tuple.Triple;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.IdentityHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static com.replaymod.replaystudio.pathing.change.RemoveKeyframe.create;
|
||||||
|
import static com.replaymod.simplepathing.ReplayModSimplePathing.LOGGER;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simplified timeline abstraction used in the SimplePathing module.
|
||||||
|
*/
|
||||||
|
public class SPTimeline implements PathingRegistry {
|
||||||
|
public enum SPPath {
|
||||||
|
TIME,
|
||||||
|
POSITION,
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final Timeline timeline;
|
||||||
|
@Getter
|
||||||
|
private final Path timePath;
|
||||||
|
@Getter
|
||||||
|
private final Path positionPath;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private EntityPositionTracker entityTracker;
|
||||||
|
private InterpolatorType defaultInterpolatorType = InterpolatorType.fromString("invalid string returns default");
|
||||||
|
|
||||||
|
public SPTimeline() {
|
||||||
|
this(createInitialTimeline());
|
||||||
|
}
|
||||||
|
|
||||||
|
public SPTimeline(Timeline timeline) {
|
||||||
|
this.timeline = timeline;
|
||||||
|
this.timePath = timeline.getPaths().get(SPPath.TIME.ordinal());
|
||||||
|
this.positionPath = timeline.getPaths().get(SPPath.POSITION.ordinal());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Path getPath(SPPath path) {
|
||||||
|
switch (path) {
|
||||||
|
case TIME:
|
||||||
|
return getTimePath();
|
||||||
|
case POSITION:
|
||||||
|
return getPositionPath();
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Unknown path " + path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Keyframe getKeyframe(SPPath path, long keyframe) {
|
||||||
|
return getPath(path).getKeyframe(keyframe);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEntityTracker(EntityPositionTracker entityTracker) {
|
||||||
|
Preconditions.checkState(this.entityTracker == null, "Entity tracker already set");
|
||||||
|
this.entityTracker = entityTracker;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultInterpolatorType(InterpolatorType defaultInterpolatorType) {
|
||||||
|
Validate.isTrue(defaultInterpolatorType != InterpolatorType.DEFAULT, "Must not be DEFAULT");
|
||||||
|
this.defaultInterpolatorType = Validate.notNull(defaultInterpolatorType);
|
||||||
|
|
||||||
|
if (entityTracker != null) {
|
||||||
|
timeline.pushChange(updateInterpolators());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Change setDefaultInterpolator(Interpolator interpolator) {
|
||||||
|
Preconditions.checkState(defaultInterpolatorType != null, "Default interpolator type not set.");
|
||||||
|
Validate.isInstanceOf(defaultInterpolatorType.getInterpolatorClass(), interpolator);
|
||||||
|
|
||||||
|
registerPositionInterpolatorProperties(interpolator);
|
||||||
|
|
||||||
|
Change change = CombinedChange.create(
|
||||||
|
positionPath.getSegments().stream()
|
||||||
|
// Ignore explicitly set segments
|
||||||
|
.filter(s -> !s.getStartKeyframe().getValue(ExplicitInterpolationProperty.PROPERTY).isPresent())
|
||||||
|
// Ignore spectator segments
|
||||||
|
.filter(s -> !isSpectatorSegment(s))
|
||||||
|
// Update interpolator for every remaining segment
|
||||||
|
// This will create a fragmented interpolator which is split by the updateInterpolators call
|
||||||
|
.map(s -> SetInterpolator.create(s, interpolator)).toArray(Change[]::new)
|
||||||
|
);
|
||||||
|
change.apply(timeline);
|
||||||
|
return CombinedChange.createFromApplied(change, updateInterpolators());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTimeKeyframe(long time) {
|
||||||
|
return timePath.getKeyframe(time) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPositionKeyframe(long time) {
|
||||||
|
return positionPath.getKeyframe(time) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSpectatorKeyframe(long time) {
|
||||||
|
Keyframe keyframe = positionPath.getKeyframe(time);
|
||||||
|
return keyframe != null && keyframe.getValue(SpectatorProperty.PROPERTY).isPresent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPositionKeyframe(long time, double posX, double posY, double posZ,
|
||||||
|
float yaw, float pitch, float roll, int spectated) {
|
||||||
|
LOGGER.debug("Adding position keyframe at {} pos {}/{}/{} rot {}/{}/{} entId {}",
|
||||||
|
time, posX, posY, posZ, yaw, pitch, roll, spectated);
|
||||||
|
|
||||||
|
Path path = positionPath;
|
||||||
|
|
||||||
|
Preconditions.checkState(positionPath.getKeyframe(time) == null, "Keyframe already exists");
|
||||||
|
|
||||||
|
Change change = AddKeyframe.create(path, time);
|
||||||
|
change.apply(timeline);
|
||||||
|
Keyframe keyframe = path.getKeyframe(time);
|
||||||
|
|
||||||
|
UpdateKeyframeProperties.Builder builder = UpdateKeyframeProperties.create(path, keyframe);
|
||||||
|
builder.setValue(CameraProperties.POSITION, Triple.of(posX, posY, posZ));
|
||||||
|
builder.setValue(CameraProperties.ROTATION, Triple.of(yaw, pitch, roll));
|
||||||
|
if (spectated != -1) {
|
||||||
|
builder.setValue(SpectatorProperty.PROPERTY, spectated);
|
||||||
|
}
|
||||||
|
UpdateKeyframeProperties updateChange = builder.done();
|
||||||
|
updateChange.apply(timeline);
|
||||||
|
change = CombinedChange.createFromApplied(change, updateChange);
|
||||||
|
|
||||||
|
// If this new keyframe formed the first segment of the path
|
||||||
|
if (path.getSegments().size() == 1) {
|
||||||
|
// then create an initial interpolator of default type
|
||||||
|
PathSegment segment = path.getSegments().iterator().next();
|
||||||
|
Interpolator interpolator = createDefaultInterpolator();
|
||||||
|
SetInterpolator setInterpolator = SetInterpolator.create(segment, interpolator);
|
||||||
|
setInterpolator.apply(timeline);
|
||||||
|
change = CombinedChange.createFromApplied(change, setInterpolator);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update interpolators for spectator keyframes
|
||||||
|
// while this is overkill, it is far simpler than updating differently for every possible case
|
||||||
|
change = CombinedChange.createFromApplied(change, updateInterpolators());
|
||||||
|
|
||||||
|
Change specPosUpdate = updateSpectatorPositions();
|
||||||
|
specPosUpdate.apply(timeline);
|
||||||
|
change = CombinedChange.createFromApplied(change, specPosUpdate);
|
||||||
|
|
||||||
|
timeline.pushChange(change);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Change updatePositionKeyframe(long time, double posX, double posY, double posZ,
|
||||||
|
float yaw, float pitch, float roll) {
|
||||||
|
LOGGER.debug("Updating position keyframe at {} to pos {}/{}/{} rot {}/{}/{}",
|
||||||
|
time, posX, posY, posZ, yaw, pitch, roll);
|
||||||
|
|
||||||
|
Keyframe keyframe = positionPath.getKeyframe(time);
|
||||||
|
|
||||||
|
Preconditions.checkState(keyframe != null, "Keyframe does not exists");
|
||||||
|
Preconditions.checkState(!keyframe.getValue(SpectatorProperty.PROPERTY).isPresent(), "Cannot update spectator keyframe");
|
||||||
|
|
||||||
|
Change change = UpdateKeyframeProperties.create(positionPath, keyframe)
|
||||||
|
.setValue(CameraProperties.POSITION, Triple.of(posX, posY, posZ))
|
||||||
|
.setValue(CameraProperties.ROTATION, Triple.of(yaw, pitch, roll))
|
||||||
|
.done();
|
||||||
|
change.apply(timeline);
|
||||||
|
return change;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePositionKeyframe(long time) {
|
||||||
|
LOGGER.debug("Removing position keyframe at {}", time);
|
||||||
|
|
||||||
|
Path path = positionPath;
|
||||||
|
Keyframe keyframe = path.getKeyframe(time);
|
||||||
|
|
||||||
|
Preconditions.checkState(keyframe != null, "No keyframe at that time");
|
||||||
|
|
||||||
|
Change change = create(path, keyframe);
|
||||||
|
change.apply(timeline);
|
||||||
|
|
||||||
|
// Update interpolators for spectator keyframes
|
||||||
|
// while this is overkill, it is far simpler than updating differently for every possible case
|
||||||
|
change = CombinedChange.createFromApplied(change, updateInterpolators());
|
||||||
|
|
||||||
|
Change specPosUpdate = updateSpectatorPositions();
|
||||||
|
specPosUpdate.apply(timeline);
|
||||||
|
change = CombinedChange.createFromApplied(change, specPosUpdate);
|
||||||
|
|
||||||
|
timeline.pushChange(change);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTimeKeyframe(long time, int replayTime) {
|
||||||
|
LOGGER.debug("Adding time keyframe at {} time {}", time, replayTime);
|
||||||
|
|
||||||
|
Path path = timePath;
|
||||||
|
|
||||||
|
Preconditions.checkState(path.getKeyframe(time) == null, "Keyframe already exists");
|
||||||
|
|
||||||
|
Change change = AddKeyframe.create(path, time);
|
||||||
|
change.apply(timeline);
|
||||||
|
Keyframe keyframe = path.getKeyframe(time);
|
||||||
|
|
||||||
|
UpdateKeyframeProperties updateChange = UpdateKeyframeProperties.create(path, keyframe)
|
||||||
|
.setValue(TimestampProperty.PROPERTY, replayTime)
|
||||||
|
.done();
|
||||||
|
updateChange.apply(timeline);
|
||||||
|
change = CombinedChange.createFromApplied(change, updateChange);
|
||||||
|
|
||||||
|
// If this new keyframe formed the first segment of the path
|
||||||
|
if (path.getSegments().size() == 1) {
|
||||||
|
// then create an initial interpolator
|
||||||
|
PathSegment segment = path.getSegments().iterator().next();
|
||||||
|
Interpolator interpolator = new LinearInterpolator();
|
||||||
|
interpolator.registerProperty(TimestampProperty.PROPERTY);
|
||||||
|
SetInterpolator setInterpolator = SetInterpolator.create(segment, interpolator);
|
||||||
|
setInterpolator.apply(timeline);
|
||||||
|
change = CombinedChange.createFromApplied(change, setInterpolator);
|
||||||
|
}
|
||||||
|
|
||||||
|
Change specPosUpdate = updateSpectatorPositions();
|
||||||
|
specPosUpdate.apply(timeline);
|
||||||
|
change = CombinedChange.createFromApplied(change, specPosUpdate);
|
||||||
|
|
||||||
|
timeline.pushChange(change);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Change updateTimeKeyframe(long time, int replayTime) {
|
||||||
|
LOGGER.debug("Updating time keyframe at {} to time {}", time, replayTime);
|
||||||
|
|
||||||
|
Keyframe keyframe = timePath.getKeyframe(time);
|
||||||
|
|
||||||
|
Preconditions.checkState(keyframe != null, "Keyframe does not exists");
|
||||||
|
|
||||||
|
Change change = UpdateKeyframeProperties.create(timePath, keyframe)
|
||||||
|
.setValue(TimestampProperty.PROPERTY, replayTime)
|
||||||
|
.done();
|
||||||
|
change.apply(timeline);
|
||||||
|
return change;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeTimeKeyframe(long time) {
|
||||||
|
LOGGER.debug("Removing time keyframe at {}", time);
|
||||||
|
|
||||||
|
Path path = timePath;
|
||||||
|
Keyframe keyframe = path.getKeyframe(time);
|
||||||
|
|
||||||
|
Preconditions.checkState(keyframe != null, "No keyframe at that time");
|
||||||
|
|
||||||
|
Change change = create(path, keyframe);
|
||||||
|
change.apply(timeline);
|
||||||
|
|
||||||
|
Change specPosUpdate = updateSpectatorPositions();
|
||||||
|
specPosUpdate.apply(timeline);
|
||||||
|
change = CombinedChange.createFromApplied(change, specPosUpdate);
|
||||||
|
|
||||||
|
timeline.pushChange(change);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Change setInterpolatorToDefault(long time) {
|
||||||
|
LOGGER.debug("Setting interpolator of position keyframe at {} to the default", time);
|
||||||
|
|
||||||
|
Keyframe keyframe = positionPath.getKeyframe(time);
|
||||||
|
|
||||||
|
Preconditions.checkState(keyframe != null, "Keyframe does not exists");
|
||||||
|
|
||||||
|
Change change = UpdateKeyframeProperties.create(positionPath, keyframe)
|
||||||
|
.removeProperty(ExplicitInterpolationProperty.PROPERTY)
|
||||||
|
.done();
|
||||||
|
change.apply(timeline);
|
||||||
|
return CombinedChange.createFromApplied(change, updateInterpolators());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Change setInterpolator(long time, Interpolator interpolator) {
|
||||||
|
LOGGER.debug("Setting interpolator of position keyframe at {} to {}", time, interpolator);
|
||||||
|
|
||||||
|
Keyframe keyframe = positionPath.getKeyframe(time);
|
||||||
|
Preconditions.checkState(keyframe != null, "Keyframe does not exists");
|
||||||
|
PathSegment segment = positionPath.getSegments().stream().filter(s -> s.getStartKeyframe() == keyframe)
|
||||||
|
.findFirst().orElseThrow(() -> new IllegalStateException("Keyframe has no following segment."));
|
||||||
|
|
||||||
|
registerPositionInterpolatorProperties(interpolator);
|
||||||
|
|
||||||
|
Change change = CombinedChange.create(
|
||||||
|
UpdateKeyframeProperties.create(positionPath, keyframe)
|
||||||
|
.setValue(ExplicitInterpolationProperty.PROPERTY, ObjectUtils.NULL)
|
||||||
|
.done(),
|
||||||
|
SetInterpolator.create(segment, interpolator)
|
||||||
|
);
|
||||||
|
change.apply(timeline);
|
||||||
|
return CombinedChange.createFromApplied(change, updateInterpolators());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Change moveKeyframe(SPPath spPath, long oldTime, long newTime) {
|
||||||
|
LOGGER.debug("Moving keyframe on {} from {} to {}", spPath, oldTime, newTime);
|
||||||
|
Path path = getPath(spPath);
|
||||||
|
Keyframe keyframe = path.getKeyframe(oldTime);
|
||||||
|
|
||||||
|
Preconditions.checkState(keyframe != null, "No keyframe at specified time");
|
||||||
|
|
||||||
|
// Interpolator of the first segment might be required later if it is the only one
|
||||||
|
Optional<Interpolator> firstInterpolator =
|
||||||
|
path.getSegments().stream().findFirst().map(PathSegment::getInterpolator);
|
||||||
|
|
||||||
|
// The interpolator of the previous segment
|
||||||
|
Optional<Interpolator> interpolatorBefore =
|
||||||
|
path.getSegments().stream().filter(s -> s.getEndKeyframe() == keyframe).findFirst().map(PathSegment::getInterpolator);
|
||||||
|
|
||||||
|
// The interpolator of the following segment
|
||||||
|
Optional<Interpolator> interpolatorAfter =
|
||||||
|
path.getSegments().stream().filter(s -> s.getStartKeyframe() == keyframe).findFirst().map(PathSegment::getInterpolator);
|
||||||
|
|
||||||
|
// First remove the old keyframe
|
||||||
|
Change removeChange = create(path, keyframe);
|
||||||
|
removeChange.apply(timeline);
|
||||||
|
|
||||||
|
// and add a new one at the correct time
|
||||||
|
Change addChange = AddKeyframe.create(path, newTime);
|
||||||
|
addChange.apply(timeline);
|
||||||
|
|
||||||
|
// Then copy over all properties
|
||||||
|
UpdateKeyframeProperties.Builder builder = UpdateKeyframeProperties.create(path, path.getKeyframe(newTime));
|
||||||
|
for (Property property : keyframe.getProperties()) {
|
||||||
|
copyProperty(property, keyframe, builder);
|
||||||
|
}
|
||||||
|
Change propertyChange = builder.done();
|
||||||
|
propertyChange.apply(timeline);
|
||||||
|
|
||||||
|
|
||||||
|
Change restoreInterpolatorChange;
|
||||||
|
Keyframe newKf = path.getKeyframe(newTime);
|
||||||
|
if (Iterables.getLast(path.getKeyframes()) != newKf) { // Unless this is the last keyframe
|
||||||
|
// the interpolator of the following segment has been lost and needs to be restored
|
||||||
|
restoreInterpolatorChange = interpolatorAfter.<Change>flatMap(interpolator ->
|
||||||
|
path.getSegments().stream().filter(s -> s.getStartKeyframe() == newKf).findFirst().map(segment ->
|
||||||
|
SetInterpolator.create(segment, interpolator)
|
||||||
|
)
|
||||||
|
).orElseGet(CombinedChange::create);
|
||||||
|
} else { // If it is the last keyframe however,
|
||||||
|
// the interpolator of the previous segment has been lost and needs to be restored
|
||||||
|
restoreInterpolatorChange = interpolatorBefore.<Change>flatMap(interpolator ->
|
||||||
|
path.getSegments().stream().filter(s -> s.getEndKeyframe() == newKf).findFirst().map(segment ->
|
||||||
|
SetInterpolator.create(segment, interpolator)
|
||||||
|
)
|
||||||
|
).orElseGet(CombinedChange::create);
|
||||||
|
}
|
||||||
|
restoreInterpolatorChange.apply(timeline);
|
||||||
|
|
||||||
|
// Finally update the interpolators
|
||||||
|
Change interpolatorUpdateChange;
|
||||||
|
if (spPath == SPPath.POSITION) {
|
||||||
|
// Position / Spectator keyframes need special handling
|
||||||
|
interpolatorUpdateChange = updateInterpolators();
|
||||||
|
} else {
|
||||||
|
// Time keyframes only need updating when only one segment of them exists
|
||||||
|
if (path.getSegments().size() == 1) {
|
||||||
|
assert firstInterpolator.isPresent() : "One segment should have existed before as well";
|
||||||
|
interpolatorUpdateChange = SetInterpolator.create(path.getSegments().iterator().next(), firstInterpolator.get());
|
||||||
|
} else {
|
||||||
|
interpolatorUpdateChange = CombinedChange.create(); // Noop change
|
||||||
|
}
|
||||||
|
interpolatorUpdateChange.apply(timeline);
|
||||||
|
}
|
||||||
|
|
||||||
|
// and update spectator positions
|
||||||
|
Change spectatorChange = updateSpectatorPositions();
|
||||||
|
spectatorChange.apply(timeline);
|
||||||
|
|
||||||
|
return CombinedChange.createFromApplied(removeChange, addChange, propertyChange,
|
||||||
|
restoreInterpolatorChange, interpolatorUpdateChange, spectatorChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method because generics cannot be defined on blocks
|
||||||
|
private <T> void copyProperty(Property<T> property, Keyframe from, UpdateKeyframeProperties.Builder to) {
|
||||||
|
from.getValue(property).ifPresent(value -> to.setValue(property, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Change updateInterpolators() {
|
||||||
|
Collection<PathSegment> pathSegments = positionPath.getSegments();
|
||||||
|
// Contains updated pathsegment-interpolator mappings, may be changed multiple times over the course of this method
|
||||||
|
Map<PathSegment, Interpolator> updates = new HashMap<>();
|
||||||
|
|
||||||
|
// First, setup spectator interpolators
|
||||||
|
Interpolator interpolator = null;
|
||||||
|
// Iterate through all segments
|
||||||
|
for (PathSegment segment : pathSegments) {
|
||||||
|
if (isSpectatorSegment(segment)) {
|
||||||
|
// If the last segment was a spectator segment, then use its interpolator for this segment as well
|
||||||
|
if (interpolator == null) {
|
||||||
|
// otherwise create a new interpolator
|
||||||
|
interpolator = new LinearInterpolator();
|
||||||
|
interpolator.registerProperty(SpectatorProperty.PROPERTY);
|
||||||
|
}
|
||||||
|
// Now that we have an interpolator, set it for the current segment
|
||||||
|
updates.put(segment, interpolator);
|
||||||
|
} else {
|
||||||
|
// Not a spectator segment, make sure we don't re-use the last interpolator (it would not be continuous)
|
||||||
|
interpolator = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Then, if required, replace old default interpolators with new ones
|
||||||
|
pathSegments.stream()
|
||||||
|
// Ignore explicitly set segments
|
||||||
|
.filter(s -> !s.getStartKeyframe().getValue(ExplicitInterpolationProperty.PROPERTY).isPresent())
|
||||||
|
// Ignore spectator segments
|
||||||
|
.filter(s -> !isSpectatorSegment(s))
|
||||||
|
// Ignore already correct segments, should ignore all if default hasn't changed
|
||||||
|
.filter(s -> !s.getInterpolator().getClass().equals(defaultInterpolatorType.getInterpolatorClass()))
|
||||||
|
// Finally, set the interpolators
|
||||||
|
// This will create one interpolator per segment, they will be merged later
|
||||||
|
.forEach(segment -> updates.put(segment, createDefaultInterpolator()));
|
||||||
|
|
||||||
|
// All interpolators should now be set appropriately but may still be fragmented.
|
||||||
|
// Cleaning that up is a two step process
|
||||||
|
|
||||||
|
// Firstly, all interpolators that are not continuous need to be split up
|
||||||
|
Interpolator lastInterpolator = null;
|
||||||
|
Set<Interpolator> used = Collections.newSetFromMap(new IdentityHashMap<>());
|
||||||
|
for (PathSegment segment : pathSegments) {
|
||||||
|
if (isSpectatorSegment(segment)) {
|
||||||
|
lastInterpolator = null;
|
||||||
|
continue; // Chain broken by spectator segment
|
||||||
|
}
|
||||||
|
|
||||||
|
Interpolator currentInterpolator = updates.getOrDefault(segment, segment.getInterpolator());
|
||||||
|
if (lastInterpolator == currentInterpolator) {
|
||||||
|
continue; // All fine, interpolator is still continuous
|
||||||
|
}
|
||||||
|
|
||||||
|
// New interpolator, make sure it hasn't been used before
|
||||||
|
if (!used.add(interpolator)) {
|
||||||
|
// It has been used before, we need to clone it and use the clone instead
|
||||||
|
// This will create a new interpolator for each segment which will be merged later
|
||||||
|
currentInterpolator = cloneInterpolator(currentInterpolator);
|
||||||
|
updates.put(segment, currentInterpolator);
|
||||||
|
}
|
||||||
|
lastInterpolator = currentInterpolator;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Secondly, all neighbouring interpolators that are equal need to be merged
|
||||||
|
lastInterpolator = null;
|
||||||
|
String lastInterpolatorSerialized = null;
|
||||||
|
for (PathSegment segment : pathSegments) {
|
||||||
|
if (isSpectatorSegment(segment)) {
|
||||||
|
lastInterpolator = null;
|
||||||
|
lastInterpolatorSerialized = null;
|
||||||
|
continue; // Spectator segments are continuous by construction
|
||||||
|
}
|
||||||
|
Interpolator currentInterpolator = updates.getOrDefault(segment, segment.getInterpolator());
|
||||||
|
String serialized = serializeInterpolator(currentInterpolator);
|
||||||
|
if (lastInterpolator != currentInterpolator && serialized.equals(lastInterpolatorSerialized)) {
|
||||||
|
// This interpolator is equal to the last one but not the same, needs merging
|
||||||
|
updates.put(segment, lastInterpolator);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// New interpolator, not related to the previous one, merged by definition
|
||||||
|
lastInterpolator = currentInterpolator;
|
||||||
|
lastInterpolatorSerialized = serialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
Change change = CombinedChange.create(updates.entrySet().stream()
|
||||||
|
.map(e -> SetInterpolator.create(e.getKey(), e.getValue())).toArray(Change[]::new));
|
||||||
|
change.apply(timeline);
|
||||||
|
return change;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isSpectatorSegment(PathSegment segment) {
|
||||||
|
return segment.getStartKeyframe().getValue(SpectatorProperty.PROPERTY).isPresent()
|
||||||
|
&& segment.getEndKeyframe().getValue(SpectatorProperty.PROPERTY).isPresent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Change updateSpectatorPositions() {
|
||||||
|
List<Change> changes = new ArrayList<>();
|
||||||
|
timePath.updateAll();
|
||||||
|
for (Keyframe keyframe : positionPath.getKeyframes()) {
|
||||||
|
Optional<Integer> spectator = keyframe.getValue(SpectatorProperty.PROPERTY);
|
||||||
|
if (spectator.isPresent()) {
|
||||||
|
Optional<Integer> time = timePath.getValue(TimestampProperty.PROPERTY, keyframe.getTime());
|
||||||
|
if (!time.isPresent()) {
|
||||||
|
continue; // No time keyframes set at this video time, cannot determine replay time
|
||||||
|
}
|
||||||
|
Location expected = entityTracker.getEntityPositionAtTimestamp(spectator.get(), time.get());
|
||||||
|
if (expected == null) {
|
||||||
|
continue; // We don't have any data on this entity for some reason
|
||||||
|
}
|
||||||
|
Triple<Double, Double, Double> pos = keyframe.getValue(CameraProperties.POSITION).orElse(Triple.of(0D, 0D, 0D));
|
||||||
|
Triple<Float, Float, Float> rot = keyframe.getValue(CameraProperties.ROTATION).orElse(Triple.of(0F, 0F, 0F));
|
||||||
|
Location actual = new Location(pos.getLeft(), pos.getMiddle(), pos.getRight(), rot.getLeft(), rot.getRight());
|
||||||
|
if (!expected.equals(actual)) {
|
||||||
|
changes.add(UpdateKeyframeProperties.create(positionPath, keyframe)
|
||||||
|
.setValue(CameraProperties.POSITION, Triple.of(expected.getX(), expected.getY(), expected.getZ()))
|
||||||
|
.setValue(CameraProperties.ROTATION, Triple.of(expected.getYaw(), expected.getPitch(), 0f)).done()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CombinedChange.create(changes.toArray(new Change[changes.size()]));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Interpolator createDefaultInterpolator() {
|
||||||
|
return registerPositionInterpolatorProperties(defaultInterpolatorType.newInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Interpolator registerPositionInterpolatorProperties(Interpolator interpolator) {
|
||||||
|
interpolator.registerProperty(CameraProperties.POSITION);
|
||||||
|
interpolator.registerProperty(CameraProperties.ROTATION);
|
||||||
|
return interpolator;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Timeline createTimeline() {
|
||||||
|
return createTimelineStatic();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Timeline createInitialTimeline() {
|
||||||
|
Timeline timeline = createTimelineStatic();
|
||||||
|
timeline.createPath();
|
||||||
|
timeline.createPath();
|
||||||
|
return timeline;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Timeline createTimelineStatic() {
|
||||||
|
Timeline timeline = new TimelineImpl();
|
||||||
|
|
||||||
|
timeline.registerProperty(TimestampProperty.PROPERTY);
|
||||||
|
timeline.registerProperty(CameraProperties.POSITION);
|
||||||
|
timeline.registerProperty(CameraProperties.ROTATION);
|
||||||
|
timeline.registerProperty(SpectatorProperty.PROPERTY);
|
||||||
|
timeline.registerProperty(ExplicitInterpolationProperty.PROPERTY);
|
||||||
|
|
||||||
|
return timeline;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serializeInterpolator(JsonWriter writer, Interpolator interpolator) throws IOException {
|
||||||
|
if (interpolator instanceof LinearInterpolator) {
|
||||||
|
writer.value("linear");
|
||||||
|
} else if (interpolator instanceof CubicSplineInterpolator) {
|
||||||
|
writer.value("cubic-spline");
|
||||||
|
} else if (interpolator instanceof CatmullRomSplineInterpolator) {
|
||||||
|
writer.beginObject();
|
||||||
|
writer.name("type").value("catmull-rom-spline");
|
||||||
|
writer.name("alpha").value(((CatmullRomSplineInterpolator) interpolator).getAlpha());
|
||||||
|
writer.endObject();
|
||||||
|
} else {
|
||||||
|
throw new IOException("Unknown interpolator type: " + interpolator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Interpolator deserializeInterpolator(JsonReader reader) throws IOException {
|
||||||
|
String type;
|
||||||
|
JsonObject args;
|
||||||
|
switch (reader.peek()) {
|
||||||
|
case STRING:
|
||||||
|
type = reader.nextString();
|
||||||
|
args = null;
|
||||||
|
break;
|
||||||
|
case BEGIN_OBJECT:
|
||||||
|
args = new JsonParser().parse(reader).getAsJsonObject();
|
||||||
|
type = args.get("type").getAsString();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IOException("Unexpected token: " + reader.peek());
|
||||||
|
}
|
||||||
|
switch (type) {
|
||||||
|
case "linear":
|
||||||
|
return new LinearInterpolator();
|
||||||
|
case "cubic-spline":
|
||||||
|
return new CubicSplineInterpolator();
|
||||||
|
case "catmull-rom-spline":
|
||||||
|
if (args == null || !args.has("alpha")) {
|
||||||
|
throw new IOException("Missing alpha value for catmull-rom-spline.");
|
||||||
|
}
|
||||||
|
return new CatmullRomSplineInterpolator(args.get("alpha").getAsDouble());
|
||||||
|
default:
|
||||||
|
throw new IOException("Unknown interpolation type: " + type);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clones an interpolator by de- and re-serializing it.
|
||||||
|
* @param interpolator The interpolator to clone
|
||||||
|
* @return The cloned interpolator
|
||||||
|
*/
|
||||||
|
private Interpolator cloneInterpolator(Interpolator interpolator) {
|
||||||
|
Interpolator cloned = deserializeInterpolator(serializeInterpolator(interpolator));
|
||||||
|
interpolator.getKeyframeProperties().forEach(cloned::registerProperty);
|
||||||
|
return cloned;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serializes the specific interpolator to String.
|
||||||
|
* Does <b>not</b> serialize the registered keyframe properties.
|
||||||
|
* @param interpolator The interpolator to serialize.
|
||||||
|
* @return The serialized interpolator
|
||||||
|
*/
|
||||||
|
private String serializeInterpolator(Interpolator interpolator) {
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
JsonWriter jsonWriter = new JsonWriter(new PrintWriter(baos));
|
||||||
|
try {
|
||||||
|
jsonWriter.beginArray();
|
||||||
|
serializeInterpolator(jsonWriter, interpolator);
|
||||||
|
jsonWriter.endArray();
|
||||||
|
jsonWriter.flush();
|
||||||
|
} catch (IOException e) {
|
||||||
|
CrashReport crash = CrashReport.makeCrashReport(e, "Serializing interpolator");
|
||||||
|
CrashReportCategory category = crash.makeCategory("Serializing interpolator");
|
||||||
|
category.addCrashSectionCallable("Interpolator", interpolator::toString);
|
||||||
|
throw new ReportedException(crash);
|
||||||
|
}
|
||||||
|
|
||||||
|
return baos.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Interpolator deserializeInterpolator(String json) {
|
||||||
|
JsonReader jsonReader = new JsonReader(new StringReader(json));
|
||||||
|
try {
|
||||||
|
jsonReader.beginArray();
|
||||||
|
return deserializeInterpolator(jsonReader);
|
||||||
|
} catch (IOException e) {
|
||||||
|
CrashReport crash = CrashReport.makeCrashReport(e, "De-serializing interpolator");
|
||||||
|
CrashReportCategory category = crash.makeCategory("De-serializing interpolator");
|
||||||
|
category.addCrashSection("Interpolator", json);
|
||||||
|
throw new ReportedException(crash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,9 +2,25 @@ package com.replaymod.simplepathing;
|
|||||||
|
|
||||||
import com.replaymod.core.SettingsRegistry;
|
import com.replaymod.core.SettingsRegistry;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public final class Setting<T> extends SettingsRegistry.SettingKeys<T> {
|
public final class Setting<T> extends SettingsRegistry.SettingKeys<T> {
|
||||||
public static final Setting<Boolean> PATH_PREVIEW = make("pathpreview", "pathpreview", true);
|
public static final Setting<Boolean> PATH_PREVIEW = make("pathpreview", "pathpreview", true);
|
||||||
public static final Setting<Boolean> LINEAR_INTERPOLATION = make("linear_interpolation", "linearinterpolation", false);
|
public static final SettingsRegistry.MultipleChoiceSettingKeys<String> DEFAULT_INTERPOLATION;
|
||||||
|
|
||||||
|
static {
|
||||||
|
String format = "replaymod.gui.editkeyframe.interpolator.%s.name";
|
||||||
|
DEFAULT_INTERPOLATION = new SettingsRegistry.MultipleChoiceSettingKeys<>(
|
||||||
|
"simplepathing", "interpolator", "replaymod.gui.settings.interpolator",
|
||||||
|
String.format(format, InterpolatorType.fromString("invalid returns default").getLocalizationKey())
|
||||||
|
);
|
||||||
|
DEFAULT_INTERPOLATION.setChoices(
|
||||||
|
Arrays.stream(InterpolatorType.values()).filter(i -> i != InterpolatorType.DEFAULT)
|
||||||
|
.map(i -> String.format(format, i.getLocalizationKey()))
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private static <T> Setting<T> make(String key, String displayName, T defaultValue) {
|
private static <T> Setting<T> make(String key, String displayName, T defaultValue) {
|
||||||
return new Setting<>(key, displayName, defaultValue);
|
return new Setting<>(key, displayName, defaultValue);
|
||||||
|
|||||||
@@ -5,14 +5,27 @@ import com.replaymod.pathing.properties.TimestampProperty;
|
|||||||
import com.replaymod.replay.ReplayModReplay;
|
import com.replaymod.replay.ReplayModReplay;
|
||||||
import com.replaymod.replaystudio.pathing.change.Change;
|
import com.replaymod.replaystudio.pathing.change.Change;
|
||||||
import com.replaymod.replaystudio.pathing.change.CombinedChange;
|
import com.replaymod.replaystudio.pathing.change.CombinedChange;
|
||||||
import com.replaymod.replaystudio.pathing.change.UpdateKeyframeProperties;
|
import com.replaymod.replaystudio.pathing.interpolation.CatmullRomSplineInterpolator;
|
||||||
|
import com.replaymod.replaystudio.pathing.interpolation.CubicSplineInterpolator;
|
||||||
|
import com.replaymod.replaystudio.pathing.interpolation.Interpolator;
|
||||||
|
import com.replaymod.replaystudio.pathing.interpolation.LinearInterpolator;
|
||||||
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
||||||
import com.replaymod.replaystudio.pathing.path.Path;
|
import com.replaymod.replaystudio.pathing.path.Path;
|
||||||
|
import com.replaymod.replaystudio.pathing.path.PathSegment;
|
||||||
|
import com.replaymod.simplepathing.InterpolatorType;
|
||||||
|
import com.replaymod.simplepathing.SPTimeline;
|
||||||
|
import com.replaymod.simplepathing.SPTimeline.SPPath;
|
||||||
|
import com.replaymod.simplepathing.Setting;
|
||||||
|
import com.replaymod.simplepathing.properties.ExplicitInterpolationProperty;
|
||||||
|
import de.johni0702.minecraft.gui.container.AbstractGuiContainer;
|
||||||
import de.johni0702.minecraft.gui.container.GuiPanel;
|
import de.johni0702.minecraft.gui.container.GuiPanel;
|
||||||
import de.johni0702.minecraft.gui.element.GuiButton;
|
import de.johni0702.minecraft.gui.element.GuiButton;
|
||||||
import de.johni0702.minecraft.gui.element.GuiLabel;
|
import de.johni0702.minecraft.gui.element.GuiLabel;
|
||||||
import de.johni0702.minecraft.gui.element.GuiNumberField;
|
import de.johni0702.minecraft.gui.element.GuiNumberField;
|
||||||
|
import de.johni0702.minecraft.gui.element.GuiTooltip;
|
||||||
|
import de.johni0702.minecraft.gui.element.IGuiClickable;
|
||||||
import de.johni0702.minecraft.gui.element.IGuiLabel;
|
import de.johni0702.minecraft.gui.element.IGuiLabel;
|
||||||
|
import de.johni0702.minecraft.gui.element.advanced.GuiDropdownMenu;
|
||||||
import de.johni0702.minecraft.gui.function.Typeable;
|
import de.johni0702.minecraft.gui.function.Typeable;
|
||||||
import de.johni0702.minecraft.gui.layout.GridLayout;
|
import de.johni0702.minecraft.gui.layout.GridLayout;
|
||||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||||
@@ -20,10 +33,16 @@ import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
|||||||
import de.johni0702.minecraft.gui.popup.AbstractGuiPopup;
|
import de.johni0702.minecraft.gui.popup.AbstractGuiPopup;
|
||||||
import de.johni0702.minecraft.gui.utils.Colors;
|
import de.johni0702.minecraft.gui.utils.Colors;
|
||||||
import de.johni0702.minecraft.gui.utils.Consumer;
|
import de.johni0702.minecraft.gui.utils.Consumer;
|
||||||
import org.apache.commons.lang3.tuple.Triple;
|
import lombok.Getter;
|
||||||
|
import net.minecraft.client.resources.I18n;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.util.ReadablePoint;
|
import org.lwjgl.util.ReadablePoint;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import static de.johni0702.minecraft.gui.utils.Utils.link;
|
import static de.johni0702.minecraft.gui.utils.Utils.link;
|
||||||
|
|
||||||
public abstract class GuiEditKeyframe<T extends GuiEditKeyframe<T>> extends AbstractGuiPopup<T> implements Typeable {
|
public abstract class GuiEditKeyframe<T extends GuiEditKeyframe<T>> extends AbstractGuiPopup<T> implements Typeable {
|
||||||
@@ -31,6 +50,11 @@ public abstract class GuiEditKeyframe<T extends GuiEditKeyframe<T>> extends Abst
|
|||||||
return new GuiNumberField().setPrecision(0).setValidateOnFocusChange(true);
|
return new GuiNumberField().setPrecision(0).setValidateOnFocusChange(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
protected final GuiPathing guiPathing;
|
||||||
|
|
||||||
|
protected final long time;
|
||||||
protected final Keyframe keyframe;
|
protected final Keyframe keyframe;
|
||||||
protected final Path path;
|
protected final Path path;
|
||||||
|
|
||||||
@@ -66,12 +90,13 @@ public abstract class GuiEditKeyframe<T extends GuiEditKeyframe<T>> extends Abst
|
|||||||
.addElements(new VerticalLayout.Data(0.5, false), title, inputs, timePanel, buttons);
|
.addElements(new VerticalLayout.Data(0.5, false), title, inputs, timePanel, buttons);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuiEditKeyframe(GuiPathing gui, Path path, Keyframe keyframe, String type) {
|
public GuiEditKeyframe(GuiPathing gui, SPPath path, long time, String type) {
|
||||||
super(ReplayModReplay.instance.getReplayHandler().getOverlay());
|
super(ReplayModReplay.instance.getReplayHandler().getOverlay());
|
||||||
this.keyframe = keyframe;
|
this.guiPathing = gui;
|
||||||
this.path = path;
|
this.time = time;
|
||||||
|
this.path = gui.getMod().getCurrentTimeline().getPath(path);
|
||||||
|
this.keyframe = this.path.getKeyframe(time);
|
||||||
|
|
||||||
long time = keyframe.getTime();
|
|
||||||
Consumer<String> updateSaveButtonState = s -> saveButton.setEnabled(canSave());
|
Consumer<String> updateSaveButtonState = s -> saveButton.setEnabled(canSave());
|
||||||
timeMinField.setValue(time / 1000 / 60).onTextChanged(updateSaveButtonState);
|
timeMinField.setValue(time / 1000 / 60).onTextChanged(updateSaveButtonState);
|
||||||
timeSecField.setValue(time / 1000 % 60).onTextChanged(updateSaveButtonState);
|
timeSecField.setValue(time / 1000 % 60).onTextChanged(updateSaveButtonState);
|
||||||
@@ -81,10 +106,11 @@ public abstract class GuiEditKeyframe<T extends GuiEditKeyframe<T>> extends Abst
|
|||||||
saveButton.onClick(() -> {
|
saveButton.onClick(() -> {
|
||||||
Change change = save();
|
Change change = save();
|
||||||
long newTime = (timeMinField.getInteger() * 60 + timeSecField.getInteger()) * 1000 + timeMSecField.getInteger();
|
long newTime = (timeMinField.getInteger() * 60 + timeSecField.getInteger()) * 1000 + timeMSecField.getInteger();
|
||||||
if (newTime != keyframe.getTime()) {
|
if (newTime != time) {
|
||||||
change = CombinedChange.createFromApplied(change, gui.moveKeyframe(path, keyframe, newTime));
|
change = CombinedChange.createFromApplied(change,
|
||||||
|
gui.getMod().getCurrentTimeline().moveKeyframe(path, time, newTime));
|
||||||
}
|
}
|
||||||
path.getTimeline().pushChange(change);
|
gui.getMod().getCurrentTimeline().getTimeline().pushChange(change);
|
||||||
close();
|
close();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -114,7 +140,7 @@ public abstract class GuiEditKeyframe<T extends GuiEditKeyframe<T>> extends Abst
|
|||||||
protected abstract Change save();
|
protected abstract Change save();
|
||||||
|
|
||||||
public static class Spectator extends GuiEditKeyframe<Spectator> {
|
public static class Spectator extends GuiEditKeyframe<Spectator> {
|
||||||
public Spectator(GuiPathing gui, Path path, Keyframe keyframe) {
|
public Spectator(GuiPathing gui, SPPath path, long keyframe) {
|
||||||
super(gui, path, keyframe, "spec");
|
super(gui, path, keyframe, "spec");
|
||||||
|
|
||||||
link(timeMinField, timeSecField, timeMSecField);
|
link(timeMinField, timeSecField, timeMSecField);
|
||||||
@@ -147,10 +173,10 @@ public abstract class GuiEditKeyframe<T extends GuiEditKeyframe<T>> extends Abst
|
|||||||
timestampMSecField, new GuiLabel().setI18nText("replaymod.gui.milliseconds"));
|
timestampMSecField, new GuiLabel().setI18nText("replaymod.gui.milliseconds"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Time(GuiPathing gui, Path path, Keyframe keyframe) {
|
public Time(GuiPathing gui, SPPath path, long keyframe) {
|
||||||
super(gui, path, keyframe, "time");
|
super(gui, path, keyframe, "time");
|
||||||
|
|
||||||
keyframe.getValue(TimestampProperty.PROPERTY).ifPresent(time -> {
|
this.keyframe.getValue(TimestampProperty.PROPERTY).ifPresent(time -> {
|
||||||
timestampMinField.setValue(time / 1000 / 60);
|
timestampMinField.setValue(time / 1000 / 60);
|
||||||
timestampSecField.setValue(time / 1000 % 60);
|
timestampSecField.setValue(time / 1000 % 60);
|
||||||
timestampMSecField.setValue(time % 1000);
|
timestampMSecField.setValue(time % 1000);
|
||||||
@@ -165,11 +191,7 @@ public abstract class GuiEditKeyframe<T extends GuiEditKeyframe<T>> extends Abst
|
|||||||
protected Change save() {
|
protected Change save() {
|
||||||
int time = (timestampMinField.getInteger() * 60 + timestampSecField.getInteger()) * 1000
|
int time = (timestampMinField.getInteger() * 60 + timestampSecField.getInteger()) * 1000
|
||||||
+ timestampMSecField.getInteger();
|
+ timestampMSecField.getInteger();
|
||||||
Change change = UpdateKeyframeProperties.create(path, keyframe)
|
return guiPathing.getMod().getCurrentTimeline().updateTimeKeyframe(keyframe.getTime(), time);
|
||||||
.setValue(TimestampProperty.PROPERTY, time)
|
|
||||||
.done();
|
|
||||||
change.apply(path.getTimeline());
|
|
||||||
return change;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -187,8 +209,11 @@ public abstract class GuiEditKeyframe<T extends GuiEditKeyframe<T>> extends Abst
|
|||||||
public final GuiNumberField pitchField = newGuiNumberField().setSize(60, 20).setPrecision(5);
|
public final GuiNumberField pitchField = newGuiNumberField().setSize(60, 20).setPrecision(5);
|
||||||
public final GuiNumberField rollField = newGuiNumberField().setSize(60, 20).setPrecision(5);
|
public final GuiNumberField rollField = newGuiNumberField().setSize(60, 20).setPrecision(5);
|
||||||
|
|
||||||
|
public final InterpolationPanel interpolationPanel = new InterpolationPanel();
|
||||||
|
|
||||||
{
|
{
|
||||||
inputs.setLayout(new GridLayout().setCellsEqualSize(false).setColumns(4).setSpacingX(3).setSpacingY(5))
|
GuiPanel positionInputs = new GuiPanel()
|
||||||
|
.setLayout(new GridLayout().setCellsEqualSize(false).setColumns(4).setSpacingX(3).setSpacingY(5))
|
||||||
.addElements(new GridLayout.Data(1, 0.5),
|
.addElements(new GridLayout.Data(1, 0.5),
|
||||||
new GuiLabel().setI18nText("replaymod.gui.editkeyframe.xpos"), xField,
|
new GuiLabel().setI18nText("replaymod.gui.editkeyframe.xpos"), xField,
|
||||||
new GuiLabel().setI18nText("replaymod.gui.editkeyframe.camyaw"), yawField,
|
new GuiLabel().setI18nText("replaymod.gui.editkeyframe.camyaw"), yawField,
|
||||||
@@ -196,17 +221,20 @@ public abstract class GuiEditKeyframe<T extends GuiEditKeyframe<T>> extends Abst
|
|||||||
new GuiLabel().setI18nText("replaymod.gui.editkeyframe.campitch"), pitchField,
|
new GuiLabel().setI18nText("replaymod.gui.editkeyframe.campitch"), pitchField,
|
||||||
new GuiLabel().setI18nText("replaymod.gui.editkeyframe.zpos"), zField,
|
new GuiLabel().setI18nText("replaymod.gui.editkeyframe.zpos"), zField,
|
||||||
new GuiLabel().setI18nText("replaymod.gui.editkeyframe.camroll"), rollField);
|
new GuiLabel().setI18nText("replaymod.gui.editkeyframe.camroll"), rollField);
|
||||||
|
|
||||||
|
inputs.setLayout(new VerticalLayout().setSpacing(10)).addElements(new VerticalLayout.Data(0.5, false),
|
||||||
|
positionInputs, interpolationPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Position(GuiPathing gui, Path path, Keyframe keyframe) {
|
public Position(GuiPathing gui, SPPath path, long keyframe) {
|
||||||
super(gui, path, keyframe, "pos");
|
super(gui, path, keyframe, "pos");
|
||||||
|
|
||||||
keyframe.getValue(CameraProperties.POSITION).ifPresent(pos -> {
|
this.keyframe.getValue(CameraProperties.POSITION).ifPresent(pos -> {
|
||||||
xField.setValue(pos.getLeft());
|
xField.setValue(pos.getLeft());
|
||||||
yField.setValue(pos.getMiddle());
|
yField.setValue(pos.getMiddle());
|
||||||
zField.setValue(pos.getRight());
|
zField.setValue(pos.getRight());
|
||||||
});
|
});
|
||||||
keyframe.getValue(CameraProperties.ROTATION).ifPresent(rot -> {
|
this.keyframe.getValue(CameraProperties.ROTATION).ifPresent(rot -> {
|
||||||
yawField.setValue(rot.getLeft());
|
yawField.setValue(rot.getLeft());
|
||||||
pitchField.setValue(rot.getMiddle());
|
pitchField.setValue(rot.getMiddle());
|
||||||
rollField.setValue(rot.getRight());
|
rollField.setValue(rot.getRight());
|
||||||
@@ -219,17 +247,176 @@ public abstract class GuiEditKeyframe<T extends GuiEditKeyframe<T>> extends Abst
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Change save() {
|
protected Change save() {
|
||||||
Change change = UpdateKeyframeProperties.create(path, keyframe)
|
SPTimeline timeline = guiPathing.getMod().getCurrentTimeline();
|
||||||
.setValue(CameraProperties.POSITION, Triple.of(xField.getDouble(), yField.getDouble(), zField.getDouble()))
|
Change positionChange = timeline.updatePositionKeyframe(time,
|
||||||
.setValue(CameraProperties.ROTATION, Triple.of(yawField.getFloat(), pitchField.getFloat(), rollField.getFloat()))
|
xField.getDouble(), yField.getDouble(), zField.getDouble(),
|
||||||
.done();
|
yawField.getFloat(), pitchField.getFloat(), rollField.getFloat()
|
||||||
change.apply(path.getTimeline());
|
);
|
||||||
return change;
|
Interpolator interpolator = interpolationPanel.getSettingsPanel().createInterpolator();
|
||||||
|
if (interpolationPanel.getInterpolatorType() == InterpolatorType.DEFAULT) {
|
||||||
|
return CombinedChange.createFromApplied(positionChange, timeline.setInterpolatorToDefault(time),
|
||||||
|
timeline.setDefaultInterpolator(interpolator));
|
||||||
|
} else {
|
||||||
|
return CombinedChange.createFromApplied(positionChange, timeline.setInterpolator(time, interpolator));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Position getThis() {
|
protected Position getThis() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class InterpolationPanel extends AbstractGuiContainer<InterpolationPanel> {
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private SettingsPanel settingsPanel;
|
||||||
|
|
||||||
|
private GuiDropdownMenu<InterpolatorType> dropdown;
|
||||||
|
|
||||||
|
public InterpolationPanel() {
|
||||||
|
setLayout(new VerticalLayout());
|
||||||
|
|
||||||
|
dropdown = new GuiDropdownMenu<InterpolatorType>()
|
||||||
|
.setToString(s -> I18n.format(s.getI18nName()))
|
||||||
|
.setValues(InterpolatorType.values()).setHeight(20)
|
||||||
|
.onSelection(i -> setSettingsPanel(dropdown.getSelectedValue()));
|
||||||
|
|
||||||
|
// set hover tooltips
|
||||||
|
for (Map.Entry<InterpolatorType, IGuiClickable> e : dropdown.getDropdownEntries().entrySet()) {
|
||||||
|
e.getValue().setTooltip(new GuiTooltip().setI18nText(e.getKey().getI18nDescription()));
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiPanel dropdownPanel = new GuiPanel()
|
||||||
|
.setLayout(new GridLayout().setCellsEqualSize(false).setColumns(2).setSpacingX(3).setSpacingY(5))
|
||||||
|
.addElements(new GridLayout.Data(1, 0.5),
|
||||||
|
new GuiLabel().setI18nText("replaymod.gui.editkeyframe.interpolator"), dropdown);
|
||||||
|
|
||||||
|
|
||||||
|
addElements(new VerticalLayout.Data(0.5, false), dropdownPanel);
|
||||||
|
|
||||||
|
Optional<PathSegment> segment = path.getSegments().stream()
|
||||||
|
.filter(s -> s.getStartKeyframe() == keyframe).findFirst();
|
||||||
|
if (segment.isPresent()) {
|
||||||
|
Interpolator interpolator = segment.get().getInterpolator();
|
||||||
|
InterpolatorType type = InterpolatorType.fromClass(interpolator.getClass());
|
||||||
|
if (keyframe.getValue(ExplicitInterpolationProperty.PROPERTY).isPresent()) {
|
||||||
|
dropdown.setSelected(type); // trigger the callback once to display settings panel
|
||||||
|
} else {
|
||||||
|
setSettingsPanel(InterpolatorType.DEFAULT);
|
||||||
|
}
|
||||||
|
if (getInterpolatorTypeNoDefault(type).getInterpolatorClass().isInstance(interpolator)) {
|
||||||
|
//noinspection unchecked
|
||||||
|
settingsPanel.loadSettings(interpolator);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Disable dropdown if this is the last keyframe
|
||||||
|
dropdown.setDisabled();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSettingsPanel(InterpolatorType type) {
|
||||||
|
removeElement(this.settingsPanel);
|
||||||
|
|
||||||
|
switch (getInterpolatorTypeNoDefault(type)) {
|
||||||
|
case CATMULL_ROM:
|
||||||
|
settingsPanel = new CatmullRomSettingsPanel();
|
||||||
|
break;
|
||||||
|
case CUBIC:
|
||||||
|
settingsPanel = new CubicSettingsPanel();
|
||||||
|
break;
|
||||||
|
case LINEAR:
|
||||||
|
settingsPanel = new LinearSettingsPanel();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
addElements(new GridLayout.Data(0.5, 0.5), settingsPanel);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected InterpolatorType getInterpolatorTypeNoDefault(InterpolatorType interpolatorType) {
|
||||||
|
if (interpolatorType == InterpolatorType.DEFAULT || interpolatorType == null) {
|
||||||
|
InterpolatorType defaultType = InterpolatorType.fromString(
|
||||||
|
guiPathing.getMod().getCore().getSettingsRegistry().get(Setting.DEFAULT_INTERPOLATION));
|
||||||
|
return defaultType;
|
||||||
|
}
|
||||||
|
return interpolatorType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InterpolatorType getInterpolatorType() {
|
||||||
|
return dropdown.getSelectedValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected InterpolationPanel getThis() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class SettingsPanel<I extends Interpolator, T extends SettingsPanel<I, T>> extends AbstractGuiContainer<T> {
|
||||||
|
|
||||||
|
public abstract void loadSettings(I interpolator);
|
||||||
|
|
||||||
|
public abstract I createInterpolator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CatmullRomSettingsPanel extends SettingsPanel<CatmullRomSplineInterpolator, CatmullRomSettingsPanel> {
|
||||||
|
public final GuiLabel alphaLabel = new GuiLabel().setColor(Colors.BLACK)
|
||||||
|
.setI18nText("replaymod.gui.editkeyframe.interpolator.catmullrom.alpha");
|
||||||
|
public final GuiNumberField alphaField = new GuiNumberField().setSize(100, 20).setPrecision(5)
|
||||||
|
.setMinValue(0).setValidateOnFocusChange(true);
|
||||||
|
|
||||||
|
{
|
||||||
|
setLayout(new HorizontalLayout(HorizontalLayout.Alignment.CENTER));
|
||||||
|
addElements(new HorizontalLayout.Data(0.5), alphaLabel, alphaField);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadSettings(CatmullRomSplineInterpolator interpolator) {
|
||||||
|
alphaField.setValue(interpolator.getAlpha());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CatmullRomSplineInterpolator createInterpolator() {
|
||||||
|
return new CatmullRomSplineInterpolator(alphaField.getDouble());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CatmullRomSettingsPanel getThis() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CubicSettingsPanel extends SettingsPanel<CubicSplineInterpolator, CubicSettingsPanel> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadSettings(CubicSplineInterpolator interpolator) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CubicSplineInterpolator createInterpolator() {
|
||||||
|
return new CubicSplineInterpolator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CubicSettingsPanel getThis() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class LinearSettingsPanel extends SettingsPanel<LinearInterpolator, LinearSettingsPanel> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadSettings(LinearInterpolator interpolator) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LinearInterpolator createInterpolator() {
|
||||||
|
return new LinearInterpolator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected LinearSettingsPanel getThis() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.replaymod.simplepathing.gui;
|
package com.replaymod.simplepathing.gui;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.replaymod.core.ReplayMod;
|
import com.replaymod.core.ReplayMod;
|
||||||
import com.replaymod.pathing.properties.CameraProperties;
|
import com.replaymod.pathing.properties.CameraProperties;
|
||||||
import com.replaymod.pathing.properties.SpectatorProperty;
|
import com.replaymod.pathing.properties.SpectatorProperty;
|
||||||
@@ -11,9 +9,10 @@ import com.replaymod.replaystudio.pathing.change.Change;
|
|||||||
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
||||||
import com.replaymod.replaystudio.pathing.path.Path;
|
import com.replaymod.replaystudio.pathing.path.Path;
|
||||||
import com.replaymod.replaystudio.pathing.path.PathSegment;
|
import com.replaymod.replaystudio.pathing.path.PathSegment;
|
||||||
import com.replaymod.replaystudio.pathing.path.Timeline;
|
|
||||||
import com.replaymod.replaystudio.pathing.property.Property;
|
import com.replaymod.replaystudio.pathing.property.Property;
|
||||||
import com.replaymod.simplepathing.ReplayModSimplePathing;
|
import com.replaymod.simplepathing.ReplayModSimplePathing;
|
||||||
|
import com.replaymod.simplepathing.SPTimeline;
|
||||||
|
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;
|
||||||
@@ -23,7 +22,6 @@ import org.lwjgl.util.Point;
|
|||||||
import org.lwjgl.util.ReadableDimension;
|
import org.lwjgl.util.ReadableDimension;
|
||||||
import org.lwjgl.util.ReadablePoint;
|
import org.lwjgl.util.ReadablePoint;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@@ -37,14 +35,14 @@ public class GuiKeyframeTimeline extends AbstractGuiTimeline<GuiKeyframeTimeline
|
|||||||
private final GuiPathing gui;
|
private final GuiPathing gui;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The keyframe that was last clicked on using the left mouse button.
|
* The keyframe (time on timeline) that was last clicked on using the left mouse button.
|
||||||
*/
|
*/
|
||||||
private Keyframe lastClickedKeyframe;
|
private long lastClickedKeyframe;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Id of the path of {@link #lastClickedKeyframe}.
|
* Path of {@link #lastClickedKeyframe}.
|
||||||
*/
|
*/
|
||||||
private int lastClickedPath;
|
private SPPath lastClickedPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The time at which {@link #lastClickedKeyframe} was updated.
|
* The time at which {@link #lastClickedKeyframe} was updated.
|
||||||
@@ -89,18 +87,13 @@ public class GuiKeyframeTimeline extends AbstractGuiTimeline<GuiKeyframeTimeline
|
|||||||
|
|
||||||
renderer.bindTexture(ReplayMod.TEXTURE);
|
renderer.bindTexture(ReplayMod.TEXTURE);
|
||||||
|
|
||||||
for (Keyframe keyframe : Iterables.concat(Iterables.transform(mod.getCurrentTimeline().getPaths(), new Function<Path, Iterable<Keyframe>>() {
|
SPTimeline timeline = mod.getCurrentTimeline();
|
||||||
@Nullable
|
|
||||||
@Override
|
timeline.getTimeline().getPaths().stream().flatMap(path -> path.getKeyframes().stream()).forEach(keyframe -> {
|
||||||
public Iterable<Keyframe> apply(@Nullable Path input) {
|
|
||||||
assert input != null;
|
|
||||||
return input.getKeyframes();
|
|
||||||
}
|
|
||||||
}))) {
|
|
||||||
if (keyframe.getTime() >= startTime && keyframe.getTime() <= endTime) {
|
if (keyframe.getTime() >= startTime && keyframe.getTime() <= endTime) {
|
||||||
double relativeTime = keyframe.getTime() - startTime;
|
double relativeTime = keyframe.getTime() - startTime;
|
||||||
int positonX = BORDER_LEFT + (int) (relativeTime / visibleTime * visibleWidth) - KEYFRAME_SIZE / 2;
|
int positonX = BORDER_LEFT + (int) (relativeTime / visibleTime * visibleWidth) - KEYFRAME_SIZE / 2;
|
||||||
int u = KEYFRAME_TEXTURE_X + (mod.getSelectedKeyframe() == keyframe ? KEYFRAME_SIZE : 0);
|
int u = KEYFRAME_TEXTURE_X + (mod.isSelected(keyframe) ? KEYFRAME_SIZE : 0);
|
||||||
int v = KEYFRAME_TEXTURE_Y;
|
int v = KEYFRAME_TEXTURE_Y;
|
||||||
if (keyframe.getValue(CameraProperties.POSITION).isPresent()) {
|
if (keyframe.getValue(CameraProperties.POSITION).isPresent()) {
|
||||||
if (keyframe.getValue(SpectatorProperty.PROPERTY).isPresent()) {
|
if (keyframe.getValue(SpectatorProperty.PROPERTY).isPresent()) {
|
||||||
@@ -113,10 +106,10 @@ public class GuiKeyframeTimeline extends AbstractGuiTimeline<GuiKeyframeTimeline
|
|||||||
renderer.drawTexturedRect(positonX, BORDER_TOP + KEYFRAME_SIZE, u, v, KEYFRAME_SIZE, KEYFRAME_SIZE);
|
renderer.drawTexturedRect(positonX, BORDER_TOP + KEYFRAME_SIZE, u, v, KEYFRAME_SIZE, KEYFRAME_SIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
// Draw colored quads on spectator path segments
|
// Draw colored quads on spectator path segments
|
||||||
for (PathSegment segment : mod.getCurrentTimeline().getPaths().get(GuiPathing.POSITION_PATH).getSegments()) {
|
for (PathSegment segment : timeline.getPositionPath().getSegments()) {
|
||||||
if (segment.getInterpolator() == null
|
if (segment.getInterpolator() == null
|
||||||
|| !segment.getInterpolator().getKeyframeProperties().contains(SpectatorProperty.PROPERTY)) {
|
|| !segment.getInterpolator().getKeyframeProperties().contains(SpectatorProperty.PROPERTY)) {
|
||||||
continue; // Not a spectator segment
|
continue; // Not a spectator segment
|
||||||
@@ -125,7 +118,7 @@ public class GuiKeyframeTimeline extends AbstractGuiTimeline<GuiKeyframeTimeline
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw red quads on time path segments that would require time going backwards
|
// Draw red quads on time path segments that would require time going backwards
|
||||||
for (PathSegment segment : mod.getCurrentTimeline().getPaths().get(GuiPathing.TIME_PATH).getSegments()) {
|
for (PathSegment segment : timeline.getTimePath().getSegments()) {
|
||||||
long startTimestamp = segment.getStartKeyframe().getValue(TimestampProperty.PROPERTY).orElseThrow(IllegalStateException::new);
|
long startTimestamp = segment.getStartKeyframe().getValue(TimestampProperty.PROPERTY).orElseThrow(IllegalStateException::new);
|
||||||
long endTimestamp = segment.getEndKeyframe().getValue(TimestampProperty.PROPERTY).orElseThrow(IllegalStateException::new);
|
long endTimestamp = segment.getEndKeyframe().getValue(TimestampProperty.PROPERTY).orElseThrow(IllegalStateException::new);
|
||||||
if (endTimestamp >= startTimestamp) {
|
if (endTimestamp >= startTimestamp) {
|
||||||
@@ -162,29 +155,28 @@ public class GuiKeyframeTimeline extends AbstractGuiTimeline<GuiKeyframeTimeline
|
|||||||
* @param position The raw position
|
* @param position The raw position
|
||||||
* @return Pair of path id and keyframe or null when no keyframe was clicked
|
* @return Pair of path id and keyframe or null when no keyframe was clicked
|
||||||
*/
|
*/
|
||||||
private Pair<Integer, Keyframe> getKeyframe(ReadablePoint position) {
|
private Pair<SPPath, Long> getKeyframe(ReadablePoint position) {
|
||||||
int time = getTimeAt(position.getX(), position.getY());
|
int time = getTimeAt(position.getX(), position.getY());
|
||||||
if (time != -1) {
|
if (time != -1) {
|
||||||
Point mouse = new Point(position);
|
Point mouse = new Point(position);
|
||||||
getContainer().convertFor(this, mouse);
|
getContainer().convertFor(this, mouse);
|
||||||
int mouseY = mouse.getY();
|
int mouseY = mouse.getY();
|
||||||
if (mouseY > BORDER_TOP && mouseY < BORDER_TOP + 2 * KEYFRAME_SIZE) {
|
if (mouseY > BORDER_TOP && mouseY < BORDER_TOP + 2 * KEYFRAME_SIZE) {
|
||||||
Timeline timeline = gui.getMod().getCurrentTimeline();
|
SPPath path;
|
||||||
int path;
|
|
||||||
if (mouseY <= BORDER_TOP + KEYFRAME_SIZE) {
|
if (mouseY <= BORDER_TOP + KEYFRAME_SIZE) {
|
||||||
// Position keyframe
|
// Position keyframe
|
||||||
path = GuiPathing.POSITION_PATH;
|
path = SPPath.POSITION;
|
||||||
} else {
|
} else {
|
||||||
// Time keyframe
|
// Time keyframe
|
||||||
path = GuiPathing.TIME_PATH;
|
path = SPPath.TIME;
|
||||||
}
|
}
|
||||||
int visibleTime = (int) (getZoom() * getLength());
|
int visibleTime = (int) (getZoom() * getLength());
|
||||||
int tolerance = visibleTime * KEYFRAME_SIZE / (size.getWidth() - BORDER_LEFT - BORDER_RIGHT) / 2;
|
int tolerance = visibleTime * KEYFRAME_SIZE / (getLastSize().getWidth() - BORDER_LEFT - BORDER_RIGHT) / 2;
|
||||||
Optional<Keyframe> keyframe = timeline.getPaths().get(path).getKeyframes().stream()
|
Optional<Keyframe> keyframe = gui.getMod().getCurrentTimeline().getPath(path).getKeyframes().stream()
|
||||||
.filter(k -> Math.abs(k.getTime() - time) <= tolerance)
|
.filter(k -> Math.abs(k.getTime() - time) <= tolerance)
|
||||||
.sorted(Comparator.comparing(k -> Math.abs(k.getTime() - time)))
|
.sorted(Comparator.comparing(k -> Math.abs(k.getTime() - time)))
|
||||||
.findFirst();
|
.findFirst();
|
||||||
return Pair.of(path, keyframe.orElse(null));
|
return Pair.of(path, keyframe.map(Keyframe::getTime).orElse(null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Pair.of(null, null);
|
return Pair.of(null, null);
|
||||||
@@ -193,30 +185,31 @@ public class GuiKeyframeTimeline extends AbstractGuiTimeline<GuiKeyframeTimeline
|
|||||||
@Override
|
@Override
|
||||||
public boolean mouseClick(ReadablePoint position, int button) {
|
public boolean mouseClick(ReadablePoint position, int button) {
|
||||||
int time = getTimeAt(position.getX(), position.getY());
|
int time = getTimeAt(position.getX(), position.getY());
|
||||||
Pair<Integer, Keyframe> pathKeyframePair = getKeyframe(position);
|
Pair<SPPath, Long> pathKeyframePair = getKeyframe(position);
|
||||||
if (pathKeyframePair.getRight() != null) {
|
if (pathKeyframePair.getRight() != null) {
|
||||||
|
SPPath path = pathKeyframePair.getLeft();
|
||||||
// Clicked on keyframe
|
// Clicked on keyframe
|
||||||
Keyframe keyframe = pathKeyframePair.getRight();
|
long keyframeTime = pathKeyframePair.getRight();
|
||||||
if (button == 0) { // Left click
|
if (button == 0) { // Left click
|
||||||
long now = Minecraft.getSystemTime();
|
long now = Minecraft.getSystemTime();
|
||||||
if (lastClickedKeyframe == keyframe) {
|
if (lastClickedKeyframe == keyframeTime) {
|
||||||
// Clicked the same keyframe again, potentially a double click
|
// Clicked the same keyframe again, potentially a double click
|
||||||
if (now - lastClickedTime < DOUBLE_CLICK_INTERVAL) {
|
if (now - lastClickedTime < DOUBLE_CLICK_INTERVAL) {
|
||||||
// Yup, double click, open the edit keyframe gui
|
// Yup, double click, open the edit keyframe gui
|
||||||
Path path = gui.getMod().getCurrentTimeline().getPaths().get(pathKeyframePair.getLeft());
|
gui.openEditKeyframePopup(path, keyframeTime);
|
||||||
gui.openEditKeyframePopup(path, keyframe);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Not a double click, just update the click time and selection
|
// Not a double click, just update the click time and selection
|
||||||
lastClickedTime = now;
|
lastClickedTime = now;
|
||||||
lastClickedKeyframe = keyframe;
|
lastClickedKeyframe = keyframeTime;
|
||||||
lastClickedPath = pathKeyframePair.getLeft();
|
lastClickedPath = path;
|
||||||
gui.getMod().setSelectedKeyframe(lastClickedKeyframe);
|
gui.getMod().setSelected(lastClickedPath, lastClickedKeyframe);
|
||||||
// We might be dragging
|
// We might be dragging
|
||||||
draggingStartX = position.getX();
|
draggingStartX = position.getX();
|
||||||
dragging = true;
|
dragging = true;
|
||||||
} else if (button == 1) { // Right click
|
} else if (button == 1) { // Right click
|
||||||
|
Keyframe keyframe = gui.getMod().getCurrentTimeline().getKeyframe(path, keyframeTime);
|
||||||
for (Property property : keyframe.getProperties()) {
|
for (Property property : keyframe.getProperties()) {
|
||||||
applyPropertyToGame(property, keyframe);
|
applyPropertyToGame(property, keyframe);
|
||||||
}
|
}
|
||||||
@@ -226,12 +219,11 @@ public class GuiKeyframeTimeline extends AbstractGuiTimeline<GuiKeyframeTimeline
|
|||||||
// Clicked on timeline but not on any keyframe
|
// Clicked on timeline but not on any keyframe
|
||||||
if (button == 0) { // Left click
|
if (button == 0) { // Left click
|
||||||
setCursorPosition(time);
|
setCursorPosition(time);
|
||||||
gui.getMod().setSelectedKeyframe(null);
|
gui.getMod().setSelected(null, 0);
|
||||||
} else if (button == 1) { // Right click
|
} else if (button == 1) { // Right click
|
||||||
if (pathKeyframePair.getLeft() != null) {
|
if (pathKeyframePair.getLeft() != null) {
|
||||||
// Apply the value of the clicked path at the clicked position
|
// Apply the value of the clicked path at the clicked position
|
||||||
Timeline timeline = gui.getMod().getCurrentTimeline();
|
Path path = gui.getMod().getCurrentTimeline().getPath(pathKeyframePair.getLeft());
|
||||||
Path path = timeline.getPaths().get(pathKeyframePair.getLeft());
|
|
||||||
path.getKeyframes().stream().flatMap(k -> k.getProperties().stream()).distinct().forEach(
|
path.getKeyframes().stream().flatMap(k -> k.getProperties().stream()).distinct().forEach(
|
||||||
p -> applyPropertyToGame(p, path, time));
|
p -> applyPropertyToGame(p, path, time));
|
||||||
}
|
}
|
||||||
@@ -280,12 +272,13 @@ public class GuiKeyframeTimeline extends AbstractGuiTimeline<GuiKeyframeTimeline
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (actuallyDragging) {
|
if (actuallyDragging) {
|
||||||
|
if (!gui.ensureEntityTracker(() -> mouseDrag(position, button, timeSinceLastCall))) return true;
|
||||||
// Threshold passed
|
// Threshold passed
|
||||||
Path path = gui.getMod().getCurrentTimeline().getPaths().get(lastClickedPath);
|
SPTimeline timeline = gui.getMod().getCurrentTimeline();
|
||||||
Point mouse = new Point(position);
|
Point mouse = new Point(position);
|
||||||
getContainer().convertFor(this, mouse);
|
getContainer().convertFor(this, mouse);
|
||||||
int mouseX = mouse.getX();
|
int mouseX = mouse.getX();
|
||||||
int width = size.getWidth();
|
int width = getLastSize().getWidth();
|
||||||
int bodyWidth = width - BORDER_LEFT - BORDER_RIGHT;
|
int bodyWidth = width - BORDER_LEFT - BORDER_RIGHT;
|
||||||
double segmentLength = getLength() * getZoom();
|
double segmentLength = getLength() * getZoom();
|
||||||
double segmentTime = segmentLength * (mouseX - BORDER_LEFT) / bodyWidth;
|
double segmentTime = segmentLength * (mouseX - BORDER_LEFT) / bodyWidth;
|
||||||
@@ -295,24 +288,21 @@ public class GuiKeyframeTimeline extends AbstractGuiTimeline<GuiKeyframeTimeline
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If there already is a keyframe at the target time, then increase the time by one until there is none
|
// If there already is a keyframe at the target time, then increase the time by one until there is none
|
||||||
while (path.getKeyframe(newTime) != null) {
|
while (timeline.getKeyframe(lastClickedPath, newTime) != null) {
|
||||||
newTime++;
|
newTime++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// First undo any previous changes
|
// First undo any previous changes
|
||||||
if (draggingChange != null) {
|
if (draggingChange != null) {
|
||||||
draggingChange.undo(gui.getMod().getCurrentTimeline());
|
draggingChange.undo(timeline.getTimeline());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move keyframe to new position and
|
// Move keyframe to new position and
|
||||||
// store change for later undoing / pushing to history
|
// store change for later undoing / pushing to history
|
||||||
draggingChange = gui.moveKeyframe(path, lastClickedKeyframe, newTime);
|
draggingChange = timeline.moveKeyframe(lastClickedPath, lastClickedKeyframe, newTime);
|
||||||
|
|
||||||
// Selected keyframe has been replaced
|
// Selected keyframe has been replaced
|
||||||
gui.getMod().setSelectedKeyframe(path.getKeyframe(newTime));
|
gui.getMod().setSelected(lastClickedPath, newTime);
|
||||||
|
|
||||||
// Path has been changed
|
|
||||||
path.updateAll();
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -321,7 +311,7 @@ public class GuiKeyframeTimeline extends AbstractGuiTimeline<GuiKeyframeTimeline
|
|||||||
public boolean mouseRelease(ReadablePoint position, int button) {
|
public boolean mouseRelease(ReadablePoint position, int button) {
|
||||||
if (dragging) {
|
if (dragging) {
|
||||||
if (actuallyDragging) {
|
if (actuallyDragging) {
|
||||||
gui.getMod().getCurrentTimeline().pushChange(draggingChange);
|
gui.getMod().getCurrentTimeline().getTimeline().pushChange(draggingChange);
|
||||||
draggingChange = null;
|
draggingChange = null;
|
||||||
actuallyDragging = false;
|
actuallyDragging = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,25 +14,26 @@ import com.replaymod.render.gui.GuiRenderSettings;
|
|||||||
import com.replaymod.replay.ReplayHandler;
|
import com.replaymod.replay.ReplayHandler;
|
||||||
import com.replaymod.replay.camera.CameraEntity;
|
import com.replaymod.replay.camera.CameraEntity;
|
||||||
import com.replaymod.replay.gui.overlay.GuiReplayOverlay;
|
import com.replaymod.replay.gui.overlay.GuiReplayOverlay;
|
||||||
import com.replaymod.replaystudio.pathing.change.*;
|
|
||||||
import com.replaymod.replaystudio.pathing.interpolation.CubicSplineInterpolator;
|
|
||||||
import com.replaymod.replaystudio.pathing.interpolation.Interpolator;
|
|
||||||
import com.replaymod.replaystudio.pathing.interpolation.LinearInterpolator;
|
|
||||||
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
||||||
import com.replaymod.replaystudio.pathing.path.Path;
|
import com.replaymod.replaystudio.pathing.path.Path;
|
||||||
import com.replaymod.replaystudio.pathing.path.PathSegment;
|
|
||||||
import com.replaymod.replaystudio.pathing.path.Timeline;
|
import com.replaymod.replaystudio.pathing.path.Timeline;
|
||||||
import com.replaymod.replaystudio.pathing.property.Property;
|
|
||||||
import com.replaymod.replaystudio.pathing.serialize.TimelineSerialization;
|
import com.replaymod.replaystudio.pathing.serialize.TimelineSerialization;
|
||||||
import com.replaymod.replaystudio.util.EntityPositionTracker;
|
import com.replaymod.replaystudio.util.EntityPositionTracker;
|
||||||
import com.replaymod.replaystudio.util.Location;
|
|
||||||
import com.replaymod.simplepathing.ReplayModSimplePathing;
|
import com.replaymod.simplepathing.ReplayModSimplePathing;
|
||||||
import com.replaymod.simplepathing.Setting;
|
import com.replaymod.simplepathing.SPTimeline;
|
||||||
|
import com.replaymod.simplepathing.SPTimeline.SPPath;
|
||||||
import de.johni0702.minecraft.gui.GuiRenderer;
|
import de.johni0702.minecraft.gui.GuiRenderer;
|
||||||
import de.johni0702.minecraft.gui.RenderInfo;
|
import de.johni0702.minecraft.gui.RenderInfo;
|
||||||
import de.johni0702.minecraft.gui.container.GuiContainer;
|
import de.johni0702.minecraft.gui.container.GuiContainer;
|
||||||
import de.johni0702.minecraft.gui.container.GuiPanel;
|
import de.johni0702.minecraft.gui.container.GuiPanel;
|
||||||
import de.johni0702.minecraft.gui.element.*;
|
import de.johni0702.minecraft.gui.element.AbstractGuiClickable;
|
||||||
|
import de.johni0702.minecraft.gui.element.AbstractGuiElement;
|
||||||
|
import de.johni0702.minecraft.gui.element.GuiElement;
|
||||||
|
import de.johni0702.minecraft.gui.element.GuiHorizontalScrollbar;
|
||||||
|
import de.johni0702.minecraft.gui.element.GuiLabel;
|
||||||
|
import de.johni0702.minecraft.gui.element.GuiTexturedButton;
|
||||||
|
import de.johni0702.minecraft.gui.element.GuiTooltip;
|
||||||
|
import de.johni0702.minecraft.gui.element.IGuiClickable;
|
||||||
import de.johni0702.minecraft.gui.element.advanced.GuiProgressBar;
|
import de.johni0702.minecraft.gui.element.advanced.GuiProgressBar;
|
||||||
import de.johni0702.minecraft.gui.element.advanced.GuiTimelineTime;
|
import de.johni0702.minecraft.gui.element.advanced.GuiTimelineTime;
|
||||||
import de.johni0702.minecraft.gui.layout.CustomLayout;
|
import de.johni0702.minecraft.gui.layout.CustomLayout;
|
||||||
@@ -43,9 +44,7 @@ import de.johni0702.minecraft.gui.popup.GuiInfoPopup;
|
|||||||
import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
||||||
import de.johni0702.minecraft.gui.utils.Colors;
|
import de.johni0702.minecraft.gui.utils.Colors;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraftforge.fml.common.Loader;
|
import net.minecraftforge.fml.common.Loader;
|
||||||
import org.apache.commons.lang3.tuple.Triple;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
@@ -57,10 +56,7 @@ import org.lwjgl.util.WritablePoint;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import static com.replaymod.core.utils.Utils.error;
|
import static com.replaymod.core.utils.Utils.error;
|
||||||
@@ -71,9 +67,6 @@ import static com.replaymod.simplepathing.ReplayModSimplePathing.LOGGER;
|
|||||||
* Gui plug-in to the GuiReplayOverlay for simple pathing.
|
* Gui plug-in to the GuiReplayOverlay for simple pathing.
|
||||||
*/
|
*/
|
||||||
public class GuiPathing {
|
public class GuiPathing {
|
||||||
public static final int TIME_PATH = 0;
|
|
||||||
public static final int POSITION_PATH = 1;
|
|
||||||
|
|
||||||
private static final Logger logger = LogManager.getLogger();
|
private static final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
public final GuiTexturedButton playPauseButton = new GuiTexturedButton() {
|
public final GuiTexturedButton playPauseButton = new GuiTexturedButton() {
|
||||||
@@ -99,10 +92,11 @@ public class GuiPathing {
|
|||||||
if (!preparePathsForPlayback()) return;
|
if (!preparePathsForPlayback()) return;
|
||||||
|
|
||||||
// Clone the timeline passed to the settings gui as it may be stored for later rendering in a queue
|
// Clone the timeline passed to the settings gui as it may be stored for later rendering in a queue
|
||||||
Timeline timeline = mod.getCurrentTimeline();
|
SPTimeline spTimeline = mod.getCurrentTimeline();
|
||||||
|
Timeline timeline;
|
||||||
try {
|
try {
|
||||||
TimelineSerialization serialization = new TimelineSerialization(mod, null);
|
TimelineSerialization serialization = new TimelineSerialization(spTimeline, null);
|
||||||
String serialized = serialization.serialize(Collections.singletonMap("", timeline));
|
String serialized = serialization.serialize(Collections.singletonMap("", spTimeline.getTimeline()));
|
||||||
timeline = serialization.deserialize(serialized).get("");
|
timeline = serialization.deserialize(serialized).get("");
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
error(LOGGER, replayHandler.getOverlay(), CrashReport.makeCrashReport(t, "Cloning timeline"), () -> {});
|
error(LOGGER, replayHandler.getOverlay(), CrashReport.makeCrashReport(t, "Cloning timeline"), () -> {});
|
||||||
@@ -296,27 +290,28 @@ public class GuiPathing {
|
|||||||
if (player.isActive()) {
|
if (player.isActive()) {
|
||||||
player.getFuture().cancel(false);
|
player.getFuture().cancel(false);
|
||||||
} else {
|
} else {
|
||||||
Timeline timeline = mod.getCurrentTimeline();
|
Path timePath = mod.getCurrentTimeline().getTimePath();
|
||||||
Path timePath = timeline.getPaths().get(TIME_PATH);
|
|
||||||
|
|
||||||
if (!preparePathsForPlayback()) return;
|
if (!preparePathsForPlayback()) return;
|
||||||
|
|
||||||
timePath.setActive(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT));
|
timePath.setActive(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT));
|
||||||
// Start from cursor time unless the control key is pressed (then start from beginning)
|
// Start from cursor time unless the control key is pressed (then start from beginning)
|
||||||
int startTime = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)? 0 : GuiPathing.this.timeline.getCursorPosition();
|
int startTime = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)? 0 : GuiPathing.this.timeline.getCursorPosition();
|
||||||
ListenableFuture<Void> future = player.start(timeline, startTime);
|
ListenableFuture<Void> future = player.start(mod.getCurrentTimeline().getTimeline(), startTime);
|
||||||
overlay.setCloseable(false);
|
overlay.setCloseable(false);
|
||||||
overlay.setMouseVisible(true);
|
overlay.setMouseVisible(true);
|
||||||
Futures.addCallback(future, new FutureCallback<Void>() {
|
Futures.addCallback(future, new FutureCallback<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(@Nullable Void result) {
|
public void onSuccess(@Nullable Void result) {
|
||||||
overlay.setCloseable(true);
|
overlay.setCloseable(true);
|
||||||
|
timePath.setActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable t) {
|
public void onFailure(Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
overlay.setCloseable(true);
|
overlay.setCloseable(true);
|
||||||
|
timePath.setActive(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -326,26 +321,28 @@ public class GuiPathing {
|
|||||||
positionKeyframeButton.setTexturePosH(new ReadablePoint() {
|
positionKeyframeButton.setTexturePosH(new ReadablePoint() {
|
||||||
@Override
|
@Override
|
||||||
public int getX() {
|
public int getX() {
|
||||||
Keyframe keyframe = mod.getSelectedKeyframe();
|
SPPath keyframePath = mod.getSelectedPath();
|
||||||
if (keyframe == null || !keyframe.getValue(CameraProperties.POSITION).isPresent()) {
|
long keyframeTime = mod.getSelectedTime();
|
||||||
|
if (keyframePath != SPPath.POSITION) {
|
||||||
// No keyframe or wrong path
|
// No keyframe or wrong path
|
||||||
keyframe = mod.getCurrentTimeline().getPaths().get(POSITION_PATH).getKeyframe(timeline.getCursorPosition());
|
keyframeTime = timeline.getCursorPosition();
|
||||||
|
keyframePath = mod.getCurrentTimeline().isPositionKeyframe(keyframeTime) ? SPPath.POSITION : null;
|
||||||
}
|
}
|
||||||
if (keyframe == null) {
|
if (keyframePath != SPPath.POSITION) {
|
||||||
return replayHandler.isCameraView() ? 0 : 40;
|
return replayHandler.isCameraView() ? 0 : 40;
|
||||||
} else {
|
} else {
|
||||||
return keyframe.getValue(SpectatorProperty.PROPERTY).isPresent() ? 40 : 0;
|
return mod.getCurrentTimeline().isSpectatorKeyframe(keyframeTime) ? 40 : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getY() {
|
public int getY() {
|
||||||
Keyframe keyframe = mod.getSelectedKeyframe();
|
SPPath keyframePath = mod.getSelectedPath();
|
||||||
if (keyframe == null || !keyframe.getValue(CameraProperties.POSITION).isPresent()) {
|
if (keyframePath != SPPath.POSITION) {
|
||||||
// No keyframe selected but there might be one at exactly the position of the cursor
|
// No keyframe selected but there might be one at exactly the position of the cursor
|
||||||
keyframe = mod.getCurrentTimeline().getPaths().get(POSITION_PATH).getKeyframe(timeline.getCursorPosition());
|
keyframePath = mod.getCurrentTimeline().isPositionKeyframe(timeline.getCursorPosition()) ? SPPath.POSITION : null;
|
||||||
}
|
}
|
||||||
return keyframe != null && keyframe.getValue(CameraProperties.POSITION).isPresent() ? 60 : 40;
|
return keyframePath == SPPath.POSITION ? 60 : 40;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -355,7 +352,7 @@ public class GuiPathing {
|
|||||||
}).onClick(new Runnable() {
|
}).onClick(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
updateKeyframe(false);
|
updateKeyframe(SPPath.POSITION);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -367,12 +364,12 @@ public class GuiPathing {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getY() {
|
public int getY() {
|
||||||
Keyframe keyframe = mod.getSelectedKeyframe();
|
SPPath keyframePath = mod.getSelectedPath();
|
||||||
if (keyframe == null || !keyframe.getValue(TimestampProperty.PROPERTY).isPresent()) {
|
if (keyframePath != SPPath.TIME) {
|
||||||
// No keyframe selected but there might be one at exactly the position of the cursor
|
// No keyframe selected but there might be one at exactly the position of the cursor
|
||||||
keyframe = mod.getCurrentTimeline().getPaths().get(TIME_PATH).getKeyframe(timeline.getCursorPosition());
|
keyframePath = mod.getCurrentTimeline().isTimeKeyframe(timeline.getCursorPosition()) ? SPPath.TIME : null;
|
||||||
}
|
}
|
||||||
return keyframe != null && keyframe.getValue(TimestampProperty.PROPERTY).isPresent() ? 100 : 80;
|
return keyframePath == SPPath.TIME ? 100 : 80;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -382,7 +379,7 @@ public class GuiPathing {
|
|||||||
}).onClick(new Runnable() {
|
}).onClick(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
updateKeyframe(true);
|
updateKeyframe(SPPath.TIME);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -404,12 +401,12 @@ public class GuiPathing {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
GuiKeyframeRepository gui = new GuiKeyframeRepository(
|
GuiKeyframeRepository gui = new GuiKeyframeRepository(
|
||||||
mod, replayHandler.getReplayFile(), mod.getCurrentTimeline());
|
mod.getCurrentTimeline(), replayHandler.getReplayFile(), mod.getCurrentTimeline().getTimeline());
|
||||||
Futures.addCallback(gui.getFuture(), new FutureCallback<Timeline>() {
|
Futures.addCallback(gui.getFuture(), new FutureCallback<Timeline>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Timeline result) {
|
public void onSuccess(Timeline result) {
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
mod.setCurrentTimeline(result);
|
mod.setCurrentTimeline(new SPTimeline(result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,10 +432,10 @@ public class GuiPathing {
|
|||||||
@Override
|
@Override
|
||||||
public void onSuccess(Boolean delete) {
|
public void onSuccess(Boolean delete) {
|
||||||
if (delete) {
|
if (delete) {
|
||||||
Timeline timeline = mod.createTimeline();
|
mod.clearCurrentTimeline();
|
||||||
timeline.createPath();
|
if (entityTracker != null) {
|
||||||
timeline.createPath();
|
mod.getCurrentTimeline().setEntityTracker(entityTracker);
|
||||||
mod.setCurrentTimeline(timeline);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -455,7 +452,7 @@ public class GuiPathing {
|
|||||||
// Position of the cursor
|
// Position of the cursor
|
||||||
int cursor = timeline.getCursorPosition();
|
int cursor = timeline.getCursorPosition();
|
||||||
// Get the last time keyframe before the cursor
|
// Get the last time keyframe before the cursor
|
||||||
mod.getCurrentTimeline().getPaths().get(TIME_PATH).getKeyframes().stream()
|
mod.getCurrentTimeline().getTimePath().getKeyframes().stream()
|
||||||
.filter(it -> it.getTime() <= cursor).reduce((__, last) -> last).ifPresent(keyframe -> {
|
.filter(it -> it.getTime() <= cursor).reduce((__, last) -> last).ifPresent(keyframe -> {
|
||||||
// Cursor position at the keyframe
|
// Cursor position at the keyframe
|
||||||
int keyframeCursor = (int) keyframe.getTime();
|
int keyframeCursor = (int) keyframe.getTime();
|
||||||
@@ -471,7 +468,7 @@ public class GuiPathing {
|
|||||||
// Move cursor to new position
|
// Move cursor to new position
|
||||||
timeline.setCursorPosition(keyframeCursor + cursorPassed);
|
timeline.setCursorPosition(keyframeCursor + cursorPassed);
|
||||||
// Deselect keyframe to allow the user to add a new one right away
|
// Deselect keyframe to allow the user to add a new one right away
|
||||||
mod.setSelectedKeyframe(null);
|
mod.setSelected(null, 0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -479,8 +476,8 @@ public class GuiPathing {
|
|||||||
if (!overlay.isVisible()) {
|
if (!overlay.isVisible()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mod.getSelectedKeyframe() != null) {
|
if (mod.getSelectedPath() != null) {
|
||||||
updateKeyframe(mod.getSelectedKeyframe().getValue(TimestampProperty.PROPERTY).isPresent());
|
updateKeyframe(mod.getSelectedPath());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -511,13 +508,12 @@ public class GuiPathing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean preparePathsForPlayback() {
|
private boolean preparePathsForPlayback() {
|
||||||
Timeline timeline = mod.getCurrentTimeline();
|
SPTimeline timeline = mod.getCurrentTimeline();
|
||||||
timeline.getPaths().get(TIME_PATH).updateAll();
|
timeline.getTimeline().getPaths().forEach(Path::updateAll);
|
||||||
timeline.getPaths().get(POSITION_PATH).updateAll();
|
|
||||||
|
|
||||||
// Make sure time keyframes's values are monotonically increasing
|
// Make sure time keyframes's values are monotonically increasing
|
||||||
int lastTime = 0;
|
int lastTime = 0;
|
||||||
for (Keyframe keyframe : timeline.getPaths().get(TIME_PATH).getKeyframes()) {
|
for (Keyframe keyframe : timeline.getTimePath().getKeyframes()) {
|
||||||
int time = keyframe.getValue(TimestampProperty.PROPERTY).orElseThrow(IllegalStateException::new);
|
int time = keyframe.getValue(TimestampProperty.PROPERTY).orElseThrow(IllegalStateException::new);
|
||||||
if (time < lastTime) {
|
if (time < lastTime) {
|
||||||
// We are going backwards in time
|
// We are going backwards in time
|
||||||
@@ -531,8 +527,8 @@ public class GuiPathing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make sure there are at least two position- and two time-keyframes
|
// Make sure there are at least two position- and two time-keyframes
|
||||||
if (timeline.getPaths().get(POSITION_PATH).getSegments().isEmpty()
|
if (timeline.getPositionPath().getSegments().isEmpty()
|
||||||
|| timeline.getPaths().get(TIME_PATH).getSegments().isEmpty()) {
|
|| timeline.getTimePath().getSegments().isEmpty()) {
|
||||||
GuiInfoPopup.open(replayHandler.getOverlay(), "replaymod.chat.morekeyframes");
|
GuiInfoPopup.open(replayHandler.getOverlay(), "replaymod.chat.morekeyframes");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -544,19 +540,19 @@ public class GuiPathing {
|
|||||||
scrollbar.setZoom(scrollbar.getZoom() * factor);
|
scrollbar.setZoom(scrollbar.getZoom() * factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public boolean ensureEntityTracker(Runnable withDelayedTracker) {
|
||||||
* Called when either one of the property buttons is pressed.
|
|
||||||
* @param isTime {@code true} for the time property button, {@code false} for the place property button
|
|
||||||
*/
|
|
||||||
private void updateKeyframe(final boolean isTime) {
|
|
||||||
if (entityTracker == null) {
|
if (entityTracker == null) {
|
||||||
|
LOGGER.debug("Entity tracker not yet loaded, delaying...");
|
||||||
LoadEntityTrackerPopup popup = new LoadEntityTrackerPopup(replayHandler.getOverlay());
|
LoadEntityTrackerPopup popup = new LoadEntityTrackerPopup(replayHandler.getOverlay());
|
||||||
entityTrackerLoadingProgress = p -> popup.progressBar.setProgress(p.floatValue());
|
entityTrackerLoadingProgress = p -> popup.progressBar.setProgress(p.floatValue());
|
||||||
Futures.addCallback(entityTrackerFuture, new FutureCallback<Void>() {
|
Futures.addCallback(entityTrackerFuture, new FutureCallback<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(@Nullable Void result) {
|
public void onSuccess(@Nullable Void result) {
|
||||||
popup.close();
|
popup.close();
|
||||||
updateKeyframe(isTime);
|
if (mod.getCurrentTimeline().getEntityTracker() == null) {
|
||||||
|
mod.getCurrentTimeline().setEntityTracker(entityTracker);
|
||||||
|
}
|
||||||
|
withDelayedTracker.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -564,184 +560,63 @@ public class GuiPathing {
|
|||||||
popup.close();
|
popup.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (mod.getCurrentTimeline().getEntityTracker() == null) {
|
||||||
|
mod.getCurrentTimeline().setEntityTracker(entityTracker);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when either one of the property buttons is pressed.
|
||||||
|
* @param path {@code TIME} for the time property button, {@code POSITION} for the place property button
|
||||||
|
*/
|
||||||
|
private void updateKeyframe(SPPath path) {
|
||||||
|
LOGGER.debug("Updating keyframe on path {}" + path);
|
||||||
|
if (!ensureEntityTracker(() -> updateKeyframe(path))) return;
|
||||||
|
|
||||||
int time = timeline.getCursorPosition();
|
int time = timeline.getCursorPosition();
|
||||||
Timeline timeline = mod.getCurrentTimeline();
|
SPTimeline timeline = mod.getCurrentTimeline();
|
||||||
Path path = timeline.getPaths().get(isTime ? TIME_PATH : POSITION_PATH);
|
|
||||||
|
|
||||||
Keyframe keyframe = mod.getSelectedKeyframe();
|
switch (path) {
|
||||||
if (keyframe != null && keyframe.getValue(TimestampProperty.PROPERTY).isPresent() ^ isTime) {
|
case TIME:
|
||||||
// Keyframe is on the wrong timeline
|
if (mod.getSelectedPath() == path) {
|
||||||
keyframe = null;
|
LOGGER.debug("Selected keyframe is time keyframe -> removing keyframe");
|
||||||
}
|
timeline.removeTimeKeyframe(mod.getSelectedTime());
|
||||||
if (keyframe == null) {
|
mod.setSelected(null, 0);
|
||||||
// No keyframe selected but there may still be one at this exact time
|
} else if (timeline.isTimeKeyframe(time)) {
|
||||||
keyframe = path.getKeyframe(time);
|
LOGGER.debug("Keyframe at cursor position is time keyframe -> removing keyframe");
|
||||||
}
|
timeline.removeTimeKeyframe(time);
|
||||||
Change change;
|
mod.setSelected(null, 0);
|
||||||
if (keyframe == null) {
|
} else {
|
||||||
change = AddKeyframe.create(path, time);
|
LOGGER.debug("No time keyframe found -> adding new keyframe");
|
||||||
change.apply(timeline);
|
timeline.addTimeKeyframe(time, replayHandler.getReplaySender().currentTimeStamp());
|
||||||
keyframe = path.getKeyframe(time);
|
mod.setSelected(path, time);
|
||||||
} else {
|
|
||||||
change = RemoveKeyframe.create(path, keyframe);
|
|
||||||
change.apply(timeline);
|
|
||||||
keyframe = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keyframe != null) {
|
|
||||||
UpdateKeyframeProperties.Builder builder = UpdateKeyframeProperties.create(path, keyframe);
|
|
||||||
if (isTime) {
|
|
||||||
builder.setValue(TimestampProperty.PROPERTY, replayHandler.getReplaySender().currentTimeStamp());
|
|
||||||
} else {
|
|
||||||
CameraEntity camera = replayHandler.getCameraEntity();
|
|
||||||
builder.setValue(CameraProperties.POSITION, Triple.of(camera.posX, camera.posY, camera.posZ));
|
|
||||||
builder.setValue(CameraProperties.ROTATION, Triple.of(camera.rotationYaw, camera.rotationPitch, camera.roll));
|
|
||||||
if (!replayHandler.isCameraView()) {
|
|
||||||
Entity spectated = replayHandler.getOverlay().getMinecraft().getRenderViewEntity();
|
|
||||||
builder.setValue(SpectatorProperty.PROPERTY, spectated.getEntityId());
|
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
UpdateKeyframeProperties updateChange = builder.done();
|
case POSITION:
|
||||||
updateChange.apply(timeline);
|
if (mod.getSelectedPath() == path) {
|
||||||
change = CombinedChange.createFromApplied(change, updateChange);
|
LOGGER.debug("Selected keyframe is position keyframe -> removing keyframe");
|
||||||
|
timeline.removePositionKeyframe(mod.getSelectedTime());
|
||||||
// If this new keyframe formed the first segment of the time path
|
mod.setSelected(null, 0);
|
||||||
if (isTime && path.getSegments().size() == 1) {
|
} else if (timeline.isPositionKeyframe(time)) {
|
||||||
PathSegment segment = path.getSegments().iterator().next();
|
LOGGER.debug("Keyframe at cursor position is position keyframe -> removing keyframe");
|
||||||
Interpolator interpolator = new LinearInterpolator();
|
timeline.removePositionKeyframe(time);
|
||||||
interpolator.registerProperty(TimestampProperty.PROPERTY);
|
mod.setSelected(null, 0);
|
||||||
SetInterpolator setInterpolator = SetInterpolator.create(segment, interpolator);
|
} else {
|
||||||
setInterpolator.apply(timeline);
|
LOGGER.debug("No position keyframe found -> adding new keyframe");
|
||||||
change = CombinedChange.createFromApplied(change, setInterpolator);
|
CameraEntity camera = replayHandler.getCameraEntity();
|
||||||
}
|
int spectatedId = -1;
|
||||||
}
|
if (!replayHandler.isCameraView()) {
|
||||||
|
spectatedId = replayHandler.getOverlay().getMinecraft().getRenderViewEntity().getEntityId();
|
||||||
// Update interpolators for spectator keyframes
|
}
|
||||||
// while this is overkill, it is far simpler than updating differently for every possible case
|
timeline.addPositionKeyframe(time, camera.posX, camera.posY, camera.posZ,
|
||||||
if (!isTime) {
|
camera.rotationYaw, camera.rotationPitch, camera.roll, spectatedId);
|
||||||
Change interpolators = updateInterpolators();
|
mod.setSelected(path, time);
|
||||||
interpolators.apply(timeline);
|
|
||||||
change = CombinedChange.createFromApplied(change, interpolators);
|
|
||||||
}
|
|
||||||
|
|
||||||
Change specPosUpdate = updateSpectatorPositions();
|
|
||||||
specPosUpdate.apply(timeline);
|
|
||||||
change = CombinedChange.createFromApplied(change, specPosUpdate);
|
|
||||||
|
|
||||||
timeline.pushChange(change);
|
|
||||||
|
|
||||||
mod.setSelectedKeyframe(keyframe);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Change updateInterpolators() {
|
|
||||||
boolean linearInterpolation = mod.getCore().getSettingsRegistry().get(Setting.LINEAR_INTERPOLATION);
|
|
||||||
List<Change> changes = new ArrayList<>();
|
|
||||||
Interpolator interpolator = null;
|
|
||||||
boolean isSpectatorInterpolator = false;
|
|
||||||
for (PathSegment segment : mod.getCurrentTimeline().getPaths().get(POSITION_PATH).getSegments()) {
|
|
||||||
if (segment.getStartKeyframe().getValue(SpectatorProperty.PROPERTY).isPresent()
|
|
||||||
&& segment.getEndKeyframe().getValue(SpectatorProperty.PROPERTY).isPresent()) {
|
|
||||||
// Spectator segment
|
|
||||||
if (!isSpectatorInterpolator) {
|
|
||||||
isSpectatorInterpolator = true;
|
|
||||||
interpolator = new LinearInterpolator();
|
|
||||||
interpolator.registerProperty(SpectatorProperty.PROPERTY);
|
|
||||||
}
|
}
|
||||||
changes.add(SetInterpolator.create(segment, interpolator));
|
break;
|
||||||
} else {
|
|
||||||
// Normal segment
|
|
||||||
if (isSpectatorInterpolator || interpolator == null) {
|
|
||||||
isSpectatorInterpolator = false;
|
|
||||||
interpolator = linearInterpolation ? new LinearInterpolator() : new CubicSplineInterpolator();
|
|
||||||
interpolator.registerProperty(CameraProperties.POSITION);
|
|
||||||
interpolator.registerProperty(CameraProperties.ROTATION);
|
|
||||||
}
|
|
||||||
changes.add(SetInterpolator.create(segment, interpolator));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return CombinedChange.create(changes.toArray(new Change[changes.size()]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Change updateSpectatorPositions() {
|
|
||||||
List<Change> changes = new ArrayList<>();
|
|
||||||
Path positionPath = mod.getCurrentTimeline().getPaths().get(POSITION_PATH);
|
|
||||||
Path timePath = mod.getCurrentTimeline().getPaths().get(TIME_PATH);
|
|
||||||
timePath.updateAll();
|
|
||||||
for (Keyframe keyframe : positionPath.getKeyframes()) {
|
|
||||||
Optional<Integer> spectator = keyframe.getValue(SpectatorProperty.PROPERTY);
|
|
||||||
if (spectator.isPresent()) {
|
|
||||||
Optional<Integer> time = timePath.getValue(TimestampProperty.PROPERTY, keyframe.getTime());
|
|
||||||
if (!time.isPresent()) {
|
|
||||||
continue; // No time keyframes set at this video time, cannot determine replay time
|
|
||||||
}
|
|
||||||
Location expected = entityTracker.getEntityPositionAtTimestamp(spectator.get(), time.get());
|
|
||||||
if (expected == null) {
|
|
||||||
continue; // We don't have any data on this entity for some reason
|
|
||||||
}
|
|
||||||
Triple<Double, Double, Double> pos = keyframe.getValue(CameraProperties.POSITION).orElse(Triple.of(0D, 0D, 0D));
|
|
||||||
Triple<Float, Float, Float> rot = keyframe.getValue(CameraProperties.ROTATION).orElse(Triple.of(0F, 0F, 0F));
|
|
||||||
Location actual = new Location(pos.getLeft(), pos.getMiddle(), pos.getRight(), rot.getLeft(), rot.getRight());
|
|
||||||
if (!expected.equals(actual)) {
|
|
||||||
changes.add(UpdateKeyframeProperties.create(positionPath, keyframe)
|
|
||||||
.setValue(CameraProperties.POSITION, Triple.of(expected.getX(), expected.getY(), expected.getZ()))
|
|
||||||
.setValue(CameraProperties.ROTATION, Triple.of(expected.getYaw(), expected.getPitch(), 0f)).done()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return CombinedChange.create(changes.toArray(new Change[changes.size()]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Change moveKeyframe(Path path, Keyframe keyframe, long newTime) {
|
|
||||||
Timeline timeline = mod.getCurrentTimeline();
|
|
||||||
// Interpolator might be required later (only if path is the time path)
|
|
||||||
Optional<Interpolator> interpolator =
|
|
||||||
path.getSegments().stream().findFirst().map(PathSegment::getInterpolator);
|
|
||||||
|
|
||||||
// First remove the old keyframe
|
|
||||||
Change removeChange = RemoveKeyframe.create(path, keyframe);
|
|
||||||
removeChange.apply(timeline);
|
|
||||||
|
|
||||||
// and add a new one at the correct time
|
|
||||||
Change addChange = AddKeyframe.create(path, newTime);
|
|
||||||
addChange.apply(timeline);
|
|
||||||
path.getKeyframe(newTime);
|
|
||||||
|
|
||||||
// Then copy over all properties
|
|
||||||
UpdateKeyframeProperties.Builder builder = UpdateKeyframeProperties.create(path, path.getKeyframe(newTime));
|
|
||||||
for (Property property : keyframe.getProperties()) {
|
|
||||||
copyProperty(property, keyframe, builder);
|
|
||||||
}
|
|
||||||
Change propertyChange = builder.done();
|
|
||||||
propertyChange.apply(timeline);
|
|
||||||
|
|
||||||
// Finally set the interpolators
|
|
||||||
Change interpolatorChange;
|
|
||||||
if (path.getTimeline().getPaths().indexOf(path) == GuiPathing.POSITION_PATH) {
|
|
||||||
// Position / Spectator keyframes need special handling
|
|
||||||
interpolatorChange = updateInterpolators();
|
|
||||||
} else {
|
|
||||||
// Time keyframes only need updating when only one segment of them exists
|
|
||||||
if (path.getSegments().size() == 1) {
|
|
||||||
interpolatorChange = SetInterpolator.create(path.getSegments().iterator().next(), interpolator.get());
|
|
||||||
} else {
|
|
||||||
interpolatorChange = CombinedChange.create(); // Noop change
|
|
||||||
}
|
|
||||||
}
|
|
||||||
interpolatorChange.apply(timeline);
|
|
||||||
// and update spectator positions
|
|
||||||
Change spectatorChange = updateSpectatorPositions();
|
|
||||||
spectatorChange.apply(timeline);
|
|
||||||
|
|
||||||
return CombinedChange.createFromApplied(removeChange, addChange, propertyChange, interpolatorChange, spectatorChange);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper method because generics cannot be defined on blocks
|
|
||||||
private <T> void copyProperty(Property<T> property, Keyframe from, UpdateKeyframeProperties.Builder to) {
|
|
||||||
from.getValue(property).ifPresent(value -> to.setValue(property, value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReplayModSimplePathing getMod() {
|
public ReplayModSimplePathing getMod() {
|
||||||
@@ -752,13 +627,15 @@ public class GuiPathing {
|
|||||||
return entityTracker;
|
return entityTracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openEditKeyframePopup(Path path, Keyframe keyframe) {
|
public void openEditKeyframePopup(SPPath path, long time) {
|
||||||
|
if (!ensureEntityTracker(() -> openEditKeyframePopup(path, time))) return;
|
||||||
|
Keyframe keyframe = mod.getCurrentTimeline().getKeyframe(path, time);
|
||||||
if (keyframe.getProperties().contains(SpectatorProperty.PROPERTY)) {
|
if (keyframe.getProperties().contains(SpectatorProperty.PROPERTY)) {
|
||||||
new GuiEditKeyframe.Spectator(this, path, keyframe).open();
|
new GuiEditKeyframe.Spectator(this, path, keyframe.getTime()).open();
|
||||||
} else if (keyframe.getProperties().contains(CameraProperties.POSITION)) {
|
} else if (keyframe.getProperties().contains(CameraProperties.POSITION)) {
|
||||||
new GuiEditKeyframe.Position(this, path, keyframe).open();
|
new GuiEditKeyframe.Position(this, path, keyframe.getTime()).open();
|
||||||
} else {
|
} else {
|
||||||
new GuiEditKeyframe.Time(this, path, keyframe).open();
|
new GuiEditKeyframe.Time(this, path, keyframe.getTime()).open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import com.replaymod.replay.events.ReplayCloseEvent;
|
|||||||
import com.replaymod.replay.events.ReplayOpenEvent;
|
import com.replaymod.replay.events.ReplayOpenEvent;
|
||||||
import com.replaymod.simplepathing.ReplayModSimplePathing;
|
import com.replaymod.simplepathing.ReplayModSimplePathing;
|
||||||
import com.replaymod.simplepathing.Setting;
|
import com.replaymod.simplepathing.Setting;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ public class PathPreview {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void register() {
|
public void register() {
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
FMLCommonHandler.instance().bus().register(this);
|
||||||
|
|
||||||
ReplayMod core = mod.getCore();
|
ReplayMod core = mod.getCore();
|
||||||
mod.getCore().getKeyBindingRegistry().registerKeyBinding("replaymod.input.pathpreview", Keyboard.KEY_H, () -> {
|
mod.getCore().getKeyBindingRegistry().registerKeyBinding("replaymod.input.pathpreview", Keyboard.KEY_H, () -> {
|
||||||
|
|||||||
@@ -9,16 +9,15 @@ import com.replaymod.replaystudio.pathing.interpolation.Interpolator;
|
|||||||
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
||||||
import com.replaymod.replaystudio.pathing.path.Path;
|
import com.replaymod.replaystudio.pathing.path.Path;
|
||||||
import com.replaymod.replaystudio.pathing.path.PathSegment;
|
import com.replaymod.replaystudio.pathing.path.PathSegment;
|
||||||
import com.replaymod.replaystudio.pathing.path.Timeline;
|
|
||||||
import com.replaymod.replaystudio.util.EntityPositionTracker;
|
import com.replaymod.replaystudio.util.EntityPositionTracker;
|
||||||
import com.replaymod.replaystudio.util.Location;
|
import com.replaymod.replaystudio.util.Location;
|
||||||
import com.replaymod.simplepathing.ReplayModSimplePathing;
|
import com.replaymod.simplepathing.ReplayModSimplePathing;
|
||||||
|
import com.replaymod.simplepathing.SPTimeline;
|
||||||
import com.replaymod.simplepathing.gui.GuiPathing;
|
import com.replaymod.simplepathing.gui.GuiPathing;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
import net.minecraft.client.renderer.VertexBuffer;
|
import net.minecraft.client.renderer.WorldRenderer;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||||
@@ -68,11 +67,11 @@ public class PathPreviewRenderer {
|
|||||||
if (guiPathing == null) return;
|
if (guiPathing == null) return;
|
||||||
EntityPositionTracker entityTracker = guiPathing.getEntityTracker();
|
EntityPositionTracker entityTracker = guiPathing.getEntityTracker();
|
||||||
|
|
||||||
Timeline timeline = mod.getCurrentTimeline();
|
SPTimeline timeline = mod.getCurrentTimeline();
|
||||||
if (timeline == null) return;
|
if (timeline == null) return;
|
||||||
Path path = timeline.getPaths().get(GuiPathing.POSITION_PATH);
|
Path path = timeline.getPositionPath();
|
||||||
if (path.getKeyframes().isEmpty()) return;
|
if (path.getKeyframes().isEmpty()) return;
|
||||||
Path timePath = timeline.getPaths().get(GuiPathing.TIME_PATH);
|
Path timePath = timeline.getTimePath();
|
||||||
|
|
||||||
path.update();
|
path.update();
|
||||||
|
|
||||||
@@ -97,8 +96,8 @@ public class PathPreviewRenderer {
|
|||||||
if (spectator && entityTracker == null) {
|
if (spectator && entityTracker == null) {
|
||||||
continue; // Cannot render spectator positions when entity tracker is not yet loaded
|
continue; // Cannot render spectator positions when entity tracker is not yet loaded
|
||||||
}
|
}
|
||||||
// Spectator segments have 20 lines per second whereas normal segments have a fixed 100
|
// Spectator segments have 20 lines per second (at least 10) whereas normal segments have a fixed 100
|
||||||
long steps = spectator ? diff / 50 : 100;
|
long steps = spectator ? Math.max(diff / 50, 10) : 100;
|
||||||
Triple<Double, Double, Double> prevPos = null;
|
Triple<Double, Double, Double> prevPos = null;
|
||||||
for (int i = 0; i <= steps; i++) {
|
for (int i = 0; i <= steps; i++) {
|
||||||
long time = start.getTime() + diff * i / steps;
|
long time = start.getTime() + diff * i / steps;
|
||||||
@@ -204,35 +203,26 @@ public class PathPreviewRenderer {
|
|||||||
if (distanceSquared(view, pos2) > renderDistanceSquared) return;
|
if (distanceSquared(view, pos2) > renderDistanceSquared) return;
|
||||||
|
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
VertexBuffer vertexBuffer = tessellator.getBuffer();
|
WorldRenderer renderer = tessellator.getWorldRenderer();
|
||||||
vertexBuffer.setTranslation(-view.getLeft(), -view.getMiddle(), -view.getRight());
|
renderer.setTranslation(-view.getLeft(), -view.getMiddle(), -view.getRight());
|
||||||
|
|
||||||
vertexBuffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
|
renderer.startDrawing(GL11.GL_LINES);
|
||||||
|
renderer.setColorRGBA_I(color, 255);
|
||||||
|
|
||||||
vertexBuffer.pos(pos1.getLeft(), pos1.getMiddle(), pos1.getRight()).color(
|
renderer.addVertex(pos1.getLeft(), pos1.getMiddle(), pos1.getRight());
|
||||||
color >> 16 & 0xff,
|
renderer.addVertex(pos2.getLeft(), pos2.getMiddle(), pos2.getRight());
|
||||||
color >> 8 & 0xff,
|
|
||||||
color & 0xff,
|
|
||||||
255
|
|
||||||
).endVertex();
|
|
||||||
vertexBuffer.pos(pos2.getLeft(), pos2.getMiddle(), pos2.getRight()).color(
|
|
||||||
color >> 16 & 0xff,
|
|
||||||
color >> 8 & 0xff,
|
|
||||||
color & 0xff,
|
|
||||||
255
|
|
||||||
).endVertex();
|
|
||||||
|
|
||||||
GL11.glLineWidth(3);
|
GL11.glLineWidth(3);
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
vertexBuffer.setTranslation(0, 0, 0);
|
renderer.setTranslation(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
VertexBuffer vertexBuffer = tessellator.getBuffer();
|
WorldRenderer renderer = tessellator.getWorldRenderer();
|
||||||
vertexBuffer.setTranslation(0, 0, 0);
|
renderer.setTranslation(0, 0, 0);
|
||||||
|
|
||||||
mc.renderEngine.bindTexture(TEXTURE);
|
mc.renderEngine.bindTexture(TEXTURE);
|
||||||
|
|
||||||
@@ -240,7 +230,7 @@ public class PathPreviewRenderer {
|
|||||||
float posY = 0f;
|
float posY = 0f;
|
||||||
float size = 10f / ReplayMod.TEXTURE_SIZE;
|
float size = 10f / ReplayMod.TEXTURE_SIZE;
|
||||||
|
|
||||||
if (keyframe == mod.getSelectedKeyframe()) {
|
if (mod.isSelected(keyframe)) {
|
||||||
posY += size;
|
posY += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,12 +243,12 @@ public class PathPreviewRenderer {
|
|||||||
float maxX = 0.5f;
|
float maxX = 0.5f;
|
||||||
float maxY = 0.5f;
|
float maxY = 0.5f;
|
||||||
|
|
||||||
vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
renderer.startDrawingQuads();
|
||||||
|
|
||||||
vertexBuffer.pos(minX, minY, 0).tex(posX + size, posY + size).endVertex();
|
renderer.addVertexWithUV(minX, minY, 0, posX + size, posY + size);
|
||||||
vertexBuffer.pos(minX, maxY, 0).tex(posX + size, posY).endVertex();
|
renderer.addVertexWithUV(minX, maxY, 0, posX + size, posY);
|
||||||
vertexBuffer.pos(maxX, maxY, 0).tex(posX, posY).endVertex();
|
renderer.addVertexWithUV(maxX, maxY, 0, posX, posY);
|
||||||
vertexBuffer.pos(maxX, minY, 0).tex(posX, posY + size).endVertex();
|
renderer.addVertexWithUV(maxX, minY, 0, posX, posY + size);
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
|
|
||||||
@@ -280,8 +270,8 @@ public class PathPreviewRenderer {
|
|||||||
Triple<Double, Double, Double> pos,
|
Triple<Double, Double, Double> pos,
|
||||||
Triple<Float, Float, Float> rot) {
|
Triple<Float, Float, Float> rot) {
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
VertexBuffer vertexBuffer = tessellator.getBuffer();
|
WorldRenderer renderer = tessellator.getWorldRenderer();
|
||||||
vertexBuffer.setTranslation(0, 0, 0);
|
renderer.setTranslation(0, 0, 0);
|
||||||
|
|
||||||
mc.renderEngine.bindTexture(CAMERA_HEAD);
|
mc.renderEngine.bindTexture(CAMERA_HEAD);
|
||||||
|
|
||||||
@@ -299,10 +289,12 @@ public class PathPreviewRenderer {
|
|||||||
|
|
||||||
//draw the position line
|
//draw the position line
|
||||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||||
vertexBuffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
|
renderer.startDrawing(GL11.GL_LINES);
|
||||||
|
|
||||||
vertexBuffer.pos(0, 0, 0).color(0, 255, 0, 170).endVertex();
|
renderer.setColorRGBA_I(0x00ff00, 170);
|
||||||
vertexBuffer.pos(0, 0, 2).color(0, 255, 0, 170).endVertex();
|
|
||||||
|
renderer.addVertex(0, 0, 0);
|
||||||
|
renderer.addVertex(0, 0, 2);
|
||||||
|
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
|
|
||||||
@@ -313,43 +305,45 @@ public class PathPreviewRenderer {
|
|||||||
|
|
||||||
double r = -cubeSize/2;
|
double r = -cubeSize/2;
|
||||||
|
|
||||||
vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
|
renderer.startDrawingQuads();
|
||||||
|
|
||||||
|
renderer.setColorRGBA_I(0xffffff, 200);
|
||||||
|
|
||||||
//back
|
//back
|
||||||
vertexBuffer.pos(r, r + cubeSize, r).tex(3 * 8 / 64f, 8 / 64f).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r, r + cubeSize, r, 3 * 8 / 64f, 8 / 64f);
|
||||||
vertexBuffer.pos(r + cubeSize, r + cubeSize, r).tex(4*8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r + cubeSize, r + cubeSize, r, 4*8/64f, 8/64f);
|
||||||
vertexBuffer.pos(r + cubeSize, r, r).tex(4*8/64f, 2*8/64f).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r + cubeSize, r, r, 4*8/64f, 2*8/64f);
|
||||||
vertexBuffer.pos(r, r, r).tex(3*8/64f, 2*8/64f).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r, r, r, 3*8/64f, 2*8/64f);
|
||||||
|
|
||||||
//front
|
//front
|
||||||
vertexBuffer.pos(r + cubeSize, r, r + cubeSize).tex(2 * 8 / 64f, 2*8/64f).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r + cubeSize, r, r + cubeSize, 2 * 8 / 64f, 2*8/64f);
|
||||||
vertexBuffer.pos(r + cubeSize, r + cubeSize, r + cubeSize).tex(2 * 8 / 64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r + cubeSize, r + cubeSize, r + cubeSize, 2 * 8 / 64f, 8/64f);
|
||||||
vertexBuffer.pos(r, r + cubeSize, r + cubeSize).tex(8 / 64f, 8 / 64f).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r, r + cubeSize, r + cubeSize, 8 / 64f, 8 / 64f);
|
||||||
vertexBuffer.pos(r, r, r + cubeSize).tex(8 / 64f, 2*8/64f).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r, r, r + cubeSize, 8 / 64f, 2*8/64f);
|
||||||
|
|
||||||
//left
|
//left
|
||||||
vertexBuffer.pos(r + cubeSize, r + cubeSize, r).tex(0, 8/64f).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r + cubeSize, r + cubeSize, r, 0, 8/64f);
|
||||||
vertexBuffer.pos(r + cubeSize, r + cubeSize, r + cubeSize).tex(8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r + cubeSize, r + cubeSize, r + cubeSize, 8/64f, 8/64f);
|
||||||
vertexBuffer.pos(r + cubeSize, r, r + cubeSize).tex(8/64f, 2*8/64f).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r + cubeSize, r, r + cubeSize, 8/64f, 2*8/64f);
|
||||||
vertexBuffer.pos(r+cubeSize, r, r).tex(0, 2*8/64f).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r+cubeSize, r, r, 0, 2*8/64f);
|
||||||
|
|
||||||
//right
|
//right
|
||||||
vertexBuffer.pos(r, r + cubeSize, r + cubeSize).tex(2*8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r, r + cubeSize, r + cubeSize, 2*8/64f, 8/64f);
|
||||||
vertexBuffer.pos(r, r + cubeSize, r).tex(3*8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r, r + cubeSize, r, 3*8/64f, 8/64f);
|
||||||
vertexBuffer.pos(r, r, r).tex(3*8/64f, 2*8/64f).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r, r, r, 3*8/64f, 2*8/64f);
|
||||||
vertexBuffer.pos(r, r, r + cubeSize).tex(2 * 8 / 64f, 2 * 8 / 64f).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r, r, r + cubeSize, 2 * 8 / 64f, 2 * 8 / 64f);
|
||||||
|
|
||||||
//bottom
|
//bottom
|
||||||
vertexBuffer.pos(r + cubeSize, r, r).tex(3*8/64f, 0).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r + cubeSize, r, r, 3*8/64f, 0);
|
||||||
vertexBuffer.pos(r + cubeSize, r, r + cubeSize).tex(3*8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r + cubeSize, r, r + cubeSize, 3*8/64f, 8/64f);
|
||||||
vertexBuffer.pos(r, r, r + cubeSize).tex(2*8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r, r, r + cubeSize, 2*8/64f, 8/64f);
|
||||||
vertexBuffer.pos(r, r, r).tex(2 * 8 / 64f, 0).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r, r, r, 2 * 8 / 64f, 0);
|
||||||
|
|
||||||
//top
|
//top
|
||||||
vertexBuffer.pos(r, r + cubeSize, r).tex(8/64f, 0).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r, r + cubeSize, r, 8/64f, 0);
|
||||||
vertexBuffer.pos(r, r + cubeSize, r + cubeSize).tex(8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r, r + cubeSize, r + cubeSize, 8/64f, 8/64f);
|
||||||
vertexBuffer.pos(r + cubeSize, r + cubeSize, r + cubeSize).tex(2*8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r + cubeSize, r + cubeSize, r + cubeSize, 2*8/64f, 8/64f);
|
||||||
vertexBuffer.pos(r + cubeSize, r + cubeSize, r).tex(2 * 8 / 64f, 0).color(255, 255, 255, 200).endVertex();
|
renderer.addVertexWithUV(r + cubeSize, r + cubeSize, r, 2 * 8 / 64f, 0);
|
||||||
|
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package com.replaymod.simplepathing.properties;
|
||||||
|
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import com.replaymod.replaystudio.pathing.property.AbstractProperty;
|
||||||
|
import com.replaymod.replaystudio.pathing.property.PropertyPart;
|
||||||
|
import lombok.NonNull;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Property indicating that the next path segment's interpolator is fixed
|
||||||
|
*/
|
||||||
|
public class ExplicitInterpolationProperty extends AbstractProperty<Object> {
|
||||||
|
public static final ExplicitInterpolationProperty PROPERTY = new ExplicitInterpolationProperty();
|
||||||
|
|
||||||
|
private ExplicitInterpolationProperty() {
|
||||||
|
super("interpolationFixed", "<internal>", null, new Object());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<PropertyPart<Object>> getParts() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyToGame(Object value, @NonNull Object replayHandler) {
|
||||||
|
// dummy property, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toJson(JsonWriter writer, Object value) throws IOException {
|
||||||
|
writer.nullValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object fromJson(JsonReader reader) throws IOException {
|
||||||
|
reader.nextNull();
|
||||||
|
return ObjectUtils.NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
# To apply changes in this file run: ./gradlew clean setupDecompWorkspace idea
|
# To apply changes in this file run: ./gradlew clean setupDecompWorkspace idea
|
||||||
|
|
||||||
# Minecraft
|
# Minecraft
|
||||||
public-f net.minecraft.client.Minecraft field_71428_T # timer
|
public net.minecraft.client.Minecraft field_71428_T # timer
|
||||||
public net.minecraft.client.Minecraft field_83002_am # debugCrashKeyPressTime
|
public net.minecraft.client.Minecraft field_83002_am # debugCrashKeyPressTime
|
||||||
public net.minecraft.client.Minecraft field_71467_ac # rightClickDelayTimer
|
public net.minecraft.client.Minecraft field_71467_ac # rightClickDelayTimer
|
||||||
public net.minecraft.client.Minecraft field_71423_H # systemTime
|
public net.minecraft.client.Minecraft field_71423_H # systemTime
|
||||||
@@ -21,23 +21,23 @@ public net.minecraft.client.Minecraft func_147112_ai()V # middleClickMouse
|
|||||||
public net.minecraft.client.Minecraft func_147115_a(Z)V # sendClickBlockToController
|
public net.minecraft.client.Minecraft func_147115_a(Z)V # sendClickBlockToController
|
||||||
|
|
||||||
# Packets
|
# Packets
|
||||||
public net.minecraft.network.play.server.SPacketSpawnMob field_149043_l # dataManager
|
public net.minecraft.network.play.server.S0FPacketSpawnMob field_149043_l # dataWatcher
|
||||||
public net.minecraft.network.play.server.SPacketSpawnPlayer field_148960_i # watcher
|
|
||||||
#public net.minecraft.network.play.server.S38PacketPlayerListItem field_179964_d # profile
|
#public net.minecraft.network.play.server.S38PacketPlayerListItem field_179964_d # profile
|
||||||
# public net.minecraft.network.play.server.S1DPacketEntityEffect field_149434_a # entityId
|
public net.minecraft.network.play.server.S1DPacketEntityEffect field_149434_a # entityId
|
||||||
# public net.minecraft.network.play.server.S1CPacketEntityMetadata field_149379_a # entityId
|
public net.minecraft.network.play.server.S1CPacketEntityMetadata field_149379_a # entityId
|
||||||
# public net.minecraft.network.play.server.S1CPacketEntityMetadata field_149378_b # list
|
public net.minecraft.network.play.server.S1CPacketEntityMetadata field_149378_b # list
|
||||||
# public net.minecraft.network.play.server.S0BPacketAnimation field_148981_a # entityId
|
public net.minecraft.network.play.server.S0BPacketAnimation field_148981_a # entityId
|
||||||
# public net.minecraft.network.play.server.S02PacketChat field_179842_b # position
|
public net.minecraft.network.play.server.S02PacketChat field_179842_b # position
|
||||||
# public net.minecraft.network.play.server.S19PacketEntityStatus field_149164_a # entityId
|
public net.minecraft.network.play.server.S19PacketEntityStatus field_149164_a # entityId
|
||||||
# public net.minecraft.network.play.server.S18PacketEntityTeleport *
|
public net.minecraft.network.play.server.S0CPacketSpawnPlayer *
|
||||||
# public net.minecraft.network.play.server.S14PacketEntity *
|
public net.minecraft.network.play.server.S18PacketEntityTeleport *
|
||||||
# public net.minecraft.network.play.server.S19PacketEntityHeadLook *
|
public net.minecraft.network.play.server.S14PacketEntity *
|
||||||
# public net.minecraft.network.play.server.S12PacketEntityVelocity *
|
public net.minecraft.network.play.server.S19PacketEntityHeadLook *
|
||||||
# public net.minecraft.network.play.server.S04PacketEntityEquipment *
|
public net.minecraft.network.play.server.S12PacketEntityVelocity *
|
||||||
# public net.minecraft.network.play.server.S1BPacketEntityAttach *
|
public net.minecraft.network.play.server.S04PacketEntityEquipment *
|
||||||
# public net.minecraft.network.play.server.S0DPacketCollectItem *
|
public net.minecraft.network.play.server.S1BPacketEntityAttach *
|
||||||
# public net.minecraft.network.play.server.S13PacketDestroyEntities *
|
public net.minecraft.network.play.server.S0DPacketCollectItem *
|
||||||
|
public net.minecraft.network.play.server.S13PacketDestroyEntities *
|
||||||
|
|
||||||
# GuiTextField
|
# GuiTextField
|
||||||
public net.minecraft.client.gui.GuiTextField field_146216_j # text
|
public net.minecraft.client.gui.GuiTextField field_146216_j # text
|
||||||
@@ -61,7 +61,7 @@ public net.minecraft.client.renderer.RenderGlobal field_175009_l # chunksToUpdat
|
|||||||
public net.minecraft.client.renderer.RenderGlobal field_72755_R # renderInfos
|
public net.minecraft.client.renderer.RenderGlobal field_72755_R # renderInfos
|
||||||
public net.minecraft.client.renderer.RenderGlobal field_175009_l # chunksToUpdate
|
public net.minecraft.client.renderer.RenderGlobal field_175009_l # chunksToUpdate
|
||||||
public net.minecraft.client.renderer.RenderGlobal field_72740_G # renderEntitiesStartupCounter
|
public net.minecraft.client.renderer.RenderGlobal field_72740_G # renderEntitiesStartupCounter
|
||||||
# public net.minecraft.client.renderer.RenderGlobal func_174983_a(Lnet.minecraft.util.BlockPos;Lnet.minecraft.client.renderer.chunk.RenderChunk;)Z # isPositionInRenderChunk
|
public net.minecraft.client.renderer.RenderGlobal func_174983_a(Lnet.minecraft.util.BlockPos;Lnet.minecraft.client.renderer.chunk.RenderChunk;)Z # isPositionInRenderChunk
|
||||||
|
|
||||||
public net.minecraft.client.renderer.RenderGlobal$ContainerLocalRenderInformation
|
public net.minecraft.client.renderer.RenderGlobal$ContainerLocalRenderInformation
|
||||||
#public net.minecraft.client.renderer.RenderGlobal$ContainerLocalRenderInformation field_178553_a # renderChunk
|
#public net.minecraft.client.renderer.RenderGlobal$ContainerLocalRenderInformation field_178553_a # renderChunk
|
||||||
@@ -88,17 +88,17 @@ public net.minecraft.entity.player.EntityPlayer *
|
|||||||
public net.minecraft.client.entity.EntityOtherPlayerMP *
|
public net.minecraft.client.entity.EntityOtherPlayerMP *
|
||||||
|
|
||||||
# EffectRenderer
|
# EffectRenderer
|
||||||
# public net.minecraft.client.particle.EffectRenderer field_110737_b # particleTextures
|
public net.minecraft.client.particle.EffectRenderer field_110737_b # particleTextures
|
||||||
# public net.minecraft.client.particle.EffectRenderer field_78876_b # fxLayers
|
public net.minecraft.client.particle.EffectRenderer field_78876_b # fxLayers
|
||||||
|
|
||||||
# IntegratedServer
|
# IntegratedServer
|
||||||
public net.minecraft.server.integrated.IntegratedServer field_71348_o # isGamePaused
|
public net.minecraft.server.integrated.IntegratedServer field_71348_o # isGamePaused
|
||||||
|
|
||||||
# GameSettings
|
# GameSettings
|
||||||
public-f net.minecraft.client.settings.GameSettings field_186714_aM # soundLevels
|
public net.minecraft.client.settings.GameSettings field_151446_aD # mapSoundLevels
|
||||||
|
|
||||||
# Frustum
|
# Frustum
|
||||||
public-f net.minecraft.client.renderer.culling.Frustum field_78552_a # clippingHelper
|
public net.minecraft.client.renderer.culling.Frustum field_78552_a # clippingHelper
|
||||||
|
|
||||||
# CrashReportCategory
|
# CrashReportCategory
|
||||||
public net.minecraft.crash.CrashReportCategory field_85077_c # children
|
public net.minecraft.crash.CrashReportCategory field_85077_c # children
|
||||||
@@ -117,12 +117,5 @@ public net.minecraft.client.renderer.GlStateManager$FogState
|
|||||||
public net.minecraft.client.renderer.GlStateManager$BooleanState
|
public net.minecraft.client.renderer.GlStateManager$BooleanState
|
||||||
public net.minecraft.client.renderer.GlStateManager$BooleanState *
|
public net.minecraft.client.renderer.GlStateManager$BooleanState *
|
||||||
|
|
||||||
# EntityLivingBase
|
|
||||||
public net.minecraft.entity.EntityLivingBase field_184621_as # HAND_STATES
|
|
||||||
public net.minecraft.entity.EntityLivingBase field_184628_bn # activeItemStackUseCount
|
|
||||||
|
|
||||||
# EntityLivingBase
|
|
||||||
public net.minecraft.client.particle.Particle *
|
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
# public net.minecraft.package.ClassName func_some_id(Ljava/lang/Class;IZS)V # methodName
|
# public net.minecraft.package.ClassName func_some_id(Ljava/lang/Class;IZS)V # methodName
|
||||||
|
|||||||
@@ -292,6 +292,7 @@ replaymod.gui.settings.title=Replay Mod Settings
|
|||||||
|
|
||||||
replaymod.gui.settings.interpolation.linear=Linear
|
replaymod.gui.settings.interpolation.linear=Linear
|
||||||
replaymod.gui.settings.interpolation.cubic=Cubic
|
replaymod.gui.settings.interpolation.cubic=Cubic
|
||||||
|
replaymod.gui.settings.interpolation.catmullrom=Catmull Rom
|
||||||
|
|
||||||
replaymod.gui.settings.bitrate=Video Bitrate
|
replaymod.gui.settings.bitrate=Video Bitrate
|
||||||
replaymod.gui.settings.framerate=Video Framerate
|
replaymod.gui.settings.framerate=Video Framerate
|
||||||
@@ -309,6 +310,7 @@ replaymod.gui.settings.keyframecleancallback=Clear Confirmation
|
|||||||
replaymod.gui.settings.renderinvisible=Render invisible Entities
|
replaymod.gui.settings.renderinvisible=Render invisible Entities
|
||||||
replaymod.gui.settings.camera=Camera
|
replaymod.gui.settings.camera=Camera
|
||||||
replaymod.gui.settings.showchat=Show Chat
|
replaymod.gui.settings.showchat=Show Chat
|
||||||
|
replaymod.gui.settings.interpolator=Default Interpolator
|
||||||
|
|
||||||
replaymod.gui.settings.warning.linea=WARNING: Recording settings will be
|
replaymod.gui.settings.warning.linea=WARNING: Recording settings will be
|
||||||
replaymod.gui.settings.warning.lineb=applied the next time you join a world.
|
replaymod.gui.settings.warning.lineb=applied the next time you join a world.
|
||||||
@@ -372,6 +374,17 @@ replaymod.gui.editkeyframe.spec.method.shoulder.pitch=Pitch Offset
|
|||||||
replaymod.gui.editkeyframe.spec.method.shoulder.yaw=Rotation Angle
|
replaymod.gui.editkeyframe.spec.method.shoulder.yaw=Rotation Angle
|
||||||
replaymod.gui.editkeyframe.spec.method.shoulder.smoothness=Path Smoothness
|
replaymod.gui.editkeyframe.spec.method.shoulder.smoothness=Path Smoothness
|
||||||
|
|
||||||
|
replaymod.gui.editkeyframe.interpolator=Interpolator
|
||||||
|
replaymod.gui.editkeyframe.interpolator.default.name=Default Interpolator
|
||||||
|
replaymod.gui.editkeyframe.interpolator.default.desc=Uses the default interpolator defined in the Replay Mod Settings.
|
||||||
|
replaymod.gui.editkeyframe.interpolator.catmullrom.name=Catmull Rom Spline Interpolator
|
||||||
|
replaymod.gui.editkeyframe.interpolator.catmullrom.desc=Calculates a catmull rom spline with customizable alpha value for precise tightness and smoothness of the camera path.
|
||||||
|
replaymod.gui.editkeyframe.interpolator.catmullrom.alpha=Alpha:
|
||||||
|
replaymod.gui.editkeyframe.interpolator.cubic.name=Cubic Spline Interpolator
|
||||||
|
replaymod.gui.editkeyframe.interpolator.cubic.desc=Calculates a cubic equation matrix for all points for a smooth camera path.
|
||||||
|
replaymod.gui.editkeyframe.interpolator.linear.name=Linear Interpolator
|
||||||
|
replaymod.gui.editkeyframe.interpolator.linear.desc=Draws straight lines between the keyframes.
|
||||||
|
|
||||||
#Render Settings GUI
|
#Render Settings GUI
|
||||||
replaymod.gui.rendersettings.title=Rendering Options
|
replaymod.gui.rendersettings.title=Rendering Options
|
||||||
replaymod.gui.rendersettings.renderer=Rendering Method
|
replaymod.gui.rendersettings.renderer=Rendering Method
|
||||||
|
|||||||
20
src/main/resources/dst_root_ca_x3.pem
Normal file
20
src/main/resources/dst_root_ca_x3.pem
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/
|
||||||
|
MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT
|
||||||
|
DkRTVCBSb290IENBIFgzMB4XDTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVow
|
||||||
|
PzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMRcwFQYDVQQD
|
||||||
|
Ew5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
|
||||||
|
AN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmTrE4O
|
||||||
|
rz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEq
|
||||||
|
OLl5CjH9UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9b
|
||||||
|
xiqKqy69cK3FCxolkHRyxXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw
|
||||||
|
7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40dutolucbY38EVAjqr2m7xPi71XAicPNaD
|
||||||
|
aeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV
|
||||||
|
HQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQMA0GCSqG
|
||||||
|
SIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69
|
||||||
|
ikugdB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXr
|
||||||
|
AvHRAosZy5Q6XkjEGB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZz
|
||||||
|
R8srzJmwN0jP41ZL9c8PDHIyh8bwRLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5
|
||||||
|
JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubSfZGL+T0yjWW06XyxV3bqxbYo
|
||||||
|
Ob8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ
|
||||||
|
-----END CERTIFICATE-----
|
||||||
@@ -7,9 +7,7 @@
|
|||||||
"MixinNetHandlerLoginClient",
|
"MixinNetHandlerLoginClient",
|
||||||
"MixinNetHandlerPlayClient",
|
"MixinNetHandlerPlayClient",
|
||||||
"MixinNetworkDispatcher",
|
"MixinNetworkDispatcher",
|
||||||
"MixinPlayerControllerMP",
|
"MixinRenderGlobal"
|
||||||
"MixinRenderGlobal",
|
|
||||||
"MixinWorldClient"
|
|
||||||
],
|
],
|
||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"refmap": "mixins.replaymod.refmap.json"
|
"refmap": "mixins.replaymod.refmap.json"
|
||||||
|
|||||||
@@ -2,9 +2,10 @@
|
|||||||
"required": true,
|
"required": true,
|
||||||
"package": "com.replaymod.render.mixin",
|
"package": "com.replaymod.render.mixin",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"MixinEffectRenderer",
|
||||||
"MixinEntityRenderer",
|
"MixinEntityRenderer",
|
||||||
"MixinParticleManager",
|
|
||||||
"MixinRender",
|
"MixinRender",
|
||||||
|
"MixinRendererLivingEntity",
|
||||||
"MixinRenderGlobal",
|
"MixinRenderGlobal",
|
||||||
"MixinRenderManager"
|
"MixinRenderManager"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -2,13 +2,12 @@
|
|||||||
"required": true,
|
"required": true,
|
||||||
"package": "com.replaymod.replay.mixin",
|
"package": "com.replaymod.replay.mixin",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"MixinArmorStandRenderer",
|
||||||
"MixinGuiSpectator",
|
"MixinGuiSpectator",
|
||||||
"MixinParticleManager",
|
|
||||||
"MixinPlayerControllerMP",
|
"MixinPlayerControllerMP",
|
||||||
"MixinRenderArmorStand",
|
|
||||||
"MixinRenderArrow",
|
"MixinRenderArrow",
|
||||||
|
"MixinRendererLivingEntity",
|
||||||
"MixinRenderItem",
|
"MixinRenderItem",
|
||||||
"MixinRenderLivingBase",
|
|
||||||
"MixinRenderManager",
|
"MixinRenderManager",
|
||||||
"MixinTileEntityEndPortalRenderer",
|
"MixinTileEntityEndPortalRenderer",
|
||||||
"MixinViewFrustum",
|
"MixinViewFrustum",
|
||||||
|
|||||||
626
src/test/java/com/replaymod/simplepathing/SPTimelineTest.java
Normal file
626
src/test/java/com/replaymod/simplepathing/SPTimelineTest.java
Normal file
@@ -0,0 +1,626 @@
|
|||||||
|
package com.replaymod.simplepathing;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.replaymod.pathing.properties.CameraProperties;
|
||||||
|
import com.replaymod.pathing.properties.SpectatorProperty;
|
||||||
|
import com.replaymod.pathing.properties.TimestampProperty;
|
||||||
|
import com.replaymod.replaystudio.pathing.change.Change;
|
||||||
|
import com.replaymod.replaystudio.pathing.interpolation.CatmullRomSplineInterpolator;
|
||||||
|
import com.replaymod.replaystudio.pathing.interpolation.Interpolator;
|
||||||
|
import com.replaymod.replaystudio.pathing.interpolation.LinearInterpolator;
|
||||||
|
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
||||||
|
import com.replaymod.replaystudio.pathing.path.Path;
|
||||||
|
import com.replaymod.replaystudio.pathing.path.PathSegment;
|
||||||
|
import com.replaymod.replaystudio.pathing.path.Timeline;
|
||||||
|
import com.replaymod.replaystudio.util.EntityPositionTracker;
|
||||||
|
import com.replaymod.replaystudio.util.Location;
|
||||||
|
import com.replaymod.simplepathing.SPTimeline.SPPath;
|
||||||
|
import org.apache.commons.lang3.tuple.Triple;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.IdentityHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertSame;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
public class SPTimelineTest {
|
||||||
|
private SPTimeline impl;
|
||||||
|
private Timeline timeline;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setupLogger() {
|
||||||
|
ReplayModSimplePathing.LOGGER = LogManager.getLogger();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
impl = new SPTimeline();
|
||||||
|
impl.setDefaultInterpolatorType(InterpolatorType.CUBIC);
|
||||||
|
impl.setEntityTracker(new EntityPositionTrackerMock());
|
||||||
|
timeline = impl.getTimeline();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPath() {
|
||||||
|
assertSame(impl.getTimeline().getPaths().get(0), impl.getTimePath());
|
||||||
|
assertSame(impl.getTimeline().getPaths().get(0), impl.getPath(SPPath.TIME));
|
||||||
|
assertSame(impl.getTimeline().getPaths().get(1), impl.getPositionPath());
|
||||||
|
assertSame(impl.getTimeline().getPaths().get(1), impl.getPath(SPPath.POSITION));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetKeyframe() {
|
||||||
|
assertSame(timeline.getPaths().get(0).insert(123), impl.getKeyframe(SPPath.TIME, 123));
|
||||||
|
assertSame(timeline.getPaths().get(1).insert(456), impl.getKeyframe(SPPath.POSITION, 456));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsTimeKeyframe() {
|
||||||
|
impl.getTimePath().insert(123);
|
||||||
|
impl.getPositionPath().insert(456);
|
||||||
|
impl.getPositionPath().insert(42).setValue(SpectatorProperty.PROPERTY, 42);
|
||||||
|
assertTrue(impl.isTimeKeyframe(123));
|
||||||
|
assertFalse(impl.isTimeKeyframe(456));
|
||||||
|
assertFalse(impl.isTimeKeyframe(789));
|
||||||
|
assertFalse(impl.isTimeKeyframe(42));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsPositionKeyframe() {
|
||||||
|
impl.getTimePath().insert(123);
|
||||||
|
impl.getPositionPath().insert(456);
|
||||||
|
impl.getPositionPath().insert(42).setValue(SpectatorProperty.PROPERTY, 42);
|
||||||
|
assertFalse(impl.isPositionKeyframe(123));
|
||||||
|
assertTrue(impl.isPositionKeyframe(456));
|
||||||
|
assertFalse(impl.isPositionKeyframe(789));
|
||||||
|
assertTrue(impl.isSpectatorKeyframe(42));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsSpectatorKeyframe() {
|
||||||
|
impl.getTimePath().insert(123);
|
||||||
|
impl.getPositionPath().insert(456);
|
||||||
|
impl.getPositionPath().insert(42).setValue(SpectatorProperty.PROPERTY, 42);
|
||||||
|
assertFalse(impl.isSpectatorKeyframe(123));
|
||||||
|
assertFalse(impl.isSpectatorKeyframe(456));
|
||||||
|
assertFalse(impl.isSpectatorKeyframe(789));
|
||||||
|
assertTrue(impl.isSpectatorKeyframe(42));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddPositionKeyframe() {
|
||||||
|
assertNull(timeline.peekUndoStack());
|
||||||
|
impl.addPositionKeyframe(0, 1, 2, 3, 4, 5, 6, -1);
|
||||||
|
assertNotNull(timeline.peekUndoStack());
|
||||||
|
Keyframe keyframe = impl.getKeyframe(SPPath.POSITION, 0);
|
||||||
|
assertNotNull(keyframe);
|
||||||
|
assertEquals(keyframe.getValue(CameraProperties.POSITION), Optional.of(Triple.of(1d, 2d, 3d)));
|
||||||
|
assertEquals(keyframe.getValue(CameraProperties.ROTATION), Optional.of(Triple.of(4f, 5f, 6f)));
|
||||||
|
assertFalse(keyframe.getValue(SpectatorProperty.PROPERTY).isPresent());
|
||||||
|
timeline.undoLastChange();
|
||||||
|
assertNull(timeline.peekUndoStack());
|
||||||
|
assertNull(impl.getKeyframe(SPPath.POSITION, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddPositionKeyframeSpectator() {
|
||||||
|
assertNull(timeline.peekUndoStack());
|
||||||
|
impl.addPositionKeyframe(0, 1, 2, 3, 4, 5, 6, 7);
|
||||||
|
assertNotNull(timeline.peekUndoStack());
|
||||||
|
Keyframe keyframe = impl.getKeyframe(SPPath.POSITION, 0);
|
||||||
|
assertNotNull(keyframe);
|
||||||
|
assertEquals(keyframe.getValue(CameraProperties.POSITION), Optional.of(Triple.of(1d, 2d, 3d)));
|
||||||
|
assertEquals(keyframe.getValue(CameraProperties.ROTATION), Optional.of(Triple.of(4f, 5f, 6f)));
|
||||||
|
assertEquals(keyframe.getValue(SpectatorProperty.PROPERTY), Optional.of(7));
|
||||||
|
timeline.undoLastChange();
|
||||||
|
assertNull(timeline.peekUndoStack());
|
||||||
|
assertNull(impl.getKeyframe(SPPath.POSITION, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPositionKeyframeSpectatorPosition() {
|
||||||
|
Keyframe keyframe;
|
||||||
|
impl.addTimeKeyframe(0, 0);
|
||||||
|
impl.addTimeKeyframe(9, 9);
|
||||||
|
|
||||||
|
impl.addPositionKeyframe(4, 1, 2, 3, 4, 5, 6, 1);
|
||||||
|
keyframe = impl.getKeyframe(SPPath.POSITION, 4);
|
||||||
|
assertEquals(keyframe.getValue(CameraProperties.POSITION), Optional.of(Triple.of(1d, 2d, 3d)));
|
||||||
|
assertEquals(keyframe.getValue(CameraProperties.ROTATION), Optional.of(Triple.of(4f, 5f, 6f)));
|
||||||
|
|
||||||
|
impl.addPositionKeyframe(6, 1, 2, 3, 4, 5, 6, 42);
|
||||||
|
keyframe = impl.getKeyframe(SPPath.POSITION, 6);
|
||||||
|
assertEquals(keyframe.getValue(CameraProperties.POSITION), Optional.of(Triple.of(12d, 0d, 0d)));
|
||||||
|
assertEquals(keyframe.getValue(CameraProperties.ROTATION), Optional.of(Triple.of(0f, 0f, 0f)));
|
||||||
|
|
||||||
|
impl.addPositionKeyframe(8, 1, 2, 3, 4, 5, 6, 42);
|
||||||
|
keyframe = impl.getKeyframe(SPPath.POSITION, 8);
|
||||||
|
assertEquals(keyframe.getValue(CameraProperties.POSITION), Optional.of(Triple.of(16d, 0d, 0d)));
|
||||||
|
assertEquals(keyframe.getValue(CameraProperties.ROTATION), Optional.of(Triple.of(0f, 0f, 0f)));
|
||||||
|
|
||||||
|
impl.addPositionKeyframe(10, 1, 2, 3, 4, 5, 6, 42);
|
||||||
|
keyframe = impl.getKeyframe(SPPath.POSITION, 10);
|
||||||
|
assertEquals(keyframe.getValue(CameraProperties.POSITION), Optional.of(Triple.of(1d, 2d, 3d)));
|
||||||
|
assertEquals(keyframe.getValue(CameraProperties.ROTATION), Optional.of(Triple.of(4f, 5f, 6f)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalStateException.class)
|
||||||
|
public void testAddPositionKeyframeDuplicate() {
|
||||||
|
impl.addPositionKeyframe(0, 1, 2, 3, 4, 5, 6, -1);
|
||||||
|
impl.addPositionKeyframe(0, 1, 2, 3, 4, 5, 6, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdatePositionKeyframe() {
|
||||||
|
impl.addPositionKeyframe(0, 1, 2, 3, 4, 5, 6, -1);
|
||||||
|
Change change = impl.updatePositionKeyframe(0, 7, 8, 9, 10, 11, 12);
|
||||||
|
assertNotNull(change);
|
||||||
|
Keyframe keyframe = impl.getKeyframe(SPPath.POSITION, 0);
|
||||||
|
assertEquals(keyframe.getValue(CameraProperties.POSITION), Optional.of(Triple.of(7d, 8d, 9d)));
|
||||||
|
assertEquals(keyframe.getValue(CameraProperties.ROTATION), Optional.of(Triple.of(10f, 11f, 12f)));
|
||||||
|
assertFalse(keyframe.getValue(SpectatorProperty.PROPERTY).isPresent());
|
||||||
|
change.undo(timeline);
|
||||||
|
keyframe = impl.getKeyframe(SPPath.POSITION, 0);
|
||||||
|
assertEquals(keyframe.getValue(CameraProperties.POSITION), Optional.of(Triple.of(1d, 2d, 3d)));
|
||||||
|
assertEquals(keyframe.getValue(CameraProperties.ROTATION), Optional.of(Triple.of(4f, 5f, 6f)));
|
||||||
|
assertFalse(keyframe.getValue(SpectatorProperty.PROPERTY).isPresent());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalStateException.class)
|
||||||
|
public void testUpdatePositionKeyframeNoKeyframe() {
|
||||||
|
impl.updatePositionKeyframe(0, 1, 2, 3, 4, 5, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalStateException.class)
|
||||||
|
public void testUpdatePositionKeyframeSpectatorKeyframe() {
|
||||||
|
impl.addPositionKeyframe(0, 1, 2, 3, 4, 5, 6, 7);
|
||||||
|
impl.updatePositionKeyframe(0, 1, 2, 3, 4, 5, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRemovePositionKeyframe() {
|
||||||
|
impl.addPositionKeyframe(0, 1, 2, 3, 4, 5, 6, -1);
|
||||||
|
impl.removePositionKeyframe(0);
|
||||||
|
assertNull(impl.getKeyframe(SPPath.POSITION, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalStateException.class)
|
||||||
|
public void testRemovePositionKeyframeNoKeyframe() {
|
||||||
|
impl.removePositionKeyframe(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddTimeKeyframe() {
|
||||||
|
assertNull(timeline.peekUndoStack());
|
||||||
|
impl.addTimeKeyframe(0, 1);
|
||||||
|
assertNotNull(timeline.peekUndoStack());
|
||||||
|
Keyframe keyframe = impl.getKeyframe(SPPath.TIME, 0);
|
||||||
|
assertNotNull(keyframe);
|
||||||
|
assertEquals(keyframe.getValue(TimestampProperty.PROPERTY), Optional.of(1));
|
||||||
|
timeline.undoLastChange();
|
||||||
|
assertNull(timeline.peekUndoStack());
|
||||||
|
assertNull(impl.getKeyframe(SPPath.TIME, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalStateException.class)
|
||||||
|
public void testAddTimeKeyframeDuplicate() {
|
||||||
|
impl.addTimeKeyframe(0, 1);
|
||||||
|
impl.addTimeKeyframe(0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateTimeKeyframe() {
|
||||||
|
impl.addTimeKeyframe(0, 1);
|
||||||
|
Change change = impl.updateTimeKeyframe(0, 2);
|
||||||
|
assertNotNull(change);
|
||||||
|
assertEquals(impl.getKeyframe(SPPath.TIME, 0).getValue(TimestampProperty.PROPERTY), Optional.of(2));
|
||||||
|
change.undo(timeline);
|
||||||
|
assertEquals(impl.getKeyframe(SPPath.TIME, 0).getValue(TimestampProperty.PROPERTY), Optional.of(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalStateException.class)
|
||||||
|
public void testUpdateTimeKeyframeNoKeyframe() {
|
||||||
|
impl.updateTimeKeyframe(0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRemoveTimeKeyframe() {
|
||||||
|
impl.addTimeKeyframe(0, 1);
|
||||||
|
impl.removeTimeKeyframe(0);
|
||||||
|
assertNull(impl.getKeyframe(SPPath.TIME, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalStateException.class)
|
||||||
|
public void testRemoveTimeKeyframeNoKeyframe() {
|
||||||
|
impl.removeTimeKeyframe(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks all interpolators to make sure that they are continuous and not fragmented.
|
||||||
|
*/
|
||||||
|
private void assertValidInterpolators(SPPath path, int expectedNumberOfInterpolators) {
|
||||||
|
String str = prettyPrintInterpolators(impl, path);
|
||||||
|
List<Interpolator> interpolators = impl.getPath(path).getSegments().stream().map(PathSegment::getInterpolator)
|
||||||
|
.distinct().collect(Collectors.toList());
|
||||||
|
assertFalse("Not all interpolators set: " + str, interpolators.contains(null));
|
||||||
|
assertEquals("Mismatched interpolator number: " + str, expectedNumberOfInterpolators, interpolators.size());
|
||||||
|
int i = 0;
|
||||||
|
for (Interpolator interpolator : interpolators) {
|
||||||
|
Keyframe lastKeyframe = null;
|
||||||
|
for (PathSegment segment : interpolator.getSegments().stream()
|
||||||
|
.sorted(Comparator.comparing(s -> s.getStartKeyframe().getTime())).collect(Collectors.toList())) {
|
||||||
|
String message = "Fragmentation in interpolator " + i + ": " + str;
|
||||||
|
assertTrue(message, lastKeyframe == null || segment.getStartKeyframe() == lastKeyframe);
|
||||||
|
lastKeyframe = segment.getEndKeyframe();
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddPositionKeyframeAppend() {
|
||||||
|
addPosition(0, 0);
|
||||||
|
addPosition(1, 1);
|
||||||
|
addPosition(2, 1);
|
||||||
|
addPosition(3, 1);
|
||||||
|
addPosition(4, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddPositionKeyframePrepend() {
|
||||||
|
addPosition(4, 0);
|
||||||
|
addPosition(3, 1);
|
||||||
|
addPosition(2, 1);
|
||||||
|
addPosition(1, 1);
|
||||||
|
addPosition(0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddPositionKeyframeMixed() {
|
||||||
|
addPosition(2, 0);
|
||||||
|
addPosition(4, 1);
|
||||||
|
addPosition(3, 1);
|
||||||
|
addPosition(0, 1);
|
||||||
|
addPosition(1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddPositionSpectatorKeyframe() {
|
||||||
|
addPosition(0, 0);
|
||||||
|
addSpectator(1, 1);
|
||||||
|
addSpectator(2, 2);
|
||||||
|
addPosition(4, 3);
|
||||||
|
addPosition(7, 3);
|
||||||
|
addPosition(8, 3);
|
||||||
|
addSpectator(3, 3);
|
||||||
|
addSpectator(5, 3);
|
||||||
|
addSpectator(6, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRemovePositionKeyframeFromStart() {
|
||||||
|
addPosition(0, 0);
|
||||||
|
addPosition(1, 1);
|
||||||
|
addPosition(2, 1);
|
||||||
|
addPosition(3, 1);
|
||||||
|
removePosition(0, 1);
|
||||||
|
removePosition(1, 1);
|
||||||
|
removePosition(2, 0);
|
||||||
|
removePosition(3, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRemovePositionKeyframeFromEnd() {
|
||||||
|
addPosition(0, 0);
|
||||||
|
addPosition(1, 1);
|
||||||
|
addPosition(2, 1);
|
||||||
|
addPosition(3, 1);
|
||||||
|
removePosition(3, 1);
|
||||||
|
removePosition(2, 1);
|
||||||
|
removePosition(1, 0);
|
||||||
|
removePosition(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRemovePositionKeyframeFromMiddle() {
|
||||||
|
addPosition(0, 0);
|
||||||
|
addPosition(1, 1);
|
||||||
|
addPosition(2, 1);
|
||||||
|
addPosition(3, 1);
|
||||||
|
removePosition(1, 1);
|
||||||
|
removePosition(2, 1);
|
||||||
|
removePosition(0, 0);
|
||||||
|
removePosition(3, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRemovePositionSpectatorKeyframe() {
|
||||||
|
addPosition(0, 0);
|
||||||
|
addPosition(1, 1);
|
||||||
|
addPosition(2, 1);
|
||||||
|
addSpectator(3, 1);
|
||||||
|
addSpectator(4, 2);
|
||||||
|
addSpectator(5, 2);
|
||||||
|
addPosition(6, 3);
|
||||||
|
addPosition(7, 3);
|
||||||
|
addSpectator(8, 3);
|
||||||
|
addSpectator(9, 4);
|
||||||
|
removePosition(4, 4);
|
||||||
|
removePosition(9, 3);
|
||||||
|
removePosition(6, 3);
|
||||||
|
removePosition(7, 2);
|
||||||
|
removePosition(0, 2);
|
||||||
|
removePosition(1, 2);
|
||||||
|
removePosition(3, 2);
|
||||||
|
removePosition(2, 1);
|
||||||
|
removePosition(5, 0);
|
||||||
|
removePosition(8, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddTimeKeyframeAppend() {
|
||||||
|
addTime(0, 0);
|
||||||
|
addTime(1, 1);
|
||||||
|
addTime(2, 1);
|
||||||
|
addTime(3, 1);
|
||||||
|
addTime(4, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddTimeKeyframePrepend() {
|
||||||
|
addTime(4, 0);
|
||||||
|
addTime(3, 1);
|
||||||
|
addTime(2, 1);
|
||||||
|
addTime(1, 1);
|
||||||
|
addTime(0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddTimeKeyframeMixed() {
|
||||||
|
addTime(2, 0);
|
||||||
|
addTime(4, 1);
|
||||||
|
addTime(3, 1);
|
||||||
|
addTime(0, 1);
|
||||||
|
addTime(1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRemoveTimeKeyframeFromStart() {
|
||||||
|
addTime(0, 0);
|
||||||
|
addTime(1, 1);
|
||||||
|
addTime(2, 1);
|
||||||
|
addTime(3, 1);
|
||||||
|
removeTime(0, 1);
|
||||||
|
removeTime(1, 1);
|
||||||
|
removeTime(2, 0);
|
||||||
|
removeTime(3, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRemoveTimeKeyframeFromEnd() {
|
||||||
|
addTime(0, 0);
|
||||||
|
addTime(1, 1);
|
||||||
|
addTime(2, 1);
|
||||||
|
addTime(3, 1);
|
||||||
|
removeTime(3, 1);
|
||||||
|
removeTime(2, 1);
|
||||||
|
removeTime(1, 0);
|
||||||
|
removeTime(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRemoveTimeKeyframeFromMiddle() {
|
||||||
|
addTime(0, 0);
|
||||||
|
addTime(1, 1);
|
||||||
|
addTime(2, 1);
|
||||||
|
addTime(3, 1);
|
||||||
|
removeTime(1, 1);
|
||||||
|
removeTime(2, 1);
|
||||||
|
removeTime(0, 0);
|
||||||
|
removeTime(3, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetInterpolator() {
|
||||||
|
addPosition(0, 0);
|
||||||
|
addPosition(1, 1);
|
||||||
|
addPosition(2, 1);
|
||||||
|
setInterpolator(1, new LinearInterpolator(), 2);
|
||||||
|
assertIsLinear(1);
|
||||||
|
Interpolator interpolator = Iterables.get(impl.getPositionPath().getSegments(), 1).getInterpolator();
|
||||||
|
assertTrue(interpolator.getKeyframeProperties().contains(CameraProperties.POSITION));
|
||||||
|
assertTrue(interpolator.getKeyframeProperties().contains(CameraProperties.ROTATION));
|
||||||
|
addPosition(3, 3);
|
||||||
|
addPosition(4, 3);
|
||||||
|
addPosition(5, 3);
|
||||||
|
setInterpolator(3, new LinearInterpolator(), 5);
|
||||||
|
assertIsLinear(3);
|
||||||
|
removePosition(2, 3);
|
||||||
|
removePosition(3, 3);
|
||||||
|
removePosition(0, 2);
|
||||||
|
removePosition(1, 1);
|
||||||
|
removePosition(4, 0);
|
||||||
|
removePosition(5, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertIsLinear(int index) {
|
||||||
|
assertTrue("Expected segment " + index + " to have linear interpolator: " + prettyPrintInterpolators(impl, SPPath.POSITION),
|
||||||
|
Iterables.get(impl.getPositionPath().getSegments(), index).getInterpolator() instanceof LinearInterpolator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalStateException.class)
|
||||||
|
public void testSetInterpolatorNoKeyframe() {
|
||||||
|
addTime(0, 0);
|
||||||
|
impl.setInterpolator(0, new LinearInterpolator());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalStateException.class)
|
||||||
|
public void testSetInterpolatorToDefaultNoKeyframe() {
|
||||||
|
addTime(0, 0);
|
||||||
|
impl.setInterpolatorToDefault(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMoveKeyframe() {
|
||||||
|
addPosition(1, 0);
|
||||||
|
addPosition(3, 1);
|
||||||
|
addPosition(5, 1);
|
||||||
|
addPosition(7, 1);
|
||||||
|
addSpectator(9, 1);
|
||||||
|
addSpectator(11, 2);
|
||||||
|
addSpectator(13, 2);
|
||||||
|
addPosition(15, 3);
|
||||||
|
addPosition(17, 3);
|
||||||
|
addPosition(19, 3);
|
||||||
|
setInterpolator(3, new LinearInterpolator(), 5);
|
||||||
|
assertIsLinear(1);
|
||||||
|
setInterpolator(5, new LinearInterpolator(), 5);
|
||||||
|
assertIsLinear(2);
|
||||||
|
// [P 1] C0 [P 3] L1 [P 5] L1 [P 7] C2 [S 9] L3 [S 11] L3 [S 13] C4 [P 15] C4 [P 17] C4 [P 19]
|
||||||
|
|
||||||
|
impl.moveKeyframe(SPPath.POSITION, 5, 0);
|
||||||
|
assertValidInterpolators(SPPath.POSITION, 6);
|
||||||
|
assertIsLinear(0);
|
||||||
|
impl.moveKeyframe(SPPath.POSITION, 0, 5);
|
||||||
|
assertValidInterpolators(SPPath.POSITION, 5);
|
||||||
|
assertIsLinear(2);
|
||||||
|
|
||||||
|
impl.moveKeyframe(SPPath.POSITION, 3, 12);
|
||||||
|
assertValidInterpolators(SPPath.POSITION, 7);
|
||||||
|
assertIsLinear(5);
|
||||||
|
impl.moveKeyframe(SPPath.POSITION, 12, 3);
|
||||||
|
assertValidInterpolators(SPPath.POSITION, 5);
|
||||||
|
assertIsLinear(1);
|
||||||
|
|
||||||
|
impl.moveKeyframe(SPPath.POSITION, 7, 14);
|
||||||
|
assertValidInterpolators(SPPath.POSITION, 4);
|
||||||
|
impl.moveKeyframe(SPPath.POSITION, 14, 20);
|
||||||
|
assertValidInterpolators(SPPath.POSITION, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void testSetDefaultInterpolatorDifferentType() {
|
||||||
|
addPosition(0, 0);
|
||||||
|
addPosition(1, 1);
|
||||||
|
impl.setDefaultInterpolator(new CatmullRomSplineInterpolator(42));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetDefaultInterpolatorSameType() {
|
||||||
|
impl.setDefaultInterpolatorType(InterpolatorType.CATMULL_ROM);
|
||||||
|
addPosition(0, 0);
|
||||||
|
addSpectator(1, 1);
|
||||||
|
addSpectator(2, 2);
|
||||||
|
addPosition(3, 3);
|
||||||
|
addPosition(4, 3);
|
||||||
|
impl.setDefaultInterpolator(new CatmullRomSplineInterpolator(42));
|
||||||
|
assertValidInterpolators(SPPath.POSITION, 3);
|
||||||
|
assertIsCatmullRom(0, 42);
|
||||||
|
assertIsCatmullRom(2, 42);
|
||||||
|
assertIsCatmullRom(3, 42);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertIsCatmullRom(int index, double alpha) {
|
||||||
|
String str = prettyPrintInterpolators(impl, SPPath.POSITION);
|
||||||
|
Interpolator interpolator = Iterables.get(impl.getPositionPath().getSegments(), index).getInterpolator();
|
||||||
|
assertTrue("Expected segment " + index + " to be catmull rom interpolator: " + str,
|
||||||
|
interpolator instanceof CatmullRomSplineInterpolator);
|
||||||
|
assertTrue("Expected interpolator of segment segment " + index + " to have alpha " + alpha + ": " + str,
|
||||||
|
((CatmullRomSplineInterpolator) interpolator).getAlpha() == 42);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addPosition(int time, int expectedNumberOfInterpolators) {
|
||||||
|
impl.addPositionKeyframe(time, 1, 2, 3, 4, 5, 6, -1);
|
||||||
|
assertNotNull(impl.getKeyframe(SPPath.POSITION, time));
|
||||||
|
assertValidInterpolators(SPPath.POSITION, expectedNumberOfInterpolators);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addSpectator(int time, int expectedNumberOfInterpolators) {
|
||||||
|
impl.addPositionKeyframe(time, 1, 2, 3, 4, 5, 6, 42);
|
||||||
|
assertNotNull(impl.getKeyframe(SPPath.POSITION, time));
|
||||||
|
assertTrue(impl.isSpectatorKeyframe(time));
|
||||||
|
assertValidInterpolators(SPPath.POSITION, expectedNumberOfInterpolators);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addTime(int time, int expectedNumberOfInterpolators) {
|
||||||
|
impl.addTimeKeyframe(time, 1);
|
||||||
|
assertNotNull(impl.getKeyframe(SPPath.TIME, time));
|
||||||
|
assertValidInterpolators(SPPath.TIME, expectedNumberOfInterpolators);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removePosition(int time, int expectedNumberOfInterpolators) {
|
||||||
|
impl.removePositionKeyframe(time);
|
||||||
|
assertNull(impl.getKeyframe(SPPath.POSITION, time));
|
||||||
|
assertValidInterpolators(SPPath.POSITION, expectedNumberOfInterpolators);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeTime(int time, int expectedNumberOfInterpolators) {
|
||||||
|
impl.removeTimeKeyframe(time);
|
||||||
|
assertNull(impl.getKeyframe(SPPath.TIME, time));
|
||||||
|
assertValidInterpolators(SPPath.TIME, expectedNumberOfInterpolators);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setInterpolator(int time, Interpolator interpolator, int expectedNumberOfInterpolators) {
|
||||||
|
impl.setInterpolator(time, interpolator);
|
||||||
|
assertValidInterpolators(SPPath.POSITION, expectedNumberOfInterpolators);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertPositionState(String expected) {
|
||||||
|
assertEquals(expected, prettyPrintInterpolators(impl, SPPath.POSITION));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tracks only entity 42 which always is at x=time*2, y,z=0
|
||||||
|
private class EntityPositionTrackerMock extends EntityPositionTracker {
|
||||||
|
public EntityPositionTrackerMock() {
|
||||||
|
super(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Location getEntityPositionAtTimestamp(int entityID, long timestamp) {
|
||||||
|
if (entityID == 42) {
|
||||||
|
return new Location(timestamp * 2, 0 ,0, 0, 0);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String prettyPrintInterpolators(SPTimeline timeline, SPPath spPath) {
|
||||||
|
return prettyPrintInterpolators(timeline, spPath, Collections.emptyMap());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String prettyPrintInterpolators(SPTimeline timeline, SPPath spPath, Map<PathSegment, Interpolator> updates) {
|
||||||
|
Map<Interpolator, String> interpolatorIdMap = new IdentityHashMap<>();
|
||||||
|
Path path = timeline.getPath(spPath);
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (Keyframe keyframe : path.getKeyframes()) {
|
||||||
|
if (spPath == SPPath.TIME) {
|
||||||
|
sb.append("[T ").append(keyframe.getTime()).append("]");
|
||||||
|
} else if (keyframe.getValue(SpectatorProperty.PROPERTY).isPresent()) {
|
||||||
|
sb.append("[S ").append(keyframe.getTime()).append("]");
|
||||||
|
} else {
|
||||||
|
sb.append("[P ").append(keyframe.getTime()).append("]");
|
||||||
|
}
|
||||||
|
path.getSegments().stream().filter(s -> s.getStartKeyframe() == keyframe).findFirst().ifPresent(segment -> {
|
||||||
|
Interpolator interpolator = updates.getOrDefault(segment, segment.getInterpolator());
|
||||||
|
String id = interpolatorIdMap.computeIfAbsent(interpolator, i ->
|
||||||
|
(i instanceof LinearInterpolator ? "L" : "C") + interpolatorIdMap.size());
|
||||||
|
sb.append(' ').append(id).append(' ');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user