Compare commits
47 Commits
1.9.4-2.0.
...
1.8.9-2.0.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed566732df | ||
|
|
91573d9487 | ||
|
|
d71358bcba | ||
|
|
1a55983986 | ||
|
|
18c5bcd469 | ||
|
|
c054fe83f6 | ||
|
|
f13297c5a5 | ||
|
|
391f304c5f | ||
|
|
0e0eaaa9a7 | ||
|
|
a34bbbcd68 | ||
|
|
60879fbbed | ||
|
|
dfafbecf35 | ||
|
|
8a6ec5191b | ||
|
|
5677fc54cb | ||
|
|
748a91e7b2 | ||
|
|
ee24866f29 | ||
|
|
dba085c700 | ||
|
|
3f0e3e725e | ||
|
|
40e1d850da | ||
|
|
03aada1f5f | ||
|
|
0c1dc658ad | ||
|
|
fcbbbc9ea1 | ||
|
|
fe6ded0143 | ||
|
|
f58fa8f9c2 | ||
|
|
4fc3a3166c | ||
|
|
24c58cbbe7 | ||
|
|
1ffeb010d5 | ||
|
|
c122d30065 | ||
|
|
27fd25ae84 | ||
|
|
db6b0ff5a6 | ||
|
|
d61d0ac670 | ||
|
|
f7460f9bf5 | ||
|
|
bdbffd5c33 | ||
|
|
5cbfd2884e | ||
|
|
6095aef3d1 | ||
|
|
3f52336852 | ||
|
|
c6293bcbb0 | ||
|
|
c8126edbb2 | ||
|
|
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
|
||||||
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -5,3 +5,7 @@
|
|||||||
[submodule "ReplayStudio"]
|
[submodule "ReplayStudio"]
|
||||||
path = ReplayStudio
|
path = ReplayStudio
|
||||||
url = https://github.com/ReplayMod/ReplayStudio
|
url = https://github.com/ReplayMod/ReplayStudio
|
||||||
|
|
||||||
|
[submodule "src/main/resources/assets/replaymod/lang"]
|
||||||
|
path = src/main/resources/assets/replaymod/lang
|
||||||
|
url = https://github.com/ReplayMod/Translations
|
||||||
|
|||||||
Submodule ReplayStudio updated: 44f7345b6b...ff12b1db0b
63
build.gradle
63
build.gradle
@@ -1,7 +1,5 @@
|
|||||||
import groovy.json.JsonOutput
|
import groovy.json.JsonOutput
|
||||||
|
|
||||||
import java.util.zip.ZipInputStream
|
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@@ -20,7 +18,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
|
||||||
classpath 'org.spongepowered:mixingradle:0.4-SNAPSHOT'
|
classpath 'org.spongepowered:mixingradle:0.3-SNAPSHOT'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,9 +34,9 @@ archivesBaseName = "replaymod"
|
|||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
coreMod = 'com.replaymod.core.LoadingPlugin'
|
coreMod = 'com.replaymod.core.LoadingPlugin'
|
||||||
version = '1.9.4-12.17.0.1976'
|
version = '1.8.9-11.15.1.1722'
|
||||||
runDir = "eclipse"
|
runDir = "eclipse"
|
||||||
mappings = "snapshot_20160518"
|
mappings = "stable_22"
|
||||||
replace '@MOD_VERSION@', project.version
|
replace '@MOD_VERSION@', project.version
|
||||||
replace '@MC_VERSION@', project.minecraft.version
|
replace '@MC_VERSION@', project.minecraft.version
|
||||||
}
|
}
|
||||||
@@ -61,7 +59,7 @@ configurations {
|
|||||||
dependencies {
|
dependencies {
|
||||||
compile 'org.projectlombok:lombok:1.16.4'
|
compile 'org.projectlombok:lombok:1.16.4'
|
||||||
|
|
||||||
compile 'org.spongepowered:mixin:0.6.4-SNAPSHOT'
|
compile 'org.spongepowered:mixin:0.6.8-SNAPSHOT'
|
||||||
shade 'com.googlecode.mp4parser:isoparser:1.1.7'
|
shade 'com.googlecode.mp4parser:isoparser:1.1.7'
|
||||||
shade 'org.apache.commons:commons-exec:1.3'
|
shade 'org.apache.commons:commons-exec:1.3'
|
||||||
shade 'com.google.apis:google-api-services-youtube:v3-rev178-1.22.0'
|
shade 'com.google.apis:google-api-services-youtube:v3-rev178-1.22.0'
|
||||||
@@ -103,27 +101,6 @@ jar {
|
|||||||
}
|
}
|
||||||
from noticeDir
|
from noticeDir
|
||||||
|
|
||||||
def langDir = file("$buildDir/languages")
|
|
||||||
doFirst {
|
|
||||||
try {
|
|
||||||
langDir.deleteDir()
|
|
||||||
langDir.mkdirs()
|
|
||||||
def dir = new File(langDir, 'assets/replaymod/lang/')
|
|
||||||
dir.mkdirs()
|
|
||||||
def zip = new ZipInputStream(new URL('http://replaymod.com/api/grab_languages').openStream())
|
|
||||||
def e;
|
|
||||||
while ((e = zip.nextEntry) != null) {
|
|
||||||
new File(dir, e.getName()) << zip
|
|
||||||
zip.closeEntry()
|
|
||||||
}
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
from (langDir) {
|
|
||||||
exclude '**/en_US.lang'
|
|
||||||
}
|
|
||||||
|
|
||||||
from ({shade().collect { it.isDirectory() ? it : zipTree(it) }}) {
|
from ({shade().collect { it.isDirectory() ? it : zipTree(it) }}) {
|
||||||
exclude '**/NOTICE*'
|
exclude '**/NOTICE*'
|
||||||
// exclude everything taken in from jGui for running the mod in a dev environment
|
// exclude everything taken in from jGui for running the mod in a dev environment
|
||||||
@@ -138,7 +115,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'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -189,6 +165,13 @@ sourceSets {
|
|||||||
}
|
}
|
||||||
refMap = "mixins.replaymod.refmap.json"
|
refMap = "mixins.replaymod.refmap.json"
|
||||||
}
|
}
|
||||||
|
integrationTest {
|
||||||
|
compileClasspath += main.runtimeClasspath + main.output
|
||||||
|
java {
|
||||||
|
srcDir file('src/integration-test/java')
|
||||||
|
}
|
||||||
|
resources.srcDir file('src/integration-test/resources')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task copySrg(type: Copy, dependsOn: 'genSrgs') {
|
task copySrg(type: Copy, dependsOn: 'genSrgs') {
|
||||||
@@ -200,6 +183,30 @@ setupDecompWorkspace.dependsOn copySrg
|
|||||||
setupDevWorkspace.dependsOn copySrg
|
setupDevWorkspace.dependsOn copySrg
|
||||||
project.tasks.idea.dependsOn copySrg
|
project.tasks.idea.dependsOn copySrg
|
||||||
|
|
||||||
|
task runIntegrationTest(type: JavaExec, dependsOn: ["makeStart", "jar"]) {
|
||||||
|
main = 'GradleStart'
|
||||||
|
standardOutput = System.out
|
||||||
|
errorOutput = System.err
|
||||||
|
workingDir file(minecraft.runDir)
|
||||||
|
|
||||||
|
def testDir = new File(minecraft.runDir, "integration-test")
|
||||||
|
doFirst {
|
||||||
|
testDir.deleteDir()
|
||||||
|
testDir.mkdirs()
|
||||||
|
}
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
testDir.deleteDir()
|
||||||
|
}
|
||||||
|
|
||||||
|
afterEvaluate {
|
||||||
|
def runClient = tasks.getByName("runClient")
|
||||||
|
runIntegrationTest.jvmArgs = runClient.jvmArgs + "-Dfml.noGrab=true"
|
||||||
|
runIntegrationTest.args = runClient.args + "--gameDir" + testDir.canonicalPath
|
||||||
|
runIntegrationTest.classpath runClient.classpath + sourceSets.integrationTest.output
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def generateVersionsJson() {
|
def generateVersionsJson() {
|
||||||
// List all tags
|
// List all tags
|
||||||
def stdout = new ByteArrayOutputStream()
|
def stdout = new ByteArrayOutputStream()
|
||||||
|
|||||||
@@ -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...1e92ad85df
30
src/integration-test/java/IntegrationTest.java
Normal file
30
src/integration-test/java/IntegrationTest.java
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entry point for running integration tests from within the IDE.
|
||||||
|
* This is <b>not</b> called when running integration tests directly from gradle.
|
||||||
|
*/
|
||||||
|
public class IntegrationTest {
|
||||||
|
public static void main(String[] args) throws Throwable {
|
||||||
|
// Prevent MC from grabbing our mouse during the test (it's not needed)
|
||||||
|
System.setProperty("fml.noGrab", "true");
|
||||||
|
|
||||||
|
// Make sure the test folder exists and is fresh
|
||||||
|
File gameDir = new File(System.getProperty("user.dir"), "integration-test");
|
||||||
|
if (gameDir.exists()) {
|
||||||
|
FileUtils.forceDelete(gameDir);
|
||||||
|
}
|
||||||
|
FileUtils.forceMkdir(gameDir);
|
||||||
|
|
||||||
|
// Set game dir to test folder and call regular entry point
|
||||||
|
List<String> argsList = new ArrayList<>(Arrays.asList(args));
|
||||||
|
argsList.add("--gameDir");
|
||||||
|
argsList.add(gameDir.getCanonicalPath());
|
||||||
|
GradleStart.main(argsList.toArray(new String[argsList.size()]));
|
||||||
|
}
|
||||||
|
}
|
||||||
342
src/integration-test/java/com/replaymod/core/AbstractTask.java
Normal file
342
src/integration-test/java/com/replaymod/core/AbstractTask.java
Normal file
@@ -0,0 +1,342 @@
|
|||||||
|
package com.replaymod.core;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
import com.google.common.util.concurrent.SettableFuture;
|
||||||
|
import de.johni0702.minecraft.gui.container.AbstractGuiOverlay;
|
||||||
|
import de.johni0702.minecraft.gui.container.AbstractGuiScreen;
|
||||||
|
import de.johni0702.minecraft.gui.container.GuiContainer;
|
||||||
|
import de.johni0702.minecraft.gui.container.GuiOverlay;
|
||||||
|
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||||
|
import de.johni0702.minecraft.gui.element.GuiButton;
|
||||||
|
import de.johni0702.minecraft.gui.element.GuiElement;
|
||||||
|
import de.johni0702.minecraft.gui.element.GuiTexturedButton;
|
||||||
|
import de.johni0702.minecraft.gui.popup.AbstractGuiPopup;
|
||||||
|
import de.johni0702.minecraft.gui.utils.Consumer;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import static com.replaymod.core.ReplayModIntegrationTest.LOGGER;
|
||||||
|
import static com.replaymod.core.utils.Utils.addCallback;
|
||||||
|
|
||||||
|
public abstract class AbstractTask implements Task {
|
||||||
|
public static Task create(Consumer<AbstractTask> init) {
|
||||||
|
return new AbstractTask() {
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
init.consume(this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
public final ReplayMod core = ReplayMod.instance;
|
||||||
|
public SettableFuture<Void> future;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ListenableFuture<Void> execute() {
|
||||||
|
future = SettableFuture.create();
|
||||||
|
|
||||||
|
FMLCommonHandler.instance().bus().register(this);
|
||||||
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
addCallback(future, success -> {
|
||||||
|
FMLCommonHandler.instance().bus().unregister(this);
|
||||||
|
MinecraftForge.EVENT_BUS.unregister(this);
|
||||||
|
}, error -> {});
|
||||||
|
|
||||||
|
init();
|
||||||
|
|
||||||
|
return future;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void init() {}
|
||||||
|
|
||||||
|
protected void runLater(Runnable runnable) {
|
||||||
|
core.runLater(() -> {
|
||||||
|
try {
|
||||||
|
runnable.run();
|
||||||
|
} catch (Throwable t) {
|
||||||
|
future.setException(t);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void expectGuiClosed(Runnable onClosed) {
|
||||||
|
expectGuiClosed0(10, onClosed);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void expectGuiClosed(int timeout, Runnable onClosed) {
|
||||||
|
expectGuiClosed0(timeout, onClosed);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void expectGuiClosed0(int timeout, Runnable onClosed) {
|
||||||
|
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
|
||||||
|
class EventHandler {
|
||||||
|
final net.minecraft.client.gui.GuiScreen currentScreen = mc.currentScreen;
|
||||||
|
int framesPassed;
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onGuiOpen(TickEvent.RenderTickEvent event) {
|
||||||
|
if (event.phase != TickEvent.Phase.START) return;
|
||||||
|
if (currentScreen != mc.currentScreen) {
|
||||||
|
FMLCommonHandler.instance().bus().unregister(this);
|
||||||
|
onClosed.run();
|
||||||
|
} else {
|
||||||
|
if (framesPassed < timeout) {
|
||||||
|
framesPassed++;
|
||||||
|
} else {
|
||||||
|
Object gui = (gui = GuiScreen.from(currentScreen)) == null ? currentScreen : gui;
|
||||||
|
Exception e = new TimeoutException("Timeout while waiting for " + gui + " to be closed.");
|
||||||
|
e.setStackTrace(Arrays.copyOfRange(stackTrace, 3, stackTrace.length));
|
||||||
|
future.setException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FMLCommonHandler.instance().bus().register(new EventHandler());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void expectPopupClosed(Runnable onClosed) {
|
||||||
|
expectPopupClosed0(10, onClosed);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void expectPopupClosed(int timeout, Runnable onClosed) {
|
||||||
|
expectPopupClosed0(timeout, onClosed);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void expectPopupClosed0(int timeout, Runnable onClosed) {
|
||||||
|
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
|
||||||
|
AbstractGuiPopup popup = getPopup(mc.currentScreen);
|
||||||
|
if (popup == null) {
|
||||||
|
throw new IllegalStateException("No popup found.");
|
||||||
|
}
|
||||||
|
class EventHandler {
|
||||||
|
int framesPassed;
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onGuiOpen(TickEvent.RenderTickEvent event) {
|
||||||
|
if (event.phase != TickEvent.Phase.START) return;
|
||||||
|
if (getPopup(mc.currentScreen) != popup) {
|
||||||
|
FMLCommonHandler.instance().bus().unregister(this);
|
||||||
|
onClosed.run();
|
||||||
|
} else {
|
||||||
|
if (framesPassed < timeout) {
|
||||||
|
framesPassed++;
|
||||||
|
} else {
|
||||||
|
Exception e = new TimeoutException("Timeout while waiting for " + popup + " to be closed.");
|
||||||
|
e.setStackTrace(Arrays.copyOfRange(stackTrace, 3, stackTrace.length));
|
||||||
|
future.setException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FMLCommonHandler.instance().bus().register(new EventHandler());
|
||||||
|
}
|
||||||
|
|
||||||
|
private AbstractGuiPopup getPopup(net.minecraft.client.gui.GuiScreen minecraft) {
|
||||||
|
GuiContainer<?> container = GuiOverlay.from(minecraft);
|
||||||
|
if (container == null) {
|
||||||
|
container = GuiScreen.from(minecraft);
|
||||||
|
}
|
||||||
|
if (container != null) {
|
||||||
|
while (container.getContainer() != null) {
|
||||||
|
container = container.getContainer();
|
||||||
|
}
|
||||||
|
GuiElement popup = Iterables.getLast(container.getChildren());
|
||||||
|
if (popup instanceof AbstractGuiPopup) {
|
||||||
|
return (AbstractGuiPopup) popup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void expectGui(Class<T> guiClass, Consumer<T> onOpen) {
|
||||||
|
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
|
||||||
|
class EventHandler {
|
||||||
|
net.minecraft.client.gui.GuiScreen currentScreen;
|
||||||
|
int framesPassed;
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onGuiOpen(TickEvent.RenderTickEvent event) {
|
||||||
|
if (event.phase != TickEvent.Phase.START) return;
|
||||||
|
if (currentScreen != mc.currentScreen) {
|
||||||
|
currentScreen = mc.currentScreen;
|
||||||
|
framesPassed = 0;
|
||||||
|
}
|
||||||
|
if (framesPassed < 10) {
|
||||||
|
framesPassed++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FMLCommonHandler.instance().bus().unregister(this);
|
||||||
|
|
||||||
|
Object foundGui = null;
|
||||||
|
if (AbstractGuiScreen.class.isAssignableFrom(guiClass)) {
|
||||||
|
AbstractGuiScreen guiScreen = GuiScreen.from(currentScreen);
|
||||||
|
if (guiClass.isInstance(guiScreen)) {
|
||||||
|
onOpen.consume(guiClass.cast(guiScreen));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foundGui = guiScreen;
|
||||||
|
} else if (AbstractGuiOverlay.class.isAssignableFrom(guiClass)) {
|
||||||
|
AbstractGuiOverlay guiScreen = GuiOverlay.from(currentScreen);
|
||||||
|
if (guiClass.isInstance(guiScreen)) {
|
||||||
|
onOpen.consume(guiClass.cast(guiScreen));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foundGui = guiScreen;
|
||||||
|
} else if (AbstractGuiPopup.class.isAssignableFrom(guiClass)) {
|
||||||
|
AbstractGuiPopup popup = getPopup(currentScreen);
|
||||||
|
if (guiClass.isInstance(popup)) {
|
||||||
|
onOpen.consume(guiClass.cast(popup));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (guiClass.isInstance(currentScreen)) {
|
||||||
|
onOpen.consume(guiClass.cast(currentScreen));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class UnexpectedGuiException extends Exception {
|
||||||
|
UnexpectedGuiException(Object foundGui) {
|
||||||
|
super("Expected instance of " + guiClass + " but found " + foundGui);
|
||||||
|
setStackTrace(Arrays.copyOfRange(stackTrace, 2, stackTrace.length));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
future.setException(new UnexpectedGuiException(foundGui == null ? currentScreen : foundGui));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FMLCommonHandler.instance().bus().register(new EventHandler());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clickNow(int x, int y) {
|
||||||
|
try {
|
||||||
|
Method method = net.minecraft.client.gui.GuiScreen.class
|
||||||
|
.getDeclaredMethod("mouseClicked", int.class, int.class, int.class);
|
||||||
|
method.setAccessible(true);
|
||||||
|
method.invoke(mc.currentScreen, x, y, 0);
|
||||||
|
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
||||||
|
future.setException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void click(int x, int y) {
|
||||||
|
runLater(() -> {
|
||||||
|
LOGGER.info("Clicking at {}/{}", x, y);
|
||||||
|
clickNow(x, y);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dragNow(int x, int y) {
|
||||||
|
try {
|
||||||
|
Method method = net.minecraft.client.gui.GuiScreen.class
|
||||||
|
.getDeclaredMethod("mouseClickMove", int.class, int.class, int.class, long.class);
|
||||||
|
method.setAccessible(true);
|
||||||
|
method.invoke(mc.currentScreen, x, y, 0, 0);
|
||||||
|
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
||||||
|
future.setException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drag(int x, int y) {
|
||||||
|
runLater(() -> {
|
||||||
|
LOGGER.info("Dragging to {}/{}", x, y);
|
||||||
|
dragNow(x, y);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void click(GuiButton button) {
|
||||||
|
runLater(() -> {
|
||||||
|
if (!button.isEnabled()) {
|
||||||
|
future.setException(new IllegalStateException("Button is disabled: " + button.getLabel()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LOGGER.info("Clicking button {}", button.getLabel());
|
||||||
|
button.onClick();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void click(GuiTexturedButton button) {
|
||||||
|
runLater(() -> {
|
||||||
|
if (!button.isEnabled()) {
|
||||||
|
future.setException(new IllegalStateException("Button is disabled: " + button.getTexture()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LOGGER.info("Clicking textured button {}", button.getTexture());
|
||||||
|
button.onClick();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void click(String buttonText) {
|
||||||
|
runLater(() -> {
|
||||||
|
LOGGER.info("Clicking button {}", buttonText);
|
||||||
|
try {
|
||||||
|
Field field = net.minecraft.client.gui.GuiScreen.class.getDeclaredField("buttonList");
|
||||||
|
field.setAccessible(true);
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<net.minecraft.client.gui.GuiButton> buttonList = (List)
|
||||||
|
field.get(mc.currentScreen);
|
||||||
|
|
||||||
|
net.minecraft.client.gui.GuiButton button = null;
|
||||||
|
for (net.minecraft.client.gui.GuiButton guiButton : buttonList) {
|
||||||
|
if (guiButton.displayString.equals(buttonText)) {
|
||||||
|
button = guiButton;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (button == null) {
|
||||||
|
future.setException(new NoSuchElementException("No button with label: " + buttonText));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
clickNow(button.xPosition + 5, button.yPosition + 5);
|
||||||
|
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||||
|
future.setException(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void type(String string) {
|
||||||
|
for (char c : string.toCharArray()) {
|
||||||
|
press(c, Keyboard.getKeyIndex(String.valueOf(c).toUpperCase()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void press(int keyCode) {
|
||||||
|
String keyName = Keyboard.getKeyName(keyCode);
|
||||||
|
char character = keyName.length() == 1 ? keyName.charAt(0) : '\0';
|
||||||
|
press(character, keyCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void press(char character, int keyCode) {
|
||||||
|
runLater(() -> {
|
||||||
|
LOGGER.info("Pressing key {}", Keyboard.getKeyName(keyCode));
|
||||||
|
if (mc.currentScreen == null || mc.currentScreen.allowUserInput) {
|
||||||
|
KeyBinding.onTick(keyCode);
|
||||||
|
FMLCommonHandler.instance().fireKeyInput();
|
||||||
|
}
|
||||||
|
if (mc.currentScreen != null) {
|
||||||
|
try {
|
||||||
|
Method method = net.minecraft.client.gui.GuiScreen.class
|
||||||
|
.getDeclaredMethod("keyTyped", char.class, int.class);
|
||||||
|
method.setAccessible(true);
|
||||||
|
method.invoke(mc.currentScreen, character, keyCode);
|
||||||
|
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
||||||
|
future.setException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.replaymod.core;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
import com.google.common.util.concurrent.SettableFuture;
|
||||||
|
|
||||||
|
import static com.replaymod.core.ReplayModIntegrationTest.LOGGER;
|
||||||
|
import static com.replaymod.core.utils.Utils.addCallback;
|
||||||
|
|
||||||
|
public class CompositeTask implements Task {
|
||||||
|
private SettableFuture<Void> future;
|
||||||
|
protected final Task[] children;
|
||||||
|
|
||||||
|
public CompositeTask(Task[] children) {
|
||||||
|
this.children = children;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ListenableFuture<Void> execute() {
|
||||||
|
future = SettableFuture.create();
|
||||||
|
executeChild(0);
|
||||||
|
return future;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void executeChild(int childIndex) {
|
||||||
|
if (future.isDone()) return;
|
||||||
|
if (childIndex < children.length) {
|
||||||
|
ReplayMod.instance.runLater(() -> {
|
||||||
|
try {
|
||||||
|
Task task = children[childIndex];
|
||||||
|
LOGGER.info("Running task {}", task);
|
||||||
|
ListenableFuture<Void> childFuture = task.execute();
|
||||||
|
addCallback(childFuture, done -> executeChild(childIndex + 1), err -> future.setException(err));
|
||||||
|
} catch (Throwable t) {
|
||||||
|
future.setException(t);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
future.set(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package com.replaymod.core;
|
||||||
|
|
||||||
|
import com.replaymod.core.regression.RegressionTest60;
|
||||||
|
import com.replaymod.core.regression.RegressionTest61;
|
||||||
|
import com.replaymod.core.regression.RegressionTest62;
|
||||||
|
import com.replaymod.extra.DownloadOpenEye;
|
||||||
|
import com.replaymod.online.SkipLogin;
|
||||||
|
import com.replaymod.recording.CreateSPWorld;
|
||||||
|
import com.replaymod.recording.ExitSPWorld;
|
||||||
|
import com.replaymod.replay.ExitReplay;
|
||||||
|
import com.replaymod.replay.LoadReplay;
|
||||||
|
import com.replaymod.replay.OpenReplayViewer;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import static com.replaymod.core.AbstractTask.mc;
|
||||||
|
import static com.replaymod.core.ReplayModIntegrationTest.MOD_ID;
|
||||||
|
import static com.replaymod.core.utils.Utils.addCallback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper mod that initiates the integration tests.
|
||||||
|
*/
|
||||||
|
@Mod(modid = MOD_ID)
|
||||||
|
public class ReplayModIntegrationTest {
|
||||||
|
public static final String MOD_ID = "replaymod-integration-test";
|
||||||
|
|
||||||
|
public static Logger LOGGER;
|
||||||
|
|
||||||
|
@Mod.EventHandler
|
||||||
|
public void init(FMLPreInitializationEvent event) {
|
||||||
|
LOGGER = event.getModLog();
|
||||||
|
|
||||||
|
// Make sure the game window doesn't have to remain in focus during the test
|
||||||
|
mc.gameSettings.pauseOnLostFocus = false;
|
||||||
|
|
||||||
|
runTasks(
|
||||||
|
new SkipLogin(),
|
||||||
|
new DownloadOpenEye(),
|
||||||
|
new CreateSPWorld(),
|
||||||
|
new Wait(5000),
|
||||||
|
new ExitSPWorld(),
|
||||||
|
new OpenReplayViewer(),
|
||||||
|
new LoadReplay(),
|
||||||
|
|
||||||
|
new RegressionTest60(),
|
||||||
|
new RegressionTest61(),
|
||||||
|
new RegressionTest62(),
|
||||||
|
|
||||||
|
// new AbstractTask() {}, // Uncomment to not exit on success (useful for writing more tests)
|
||||||
|
new ExitReplay()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runTasks(Task... tests) {
|
||||||
|
addCallback(new CompositeTask(tests).execute(), success -> {
|
||||||
|
if (!Minecraft.getMinecraft().hasCrashed) {
|
||||||
|
LOGGER.info("===================================================");
|
||||||
|
LOGGER.info("= ALL TESTS PASSED =");
|
||||||
|
LOGGER.info("===================================================");
|
||||||
|
FMLCommonHandler.instance().exitJava(0, false);
|
||||||
|
}
|
||||||
|
}, error -> {
|
||||||
|
LOGGER.error("Failed task:", error);
|
||||||
|
LOGGER.error("===================================================");
|
||||||
|
LOGGER.error("= TEST FAILED =");
|
||||||
|
LOGGER.error("===================================================");
|
||||||
|
FMLCommonHandler.instance().exitJava(1, false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
35
src/integration-test/java/com/replaymod/core/Task.java
Normal file
35
src/integration-test/java/com/replaymod/core/Task.java
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
package com.replaymod.core;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
public interface Task {
|
||||||
|
ListenableFuture<Void> execute();
|
||||||
|
|
||||||
|
static Task click(int x, int y) {
|
||||||
|
return AbstractTask.create(task -> {
|
||||||
|
task.click(x, y);
|
||||||
|
task.runLater(() -> task.future.set(null));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static Task drag(int x, int y) {
|
||||||
|
return AbstractTask.create(task -> {
|
||||||
|
task.drag(x, y);
|
||||||
|
task.runLater(() -> task.future.set(null));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static Task pressKey(int keyCode) {
|
||||||
|
return AbstractTask.create(task -> {
|
||||||
|
task.press(keyCode);
|
||||||
|
task.runLater(() -> task.future.set(null));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static Task pressKey(char character, int keyCode) {
|
||||||
|
return AbstractTask.create(task -> {
|
||||||
|
task.press(character, keyCode);
|
||||||
|
task.runLater(() -> task.future.set(null));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
9
src/integration-test/java/com/replaymod/core/Utils.java
Normal file
9
src/integration-test/java/com/replaymod/core/Utils.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package com.replaymod.core;
|
||||||
|
|
||||||
|
public class Utils {
|
||||||
|
public static void times(int x, Runnable runnable) {
|
||||||
|
for (int i = 0; i < x; i++) {
|
||||||
|
runnable.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
21
src/integration-test/java/com/replaymod/core/Wait.java
Normal file
21
src/integration-test/java/com/replaymod/core/Wait.java
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package com.replaymod.core;
|
||||||
|
|
||||||
|
public class Wait extends AbstractTask {
|
||||||
|
private final int duration;
|
||||||
|
|
||||||
|
public Wait(int duration) {
|
||||||
|
this.duration = duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
Thread.sleep(duration);
|
||||||
|
runLater(() -> future.set(null));
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
runLater(() -> future.setException(e));
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package com.replaymod.core.regression;
|
||||||
|
|
||||||
|
import com.replaymod.core.AbstractTask;
|
||||||
|
import com.replaymod.core.CompositeTask;
|
||||||
|
import com.replaymod.core.Task;
|
||||||
|
import com.replaymod.replay.SpectatePlayer;
|
||||||
|
import com.replaymod.replay.overlay.OverlayGui;
|
||||||
|
import com.replaymod.simplepathing.GuiPathingTasks;
|
||||||
|
import com.replaymod.simplepathing.gui.GuiEditKeyframe;
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
|
import static com.replaymod.core.AbstractTask.mc;
|
||||||
|
import static com.replaymod.core.Utils.times;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regression test: #60 Crash in path preview when two spectator keyframes are closer than 50ms
|
||||||
|
*/
|
||||||
|
public class RegressionTest60 extends CompositeTask {
|
||||||
|
public RegressionTest60() {
|
||||||
|
super(new Task[]{
|
||||||
|
new SpectatePlayer(),
|
||||||
|
OverlayGui.whileOpened(
|
||||||
|
// Place first spectator keyframe
|
||||||
|
new GuiPathingTasks.ClickPositionKeyframeButton(),
|
||||||
|
// Place second spectator keyframe
|
||||||
|
Task.click(130, 50),
|
||||||
|
new GuiPathingTasks.ClickPositionKeyframeButton(),
|
||||||
|
// Move second keyframe to 20ms on the keyframe timeline
|
||||||
|
AbstractTask.create(task -> {
|
||||||
|
// Double click keyframe
|
||||||
|
task.click(130, 50);
|
||||||
|
task.click(130, 50);
|
||||||
|
task.expectGui(GuiEditKeyframe.Spectator.class, gui -> {
|
||||||
|
// Set ms field to 20
|
||||||
|
task.click(mc.currentScreen.width / 2 + 80, mc.currentScreen.height / 2);
|
||||||
|
times(4, () -> task.press(Keyboard.KEY_BACK));
|
||||||
|
task.type("20");
|
||||||
|
// Set other fields to 0
|
||||||
|
times(2, () -> {
|
||||||
|
task.press(Keyboard.KEY_TAB);
|
||||||
|
times(4, () -> task.press(Keyboard.KEY_BACK));
|
||||||
|
task.press(Keyboard.KEY_0);
|
||||||
|
});
|
||||||
|
task.click(gui.saveButton);
|
||||||
|
task.expectPopupClosed(() -> task.future.set(null));
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
// Place second spectator keyframe
|
||||||
|
new GuiPathingTasks.ClickPositionKeyframeButton()
|
||||||
|
),
|
||||||
|
// Stop spectating player
|
||||||
|
new SpectatePlayer.End(),
|
||||||
|
// Enable path preview
|
||||||
|
Task.pressKey(Keyboard.KEY_H),
|
||||||
|
new GuiPathingTasks.ClearKeyframeTimeline(),
|
||||||
|
Task.pressKey(Keyboard.KEY_H),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.replaymod.core.regression;
|
||||||
|
|
||||||
|
import com.replaymod.core.AbstractTask;
|
||||||
|
import com.replaymod.core.CompositeTask;
|
||||||
|
import com.replaymod.core.Task;
|
||||||
|
import com.replaymod.replay.overlay.OverlayGui;
|
||||||
|
import com.replaymod.simplepathing.GuiPathingTasks;
|
||||||
|
import com.replaymod.simplepathing.gui.GuiEditKeyframe;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regression test: #61 NPE when saving in edit keyframe gui of last keyframe
|
||||||
|
*/
|
||||||
|
public class RegressionTest61 extends CompositeTask {
|
||||||
|
public RegressionTest61() {
|
||||||
|
super(new Task[]{
|
||||||
|
OverlayGui.whileOpened(
|
||||||
|
// Place keyframe
|
||||||
|
Task.click(130, 50),
|
||||||
|
new GuiPathingTasks.ClickPositionKeyframeButton(),
|
||||||
|
AbstractTask.create(task -> {
|
||||||
|
// Double click keyframe
|
||||||
|
task.click(130, 50);
|
||||||
|
task.click(130, 50);
|
||||||
|
task.expectGui(GuiEditKeyframe.Position.class, gui -> {
|
||||||
|
task.click(gui.saveButton);
|
||||||
|
task.expectPopupClosed(() -> task.future.set(null));
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
// Place second spectator keyframe
|
||||||
|
new GuiPathingTasks.ClickPositionKeyframeButton()
|
||||||
|
),
|
||||||
|
new GuiPathingTasks.ClearKeyframeTimeline(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.replaymod.core.regression;
|
||||||
|
|
||||||
|
import com.replaymod.core.CompositeTask;
|
||||||
|
import com.replaymod.core.Task;
|
||||||
|
import com.replaymod.replay.overlay.OverlayGui;
|
||||||
|
import com.replaymod.simplepathing.GuiPathingTasks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regression test: #62 Swapping the only two existing keyframes causes NPE
|
||||||
|
*/
|
||||||
|
public class RegressionTest62 extends CompositeTask {
|
||||||
|
public RegressionTest62() {
|
||||||
|
super(new Task[]{
|
||||||
|
OverlayGui.whileOpened(
|
||||||
|
// Place first keyframe
|
||||||
|
Task.click(130, 50),
|
||||||
|
new GuiPathingTasks.ClickPositionKeyframeButton(),
|
||||||
|
// Place second keyframe
|
||||||
|
Task.click(150, 50),
|
||||||
|
new GuiPathingTasks.ClickPositionKeyframeButton(),
|
||||||
|
// Move first keyframe past second keyframe
|
||||||
|
Task.click(130,50),
|
||||||
|
Task.drag(170,50)
|
||||||
|
),
|
||||||
|
new GuiPathingTasks.ClearKeyframeTimeline()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.replaymod.extra;
|
||||||
|
|
||||||
|
import com.replaymod.core.AbstractTask;
|
||||||
|
import com.replaymod.extras.OpenEyeExtra;
|
||||||
|
import net.minecraftforge.fml.common.Loader;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.file.NoSuchFileException;
|
||||||
|
|
||||||
|
public class DownloadOpenEye extends AbstractTask {
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
expectGui(OpenEyeExtra.OfferGui.class, offerGui -> {
|
||||||
|
click(offerGui.yesButton);
|
||||||
|
expectGuiClosed(20 * 1000, () -> {
|
||||||
|
File targetFile = new File(mc.mcDataDir, "mods/" + Loader.MC_VERSION + "/OpenEye.jar");
|
||||||
|
if (!targetFile.exists()) {
|
||||||
|
future.setException(new NoSuchFileException(targetFile.getAbsolutePath()));
|
||||||
|
} else {
|
||||||
|
future.set(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.replaymod.online;
|
||||||
|
|
||||||
|
import com.replaymod.core.AbstractTask;
|
||||||
|
import com.replaymod.online.gui.GuiLoginPrompt;
|
||||||
|
|
||||||
|
public class SkipLogin extends AbstractTask {
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
expectGui(GuiLoginPrompt.class, gui -> {
|
||||||
|
click(gui.cancelButton);
|
||||||
|
expectGuiClosed(() -> future.set(null));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.replaymod.recording;
|
||||||
|
|
||||||
|
import com.replaymod.core.AbstractTask;
|
||||||
|
import net.minecraft.client.gui.GuiCreateWorld;
|
||||||
|
import net.minecraft.client.gui.GuiMainMenu;
|
||||||
|
import net.minecraft.client.gui.GuiSelectWorld;
|
||||||
|
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
|
public class CreateSPWorld extends AbstractTask {
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
expectGui(GuiMainMenu.class, mainMenu -> {
|
||||||
|
click("Singleplayer");
|
||||||
|
expectGui(GuiSelectWorld.class, selectWorld -> {
|
||||||
|
click("Create New World");
|
||||||
|
expectGui(GuiCreateWorld.class, createWorld -> {
|
||||||
|
click("Create New World");
|
||||||
|
class EventHandler {
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onRenderIngame(RenderGameOverlayEvent.Pre event) {
|
||||||
|
MinecraftForge.EVENT_BUS.unregister(this);
|
||||||
|
runLater(() -> future.set(null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MinecraftForge.EVENT_BUS.register(new EventHandler());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.replaymod.recording;
|
||||||
|
|
||||||
|
import com.replaymod.core.AbstractTask;
|
||||||
|
import net.minecraft.client.gui.GuiIngameMenu;
|
||||||
|
import net.minecraft.client.gui.GuiMainMenu;
|
||||||
|
import org.apache.commons.io.filefilter.DirectoryFileFilter;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ExitSPWorld extends AbstractTask {
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
mc.displayInGameMenu();
|
||||||
|
expectGui(GuiIngameMenu.class, ingameMenu -> {
|
||||||
|
click("Save and Quit to Title");
|
||||||
|
expectGui(GuiMainMenu.class, mainMenu -> new Thread(() -> {
|
||||||
|
try {
|
||||||
|
while (true) {
|
||||||
|
String[] dirs = core.getReplayFolder().list(DirectoryFileFilter.DIRECTORY);
|
||||||
|
if (dirs == null) {
|
||||||
|
future.setException(new NullPointerException("dirs is null"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (dirs.length == 0) {
|
||||||
|
runLater(() -> future.set(null));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Thread.sleep(10);
|
||||||
|
}
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
future.setException(e);
|
||||||
|
}
|
||||||
|
}).start());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.replaymod.replay;
|
||||||
|
|
||||||
|
import com.replaymod.core.AbstractTask;
|
||||||
|
import net.minecraft.client.gui.GuiIngameMenu;
|
||||||
|
import net.minecraft.client.gui.GuiMainMenu;
|
||||||
|
|
||||||
|
public class ExitReplay extends AbstractTask {
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
mc.displayInGameMenu();
|
||||||
|
expectGui(GuiIngameMenu.class, ingameMenu -> {
|
||||||
|
click("Exit Replay");
|
||||||
|
expectGui(GuiMainMenu.class, mainMenu -> future.set(null));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.replaymod.replay;
|
||||||
|
|
||||||
|
import com.replaymod.core.AbstractTask;
|
||||||
|
import com.replaymod.replay.gui.screen.GuiReplayViewer;
|
||||||
|
import de.johni0702.minecraft.gui.function.Clickable;
|
||||||
|
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import org.lwjgl.util.Point;
|
||||||
|
import org.lwjgl.util.ReadableDimension;
|
||||||
|
|
||||||
|
public class LoadReplay extends AbstractTask {
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
expectGui(GuiReplayViewer.class, replayViewer -> runLater(() -> {
|
||||||
|
ReadableDimension size = replayViewer.getMaxSize();
|
||||||
|
// Select first entry
|
||||||
|
replayViewer.forEach(Clickable.class).mouseClick(new Point(size.getWidth() / 2, 40), 0);
|
||||||
|
// Load first replay
|
||||||
|
click(replayViewer.loadButton);
|
||||||
|
|
||||||
|
class EventHandler {
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onRenderIngame(RenderGameOverlayEvent.Pre event) {
|
||||||
|
MinecraftForge.EVENT_BUS.unregister(this);
|
||||||
|
runLater(() -> future.set(null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MinecraftForge.EVENT_BUS.register(new EventHandler());
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.replaymod.replay;
|
||||||
|
|
||||||
|
import com.replaymod.core.AbstractTask;
|
||||||
|
import com.replaymod.replay.gui.screen.GuiReplayViewer;
|
||||||
|
import net.minecraft.client.gui.GuiMainMenu;
|
||||||
|
|
||||||
|
public class OpenReplayViewer extends AbstractTask {
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
expectGui(GuiMainMenu.class, mainMenu -> {
|
||||||
|
click("Replay Viewer");
|
||||||
|
expectGui(GuiReplayViewer.class, replayViewer -> future.set(null));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.replaymod.replay;
|
||||||
|
|
||||||
|
import com.replaymod.core.AbstractTask;
|
||||||
|
import com.replaymod.extras.playeroverview.PlayerOverviewGui;
|
||||||
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
public class SpectatePlayer extends AbstractTask {
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
press(Keyboard.KEY_B);
|
||||||
|
expectGui(PlayerOverviewGui.class, overview -> {
|
||||||
|
click(overview.getMaxSize().getWidth() / 2 - 60, 60);
|
||||||
|
press(Keyboard.KEY_ESCAPE);
|
||||||
|
expectGuiClosed(() -> future.set(null));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class End extends AbstractTask {
|
||||||
|
private int timeout;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
runLater(() -> press(Keyboard.KEY_LSHIFT));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onTick(TickEvent.RenderTickEvent event) {
|
||||||
|
if (event.phase != TickEvent.Phase.START) return;
|
||||||
|
if (timeout++ > 20) {
|
||||||
|
future.setException(new TimeoutException("Camera hasn't stopped spectating."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (mc.getRenderViewEntity() == mc.thePlayer) {
|
||||||
|
future.set(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.replaymod.replay.overlay;
|
||||||
|
|
||||||
|
import com.replaymod.core.AbstractTask;
|
||||||
|
import com.replaymod.core.CompositeTask;
|
||||||
|
import com.replaymod.core.Task;
|
||||||
|
import com.replaymod.replay.gui.overlay.GuiReplayOverlay;
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
|
public class OverlayGui {
|
||||||
|
public static Task whileOpened(Task...tasks) {
|
||||||
|
Task[] nTasks = new Task[tasks.length + 2];
|
||||||
|
System.arraycopy(tasks, 0, nTasks, 1, tasks.length);
|
||||||
|
nTasks[0] = new Open();
|
||||||
|
nTasks[tasks.length + 1] = new Close();
|
||||||
|
return new CompositeTask(nTasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Open extends AbstractTask {
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
press(Keyboard.KEY_T);
|
||||||
|
expectGui(GuiReplayOverlay.class, done -> future.set(null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Close extends AbstractTask {
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
press(Keyboard.KEY_ESCAPE);
|
||||||
|
expectGuiClosed(() -> future.set(null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.replaymod.simplepathing;
|
||||||
|
|
||||||
|
import com.replaymod.core.AbstractTask;
|
||||||
|
import com.replaymod.replay.gui.overlay.GuiReplayOverlay;
|
||||||
|
import com.replaymod.simplepathing.gui.GuiPathing;
|
||||||
|
import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
|
public abstract class GuiPathingTasks extends AbstractTask {
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
expectGui(GuiReplayOverlay.class, ign -> init0(ReplayModSimplePathing.instance.getGuiPathing()));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void init0(GuiPathing guiPathing);
|
||||||
|
|
||||||
|
public static class ClickPositionKeyframeButton extends GuiPathingTasks {
|
||||||
|
@Override
|
||||||
|
protected void init0(GuiPathing guiPathing) {
|
||||||
|
click(guiPathing.positionKeyframeButton);
|
||||||
|
runLater(() -> future.set(null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ClearKeyframeTimeline extends AbstractTask {
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
press(Keyboard.KEY_C);
|
||||||
|
expectGui(GuiYesNoPopup.class, popup -> {
|
||||||
|
click(popup.getYesButton());
|
||||||
|
expectGuiClosed(() -> future.set(null));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,15 @@ 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.ChatComponentText;
|
||||||
|
import net.minecraft.util.ChatComponentTranslation;
|
||||||
|
import net.minecraft.util.ChatStyle;
|
||||||
|
import net.minecraft.util.EnumChatFormatting;
|
||||||
|
import net.minecraft.util.IChatComponent;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
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;
|
||||||
@@ -67,6 +72,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 +116,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();
|
||||||
@@ -190,13 +197,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,7 +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 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,7 +35,7 @@ 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 vertexBuffer = 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);
|
vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.replaymod.core.utils;
|
|||||||
|
|
||||||
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.common.util.concurrent.ListenableFuture;
|
||||||
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.AbstractGuiScrollable;
|
import de.johni0702.minecraft.gui.container.AbstractGuiScrollable;
|
||||||
@@ -25,14 +26,28 @@ import org.lwjgl.input.Keyboard;
|
|||||||
import org.lwjgl.util.Dimension;
|
import org.lwjgl.util.Dimension;
|
||||||
import org.lwjgl.util.ReadableDimension;
|
import org.lwjgl.util.ReadableDimension;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
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;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import static net.minecraft.client.Minecraft.getMinecraft;
|
import static net.minecraft.client.Minecraft.getMinecraft;
|
||||||
|
|
||||||
@@ -51,6 +66,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 +138,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();
|
||||||
@@ -101,6 +152,20 @@ public class Utils {
|
|||||||
return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
|
return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> void addCallback(ListenableFuture<T> future, Consumer<T> onSuccess, Consumer<Throwable> onFailure) {
|
||||||
|
Futures.addCallback(future, new FutureCallback<T>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(@Nullable T result) {
|
||||||
|
onSuccess.accept(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@Nonnull Throwable t) {
|
||||||
|
onFailure.accept(t);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static GuiInfoPopup error(Logger logger, GuiContainer container, CrashReport crashReport, Runnable onClose) {
|
public static GuiInfoPopup error(Logger logger, GuiContainer container, CrashReport crashReport, Runnable onClose) {
|
||||||
// Convert crash report to string
|
// Convert crash report to string
|
||||||
String crashReportStr = crashReport.getCompleteReport();
|
String crashReportStr = crashReport.getCompleteReport();
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
@@ -57,6 +59,9 @@ public class GuiReplayEditor extends GuiScreen {
|
|||||||
public GuiButton currentTabButton;
|
public GuiButton currentTabButton;
|
||||||
public GuiPanel currentTabPanel;
|
public GuiPanel currentTabPanel;
|
||||||
|
|
||||||
|
public final GuiLabel warningLabel = new GuiLabel(this).setColor(Colors.RED)
|
||||||
|
.setI18nText("replaymod.gui.editor.disclaimer");
|
||||||
|
|
||||||
public final GuiPanel tabButtons = new GuiPanel(this).setLayout(new GridLayout().setSpacingX(5));
|
public final GuiPanel tabButtons = new GuiPanel(this).setLayout(new GridLayout().setSpacingX(5));
|
||||||
public final List<GuiPanel> tabPanels = new ArrayList<>();
|
public final List<GuiPanel> tabPanels = new ArrayList<>();
|
||||||
|
|
||||||
@@ -82,15 +87,18 @@ public class GuiReplayEditor extends GuiScreen {
|
|||||||
// Move all inactive panels aside
|
// Move all inactive panels aside
|
||||||
tabPanels.forEach(e -> pos(e, Integer.MIN_VALUE, Integer.MIN_VALUE));
|
tabPanels.forEach(e -> pos(e, Integer.MIN_VALUE, Integer.MIN_VALUE));
|
||||||
|
|
||||||
|
pos(warningLabel, 10, 22);
|
||||||
|
size(warningLabel, width - 20, 10);
|
||||||
|
|
||||||
|
pos(tabButtons, 10, y(warningLabel) + height(warningLabel) + 2);
|
||||||
|
size(tabButtons, width - 20, 20);
|
||||||
|
|
||||||
pos(buttonPanel, width - 10 - width(buttonPanel), height - 10 - height(buttonPanel));
|
pos(buttonPanel, width - 10 - width(buttonPanel), height - 10 - height(buttonPanel));
|
||||||
|
|
||||||
if (currentTabPanel != null) {
|
if (currentTabPanel != null) {
|
||||||
pos(currentTabPanel, 10, 50);
|
pos(currentTabPanel, 10, y(tabButtons) + height(tabButtons) + 10);
|
||||||
size(currentTabPanel, width - 20, y(buttonPanel) - 10 - y(currentTabPanel));
|
size(currentTabPanel, width - 20, y(buttonPanel) - 10 - y(currentTabPanel));
|
||||||
}
|
}
|
||||||
|
|
||||||
pos(tabButtons, 10, 20);
|
|
||||||
size(tabButtons, width - 20, 20);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -119,10 +127,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 +173,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
|
||||||
|
|||||||
@@ -1,106 +1,110 @@
|
|||||||
package com.replaymod.extras;
|
package com.replaymod.extras;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.replaymod.core.ReplayMod;
|
import com.replaymod.core.ReplayMod;
|
||||||
import com.replaymod.online.ReplayModOnline;
|
|
||||||
import com.replaymod.online.api.ApiClient;
|
|
||||||
import com.replaymod.online.api.ApiException;
|
|
||||||
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.io.IOUtils;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.ConnectException;
|
import java.net.URL;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
|
import static com.replaymod.extras.ReplayModExtras.LOGGER;
|
||||||
|
|
||||||
public class LocalizationExtra implements Extra {
|
public class LocalizationExtra implements Extra {
|
||||||
private ReplayModOnline module;
|
private static final String ZIP_FILE_URL = "https://github.com/ReplayMod/Translations/archive/master.zip";
|
||||||
|
private static final String LANG_PREFIX = "Translations-master/";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(ReplayMod mod) throws Exception {
|
public void register(ReplayMod mod) throws Exception {
|
||||||
this.module = ReplayModOnline.instance;
|
|
||||||
|
|
||||||
final Minecraft mc = mod.getMinecraft();
|
final Minecraft mc = mod.getMinecraft();
|
||||||
Thread localizedResourcePackLoader = new Thread(new Runnable() {
|
if (Boolean.parseBoolean(System.getProperty("replaymod.offline", "false"))) {
|
||||||
@Override
|
return;
|
||||||
public void run() {
|
}
|
||||||
try {
|
Thread localizedResourcePackLoader = new Thread(() -> {
|
||||||
|
try {
|
||||||
|
// Download zip of lang files
|
||||||
|
LOGGER.debug("Downloading languages from {}", ZIP_FILE_URL);
|
||||||
|
Map<String, byte[]> languages = new HashMap<>();
|
||||||
|
try (InputStream urlIn = new URL(ZIP_FILE_URL).openStream();
|
||||||
|
ZipInputStream in = new ZipInputStream(urlIn)) {
|
||||||
|
ZipEntry entry;
|
||||||
|
while ((entry = in.getNextEntry()) != null) {
|
||||||
|
String name = entry.getName();
|
||||||
|
if (!name.startsWith(LANG_PREFIX) || !name.endsWith(".lang")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
name = name.substring(LANG_PREFIX.length());
|
||||||
|
languages.put(name, IOUtils.toByteArray(in));
|
||||||
|
LOGGER.debug("Added language file {}", name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LOGGER.debug("Downloaded {} languages", languages.size());
|
||||||
|
|
||||||
|
// Add lang files as resource pack
|
||||||
|
mc.addScheduledTask(() -> {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<IResourcePack> defaultResourcePacks = mc.defaultResourcePacks;
|
List<IResourcePack> defaultResourcePacks = mc.defaultResourcePacks;
|
||||||
defaultResourcePacks.add(new LocalizedResourcePack(module.getApiClient()));
|
defaultResourcePacks.add(new LocalizedResourcePack(languages));
|
||||||
mc.addScheduledTask(new Runnable() {
|
mc.getLanguageManager().onResourceManagerReload(mc.getResourceManager());
|
||||||
@Override
|
LOGGER.debug("Added language files to resource packs and reloaded LanguageManager");
|
||||||
public void run() {
|
});
|
||||||
mc.refreshResources();
|
} catch (Throwable t) {
|
||||||
}
|
LOGGER.error("Loading localized resource pack:", t);
|
||||||
});
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, "localizedResourcePackLoader");
|
}, "localizedResourcePackLoader");
|
||||||
|
localizedResourcePackLoader.setDaemon(true);
|
||||||
localizedResourcePackLoader.start();
|
localizedResourcePackLoader.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public static class LocalizedResourcePack implements IResourcePack {
|
public static class LocalizedResourcePack implements IResourcePack {
|
||||||
private final ApiClient apiClient;
|
private final Pattern LANG_PATTERN = Pattern.compile("^lang/([.+].lang)$");
|
||||||
private Map<String, String> availableLanguages = new HashMap<>();
|
private final Map<String, byte[]> languages;
|
||||||
private boolean websiteAvailable = true;
|
|
||||||
|
public LocalizedResourcePack(Map<String, byte[]> languages) {
|
||||||
|
this.languages = languages;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream getInputStream(ResourceLocation loc) {
|
public InputStream getInputStream(ResourceLocation loc) {
|
||||||
if(!loc.getResourcePath().endsWith(".lang")) return null;
|
if (!"replaymod".equals(loc.getResourceDomain())) return null;
|
||||||
String langcode = loc.getResourcePath().split("/")[1].split("\\.")[0];
|
Matcher matcher = LANG_PATTERN.matcher(loc.getResourcePath());
|
||||||
if(availableLanguages.containsKey(langcode)) return new ByteArrayInputStream(availableLanguages.get(langcode).getBytes(Charsets.UTF_8));
|
if (matcher.matches()) {
|
||||||
|
byte[] bytes = languages.get(matcher.group());
|
||||||
|
if (bytes != null) {
|
||||||
|
return new ByteArrayInputStream(bytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean resourceExists(ResourceLocation loc) {
|
public boolean resourceExists(ResourceLocation loc) {
|
||||||
if(!(loc.getResourcePath().endsWith(".lang"))) return false;
|
// Assumes that getInputStream returns a ByteArrayInputStream that doesn't need to be closed
|
||||||
String langcode = loc.getResourcePath().split("/")[1].split("\\.")[0];
|
return getInputStream(loc) != null;
|
||||||
if(availableLanguages.containsKey(langcode)) return true;
|
|
||||||
if(!websiteAvailable) return false;
|
|
||||||
try {
|
|
||||||
if (Boolean.parseBoolean(System.getProperty("replaymod.offline", "false"))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String lang = apiClient.getTranslation(langcode);
|
|
||||||
String prop = StringEscapeUtils.unescapeHtml4(lang);
|
|
||||||
availableLanguages.put(langcode, prop);
|
|
||||||
return true;
|
|
||||||
} catch (ApiException e) {
|
|
||||||
if (e.getError().getId() != 16) { // This language has not been translated
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
} catch(ConnectException ce) {
|
|
||||||
websiteAvailable = false;
|
|
||||||
ce.printStackTrace();
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getResourceDomains() {
|
public Set getResourceDomains() {
|
||||||
return ImmutableSet.of("minecraft", "replaymod");
|
return ImmutableSet.of("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;
|
||||||
@@ -40,7 +43,7 @@ public class OpenEyeExtra implements Extra {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class OfferGui extends AbstractGuiScreen<OfferGui> {
|
public class OfferGui extends AbstractGuiScreen<OfferGui> {
|
||||||
public final GuiScreen parent;
|
public final GuiScreen parent;
|
||||||
public final GuiPanel textPanel = new GuiPanel().setLayout(new VerticalLayout().setSpacing(3))
|
public final GuiPanel textPanel = new GuiPanel().setLayout(new VerticalLayout().setSpacing(3))
|
||||||
.addElements(new VerticalLayout.Data(0.5),
|
.addElements(new VerticalLayout.Data(0.5),
|
||||||
@@ -66,10 +69,12 @@ public class OpenEyeExtra implements Extra {
|
|||||||
GuiPopup popup = new GuiPopup(OfferGui.this);
|
GuiPopup popup = new GuiPopup(OfferGui.this);
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
File targetFile = new File("mods/" + Loader.MC_VERSION, "OpenEye.jar");
|
File targetFile = new File(mod.getMinecraft().mcDataDir, "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) {
|
||||||
@@ -102,7 +107,7 @@ public class OpenEyeExtra implements Extra {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class GuiPopup extends AbstractGuiPopup<GuiPopup> {
|
public static final class GuiPopup extends AbstractGuiPopup<GuiPopup> {
|
||||||
GuiPopup(GuiContainer container) {
|
GuiPopup(GuiContainer container) {
|
||||||
super(container);
|
super(container);
|
||||||
popup.addElements(null, new GuiIndicator().setColor(Colors.BLACK));
|
popup.addElements(null, new GuiIndicator().setColor(Colors.BLACK));
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ public class ReplayModExtras {
|
|||||||
OpenEyeExtra.class
|
OpenEyeExtra.class
|
||||||
);
|
);
|
||||||
|
|
||||||
private Logger logger;
|
public static Logger LOGGER;
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void preInit(FMLPreInitializationEvent event) {
|
public void preInit(FMLPreInitializationEvent event) {
|
||||||
logger = event.getModLog();
|
LOGGER = event.getModLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
@@ -46,7 +46,7 @@ public class ReplayModExtras {
|
|||||||
Extra extra = cls.newInstance();
|
Extra extra = cls.newInstance();
|
||||||
extra.register(ReplayMod.instance);
|
extra.register(ReplayMod.instance);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
logger.warn("Failed to load extra " + cls.getName() + ": ", t);
|
LOGGER.warn("Failed to load extra " + cls.getName() + ": ", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,15 @@ import com.replaymod.core.utils.Utils;
|
|||||||
import com.replaymod.replay.ReplayModReplay;
|
import com.replaymod.replay.ReplayModReplay;
|
||||||
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.*;
|
import de.johni0702.minecraft.gui.container.GuiClickable;
|
||||||
|
import de.johni0702.minecraft.gui.container.GuiContainer;
|
||||||
|
import de.johni0702.minecraft.gui.container.GuiPanel;
|
||||||
|
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||||
|
import de.johni0702.minecraft.gui.container.GuiVerticalList;
|
||||||
import de.johni0702.minecraft.gui.element.GuiCheckbox;
|
import de.johni0702.minecraft.gui.element.GuiCheckbox;
|
||||||
import de.johni0702.minecraft.gui.element.GuiImage;
|
import de.johni0702.minecraft.gui.element.GuiImage;
|
||||||
import de.johni0702.minecraft.gui.element.GuiLabel;
|
import de.johni0702.minecraft.gui.element.GuiLabel;
|
||||||
|
import de.johni0702.minecraft.gui.element.GuiTooltip;
|
||||||
import de.johni0702.minecraft.gui.element.IGuiCheckbox;
|
import de.johni0702.minecraft.gui.element.IGuiCheckbox;
|
||||||
import de.johni0702.minecraft.gui.function.Closeable;
|
import de.johni0702.minecraft.gui.function.Closeable;
|
||||||
import de.johni0702.minecraft.gui.layout.CustomLayout;
|
import de.johni0702.minecraft.gui.layout.CustomLayout;
|
||||||
@@ -16,8 +21,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;
|
||||||
@@ -37,21 +41,22 @@ public class PlayerOverviewGui extends GuiScreen implements Closeable {
|
|||||||
public final GuiVerticalList playersScrollable = new GuiVerticalList(contentPanel)
|
public final GuiVerticalList playersScrollable = new GuiVerticalList(contentPanel)
|
||||||
.setDrawSlider(true).setDrawShadow(true);
|
.setDrawSlider(true).setDrawShadow(true);
|
||||||
public final GuiCheckbox saveCheckbox = new GuiCheckbox(contentPanel)
|
public final GuiCheckbox saveCheckbox = new GuiCheckbox(contentPanel)
|
||||||
|
.setTooltip(new GuiTooltip().setI18nText("replaymod.gui.playeroverview.remembersettings.description"))
|
||||||
.setI18nLabel("replaymod.gui.playeroverview.remembersettings");
|
.setI18nLabel("replaymod.gui.playeroverview.remembersettings");
|
||||||
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).setTooltip(new GuiTooltip().setI18nText("replaymod.gui.playeroverview.showall"));
|
||||||
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).setTooltip(new GuiTooltip().setI18nText("replaymod.gui.playeroverview.hideall"));
|
||||||
|
|
||||||
{
|
{
|
||||||
setBackground(Background.NONE);
|
setBackground(Background.NONE);
|
||||||
@@ -140,7 +145,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> {
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -82,7 +82,7 @@ public class ReplayModOnline {
|
|||||||
// Initial login prompt
|
// Initial login prompt
|
||||||
if (!core.getSettingsRegistry().get(Setting.SKIP_LOGIN_PROMPT)) {
|
if (!core.getSettingsRegistry().get(Setting.SKIP_LOGIN_PROMPT)) {
|
||||||
if (!isLoggedIn()) {
|
if (!isLoggedIn()) {
|
||||||
new GuiLoginPrompt(apiClient, null, null, false).display();
|
core.runLater(() -> new GuiLoginPrompt(apiClient, GuiScreen.wrap(getMinecraft().currentScreen), null, false).display());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,8 +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");
|
|
||||||
|
|
||||||
private String niceName, apiName;
|
private String niceName, apiName;
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public class GuiLoginPrompt extends AbstractGuiScreen<GuiLoginPrompt> {
|
|||||||
private GuiLabel noAccountLabel = new GuiLabel(this).setI18nText("replaymod.gui.login.noacc");
|
private GuiLabel noAccountLabel = new GuiLabel(this).setI18nText("replaymod.gui.login.noacc");
|
||||||
private GuiLabel statusLabel = new GuiLabel(this);
|
private GuiLabel statusLabel = new GuiLabel(this);
|
||||||
private GuiButton loginButton = new GuiButton(this).setI18nLabel("replaymod.gui.login").setSize(150, 20).setEnabled(false);
|
private GuiButton loginButton = new GuiButton(this).setI18nLabel("replaymod.gui.login").setSize(150, 20).setEnabled(false);
|
||||||
private GuiButton cancelButton = new GuiButton(this).setI18nLabel("replaymod.gui.cancel").setSize(150, 20);
|
public GuiButton cancelButton = new GuiButton(this).setI18nLabel("replaymod.gui.cancel").setSize(150, 20);
|
||||||
private GuiButton registerButton = new GuiButton(this).setI18nLabel("replaymod.gui.register").setSize(150, 20);
|
private GuiButton registerButton = new GuiButton(this).setI18nLabel("replaymod.gui.register").setSize(150, 20);
|
||||||
private GuiTextField username = new GuiTextField(this).setSize(145, 20).setMaxLength(16).setFocused(true);
|
private GuiTextField username = new GuiTextField(this).setSize(145, 20).setMaxLength(16).setFocused(true);
|
||||||
private GuiPasswordField password = new GuiPasswordField(this).setSize(145, 20)
|
private GuiPasswordField password = new GuiPasswordField(this).setSize(145, 20)
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import de.johni0702.minecraft.gui.container.GuiScreen;
|
|||||||
import de.johni0702.minecraft.gui.element.GuiButton;
|
import de.johni0702.minecraft.gui.element.GuiButton;
|
||||||
import de.johni0702.minecraft.gui.element.GuiImage;
|
import de.johni0702.minecraft.gui.element.GuiImage;
|
||||||
import de.johni0702.minecraft.gui.element.GuiLabel;
|
import de.johni0702.minecraft.gui.element.GuiLabel;
|
||||||
|
import de.johni0702.minecraft.gui.element.GuiTooltip;
|
||||||
import de.johni0702.minecraft.gui.element.IGuiButton;
|
import de.johni0702.minecraft.gui.element.IGuiButton;
|
||||||
import de.johni0702.minecraft.gui.element.advanced.GuiResourceLoadingList;
|
import de.johni0702.minecraft.gui.element.advanced.GuiResourceLoadingList;
|
||||||
import de.johni0702.minecraft.gui.layout.CustomLayout;
|
import de.johni0702.minecraft.gui.layout.CustomLayout;
|
||||||
@@ -109,6 +110,7 @@ public class GuiReplayCenter extends GuiScreen {
|
|||||||
public void run() {
|
public void run() {
|
||||||
GuiReplayEntry selected = list.getSelected();
|
GuiReplayEntry selected = list.getSelected();
|
||||||
replayButtonPanel.forEach(IGuiButton.class).setEnabled(selected != null);
|
replayButtonPanel.forEach(IGuiButton.class).setEnabled(selected != null);
|
||||||
|
replayButtonPanel.forEach(IGuiButton.class).setTooltip(null);
|
||||||
if (selected != null) {
|
if (selected != null) {
|
||||||
int replayId = selected.fileInfo.getId();
|
int replayId = selected.fileInfo.getId();
|
||||||
boolean favorited = favoritedReplays.contains(replayId);
|
boolean favorited = favoritedReplays.contains(replayId);
|
||||||
@@ -123,10 +125,22 @@ public class GuiReplayCenter extends GuiScreen {
|
|||||||
favoriteButton.setI18nLabel("replaymod.gui.center." + (favorited ? "unfavorite" : "favorite"));
|
favoriteButton.setI18nLabel("replaymod.gui.center." + (favorited ? "unfavorite" : "favorite"));
|
||||||
// Only allow button usage for either unfavorite or favorite after they've actually downloaded it
|
// Only allow button usage for either unfavorite or favorite after they've actually downloaded it
|
||||||
favoriteButton.setEnabled(favorited || selected.downloaded);
|
favoriteButton.setEnabled(favorited || selected.downloaded);
|
||||||
|
if (favoriteButton.isEnabled()) {
|
||||||
|
favoriteButton.setTooltip(null);
|
||||||
|
} else {
|
||||||
|
favoriteButton.setTooltip(new GuiTooltip().setI18nText("replaymod.gui.center.downloadrequired"));
|
||||||
|
}
|
||||||
|
|
||||||
// Similar for like/dislike buttons
|
// Similar for like/dislike buttons
|
||||||
likeButton.setEnabled(selected.downloaded);
|
likeButton.setEnabled(selected.downloaded);
|
||||||
dislikeButton.setEnabled(selected.downloaded);
|
dislikeButton.setEnabled(selected.downloaded);
|
||||||
|
if (likeButton.isEnabled()) {
|
||||||
|
likeButton.setTooltip(null);
|
||||||
|
dislikeButton.setTooltip(null);
|
||||||
|
} else {
|
||||||
|
likeButton.setTooltip(new GuiTooltip().setI18nText("replaymod.gui.center.downloadrequired"));
|
||||||
|
dislikeButton.setTooltip(new GuiTooltip().setI18nText("replaymod.gui.center.downloadrequired"));
|
||||||
|
}
|
||||||
likeButton.setI18nLabel("replaymod.gui." + (liked ? "removelike" : "like"));
|
likeButton.setI18nLabel("replaymod.gui." + (liked ? "removelike" : "like"));
|
||||||
dislikeButton.setI18nLabel("replaymod.gui." + (disliked ? "removedislike" : "dislike"));
|
dislikeButton.setI18nLabel("replaymod.gui." + (disliked ? "removedislike" : "dislike"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,12 @@ import com.replaymod.replaystudio.studio.ReplayStudio;
|
|||||||
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.container.GuiScreen;
|
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||||
import de.johni0702.minecraft.gui.element.*;
|
import de.johni0702.minecraft.gui.element.GuiButton;
|
||||||
|
import de.johni0702.minecraft.gui.element.GuiCheckbox;
|
||||||
|
import de.johni0702.minecraft.gui.element.GuiImage;
|
||||||
|
import de.johni0702.minecraft.gui.element.GuiLabel;
|
||||||
|
import de.johni0702.minecraft.gui.element.GuiTextField;
|
||||||
|
import de.johni0702.minecraft.gui.element.GuiTooltip;
|
||||||
import de.johni0702.minecraft.gui.element.advanced.GuiDropdownMenu;
|
import de.johni0702.minecraft.gui.element.advanced.GuiDropdownMenu;
|
||||||
import de.johni0702.minecraft.gui.element.advanced.GuiProgressBar;
|
import de.johni0702.minecraft.gui.element.advanced.GuiProgressBar;
|
||||||
import de.johni0702.minecraft.gui.element.advanced.GuiTextArea;
|
import de.johni0702.minecraft.gui.element.advanced.GuiTextArea;
|
||||||
@@ -234,6 +239,8 @@ public class GuiUploadReplay extends GuiScreen {
|
|||||||
});
|
});
|
||||||
|
|
||||||
validateInputs();
|
validateInputs();
|
||||||
|
name.onTextChanged(s -> validateInputs());
|
||||||
|
tags.onTextChanged(s -> validateInputs());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void validateInputs() {
|
public void validateInputs() {
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.google.common.util.concurrent.FutureCallback;
|
|||||||
import com.google.common.util.concurrent.Futures;
|
import com.google.common.util.concurrent.Futures;
|
||||||
import com.google.common.util.concurrent.SettableFuture;
|
import com.google.common.util.concurrent.SettableFuture;
|
||||||
import com.replaymod.core.ReplayMod;
|
import com.replaymod.core.ReplayMod;
|
||||||
|
import com.replaymod.core.utils.Utils;
|
||||||
import com.replaymod.replay.ReplayModReplay;
|
import com.replaymod.replay.ReplayModReplay;
|
||||||
import com.replaymod.replaystudio.pathing.PathingRegistry;
|
import com.replaymod.replaystudio.pathing.PathingRegistry;
|
||||||
import com.replaymod.replaystudio.pathing.path.Path;
|
import com.replaymod.replaystudio.pathing.path.Path;
|
||||||
@@ -11,7 +12,11 @@ import com.replaymod.replaystudio.pathing.path.Timeline;
|
|||||||
import com.replaymod.replaystudio.replay.ReplayFile;
|
import com.replaymod.replaystudio.replay.ReplayFile;
|
||||||
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.*;
|
import de.johni0702.minecraft.gui.container.AbstractGuiClickableContainer;
|
||||||
|
import de.johni0702.minecraft.gui.container.GuiContainer;
|
||||||
|
import de.johni0702.minecraft.gui.container.GuiPanel;
|
||||||
|
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||||
|
import de.johni0702.minecraft.gui.container.GuiVerticalList;
|
||||||
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.GuiTextField;
|
import de.johni0702.minecraft.gui.element.GuiTextField;
|
||||||
@@ -41,9 +46,16 @@ public class GuiKeyframeRepository extends GuiScreen implements Closeable {
|
|||||||
public final GuiButton overwriteButton = new GuiButton(buttonPanel).onClick(new Runnable() {
|
public final GuiButton overwriteButton = new GuiButton(buttonPanel).onClick(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
timelines.put(selectedEntry.name, currentTimeline);
|
GuiYesNoPopup popup = GuiYesNoPopup.open(GuiKeyframeRepository.this,
|
||||||
overwriteButton.setDisabled();
|
new GuiLabel().setI18nText("replaymod.gui.keyframerepo.overwrite").setColor(Colors.BLACK)
|
||||||
save();
|
).setYesI18nLabel("gui.yes").setNoI18nLabel("gui.no");
|
||||||
|
Utils.addCallback(popup.getFuture(), doIt -> {
|
||||||
|
if (doIt) {
|
||||||
|
timelines.put(selectedEntry.name, currentTimeline);
|
||||||
|
overwriteButton.setDisabled();
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
}, Throwable::printStackTrace);
|
||||||
}
|
}
|
||||||
}).setSize(75, 20).setI18nLabel("replaymod.gui.overwrite").setDisabled();
|
}).setSize(75, 20).setI18nLabel("replaymod.gui.overwrite").setDisabled();
|
||||||
public final GuiButton saveAsButton = new GuiButton(buttonPanel).onClick(new Runnable() {
|
public final GuiButton saveAsButton = new GuiButton(buttonPanel).onClick(new Runnable() {
|
||||||
|
|||||||
@@ -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,8 +4,10 @@ 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 io.netty.channel.ChannelDuplexHandler;
|
||||||
|
import io.netty.channel.ChannelHandler;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
|
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.FMLPreInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
@@ -51,12 +53,15 @@ 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.newChannel(Restrictions.PLUGIN_CHANNEL, new RestrictionsChannelHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ChannelHandler.Sharable
|
||||||
|
private static class RestrictionsChannelHandler extends ChannelDuplexHandler {}
|
||||||
|
|
||||||
public void initiateRecording(NetworkManager networkManager) {
|
public void initiateRecording(NetworkManager networkManager) {
|
||||||
connectionEventHandler.onConnectedToServerEvent(networkManager);
|
connectionEventHandler.onConnectedToServerEvent(networkManager);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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.inventory.armorInventory[0]) {
|
if(playerItems[2] != mc.thePlayer.inventory.armorInventory[1]) {
|
||||||
playerItems[2] = mc.thePlayer.inventory.armorInventory[0];
|
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.inventory.armorInventory[1]) {
|
if(playerItems[3] != mc.thePlayer.inventory.armorInventory[2]) {
|
||||||
playerItems[3] = mc.thePlayer.inventory.armorInventory[1];
|
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.inventory.armorInventory[2]) {
|
if(playerItems[4] != mc.thePlayer.inventory.armorInventory[3]) {
|
||||||
playerItems[4] = mc.thePlayer.inventory.armorInventory[2];
|
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.inventory.armorInventory[3]) {
|
|
||||||
playerItems[5] = mc.thePlayer.inventory.armorInventory[3];
|
|
||||||
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,7 +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()));
|
||||||
|
} 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();
|
||||||
}
|
}
|
||||||
@@ -243,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;
|
||||||
|
|
||||||
@@ -259,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();
|
||||||
}
|
}
|
||||||
@@ -274,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,8 +4,8 @@ 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;
|
||||||
@@ -36,12 +36,12 @@ 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.getAction() == S38PacketPlayerListItem.Action.ADD_PLAYER) {
|
||||||
for (SPacketPlayerListItem.AddPlayerData data : packet.getEntries()) {
|
for (S38PacketPlayerListItem.AddPlayerData data : packet.getEntries()) {
|
||||||
if (data.getProfile() == null || data.getProfile().getId() == null) continue;
|
if (data.getProfile() == null || data.getProfile().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.getProfile().getId().equals(Minecraft.getMinecraft().thePlayer.getGameProfile().getId())
|
||||||
@@ -55,12 +55,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).getPlayer();
|
||||||
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).getEntityID() == 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.watcher == null) {
|
||||||
p.watcher = new EntityDataManager(null);
|
p.watcher = new DataWatcher(null);
|
||||||
if (p.getDataManagerEntries() != null) {
|
if(p.func_148944_c() != null) {
|
||||||
for (EntityDataManager.DataEntry<?> entry : p.getDataManagerEntries()) {
|
for(DataWatcher.WatchableObject wo : p.func_148944_c()) {
|
||||||
DataManager_set(p.watcher, entry);
|
p.watcher.addObject(wo.getDataValueId(), wo.getObject());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ 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 +26,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 +53,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,9 +74,9 @@ 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.getURL();
|
||||||
final String hash = packet.getHash();
|
final String hash = packet.getHash();
|
||||||
@@ -83,60 +87,60 @@ 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(hash, CPacketResourcePackStatus.Action.ACCEPTED));
|
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.ACCEPTED));
|
||||||
Futures.addCallback(mc.getResourcePackRepository().setResourcePackInstance(levelDir), new FutureCallback<Object>() {
|
Futures.addCallback(mc.getResourcePackRepository().setResourcePackInstance(levelDir), new FutureCallback<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Object result) {
|
public void onSuccess(Object result) {
|
||||||
recordResourcePack(levelDir, requestId);
|
recordResourcePack(levelDir, requestId);
|
||||||
netManager.sendPacket(new CPacketResourcePackStatus(hash, 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(hash, CPacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
netManager.sendPacket(new CPacketResourcePackStatus(hash, 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(hash, 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(hash, CPacketResourcePackStatus.Action.DECLINED));
|
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.DECLINED));
|
||||||
} else {
|
} else {
|
||||||
mc.addScheduledTask(() -> mc.displayGuiScreen(new GuiYesNo((result, id) -> {
|
mc.addScheduledTask(() -> mc.displayGuiScreen(new GuiYesNo((result, id) -> {
|
||||||
if (serverData != null) {
|
if (serverData != null) {
|
||||||
serverData.setResourceMode(result ? ServerData.ServerResourceMode.ENABLED : ServerData.ServerResourceMode.DISABLED);
|
serverData.setResourceMode(result ? ServerData.ServerResourceMode.ENABLED : ServerData.ServerResourceMode.DISABLED);
|
||||||
}
|
}
|
||||||
if (result) {
|
if (result) {
|
||||||
netManager.sendPacket(new CPacketResourcePackStatus(hash, CPacketResourcePackStatus.Action.ACCEPTED));
|
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.ACCEPTED));
|
||||||
downloadResourcePackFuture(requestId, url, hash);
|
downloadResourcePackFuture(requestId, url, hash);
|
||||||
} else {
|
} else {
|
||||||
netManager.sendPacket(new CPacketResourcePackStatus(hash, CPacketResourcePackStatus.Action.DECLINED));
|
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(hash, 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(hash, CPacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
mc.getNetHandler().addToSendQueue(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,7 +10,7 @@ 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 {
|
||||||
|
|
||||||
@@ -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<ChunkCompileTaskGenerator> 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);
|
||||||
@@ -68,7 +68,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;renderParticle(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;renderParticle(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.renderParticle(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);
|
||||||
|
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();
|
||||||
|
|
||||||
|
|||||||
@@ -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,7 +143,6 @@ 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) {
|
||||||
|
|||||||
@@ -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,7 +124,7 @@ 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() {
|
||||||
@@ -209,6 +209,9 @@ public class ReplayHandler {
|
|||||||
*/
|
*/
|
||||||
public void spectateEntity(Entity e) {
|
public void spectateEntity(Entity e) {
|
||||||
CameraEntity cameraEntity = getCameraEntity();
|
CameraEntity cameraEntity = getCameraEntity();
|
||||||
|
if (cameraEntity == null) {
|
||||||
|
return; // Cannot spectate if we have no camera
|
||||||
|
}
|
||||||
if (e == null || e == cameraEntity) {
|
if (e == null || e == cameraEntity) {
|
||||||
spectating = null;
|
spectating = null;
|
||||||
e = cameraEntity;
|
e = cameraEntity;
|
||||||
@@ -328,7 +331,7 @@ 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) {
|
for (Entity entity : mc.theWorld.loadedEntityList) {
|
||||||
if (entity instanceof EntityOtherPlayerMP) {
|
if (entity instanceof EntityOtherPlayerMP) {
|
||||||
EntityOtherPlayerMP e = (EntityOtherPlayerMP) entity;
|
EntityOtherPlayerMP e = (EntityOtherPlayerMP) entity;
|
||||||
|
|||||||
@@ -6,7 +6,11 @@ import com.google.common.util.concurrent.Futures;
|
|||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import com.replaymod.core.ReplayMod;
|
import com.replaymod.core.ReplayMod;
|
||||||
import com.replaymod.core.utils.ModCompat;
|
import com.replaymod.core.utils.ModCompat;
|
||||||
import com.replaymod.replay.camera.*;
|
import com.replaymod.replay.camera.CameraController;
|
||||||
|
import com.replaymod.replay.camera.CameraControllerRegistry;
|
||||||
|
import com.replaymod.replay.camera.CameraEntity;
|
||||||
|
import com.replaymod.replay.camera.ClassicCameraController;
|
||||||
|
import com.replaymod.replay.camera.VanillaCameraController;
|
||||||
import com.replaymod.replay.gui.overlay.GuiMarkerTimeline;
|
import com.replaymod.replay.gui.overlay.GuiMarkerTimeline;
|
||||||
import com.replaymod.replay.gui.screen.GuiModCompatWarning;
|
import com.replaymod.replay.gui.screen.GuiModCompatWarning;
|
||||||
import com.replaymod.replay.handler.GuiHandler;
|
import com.replaymod.replay.handler.GuiHandler;
|
||||||
@@ -99,6 +103,7 @@ public class ReplayModReplay {
|
|||||||
@Override
|
@Override
|
||||||
public void onSuccess(NoGuiScreenshot result) {
|
public void onSuccess(NoGuiScreenshot result) {
|
||||||
try {
|
try {
|
||||||
|
core.printInfoToChat("replaymod.chat.savingthumb");
|
||||||
replayHandler.getReplayFile().writeThumb(result.getImage());
|
replayHandler.getReplayFile().writeThumb(result.getImage());
|
||||||
core.printInfoToChat("replaymod.chat.savedthumb");
|
core.printInfoToChat("replaymod.chat.savedthumb");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -109,6 +114,7 @@ public class ReplayModReplay {
|
|||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable t) {
|
public void onFailure(Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
|
core.printWarningToChat("replaymod.chat.failedthumb");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldSettings.GameType;
|
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).getReason();
|
||||||
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,8 +364,10 @@ 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;
|
|
||||||
|
if(p instanceof S48PacketResourcePackSend) {
|
||||||
|
S48PacketResourcePackSend packet = (S48PacketResourcePackSend) p;
|
||||||
String url = packet.getURL();
|
String url = packet.getURL();
|
||||||
if (url.startsWith("replay://")) {
|
if (url.startsWith("replay://")) {
|
||||||
int id = Integer.parseInt(url.substring("replay://".length()));
|
int id = Integer.parseInt(url.substring("replay://".length()));
|
||||||
@@ -403,10 +386,10 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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.getDimensionID(),
|
||||||
respawn.getDifficulty(), respawn.getWorldType(), GameType.SPECTATOR);
|
respawn.getDifficulty(), respawn.getWorldType(), 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,10 +422,10 @@ 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -474,8 +457,8 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
}.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.getGameState();
|
||||||
|
|
||||||
// only allow the following packets:
|
// only allow the following packets:
|
||||||
@@ -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,10 +691,10 @@ 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.getType();
|
||||||
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.entityId == LEGACY_ENTITY_ID) {
|
||||||
|
p.entityId = actualID;
|
||||||
|
}
|
||||||
|
} else if (packet instanceof S18PacketEntityTeleport) {
|
||||||
|
S18PacketEntityTeleport p = (S18PacketEntityTeleport) packet;
|
||||||
|
if (p.entityId == LEGACY_ENTITY_ID) {
|
||||||
|
p.entityId = actualID;
|
||||||
|
}
|
||||||
|
} else if (packet instanceof S14PacketEntity.S17PacketEntityLookMove) {
|
||||||
|
S14PacketEntity.S17PacketEntityLookMove p = (S14PacketEntity.S17PacketEntityLookMove) packet;
|
||||||
|
if (p.entityId == LEGACY_ENTITY_ID) {
|
||||||
|
p.entityId = actualID;
|
||||||
|
}
|
||||||
|
} else if (packet instanceof S19PacketEntityHeadLook) {
|
||||||
|
S19PacketEntityHeadLook p = (S19PacketEntityHeadLook) packet;
|
||||||
|
if (p.entityId == LEGACY_ENTITY_ID) {
|
||||||
|
p.entityId = actualID;
|
||||||
|
}
|
||||||
|
} else if (packet instanceof S12PacketEntityVelocity) {
|
||||||
|
S12PacketEntityVelocity p = (S12PacketEntityVelocity) packet;
|
||||||
|
if (p.entityID == LEGACY_ENTITY_ID) {
|
||||||
|
p.entityID = 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.entityID == LEGACY_ENTITY_ID) {
|
||||||
|
p.entityID = actualID;
|
||||||
|
}
|
||||||
|
} else if (packet instanceof S1BPacketEntityAttach) {
|
||||||
|
S1BPacketEntityAttach p = (S1BPacketEntityAttach) packet;
|
||||||
|
if (p.entityId == LEGACY_ENTITY_ID) {
|
||||||
|
p.entityId = actualID;
|
||||||
|
}
|
||||||
|
if (p.vehicleEntityId == LEGACY_ENTITY_ID) {
|
||||||
|
p.vehicleEntityId = actualID;
|
||||||
|
}
|
||||||
|
} else if (packet instanceof S0DPacketCollectItem) {
|
||||||
|
S0DPacketCollectItem p = (S0DPacketCollectItem) packet;
|
||||||
|
if (p.entityId == LEGACY_ENTITY_ID) {
|
||||||
|
p.entityId = actualID;
|
||||||
|
}
|
||||||
|
} else if (packet instanceof S13PacketDestroyEntities) {
|
||||||
|
S13PacketDestroyEntities p = (S13PacketDestroyEntities) packet;
|
||||||
|
if (p.entityIDs.length == 1 && p.entityIDs[0] == LEGACY_ENTITY_ID) {
|
||||||
|
p.entityIDs[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,14 +9,15 @@ 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;
|
||||||
private static final int BUTTON_RETURN_TO_GAME = 4;
|
|
||||||
private static final int BUTTON_ACHIEVEMENTS = 5;
|
private static final int BUTTON_ACHIEVEMENTS = 5;
|
||||||
private static final int BUTTON_STATS = 6;
|
private static final int BUTTON_STATS = 6;
|
||||||
private static final int BUTTON_OPEN_TO_LAN = 7;
|
private static final int BUTTON_OPEN_TO_LAN = 7;
|
||||||
@@ -33,12 +34,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 +48,10 @@ 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())) {
|
GuiButton achievements = null, stats = null, openToLan = null;
|
||||||
|
@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:
|
||||||
@@ -55,43 +60,69 @@ public class GuiHandler {
|
|||||||
break;
|
break;
|
||||||
// Remove "Achievements", "Stats" and "Open to LAN" buttons
|
// Remove "Achievements", "Stats" and "Open to LAN" buttons
|
||||||
case BUTTON_ACHIEVEMENTS:
|
case BUTTON_ACHIEVEMENTS:
|
||||||
|
buttonList.remove(achievements = b);
|
||||||
|
break;
|
||||||
case BUTTON_STATS:
|
case BUTTON_STATS:
|
||||||
|
buttonList.remove(stats = b);
|
||||||
|
break;
|
||||||
case BUTTON_OPEN_TO_LAN:
|
case BUTTON_OPEN_TO_LAN:
|
||||||
event.getButtonList().remove(b);
|
buttonList.remove(openToLan = b);
|
||||||
}
|
break;
|
||||||
// Move all buttons except the "Return to game" button upwards
|
|
||||||
if (b.id != BUTTON_RETURN_TO_GAME) {
|
|
||||||
b.yPosition -= 48;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (achievements != null && stats != null) {
|
||||||
|
moveAllButtonsDirectlyBelowUpwards(buttonList, achievements.yPosition,
|
||||||
|
achievements.xPosition, stats.xPosition + stats.width);
|
||||||
|
}
|
||||||
|
if (openToLan != null) {
|
||||||
|
moveAllButtonsDirectlyBelowUpwards(buttonList, openToLan.yPosition,
|
||||||
|
openToLan.xPosition, openToLan.xPosition + openToLan.width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves all buttons that are within a rectangle below a certain y coordinate upwards by 24 units.
|
||||||
|
* @param buttons List of buttons
|
||||||
|
* @param belowY The Y limit
|
||||||
|
* @param xStart Left x limit of the rectangle
|
||||||
|
* @param xEnd Right x limit of the rectangle
|
||||||
|
*/
|
||||||
|
private void moveAllButtonsDirectlyBelowUpwards(List<GuiButton> buttons, int belowY, int xStart, int xEnd) {
|
||||||
|
for (GuiButton button : buttons) {
|
||||||
|
if (button.yPosition >= belowY && button.xPosition <= xEnd && button.xPosition + button.width >= xStart) {
|
||||||
|
button.yPosition -= 24;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@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,8 +10,8 @@ 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 = "canRenderName", 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;
|
||||||
@@ -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;
|
||||||
@@ -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#setOrigin(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);
|
||||||
).setOrigin(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_);
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user