Compare commits
87 Commits
1.8.9-2.0.
...
1.12.1-2.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1a2826cb4 | ||
|
|
0d6c1caffc | ||
|
|
13bb0bde13 | ||
|
|
5257a412a5 | ||
|
|
689f897930 | ||
|
|
0aed9c3c17 | ||
|
|
f36ebf1d0a | ||
|
|
08170b38ef | ||
|
|
41d2547f3c | ||
|
|
00e999ffd2 | ||
|
|
767ea292a7 | ||
|
|
5b04edbbd3 | ||
|
|
6aff99d3ac | ||
|
|
703805f269 | ||
|
|
922c039e43 | ||
|
|
7a4440c4a8 | ||
|
|
0b9c56cdfd | ||
|
|
933ee5f866 | ||
|
|
83b1090e42 | ||
|
|
5c73117e9f | ||
|
|
4704b2984e | ||
|
|
0c226b0236 | ||
|
|
1b9b13ee7f | ||
|
|
c2000b3edc | ||
|
|
aafeecc670 | ||
|
|
9292add867 | ||
|
|
8499c0f154 | ||
|
|
b9ea572e19 | ||
|
|
a2f8c88a3d | ||
|
|
19629c32f0 | ||
|
|
fe1d9b828d | ||
|
|
0b462280fc | ||
|
|
d56fa9b88f | ||
|
|
7c719e03cc | ||
|
|
1a1e96c375 | ||
|
|
35eb9cad33 | ||
|
|
cae95d1c8f | ||
|
|
67b7872c4d | ||
|
|
9b04d317c5 | ||
|
|
a6ffae2148 | ||
|
|
6109960d4a | ||
|
|
4dcecc5697 | ||
|
|
bef5e41a8d | ||
|
|
6ecb87e8dd | ||
|
|
921c9e0098 | ||
|
|
5dd31f4cac | ||
|
|
2a47f579a9 | ||
|
|
96b2904e4b | ||
|
|
6c8c779983 | ||
|
|
aa16e42a4f | ||
|
|
cda8493df1 | ||
|
|
0c36022b47 | ||
|
|
325d041bd9 | ||
|
|
d9d57e283c | ||
|
|
33cb1405d5 | ||
|
|
b6cf42c3be | ||
|
|
c6dec95a57 | ||
|
|
4fdfa9ec87 | ||
|
|
44d4a250eb | ||
|
|
503b308043 | ||
|
|
7b491d188d | ||
|
|
fb4140a123 | ||
|
|
905ae75330 | ||
|
|
72e1fe0d6c | ||
|
|
2428c01c9c | ||
|
|
260720d5ba | ||
|
|
372206fdff | ||
|
|
4a1cceaa47 | ||
|
|
58b7c44a33 | ||
|
|
9f7ccb9d07 | ||
|
|
ca2bbca7a4 | ||
|
|
75c0e7b77a | ||
|
|
ce313596db | ||
|
|
b1661e359a | ||
|
|
e20dfa6d7f | ||
|
|
7cc0ee523a | ||
|
|
54790d33f9 | ||
|
|
165861764c | ||
|
|
5014edafe0 | ||
|
|
09f167f10e | ||
|
|
21ac84e990 | ||
|
|
8e6eec879f | ||
|
|
5100f36b2c | ||
|
|
7ef6a6d166 | ||
|
|
446b9be384 | ||
|
|
d1ed67f1a0 | ||
|
|
a80a20c37a |
@@ -7,7 +7,6 @@ pipeline:
|
||||
commands:
|
||||
- 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
|
||||
- ./gradlew setupCIWorkspace
|
||||
- ./gradlew :build
|
||||
archive:
|
||||
image: plugins/s3
|
||||
|
||||
@@ -1 +1 @@
|
||||
eyJhbGciOiJIUzI1NiJ9.cGlwZWxpbmU6CiAgY2xvbmU6CiAgICBpbWFnZTogcGx1Z2lucy9naXQKICAgIHRhZ3M6IHRydWUKICBidWlsZDoKICAgIGltYWdlOiBtYXZlbjozLjMuOS1qZGstOAogICAgY29tbWFuZHM6CiAgICAgIC0gY3VybCAtLWZhaWwgLS1jcmVhdGUtZGlycyAtbyAkSE9NRS8uZ3JhZGxlL2luaXQuZC9taXJyb3IuZ3JhZGxlIGh0dHBzOi8vbWF2ZW4uam9obmkwNzAyLmRlL2NvbmZpZy9ncmFkbGUKICAgICAgLSBjdXJsIC0tZmFpbCAtLWNyZWF0ZS1kaXJzIC1vICRIT01FLy5tMi9zZXR0aW5ncy54bWwgaHR0cHM6Ly9tYXZlbi5qb2huaTA3MDIuZGUvY29uZmlnL21hdmVuCiAgICAgIC0gLi9ncmFkbGV3IHNldHVwQ0lXb3Jrc3BhY2UKICAgICAgLSAuL2dyYWRsZXcgOmJ1aWxkCiAgYXJjaGl2ZToKICAgIGltYWdlOiBwbHVnaW5zL3MzCiAgICBhY2w6IHB1YmxpYy1yZWFkCiAgICByZWdpb246ICJ1cy1lYXN0LTEiCiAgICBidWNrZXQ6ICJyZXBsYXltb2QiCiAgICBwYXRoX3N0eWxlOiB0cnVlCiAgICBzb3VyY2U6IGJ1aWxkL2xpYnMvKgogICAgc3RyaXBfcHJlZml4OiBidWlsZC9saWJzLwogICAgdGFyZ2V0OiAvCg.riE6lhwfdNUhI7LO2SxEKFOjzjaX40ne7Ae9gyP75KE
|
||||
eyJhbGciOiJIUzI1NiJ9.cGlwZWxpbmU6CiAgY2xvbmU6CiAgICBpbWFnZTogcGx1Z2lucy9naXQKICAgIHRhZ3M6IHRydWUKICBidWlsZDoKICAgIGltYWdlOiBtYXZlbjozLjMuOS1qZGstOAogICAgY29tbWFuZHM6CiAgICAgIC0gY3VybCAtLWZhaWwgLS1jcmVhdGUtZGlycyAtbyAkSE9NRS8uZ3JhZGxlL2luaXQuZC9taXJyb3IuZ3JhZGxlIGh0dHBzOi8vbWF2ZW4uam9obmkwNzAyLmRlL2NvbmZpZy9ncmFkbGUKICAgICAgLSBjdXJsIC0tZmFpbCAtLWNyZWF0ZS1kaXJzIC1vICRIT01FLy5tMi9zZXR0aW5ncy54bWwgaHR0cHM6Ly9tYXZlbi5qb2huaTA3MDIuZGUvY29uZmlnL21hdmVuCiAgICAgIC0gLi9ncmFkbGV3IDpidWlsZAogIGFyY2hpdmU6CiAgICBpbWFnZTogcGx1Z2lucy9zMwogICAgYWNsOiBwdWJsaWMtcmVhZAogICAgcmVnaW9uOiAidXMtZWFzdC0xIgogICAgYnVja2V0OiAicmVwbGF5bW9kIgogICAgcGF0aF9zdHlsZTogdHJ1ZQogICAgc291cmNlOiBidWlsZC9saWJzLyoKICAgIHN0cmlwX3ByZWZpeDogYnVpbGQvbGlicy8KICAgIHRhcmdldDogLwo.Z6rpaLplJKQ4pzB8AjCnplgci42qEu7L4LeS0fGm4SY
|
||||
Submodule ReplayStudio updated: ff12b1db0b...f1d6fbbf8a
71
build.gradle
71
build.gradle
@@ -17,8 +17,8 @@ buildscript {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
|
||||
classpath 'org.spongepowered:mixingradle:0.3-SNAPSHOT'
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||
classpath 'org.spongepowered:mixingradle:0.4-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,11 +34,13 @@ archivesBaseName = "replaymod"
|
||||
|
||||
minecraft {
|
||||
coreMod = 'com.replaymod.core.LoadingPlugin'
|
||||
version = '1.8.9-11.15.1.1722'
|
||||
version = '1.12.1-14.22.0.2444'
|
||||
runDir = "eclipse"
|
||||
mappings = "stable_22"
|
||||
mappings = "snapshot_20170615"
|
||||
replace '@MOD_VERSION@', project.version
|
||||
replace '@MC_VERSION@', project.minecraft.version
|
||||
// Includes intentional whitespace to stop Forge from declaring the mod to be compatible with
|
||||
// a newer srg-compatible MC version (that may be using a different protocol version)
|
||||
replace '@MC_VERSION@', "[ ${project.minecraft.version} ]"
|
||||
}
|
||||
|
||||
repositories {
|
||||
@@ -46,9 +48,6 @@ repositories {
|
||||
name = "SpongePowered Repo"
|
||||
url = "http://repo.spongepowered.org/maven/"
|
||||
}
|
||||
maven {
|
||||
url 'https://repo.spacehq.org/content/repositories/snapshots/'
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
@@ -59,7 +58,9 @@ configurations {
|
||||
dependencies {
|
||||
compile 'org.projectlombok:lombok:1.16.4'
|
||||
|
||||
compile 'org.spongepowered:mixin:0.6.8-SNAPSHOT'
|
||||
compile('org.spongepowered:mixin:0.6.11-SNAPSHOT') {
|
||||
exclude group: 'org.apache.logging.log4j'
|
||||
}
|
||||
shade 'com.googlecode.mp4parser:isoparser:1.1.7'
|
||||
shade 'org.apache.commons:commons-exec:1.3'
|
||||
shade 'com.google.apis:google-api-services-youtube:v3-rev178-1.22.0'
|
||||
@@ -115,6 +116,7 @@ jar {
|
||||
manifest {
|
||||
attributes 'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
|
||||
'TweakOrder': '0',
|
||||
'FMLCorePluginContainsFMLMod': 'true',
|
||||
'FMLAT': 'replaymod_at.cfg'
|
||||
}
|
||||
}
|
||||
@@ -183,6 +185,57 @@ setupDecompWorkspace.dependsOn copySrg
|
||||
setupDevWorkspace.dependsOn copySrg
|
||||
project.tasks.idea.dependsOn copySrg
|
||||
|
||||
|
||||
import org.objectweb.asm.*
|
||||
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipFile
|
||||
import java.util.zip.ZipOutputStream
|
||||
|
||||
import static org.objectweb.asm.Opcodes.ASM5
|
||||
|
||||
// MC binaries were complied with a java version that produces invalid class files under certain circumstances
|
||||
// This causes setupCIWorkspace to be insufficient for compiling.
|
||||
// Related JDK bug: https://bugs.openjdk.java.net/browse/JDK-8066725
|
||||
// As a workaround, to use setupCIWorkspace on Drone, we modify the bin jar in-place and remove all parameter annotations.
|
||||
// WARNING: This piece of code ignores any and all gradle conventions and will probably fail horribly when run outside
|
||||
// of a single-use environment (e.g. Drone). Use setupDecompWorkspace for normal use.
|
||||
tasks.deobfMcMCP.doLast {
|
||||
println "Applying RuntimeInvisibleParameterAnnotations workaround..."
|
||||
File jar = getOutJar()
|
||||
File tmp = new File((File) getTemporaryDir(), "workaround.jar")
|
||||
tmp.withOutputStream {
|
||||
new ZipOutputStream(it).withStream { dst ->
|
||||
new ZipFile(jar).withCloseable { src ->
|
||||
src.entries().each {
|
||||
if (it.name.startsWith("net/minecraft/") && it.name.endsWith(".class")) {
|
||||
def cw = new ClassWriter(0)
|
||||
def cv = new ClassVisitor(ASM5, cw) {
|
||||
@Override
|
||||
MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
||||
return new MethodVisitor(ASM5, cv.visitMethod(access, name, desc, signature, exceptions)) {
|
||||
@Override
|
||||
AnnotationVisitor visitParameterAnnotation(int parameter, String pdesc, boolean visible) {
|
||||
return null // Strip all parameter annotations
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
new ClassReader(src.getInputStream(it)).accept(cv, 0)
|
||||
dst.putNextEntry(new ZipEntry(it.name))
|
||||
dst.write(cw.toByteArray())
|
||||
} else {
|
||||
dst.putNextEntry(it)
|
||||
dst.write(src.getInputStream(it).bytes)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
jar.delete()
|
||||
tmp.renameTo(jar)
|
||||
}
|
||||
|
||||
task runIntegrationTest(type: JavaExec, dependsOn: ["makeStart", "jar"]) {
|
||||
main = 'GradleStart'
|
||||
standardOutput = System.out
|
||||
|
||||
2
jGui
2
jGui
Submodule jGui updated: 1e92ad85df...e5fcc65032
@@ -50,10 +50,8 @@ public abstract class AbstractTask implements Task {
|
||||
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 -> {});
|
||||
|
||||
@@ -92,7 +90,7 @@ public abstract class AbstractTask implements Task {
|
||||
public void onGuiOpen(TickEvent.RenderTickEvent event) {
|
||||
if (event.phase != TickEvent.Phase.START) return;
|
||||
if (currentScreen != mc.currentScreen) {
|
||||
FMLCommonHandler.instance().bus().unregister(this);
|
||||
MinecraftForge.EVENT_BUS.unregister(this);
|
||||
onClosed.run();
|
||||
} else {
|
||||
if (framesPassed < timeout) {
|
||||
@@ -106,7 +104,7 @@ public abstract class AbstractTask implements Task {
|
||||
}
|
||||
}
|
||||
}
|
||||
FMLCommonHandler.instance().bus().register(new EventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new EventHandler());
|
||||
}
|
||||
|
||||
public void expectPopupClosed(Runnable onClosed) {
|
||||
@@ -130,7 +128,7 @@ public abstract class AbstractTask implements Task {
|
||||
public void onGuiOpen(TickEvent.RenderTickEvent event) {
|
||||
if (event.phase != TickEvent.Phase.START) return;
|
||||
if (getPopup(mc.currentScreen) != popup) {
|
||||
FMLCommonHandler.instance().bus().unregister(this);
|
||||
MinecraftForge.EVENT_BUS.unregister(this);
|
||||
onClosed.run();
|
||||
} else {
|
||||
if (framesPassed < timeout) {
|
||||
@@ -143,7 +141,7 @@ public abstract class AbstractTask implements Task {
|
||||
}
|
||||
}
|
||||
}
|
||||
FMLCommonHandler.instance().bus().register(new EventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new EventHandler());
|
||||
}
|
||||
|
||||
private AbstractGuiPopup getPopup(net.minecraft.client.gui.GuiScreen minecraft) {
|
||||
@@ -181,7 +179,7 @@ public abstract class AbstractTask implements Task {
|
||||
return;
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().bus().unregister(this);
|
||||
MinecraftForge.EVENT_BUS.unregister(this);
|
||||
|
||||
Object foundGui = null;
|
||||
if (AbstractGuiScreen.class.isAssignableFrom(guiClass)) {
|
||||
@@ -219,7 +217,7 @@ public abstract class AbstractTask implements Task {
|
||||
future.setException(new UnexpectedGuiException(foundGui == null ? currentScreen : foundGui));
|
||||
}
|
||||
}
|
||||
FMLCommonHandler.instance().bus().register(new EventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new EventHandler());
|
||||
}
|
||||
|
||||
private void clickNow(int x, int y) {
|
||||
@@ -301,7 +299,7 @@ public abstract class AbstractTask implements Task {
|
||||
return;
|
||||
}
|
||||
|
||||
clickNow(button.xPosition + 5, button.yPosition + 5);
|
||||
clickNow(button.x + 5, button.y + 5);
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
future.setException(e);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,11 @@ public class ReplayModIntegrationTest {
|
||||
// Make sure the game window doesn't have to remain in focus during the test
|
||||
mc.gameSettings.pauseOnLostFocus = false;
|
||||
|
||||
// Vanilla uses our keys
|
||||
mc.gameSettings.keyBindAdvancements.setKeyCode(0);
|
||||
mc.gameSettings.keyBindLoadToolbar.setKeyCode(0);
|
||||
mc.gameSettings.keyBindSaveToolbar.setKeyCode(0);
|
||||
|
||||
runTasks(
|
||||
new SkipLogin(),
|
||||
new DownloadOpenEye(),
|
||||
|
||||
@@ -10,6 +10,10 @@ import java.nio.file.NoSuchFileException;
|
||||
public class DownloadOpenEye extends AbstractTask {
|
||||
@Override
|
||||
protected void init() {
|
||||
if ("1".equals(System.getenv("RM_INTEGRATION_TEST_NO_OPENEYE"))) {
|
||||
runLater(() -> future.set(null));
|
||||
return;
|
||||
}
|
||||
expectGui(OpenEyeExtra.OfferGui.class, offerGui -> {
|
||||
click(offerGui.yesButton);
|
||||
expectGuiClosed(20 * 1000, () -> {
|
||||
|
||||
@@ -3,7 +3,7 @@ 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.minecraft.client.gui.GuiWorldSelection;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
@@ -13,7 +13,7 @@ public class CreateSPWorld extends AbstractTask {
|
||||
protected void init() {
|
||||
expectGui(GuiMainMenu.class, mainMenu -> {
|
||||
click("Singleplayer");
|
||||
expectGui(GuiSelectWorld.class, selectWorld -> {
|
||||
expectGui(GuiWorldSelection.class, selectWorld -> {
|
||||
click("Create New World");
|
||||
expectGui(GuiCreateWorld.class, createWorld -> {
|
||||
click("Create New World");
|
||||
|
||||
@@ -34,7 +34,7 @@ public class SpectatePlayer extends AbstractTask {
|
||||
future.setException(new TimeoutException("Camera hasn't stopped spectating."));
|
||||
return;
|
||||
}
|
||||
if (mc.getRenderViewEntity() == mc.thePlayer) {
|
||||
if (mc.getRenderViewEntity() == mc.player) {
|
||||
future.set(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.replaymod.compat;
|
||||
|
||||
import com.replaymod.compat.bettersprinting.DisableBetterSprinting;
|
||||
import com.replaymod.compat.optifine.DisableFastRender;
|
||||
import com.replaymod.compat.oranges17animations.HideInvisibleEntities;
|
||||
import com.replaymod.compat.shaders.ShaderBeginRender;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventBus;
|
||||
@@ -10,15 +12,18 @@ import net.minecraftforge.fml.common.eventhandler.EventBus;
|
||||
@Mod(modid = ReplayModCompat.MOD_ID,
|
||||
version = "@MOD_VERSION@",
|
||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||
acceptableRemoteVersions = "*",
|
||||
useMetadata = true)
|
||||
public class ReplayModCompat {
|
||||
public static final String MOD_ID = "replaymod-compat";
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
EventBus bus = FMLCommonHandler.instance().bus();
|
||||
EventBus bus = MinecraftForge.EVENT_BUS;
|
||||
bus.register(new ShaderBeginRender());
|
||||
bus.register(new DisableFastRender());
|
||||
bus.register(new HideInvisibleEntities());
|
||||
DisableBetterSprinting.register();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.replaymod.compat.bettersprinting;
|
||||
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
import com.replaymod.replay.events.ReplayChatMessageEvent;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorldEventListener;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.GuiOpenEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.ModContainer;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion;
|
||||
import net.minecraftforge.fml.common.versioning.Restriction;
|
||||
import net.minecraftforge.fml.common.versioning.VersionRange;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Old Better Sprinting versions replace the vanilla player with their own, overridden instance (replacing the camera entity).
|
||||
*
|
||||
* See: https://github.com/chylex/Better-Sprinting/blob/1.8/src/main/java/chylex/bettersprinting/client/player/impl/LogicImplOverride.java
|
||||
*/
|
||||
public class DisableBetterSprinting {
|
||||
private static final VersionRange OLD_VERSION = VersionRange.newRange(null,
|
||||
Collections.singletonList(new Restriction(null, false, new DefaultArtifactVersion("2.0.0"), false)));
|
||||
private static final String LOGIC_CLASS_NAME = "chylex.bettersprinting.client.player.impl.LogicImplOverride";
|
||||
private static final String CONTROLLER_OVERRIDE_CLASS_NAME = LOGIC_CLASS_NAME + ".PlayerControllerMPOverride";
|
||||
|
||||
public static void register() {
|
||||
Loader.instance().getModList().stream()
|
||||
.filter(mod -> mod.getModId().equalsIgnoreCase("bettersprinting"))
|
||||
.findFirst()
|
||||
.map(ModContainer::getProcessedVersion).filter(OLD_VERSION::containsVersion)
|
||||
.ifPresent($_ -> MinecraftForge.EVENT_BUS.register(new DisableBetterSprinting()));
|
||||
}
|
||||
|
||||
private DisableBetterSprinting() {}
|
||||
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
private PlayerControllerMP originalController;
|
||||
private BetterSprintingWorldAccess worldAccessHook = new BetterSprintingWorldAccess();
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public void beforeGuiOpenEvent(GuiOpenEvent event) {
|
||||
if (ReplayModReplay.instance.getReplayHandler() != null && mc.world != null) {
|
||||
// During replay, get ready to revert BetterSprinting's overwritten playerController
|
||||
originalController = mc.playerController;
|
||||
mc.world.addEventListener(worldAccessHook);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
public void afterGuiOpenEvent(GuiOpenEvent event) {
|
||||
if (ReplayModReplay.instance.getReplayHandler() != null && mc.world != null) {
|
||||
mc.world.addEventListener(worldAccessHook);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onReplayChatMessage(ReplayChatMessageEvent event) {
|
||||
// Suppress this message if it's the Better Sprinting warning message
|
||||
for (StackTraceElement elem : Thread.currentThread().getStackTrace()) {
|
||||
if (LOGIC_CLASS_NAME.equals(elem.getClassName())) {
|
||||
event.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class BetterSprintingWorldAccess implements IWorldEventListener {
|
||||
@Override
|
||||
public void onEntityRemoved(Entity entityIn) {
|
||||
if (mc.playerController != null && mc.playerController.getClass().getName().equals(CONTROLLER_OVERRIDE_CLASS_NAME)) {
|
||||
// Someone has secretly swapped out the player controller and is about to substitute their own player entity.
|
||||
// This is the right time to destroy their plan.
|
||||
mc.playerController = originalController;
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void notifyBlockUpdate(World worldIn, BlockPos pos, IBlockState oldState, IBlockState newState, int flags) {}
|
||||
@Override public void notifyLightSet(BlockPos pos) {}
|
||||
@Override public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2) {}
|
||||
@Override public void playSoundToAllNearExcept(@Nullable EntityPlayer player, SoundEvent soundIn, SoundCategory category, double x, double y, double z, float volume, float pitch) {}
|
||||
@Override public void playRecord(SoundEvent soundIn, BlockPos pos) {}
|
||||
@Override public void spawnParticle(int p_180442_1_, boolean p_180442_2_, double p_180442_3_, double p_180442_5_, double p_180442_7_, double p_180442_9_, double p_180442_11_, double p_180442_13_, int... p_180442_15_) {}
|
||||
@Override public void spawnParticle(int p_190570_1_, boolean p_190570_2_, boolean p_190570_3_, double p_190570_4_, double p_190570_6_, double p_190570_8_, double p_190570_10_, double p_190570_12_, double p_190570_14_, int... p_190570_16_) {}
|
||||
@Override public void onEntityAdded(Entity entityIn) {}
|
||||
@Override public void broadcastSound(int p_180440_1_, BlockPos p_180440_2_, int p_180440_3_) {}
|
||||
@Override public void playEvent(EntityPlayer player, int type, BlockPos blockPosIn, int data) {}
|
||||
@Override public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress) {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.replaymod.compat.oranges17animations;
|
||||
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.client.event.RenderLivingEvent;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
/**
|
||||
* Orange seems to have copied vast parts of the RendererLivingEntity into their ArmorAnimation class which cancels the RenderLivingEvent.Pre and calls its own code instead.
|
||||
* This breaks our mixin which assures that, even though the camera is in spectator mode, it cannot see invisible entities.
|
||||
*
|
||||
* To fix this issue, we simply cancel the RenderLivingEvent.Pre before it gets to ArmorAnimation if the entity is invisible.
|
||||
*/
|
||||
public class HideInvisibleEntities {
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
private final boolean modLoaded = Loader.isModLoaded("animations");
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public void preRenderLiving(RenderLivingEvent.Pre event) {
|
||||
if (modLoaded) {
|
||||
if (mc.player instanceof CameraEntity && event.getEntity().isInvisible()) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public class ShaderBeginRender {
|
||||
// check if Shaders are enabled
|
||||
if (!(boolean) (ShaderReflection.config_isShaders.invoke(null))) return;
|
||||
|
||||
ShaderReflection.shaders_beginRender.invoke(null, mc, mc.timer.elapsedPartialTicks, 0);
|
||||
ShaderReflection.shaders_beginRender.invoke(null, mc, mc.timer.renderPartialTicks, 0);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ public abstract class MixinShaderRenderChunk {
|
||||
*/
|
||||
@Inject(method = "isPlayerUpdate", at = @At("HEAD"), cancellable = true)
|
||||
private void replayModCompat_disableIsPlayerUpdate(CallbackInfoReturnable<Boolean> ci) {
|
||||
// TODO: Update to 1.12 once optifine is available
|
||||
if (((EntityRendererHandler.IEntityRenderer) mc.entityRenderer).replayModRender_getHandler() == null) return;
|
||||
ci.setReturnValue(true);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class KeyBindingRegistry {
|
||||
private Map<String, KeyBinding> keyBindings = new HashMap<String, KeyBinding>();
|
||||
@@ -86,7 +85,7 @@ public class KeyBindingRegistry {
|
||||
CrashReport crashReport = CrashReport.makeCrashReport(cause, "Handling Key Binding");
|
||||
CrashReportCategory category = crashReport.makeCategory("Key Binding");
|
||||
category.addCrashSection("Key Binding", keyBinding);
|
||||
category.addCrashSectionCallable("Handler", runnable::toString);
|
||||
category.addDetail("Handler", runnable::toString);
|
||||
throw new ReportedException(crashReport);
|
||||
}
|
||||
}
|
||||
@@ -101,12 +100,7 @@ public class KeyBindingRegistry {
|
||||
CrashReport crashReport = CrashReport.makeCrashReport(cause, "Handling Raw Key Binding");
|
||||
CrashReportCategory category = crashReport.makeCategory("Key Binding");
|
||||
category.addCrashSection("Key Code", keyCode);
|
||||
category.addCrashSectionCallable("Handler", new Callable() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
return runnable;
|
||||
}
|
||||
});
|
||||
category.addDetail("Handler", runnable::toString);
|
||||
throw new ReportedException(crashReport);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ public class LoadingPlugin implements IFMLLoadingPlugin {
|
||||
Mixins.addConfiguration("mixins.render.replaymod.json");
|
||||
Mixins.addConfiguration("mixins.replay.replaymod.json");
|
||||
Mixins.addConfiguration("mixins.compat.shaders.replaymod.json");
|
||||
Mixins.addConfiguration("mixins.extras.playeroverview.replaymod.json");
|
||||
|
||||
CodeSource codeSource = getClass().getProtectionDomain().getCodeSource();
|
||||
if (codeSource != null) {
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.replaymod.core.gui.GuiReplaySettings;
|
||||
import com.replaymod.core.gui.RestoreReplayGui;
|
||||
import com.replaymod.core.handler.MainMenuHandler;
|
||||
import com.replaymod.core.utils.OpenGLUtils;
|
||||
import com.replaymod.render.utils.SoundHandler;
|
||||
import com.replaymod.replaystudio.util.I18n;
|
||||
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||
import lombok.Getter;
|
||||
@@ -14,15 +13,11 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
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.text.*;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
@@ -31,6 +26,9 @@ import net.minecraftforge.fml.common.ModContainer;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventBus;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -41,6 +39,7 @@ import java.util.List;
|
||||
useMetadata = true,
|
||||
version = "@MOD_VERSION@",
|
||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||
acceptableRemoteVersions = "*",
|
||||
updateJSON = "https://raw.githubusercontent.com/ReplayMod/ReplayMod/master/versions.json",
|
||||
guiFactory = "com.replaymod.core.gui.GuiFactory")
|
||||
public class ReplayMod {
|
||||
@@ -72,8 +71,6 @@ public class ReplayMod {
|
||||
|
||||
@Deprecated
|
||||
public static Configuration config;
|
||||
@Deprecated
|
||||
public static SoundHandler soundHandler = new SoundHandler();
|
||||
|
||||
private final KeyBindingRegistry keyBindingRegistry = new KeyBindingRegistry();
|
||||
private final SettingsRegistry settingsRegistry = new SettingsRegistry();
|
||||
@@ -116,7 +113,7 @@ public class ReplayMod {
|
||||
|
||||
new MainMenuHandler().register();
|
||||
|
||||
FMLCommonHandler.instance().bus().register(keyBindingRegistry);
|
||||
MinecraftForge.EVENT_BUS.register(keyBindingRegistry);
|
||||
|
||||
getKeyBindingRegistry().registerKeyBinding("replaymod.input.settings", 0, () -> {
|
||||
new GuiReplaySettings(null, settingsRegistry).display();
|
||||
@@ -166,9 +163,36 @@ public class ReplayMod {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set when the currently running code has been scheduled by runLater.
|
||||
* If this is the case, subsequent calls to runLater have to be delayed until all scheduled tasks have been
|
||||
* processed, otherwise a livelock may occur.
|
||||
*/
|
||||
private boolean inRunLater = false;
|
||||
|
||||
public void runLater(Runnable runnable) {
|
||||
if (mc.isCallingFromMinecraftThread() && inRunLater) {
|
||||
EventBus bus = MinecraftForge.EVENT_BUS;
|
||||
bus.register(new Object() {
|
||||
@SubscribeEvent
|
||||
public void onRenderTick(TickEvent.RenderTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.START) {
|
||||
runLater(runnable);
|
||||
bus.unregister(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
synchronized (mc.scheduledTasks) {
|
||||
mc.scheduledTasks.add(ListenableFutureTask.create(runnable, null));
|
||||
mc.scheduledTasks.add(ListenableFutureTask.create(() -> {
|
||||
inRunLater = true;
|
||||
try {
|
||||
runnable.run();
|
||||
} finally {
|
||||
inRunLater = false;
|
||||
}
|
||||
}, null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,13 +221,13 @@ public class ReplayMod {
|
||||
private void printToChat(boolean warning, String message, Object... args) {
|
||||
if (getSettingsRegistry().get(Setting.NOTIFICATIONS)) {
|
||||
// Some nostalgia: "§8[§6Replay Mod§8]§r Your message goes here"
|
||||
ChatStyle coloredDarkGray = new ChatStyle().setColor(EnumChatFormatting.DARK_GRAY);
|
||||
ChatStyle coloredGold = new ChatStyle().setColor(EnumChatFormatting.GOLD);
|
||||
IChatComponent text = new ChatComponentText("[").setChatStyle(coloredDarkGray)
|
||||
.appendSibling(new ChatComponentTranslation("replaymod.title").setChatStyle(coloredGold))
|
||||
.appendSibling(new ChatComponentText("] "))
|
||||
.appendSibling(new ChatComponentTranslation(message, args).setChatStyle(new ChatStyle()
|
||||
.setColor(warning ? EnumChatFormatting.RED : EnumChatFormatting.DARK_GREEN)));
|
||||
Style coloredDarkGray = new Style().setColor(TextFormatting.DARK_GRAY);
|
||||
Style coloredGold = new Style().setColor(TextFormatting.GOLD);
|
||||
ITextComponent text = new TextComponentString("[").setStyle(coloredDarkGray)
|
||||
.appendSibling(new TextComponentTranslation("replaymod.title").setStyle(coloredGold))
|
||||
.appendSibling(new TextComponentString("] "))
|
||||
.appendSibling(new TextComponentTranslation(message, args).setStyle(new Style()
|
||||
.setColor(warning ? TextFormatting.RED : TextFormatting.DARK_GREEN)));
|
||||
// Send message to chat GUI
|
||||
// The ingame GUI is initialized at startup, therefore this is possible before the client is connected
|
||||
mc.ingameGUI.getChatGUI().printChatMessage(text);
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.replaymod.core;
|
||||
|
||||
import com.replaymod.core.events.SettingsChangedEvent;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
@@ -83,7 +83,7 @@ public class SettingsRegistry {
|
||||
throw new IllegalArgumentException("Default type " + key.getDefault().getClass() + " not supported.");
|
||||
}
|
||||
settings.put(key, value);
|
||||
FMLCommonHandler.instance().bus().post(new SettingsChangedEvent(this, key));
|
||||
MinecraftForge.EVENT_BUS.post(new SettingsChangedEvent(this, key));
|
||||
}
|
||||
|
||||
public void save() {
|
||||
|
||||
@@ -15,30 +15,17 @@ public class GuiFactory implements IModGuiFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiScreen> mainConfigGuiClass() {
|
||||
return ConfigGuiWrapper.class;
|
||||
public boolean hasConfigGui() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiScreen createConfigGui(GuiScreen parentScreen) {
|
||||
return new GuiReplaySettings(parentScreen, ReplayMod.instance.getSettingsRegistry()).toMinecraft();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class ConfigGuiWrapper extends GuiScreen {
|
||||
private final GuiScreen parent;
|
||||
|
||||
public ConfigGuiWrapper(GuiScreen parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
new GuiReplaySettings(parent, ReplayMod.instance.getSettingsRegistry()).display();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
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.
|
||||
*/
|
||||
@@ -18,17 +16,15 @@ public class MainMenuHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onInit(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||
if (event.gui instanceof GuiMainMenu) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GuiButton> buttonList = event.buttonList;
|
||||
for (GuiButton button : buttonList) {
|
||||
if (event.getGui() instanceof GuiMainMenu) {
|
||||
for (GuiButton button : event.getButtonList()) {
|
||||
// Buttons that aren't in a rectangle directly above our space don't need moving
|
||||
if (button.xPosition + button.width < event.gui.width / 2 - 100
|
||||
|| button.xPosition > event.gui.width / 2 + 100
|
||||
|| button.yPosition > event.gui.height / 4 + 10 + 4 * 24) continue;
|
||||
if (button.x + button.width < event.getGui().width / 2 - 100
|
||||
|| button.x > event.getGui().width / 2 + 100
|
||||
|| button.y > event.getGui().height / 4 + 10 + 4 * 24) continue;
|
||||
// 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
|
||||
button.yPosition -= 2 * 24 - 10;
|
||||
button.y -= 2 * 24 - 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,22 +4,22 @@ import com.replaymod.replaystudio.data.ModInfo;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.ModContainer;
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
import net.minecraftforge.registries.ForgeRegistry;
|
||||
import net.minecraftforge.registries.RegistryManager;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class ModCompat {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Collection<ModInfo> getInstalledNetworkMods() {
|
||||
Map<String, ModContainer> ignoreCaseMap = Loader.instance().getModList().stream()
|
||||
.collect(Collectors.toMap(m -> m.getModId().toLowerCase(), Function.identity()));
|
||||
return Stream.concat(
|
||||
((Set<ResourceLocation>) GameData.getBlockRegistry().getKeys()).stream(),
|
||||
((Set<ResourceLocation>) GameData.getItemRegistry().getKeys()).stream()
|
||||
).map(ResourceLocation::getResourceDomain).filter(s -> !s.equals("minecraft")).distinct()
|
||||
return RegistryManager.ACTIVE.takeSnapshot(false).keySet().stream()
|
||||
.map(RegistryManager.ACTIVE::getRegistry)
|
||||
.map(ForgeRegistry::getKeys).flatMap(Set::stream)
|
||||
.map(ResourceLocation::getResourceDomain).filter(s -> !s.equals("minecraft")).distinct()
|
||||
.map(String::toLowerCase).map(ignoreCaseMap::get).filter(mod -> mod != null)
|
||||
.map(mod -> new ModInfo(mod.getModId(), mod.getName(), mod.getVersion()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.replaymod.core.utils;
|
||||
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -35,7 +35,7 @@ public class OpenGLUtils {
|
||||
float f5 = 1.0F / textureHeight;
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer vertexBuffer = tessellator.getWorldRenderer();
|
||||
BufferBuilder vertexBuffer = tessellator.getBuffer();
|
||||
GlStateManager.translate(x+(width/2), y+(width/2), 0);
|
||||
GlStateManager.rotate(rotation, 0, 0, 1);
|
||||
vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.replaymod.core.utils;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.server.S3FPacketCustomPayload;
|
||||
import net.minecraft.network.play.server.SPacketCustomPayload;
|
||||
|
||||
/**
|
||||
* Restrictions set by the server,
|
||||
@@ -14,10 +14,10 @@ public class Restrictions {
|
||||
private boolean onlyFirstPerson;
|
||||
private boolean onlyRecordingPlayer;
|
||||
|
||||
public String handle(S3FPacketCustomPayload packet) {
|
||||
public String handle(SPacketCustomPayload packet) {
|
||||
PacketBuffer buffer = packet.getBufferData();
|
||||
while (buffer.isReadable()) {
|
||||
String name = buffer.readStringFromBuffer(64);
|
||||
String name = buffer.readString(64);
|
||||
boolean active = buffer.readBoolean();
|
||||
// if ("no_xray".equals(name)) {
|
||||
// noXray = active;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.replaymod.core.utils;
|
||||
|
||||
import com.google.common.net.PercentEscaper;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
@@ -16,11 +17,14 @@ import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||
import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
||||
import de.johni0702.minecraft.gui.popup.GuiInfoPopup;
|
||||
import de.johni0702.minecraft.gui.utils.Colors;
|
||||
import lombok.SneakyThrows;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.util.Dimension;
|
||||
@@ -36,6 +40,8 @@ import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.KeyStore;
|
||||
import java.security.KeyStoreException;
|
||||
@@ -137,8 +143,24 @@ public class Utils {
|
||||
return mail.matches("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$");
|
||||
}
|
||||
|
||||
private static final PercentEscaper REPLAY_NAME_ENCODER = new PercentEscaper(".-_ ", false);
|
||||
|
||||
public static String replayNameToFileName(String replayName) {
|
||||
return REPLAY_NAME_ENCODER.escape(replayName) + ".mcpr";
|
||||
}
|
||||
|
||||
@SneakyThrows(UnsupportedEncodingException.class)
|
||||
public static String fileNameToReplayName(String fileName) {
|
||||
String baseName = FilenameUtils.getBaseName(fileName);
|
||||
try {
|
||||
return URLDecoder.decode(baseName, Charsets.UTF_8.name());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return baseName;
|
||||
}
|
||||
}
|
||||
|
||||
public static ResourceLocation getResourceLocationForPlayerUUID(UUID uuid) {
|
||||
NetworkPlayerInfo info = getMinecraft().getNetHandler().getPlayerInfo(uuid);
|
||||
NetworkPlayerInfo info = getMinecraft().getConnection().getPlayerInfo(uuid);
|
||||
ResourceLocation skinLocation;
|
||||
if (info != null && info.hasLocationSkin()) {
|
||||
skinLocation = info.getLocationSkin();
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.replaymod.core.utils;
|
||||
import net.minecraft.util.Timer;
|
||||
|
||||
public class WrappedTimer extends Timer {
|
||||
public static final float DEFAULT_MS_PER_TICK = 1000 / 20;
|
||||
|
||||
protected final Timer wrapped;
|
||||
|
||||
public WrappedTimer(Timer wrapped) {
|
||||
@@ -19,15 +21,10 @@ public class WrappedTimer extends Timer {
|
||||
}
|
||||
|
||||
protected void copy(Timer from, Timer to) {
|
||||
to.ticksPerSecond = from.ticksPerSecond;
|
||||
to.lastHRTime = from.lastHRTime;
|
||||
to.elapsedTicks = from.elapsedTicks;
|
||||
to.renderPartialTicks = from.renderPartialTicks;
|
||||
to.timerSpeed = from.timerSpeed;
|
||||
to.elapsedPartialTicks = from.elapsedPartialTicks;
|
||||
to.lastSyncSysClock = from.lastSyncSysClock;
|
||||
to.lastSyncHRClock = from.lastSyncHRClock;
|
||||
to.counter = from.counter;
|
||||
to.timeSyncAdjustment = from.timeSyncAdjustment;
|
||||
to.elapsedPartialTicks = from.elapsedPartialTicks;
|
||||
to.tickLength = from.tickLength;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.apache.logging.log4j.Logger;
|
||||
@Mod(modid = ReplayModEditor.MOD_ID,
|
||||
version = "@MOD_VERSION@",
|
||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||
acceptableRemoteVersions = "*",
|
||||
useMetadata = true)
|
||||
public class ReplayModEditor {
|
||||
public static final String MOD_ID = "replaymod-editor";
|
||||
|
||||
@@ -36,7 +36,6 @@ import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
||||
import de.johni0702.minecraft.gui.utils.Colors;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.lwjgl.util.ReadableDimension;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -125,7 +124,7 @@ public class GuiReplayEditor extends GuiScreen {
|
||||
}
|
||||
|
||||
public void save(File inputFile, PacketStream.FilterInfo...filters) {
|
||||
save(FilenameUtils.getBaseName(inputFile.getName()), (outputFile) -> {
|
||||
save(Utils.fileNameToReplayName(inputFile.getName()), (outputFile) -> {
|
||||
Studio studio = new ReplayStudio();
|
||||
File tmpDir = null;
|
||||
try {
|
||||
@@ -220,7 +219,7 @@ public class GuiReplayEditor extends GuiScreen {
|
||||
Utils.error(LOGGER, GuiReplayEditor.this, CrashReport.makeCrashReport(e, "Getting replay folder"), null);
|
||||
return;
|
||||
}
|
||||
File targetFile = new File(replayFolder, name + ".mcpr");
|
||||
File targetFile = new File(replayFolder, Utils.replayNameToFileName(name));
|
||||
if (targetFile.exists()) {
|
||||
LOGGER.trace("Selected file already exists, asking for confirmation");
|
||||
Futures.addCallback(GuiYesNoPopup.open(GuiReplayEditor.this,
|
||||
|
||||
@@ -20,7 +20,6 @@ import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||
import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.io.IOCase;
|
||||
import org.apache.commons.io.filefilter.SuffixFileFilter;
|
||||
import org.lwjgl.util.Dimension;
|
||||
@@ -52,7 +51,7 @@ public class GuiTrimPanel extends GuiPanel {
|
||||
|
||||
public final GuiDropdownMenu<File> inputReplays = new GuiDropdownMenu<File>(this)
|
||||
.setMinSize(new Dimension(200, 20)).onSelection(i -> updateSelectedReplay())
|
||||
.setToString(f -> f == NO_REPLAY ? "" : FilenameUtils.getBaseName(f.getName()));
|
||||
.setToString(f -> f == NO_REPLAY ? "" : Utils.fileNameToReplayName(f.getName()));
|
||||
|
||||
public final GuiNumberField startHour = newGuiNumberField();
|
||||
public final GuiNumberField startMin = newGuiNumberField();
|
||||
|
||||
@@ -8,11 +8,8 @@ import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GuiHandler {
|
||||
private static final int BUTTON_REPLAY_EDITOR = 17890237;
|
||||
|
||||
@@ -23,31 +20,28 @@ public class GuiHandler {
|
||||
}
|
||||
|
||||
public void register() {
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
||||
if (!(event.gui instanceof GuiMainMenu)) {
|
||||
if (!(event.getGui() instanceof GuiMainMenu)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
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"));
|
||||
GuiButton button = new GuiButton(BUTTON_REPLAY_EDITOR, event.getGui().width / 2 + 2,
|
||||
event.getGui().height / 4 + 10 + 3 * 24, I18n.format("replaymod.gui.replayeditor"));
|
||||
button.width = button.width / 2 - 2;
|
||||
buttonList.add(button);
|
||||
event.getButtonList().add(button);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
||||
if(!event.button.enabled) return;
|
||||
if(!event.getButton().enabled) return;
|
||||
|
||||
if (event.gui instanceof GuiMainMenu) {
|
||||
if (event.button.id == BUTTON_REPLAY_EDITOR) {
|
||||
new GuiReplayEditor(GuiScreen.wrap(event.gui), mod.getCore()).display();
|
||||
if (event.getGui() instanceof GuiMainMenu) {
|
||||
if (event.getButton().id == BUTTON_REPLAY_EDITOR) {
|
||||
new GuiReplayEditor(GuiScreen.wrap(event.getGui()), 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.layout.HorizontalLayout;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
@@ -40,7 +40,7 @@ public class FullBrightness implements Extra {
|
||||
}
|
||||
});
|
||||
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@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.LayoutData;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.util.Dimension;
|
||||
@@ -35,7 +35,7 @@ public class HotkeyButtons implements Extra {
|
||||
public void register(ReplayMod mod) throws Exception {
|
||||
this.mod = mod;
|
||||
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.replaymod.core.ReplayMod;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.IResourcePack;
|
||||
import net.minecraft.client.resources.data.IMetadataSection;
|
||||
import net.minecraft.client.resources.data.IMetadataSerializer;
|
||||
import net.minecraft.client.resources.data.MetadataSerializer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
@@ -99,12 +99,12 @@ public class LocalizationExtra implements Extra {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set getResourceDomains() {
|
||||
public Set<String> getResourceDomains() {
|
||||
return ImmutableSet.of("replaymod");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMetadataSection getPackMetadata(IMetadataSerializer p_135058_1_, String p_135058_2_) throws IOException {
|
||||
public <T extends IMetadataSection> T getPackMetadata(MetadataSerializer metadataSerializer, String metadataSectionName) throws IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
|
||||
import static com.replaymod.core.utils.Utils.SSL_SOCKET_FACTORY;
|
||||
import static com.replaymod.extras.ReplayModExtras.LOGGER;
|
||||
|
||||
public class OpenEyeExtra implements Extra {
|
||||
private static final String DOWNLOAD_URL = "https://www.replaymod.com/dl/openeye/" + Loader.MC_VERSION;
|
||||
@@ -39,7 +40,25 @@ public class OpenEyeExtra implements Extra {
|
||||
mod.getSettingsRegistry().register(ASK_FOR_OPEN_EYE);
|
||||
|
||||
if (!Loader.isModLoaded("OpenEye") && mod.getSettingsRegistry().get(ASK_FOR_OPEN_EYE)) {
|
||||
mod.runLater(() -> new OfferGui(GuiScreen.wrap(mod.getMinecraft().currentScreen)).display());
|
||||
new Thread(() -> {
|
||||
try {
|
||||
LOGGER.trace("Checking for OpenEye availability");
|
||||
HttpsURLConnection connection = (HttpsURLConnection) new URL(DOWNLOAD_URL).openConnection();
|
||||
connection.setSSLSocketFactory(SSL_SOCKET_FACTORY);
|
||||
connection.setRequestMethod("HEAD");
|
||||
connection.connect();
|
||||
LOGGER.trace("Got response code: {}", connection.getResponseCode());
|
||||
if (connection.getResponseCode() == 200) {
|
||||
mod.runLater(() -> new OfferGui(GuiScreen.wrap(mod.getMinecraft().currentScreen)).display());
|
||||
} else {
|
||||
LOGGER.info("Cannot offer OpenEye, server returned: {} {}",
|
||||
connection.getResponseCode(), connection.getResponseMessage());
|
||||
}
|
||||
connection.disconnect();
|
||||
} catch (Throwable e) {
|
||||
LOGGER.error("Failed to check for OpenEye availability:", e);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,11 +10,15 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@Mod(modid = ReplayModExtras.MOD_ID,
|
||||
version = "@MOD_VERSION@",
|
||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||
acceptableRemoteVersions = "*",
|
||||
useMetadata = true)
|
||||
public class ReplayModExtras {
|
||||
public static final String MOD_ID = "replaymod-extras";
|
||||
@@ -32,6 +36,8 @@ public class ReplayModExtras {
|
||||
OpenEyeExtra.class
|
||||
);
|
||||
|
||||
private final Map<Class<? extends Extra>, Extra> instances = new HashMap<>();
|
||||
|
||||
public static Logger LOGGER;
|
||||
|
||||
@Mod.EventHandler
|
||||
@@ -45,9 +51,14 @@ public class ReplayModExtras {
|
||||
try {
|
||||
Extra extra = cls.newInstance();
|
||||
extra.register(ReplayMod.instance);
|
||||
instances.put(cls, extra);
|
||||
} catch (Throwable t) {
|
||||
LOGGER.warn("Failed to load extra " + cls.getName() + ": ", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends Extra> Optional<T> get(Class<T> cls) {
|
||||
return Optional.ofNullable(instances.get(cls)).map(cls::cast);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,13 +9,10 @@ import com.replaymod.replay.ReplayModReplay;
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import com.replaymod.replay.events.ReplayCloseEvent;
|
||||
import com.replaymod.replay.events.ReplayOpenEvent;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
@@ -37,7 +34,7 @@ public class PlayerOverview implements Extra {
|
||||
public void run() {
|
||||
if (module.getReplayHandler() != null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<EntityPlayer> players = mod.getMinecraft().theWorld.getPlayers(EntityPlayer.class, new Predicate() {
|
||||
List<EntityPlayer> players = mod.getMinecraft().world.getPlayers(EntityPlayer.class, new Predicate() {
|
||||
@Override
|
||||
public boolean apply(Object input) {
|
||||
return !(input instanceof CameraEntity); // Exclude the camera entity
|
||||
@@ -58,14 +55,7 @@ public class PlayerOverview implements Extra {
|
||||
}
|
||||
});
|
||||
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
RenderManager renderManager = mod.getMinecraft().getRenderManager();
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, RenderPlayer> skinMap = renderManager.skinMap;
|
||||
skinMap.put("default", new PlayerRenderHook(this, renderManager, false));
|
||||
skinMap.put("slim", new PlayerRenderHook(this, renderManager, true));
|
||||
}
|
||||
|
||||
public boolean isHidden(UUID uuid) {
|
||||
|
||||
@@ -21,7 +21,8 @@ import de.johni0702.minecraft.gui.utils.Colors;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EnumPlayerModelParts;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.util.Dimension;
|
||||
import org.lwjgl.util.ReadableDimension;
|
||||
@@ -46,14 +47,14 @@ public class PlayerOverviewGui extends GuiScreen implements Closeable {
|
||||
public final GuiCheckbox checkAll = new GuiCheckbox(contentPanel){
|
||||
@Override
|
||||
public void onClick() {
|
||||
getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(BUTTON_SOUND, 1.0F));
|
||||
getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
||||
playersScrollable.forEach(IGuiCheckbox.class).setChecked(true);
|
||||
}
|
||||
}.setLabel("").setChecked(true).setTooltip(new GuiTooltip().setI18nText("replaymod.gui.playeroverview.showall"));
|
||||
public final GuiCheckbox uncheckAll = new GuiCheckbox(contentPanel){
|
||||
@Override
|
||||
public void onClick() {
|
||||
getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(BUTTON_SOUND, 1.0F));
|
||||
getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
||||
playersScrollable.forEach(IGuiCheckbox.class).setChecked(false);
|
||||
}
|
||||
}.setLabel("").setChecked(false).setTooltip(new GuiTooltip().setI18nText("replaymod.gui.playeroverview.hideall"));
|
||||
@@ -145,7 +146,7 @@ public class PlayerOverviewGui extends GuiScreen implements Closeable {
|
||||
}
|
||||
|
||||
private static boolean isSpectator(EntityPlayer e) {
|
||||
return e.isInvisible() && e.getActivePotionEffect(Potion.invisibility) == null;
|
||||
return e.isInvisible() && e.getActivePotionEffect(MobEffects.INVISIBILITY) == null;
|
||||
}
|
||||
|
||||
private static final class PlayerComparator implements Comparator<EntityPlayer> {
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.replaymod.extras.playeroverview;
|
||||
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.renderer.culling.ICamera;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||
|
||||
public class PlayerRenderHook extends RenderPlayer {
|
||||
private final PlayerOverview extra;
|
||||
|
||||
public PlayerRenderHook(PlayerOverview extra, RenderManager renderManager, boolean useSmallArms) {
|
||||
super(renderManager, useSmallArms);
|
||||
this.extra = extra;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender(AbstractClientPlayer entity, ICamera camera, double camX, double camY, double camZ) {
|
||||
return !extra.isHidden(entity.getUniqueID()) && super.shouldRender(entity, camera, camX, camY, camZ);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.replaymod.extras.playeroverview.mixin;
|
||||
|
||||
import com.replaymod.extras.ReplayModExtras;
|
||||
import com.replaymod.extras.playeroverview.PlayerOverview;
|
||||
import net.minecraft.client.renderer.culling.ICamera;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
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;
|
||||
|
||||
/**
|
||||
* This mixin prevents players that are hidden in the PlayerOverview from being rendered.
|
||||
*
|
||||
* Cancelling the RenderPlayerEvent.Pre is insufficient because it affects neither the shadows nor the fire texture.
|
||||
* See: https://github.com/MinecraftForge/MinecraftForge/issues/2987
|
||||
*
|
||||
* The previous solution was to overwrite the RenderPlayer instances which has been dropped in favor of this one
|
||||
* because it is less compatible with other mods whereas this one should be fine as long as no other mod completely
|
||||
* overwrites the shouldRender method.
|
||||
* One example of the previous solution breaking is when used with VanillaEnhancements because it replaces the
|
||||
* RenderManager with a new custom one which in turn will reset our registered RenderPlayer instances because
|
||||
* it does so after we have already registered with the old RenderManager.
|
||||
*/
|
||||
@Mixin(value = Render.class, priority = 1200)
|
||||
public abstract class MixinRender {
|
||||
@Inject(method = "shouldRender", at=@At("HEAD"), cancellable = true)
|
||||
public void replayModExtras_isPlayerHidden(Entity entity, ICamera camera, double camX, double camY, double camZ, CallbackInfoReturnable<Boolean> ci) {
|
||||
ReplayModExtras.instance.get(PlayerOverview.class).ifPresent(playerOverview -> {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
if (playerOverview.isHidden(player.getUniqueID())) {
|
||||
ci.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ public class LinuxUriScheme extends UriScheme {
|
||||
"Icon=" + iconFile.getAbsolutePath().replace("\\", "\\\\").replace("\"", "\\\"") + "\n" +
|
||||
"Type=Application\n" +
|
||||
"Terminal=false\n" +
|
||||
"NoDisplay=true\n" +
|
||||
"MimeType=x-scheme-handler/replaymod;";
|
||||
|
||||
FileOutputStream out = new FileOutputStream(file);
|
||||
|
||||
@@ -17,8 +17,8 @@ public class YoutubeUpload implements Extra {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onGuiOpen(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||
if (GuiScreen.from(event.gui) instanceof GuiRenderingDone) {
|
||||
GuiRenderingDone gui = (GuiRenderingDone) GuiScreen.from(event.gui);
|
||||
if (GuiScreen.from(event.getGui()) instanceof GuiRenderingDone) {
|
||||
GuiRenderingDone gui = (GuiRenderingDone) GuiScreen.from(event.getGui());
|
||||
// Check if there already is a youtube button
|
||||
if (gui.actionsPanel.getChildren().stream().anyMatch(it -> it instanceof YoutubeButton)) {
|
||||
return; // Button already added
|
||||
|
||||
@@ -36,6 +36,8 @@ import java.security.GeneralSecurityException;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static com.replaymod.extras.ReplayModExtras.LOGGER;
|
||||
|
||||
public class YoutubeUploader {
|
||||
private static final String CLIENT_ID = "743126594724-mfe7pj1k7e47uu5pk4503c8st9vj9ibu.apps.googleusercontent.com";
|
||||
private static final String CLIENT_SECRET = "gMwcy3mRYCRamCIjJIYP7rqc";
|
||||
@@ -137,7 +139,7 @@ public class YoutubeUploader {
|
||||
|
||||
CommandLine commandLine = new CommandLine(settings.getExportCommand());
|
||||
commandLine.addArguments(args);
|
||||
System.out.println("Re-encoding for ODS with " + settings.getExportCommand() + args);
|
||||
LOGGER.info("Re-encoding for ODS with {} {}", settings.getExportCommand(), args);
|
||||
Process process = new ProcessBuilder(commandLine.toStrings()).directory(videoFile.getParentFile()).start();
|
||||
|
||||
final AtomicBoolean active = new AtomicBoolean(true);
|
||||
@@ -149,7 +151,7 @@ public class YoutubeUploader {
|
||||
char c = (char) in.read();
|
||||
if (c == '\r') {
|
||||
String str = sb.toString();
|
||||
System.out.println(str);
|
||||
LOGGER.debug("[FFmpeg] {}", str);
|
||||
if (str.startsWith("frame=")) {
|
||||
str = str.substring(6).trim();
|
||||
str = str.substring(0, str.indexOf(' '));
|
||||
|
||||
@@ -12,8 +12,8 @@ import com.replaymod.replaystudio.replay.ReplayFile;
|
||||
import com.replaymod.replaystudio.replay.ZipReplayFile;
|
||||
import com.replaymod.replaystudio.studio.ReplayStudio;
|
||||
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
@@ -29,6 +29,7 @@ import static net.minecraft.client.Minecraft.getMinecraft;
|
||||
@Mod(modid = ReplayModOnline.MOD_ID,
|
||||
version = "@MOD_VERSION@",
|
||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||
acceptableRemoteVersions = "*",
|
||||
useMetadata = true)
|
||||
public class ReplayModOnline {
|
||||
public static final String MOD_ID = "replaymod-online";
|
||||
@@ -40,7 +41,7 @@ public class ReplayModOnline {
|
||||
|
||||
private ReplayModReplay replayModule;
|
||||
|
||||
private Logger logger;
|
||||
public static Logger LOGGER;
|
||||
|
||||
private ApiClient apiClient;
|
||||
|
||||
@@ -53,7 +54,7 @@ public class ReplayModOnline {
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
logger = event.getModLog();
|
||||
LOGGER = event.getModLog();
|
||||
core = ReplayMod.instance;
|
||||
replayModule = ReplayModReplay.instance;
|
||||
|
||||
@@ -69,12 +70,12 @@ public class ReplayModOnline {
|
||||
public void init(FMLInitializationEvent event) {
|
||||
if (!getDownloadsFolder().exists()){
|
||||
if (!getDownloadsFolder().mkdirs()) {
|
||||
logger.warn("Failed to create downloads folder: " + getDownloadsFolder());
|
||||
LOGGER.warn("Failed to create downloads folder: " + getDownloadsFolder());
|
||||
}
|
||||
}
|
||||
|
||||
new GuiHandler(this).register();
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
@@ -82,7 +83,10 @@ public class ReplayModOnline {
|
||||
// Initial login prompt
|
||||
if (!core.getSettingsRegistry().get(Setting.SKIP_LOGIN_PROMPT)) {
|
||||
if (!isLoggedIn()) {
|
||||
core.runLater(() -> new GuiLoginPrompt(apiClient, GuiScreen.wrap(getMinecraft().currentScreen), null, false).display());
|
||||
core.runLater(() -> {
|
||||
GuiScreen parent = GuiScreen.wrap(getMinecraft().currentScreen);
|
||||
new GuiLoginPrompt(apiClient, parent, parent, false).display();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,7 +100,7 @@ public class ReplayModOnline {
|
||||
}
|
||||
|
||||
public Logger getLogger() {
|
||||
return logger;
|
||||
return LOGGER;
|
||||
}
|
||||
|
||||
public ApiClient getApiClient() {
|
||||
|
||||
@@ -2,7 +2,13 @@ package com.replaymod.online.api.replay.holders;
|
||||
|
||||
public enum MinecraftVersion {
|
||||
|
||||
MC_1_8("Minecraft 1.8", "1.8");
|
||||
MC_1_8("Minecraft 1.8", "1.8"),
|
||||
MC_1_9_4("Minecraft 1.9.4", "1.9.4"),
|
||||
MC_1_10_2("Minecraft 1.10.2", "1.10.2"),
|
||||
MC_1_11("Minecraft 1.11", "1.11"),
|
||||
MC_1_11_2("Minecraft 1.11.2", "1.11.2"),
|
||||
MC_1_12("Minecraft 1.12", "1.12"),
|
||||
MC_1_12_1("Minecraft 1.12.1", "1.12.1");
|
||||
|
||||
private String niceName, apiName;
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class GuiRegister extends AbstractGuiScreen<GuiRegister> {
|
||||
pos(cancelButton, width / 2 + 2, 170);
|
||||
pos(statusLabel, width / 2 - statusLabel.getMinSize().getWidth() / 2, 152);
|
||||
|
||||
FontRenderer font = getMinecraft().fontRendererObj;
|
||||
FontRenderer font = getMinecraft().fontRenderer;
|
||||
int lineCount = font.listFormattedStringToWidth(disclaimerLabel.getText(), width - 10).size();
|
||||
Dimension dim = new Dimension(width - 10, font.FONT_HEIGHT * lineCount);
|
||||
disclaimerLabel.setSize(dim);
|
||||
|
||||
@@ -37,9 +37,7 @@ import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
||||
import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
||||
import de.johni0702.minecraft.gui.utils.Colors;
|
||||
import de.johni0702.minecraft.gui.utils.Consumer;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.logging.log4j.core.helpers.Strings;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.lwjgl.util.Dimension;
|
||||
import org.lwjgl.util.ReadableDimension;
|
||||
|
||||
@@ -51,6 +49,8 @@ import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.replaymod.online.ReplayModOnline.LOGGER;
|
||||
|
||||
public class GuiReplayCenter extends GuiScreen {
|
||||
private final ReplayModOnline mod;
|
||||
private final ApiClient apiClient;
|
||||
@@ -336,7 +336,7 @@ public class GuiReplayCenter extends GuiScreen {
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
FMLLog.getLogger().error("Could not load Replay File " + fileInfo.getId(), e);
|
||||
LOGGER.error("Could not load Replay File {}", fileInfo.getId(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -417,7 +417,7 @@ public class GuiReplayCenter extends GuiScreen {
|
||||
this.downloaded = downloaded;
|
||||
ReplayMetaData metaData = fileInfo.getMetadata();
|
||||
|
||||
name.setText(ChatFormatting.UNDERLINE + FilenameUtils.getBaseName(fileInfo.getName()));
|
||||
name.setText(ChatFormatting.UNDERLINE + Utils.fileNameToReplayName(fileInfo.getName()));
|
||||
author.setI18nText("replaymod.gui.center.author",
|
||||
"" + ChatFormatting.GRAY + ChatFormatting.ITALIC, fileInfo.getOwner());
|
||||
if (Strings.isEmpty(metaData.getServerName())) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.replaymod.online.gui;
|
||||
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.replaymod.core.utils.Utils;
|
||||
import de.johni0702.minecraft.gui.container.GuiPanel;
|
||||
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||
import de.johni0702.minecraft.gui.element.GuiButton;
|
||||
@@ -27,7 +28,7 @@ public class GuiSaveModifiedReplay extends GuiScreen {
|
||||
@Override
|
||||
public void run() {
|
||||
String resultName = name.getText().trim().replace("[^a-zA-Z0-9\\.\\- ]", "_");
|
||||
final File resultFile = new File(file.getParentFile(), resultName + ".mcpr");
|
||||
final File resultFile = new File(file.getParentFile(), Utils.replayNameToFileName(resultName));
|
||||
if (resultFile.exists()) {
|
||||
Futures.addCallback(GuiYesNoPopup.open(GuiSaveModifiedReplay.this,
|
||||
new GuiLabel().setI18nText("replaymod.gui.replaymodified.warning1", resultName).setColor(Colors.BLACK),
|
||||
|
||||
@@ -38,7 +38,6 @@ import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.util.ReportedException;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -135,7 +134,7 @@ public class GuiUploadReplay extends GuiScreen {
|
||||
}
|
||||
|
||||
// Apply to gui
|
||||
name.setText(FilenameUtils.getBaseName(file.getName()));
|
||||
name.setText(Utils.fileNameToReplayName(file.getName()));
|
||||
int secs = metaData.getDuration() / 1000;
|
||||
durationLabel.setI18nText("replaymod.gui.upload.duration", secs / 60, secs % 60);
|
||||
hideServerIP.setEnabled(!metaData.isSingleplayer());
|
||||
|
||||
@@ -14,11 +14,9 @@ import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiHandler {
|
||||
private static final int BUTTON_REPLAY_CENTER = 17890236;
|
||||
@@ -30,26 +28,23 @@ public class GuiHandler {
|
||||
}
|
||||
|
||||
public void register() {
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
||||
if (!(event.gui instanceof GuiMainMenu)) {
|
||||
if (!(event.getGui() instanceof GuiMainMenu)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GuiButton> buttonList = event.buttonList;
|
||||
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);
|
||||
GuiButton button = new GuiButton(BUTTON_REPLAY_CENTER, event.getGui().width / 2 - 100,
|
||||
event.getGui().height / 4 + 10 + 4 * 24, I18n.format("replaymod.gui.replaycenter"));
|
||||
event.getButtonList().add(button);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void injectIntoReplayViewer(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||
AbstractGuiScreen guiScreen = GuiScreen.from(event.gui);
|
||||
AbstractGuiScreen guiScreen = GuiScreen.from(event.getGui());
|
||||
if (!(guiScreen instanceof GuiReplayViewer)) {
|
||||
return;
|
||||
}
|
||||
@@ -75,15 +70,15 @@ public class GuiHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
||||
if(!event.button.enabled) return;
|
||||
if(!event.getButton().enabled) return;
|
||||
|
||||
if (event.gui instanceof GuiMainMenu) {
|
||||
if (event.button.id == BUTTON_REPLAY_CENTER) {
|
||||
if (event.getGui() instanceof GuiMainMenu) {
|
||||
if (event.getButton().id == BUTTON_REPLAY_CENTER) {
|
||||
GuiReplayCenter replayCenter = new GuiReplayCenter(mod);
|
||||
if (mod.isLoggedIn()) {
|
||||
replayCenter.display();
|
||||
} else {
|
||||
new GuiLoginPrompt(mod.getApiClient(), GuiScreen.wrap(event.gui), replayCenter, true).display();
|
||||
new GuiLoginPrompt(mod.getApiClient(), GuiScreen.wrap(event.getGui()), replayCenter, true).display();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,13 @@ import com.google.common.collect.Ordering;
|
||||
import com.google.common.primitives.Longs;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.common.util.concurrent.SettableFuture;
|
||||
import com.replaymod.core.utils.WrappedTimer;
|
||||
import com.replaymod.replay.ReplayHandler;
|
||||
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
||||
import com.replaymod.replaystudio.pathing.path.Path;
|
||||
import com.replaymod.replaystudio.pathing.path.Timeline;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -65,11 +66,11 @@ public abstract class AbstractTimelinePlayer {
|
||||
}
|
||||
|
||||
replayHandler.getReplaySender().setSyncModeAndWait();
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
lastTime = 0;
|
||||
mc.timer = new ReplayTimer(mc.timer);
|
||||
mc.timer.timerSpeed = 1;
|
||||
mc.timer.elapsedPartialTicks = mc.timer.elapsedTicks = 0;
|
||||
mc.timer.tickLength = WrappedTimer.DEFAULT_MS_PER_TICK;
|
||||
mc.timer.renderPartialTicks = mc.timer.elapsedTicks = 0;
|
||||
return future = settableFuture = SettableFuture.create();
|
||||
}
|
||||
|
||||
@@ -87,7 +88,7 @@ public abstract class AbstractTimelinePlayer {
|
||||
mc.timer = ((ReplayTimer) mc.timer).getWrapped();
|
||||
replayHandler.getReplaySender().setReplaySpeed(0);
|
||||
replayHandler.getReplaySender().setAsyncMode(true);
|
||||
FMLCommonHandler.instance().bus().unregister(this);
|
||||
MinecraftForge.EVENT_BUS.unregister(this);
|
||||
return;
|
||||
}
|
||||
long time = getTimePassed();
|
||||
@@ -107,10 +108,9 @@ public abstract class AbstractTimelinePlayer {
|
||||
float timeInTicks = replayTime / 50f;
|
||||
float previousTimeInTicks = lastTime / 50f;
|
||||
float passedTicks = timeInTicks - previousTimeInTicks;
|
||||
mc.timer.elapsedPartialTicks += passedTicks;
|
||||
mc.timer.elapsedTicks = (int) mc.timer.elapsedPartialTicks;
|
||||
mc.timer.elapsedPartialTicks -= mc.timer.elapsedTicks;
|
||||
mc.timer.renderPartialTicks = mc.timer.elapsedPartialTicks;
|
||||
mc.timer.renderPartialTicks += passedTicks;
|
||||
mc.timer.elapsedTicks = (int) mc.timer.renderPartialTicks;
|
||||
mc.timer.renderPartialTicks -= mc.timer.elapsedTicks;
|
||||
|
||||
lastTime = replayTime;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.replaymod.pathing.player;
|
||||
|
||||
import com.replaymod.core.utils.WrappedTimer;
|
||||
import net.minecraft.util.Timer;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
/**
|
||||
@@ -20,7 +20,7 @@ public class ReplayTimer extends WrappedTimer {
|
||||
copy(this, state); // Save our current state
|
||||
super.updateTimer(); // Update current state
|
||||
copy(state, this); // Restore our old state
|
||||
FMLCommonHandler.instance().bus().post(new UpdatedEvent());
|
||||
MinecraftForge.EVENT_BUS.post(new UpdatedEvent());
|
||||
}
|
||||
|
||||
public Timer getWrapped() {
|
||||
|
||||
@@ -6,8 +6,8 @@ import com.replaymod.recording.handler.ConnectionEventHandler;
|
||||
import com.replaymod.recording.packet.PacketListener;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
@@ -19,6 +19,7 @@ import org.lwjgl.input.Keyboard;
|
||||
@Mod(modid = ReplayModRecording.MOD_ID,
|
||||
version = "@MOD_VERSION@",
|
||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||
acceptableRemoteVersions = "*",
|
||||
useMetadata = true)
|
||||
public class ReplayModRecording {
|
||||
public static final String MOD_ID = "replaymod-recording";
|
||||
@@ -53,7 +54,7 @@ public class ReplayModRecording {
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
EventBus bus = FMLCommonHandler.instance().bus();
|
||||
EventBus bus = MinecraftForge.EVENT_BUS;
|
||||
bus.register(connectionEventHandler = new ConnectionEventHandler(logger, core));
|
||||
|
||||
NetworkRegistry.INSTANCE.newChannel(Restrictions.PLUGIN_CHANNEL, new RestrictionsChannelHandler());
|
||||
|
||||
@@ -40,9 +40,9 @@ public class GuiRecordingOverlay {
|
||||
*/
|
||||
@SubscribeEvent
|
||||
public void renderRecordingIndicator(RenderGameOverlayEvent.Post event) {
|
||||
if (event.type != RenderGameOverlayEvent.ElementType.ALL) return;
|
||||
if (event.getType() != RenderGameOverlayEvent.ElementType.ALL) return;
|
||||
if (settingsRegistry.get(Setting.INDICATOR)) {
|
||||
FontRenderer fontRenderer = mc.fontRendererObj;
|
||||
FontRenderer fontRenderer = mc.fontRenderer;
|
||||
fontRenderer.drawString(I18n.format("replaymod.gui.recording").toUpperCase(), 30, 18 - (fontRenderer.FONT_HEIGHT / 2), 0xffffffff);
|
||||
mc.renderEngine.bindTexture(TEXTURE);
|
||||
GlStateManager.resetColor();
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.replaymod.recording.handler;
|
||||
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import com.replaymod.core.utils.ModCompat;
|
||||
import com.replaymod.core.utils.Utils;
|
||||
import com.replaymod.recording.Setting;
|
||||
import com.replaymod.recording.gui.GuiRecordingOverlay;
|
||||
import com.replaymod.recording.packet.PacketListener;
|
||||
@@ -46,7 +47,7 @@ public class ConnectionEventHandler {
|
||||
try {
|
||||
boolean local = networkManager.isLocalChannel();
|
||||
if (local) {
|
||||
if (mc.getIntegratedServer().getEntityWorld().getWorldType() == WorldType.DEBUG_WORLD) {
|
||||
if (mc.getIntegratedServer().getEntityWorld().getWorldType() == WorldType.DEBUG_ALL_BLOCK_STATES) {
|
||||
logger.info("Debug World recording is not supported.");
|
||||
return;
|
||||
}
|
||||
@@ -66,6 +67,9 @@ public class ConnectionEventHandler {
|
||||
worldName = mc.getIntegratedServer().getWorldName();
|
||||
} else if (Minecraft.getMinecraft().getCurrentServerData() != null) {
|
||||
worldName = Minecraft.getMinecraft().getCurrentServerData().serverIP;
|
||||
} else if (Minecraft.getMinecraft().isConnectedToRealms()) {
|
||||
// we can't access the server name without tapping too deep in the Realms Library
|
||||
worldName = "A Realms Server";
|
||||
} else {
|
||||
logger.info("Recording not started as the world is neither local nor remote (probably a replay).");
|
||||
return;
|
||||
@@ -74,7 +78,7 @@ public class ConnectionEventHandler {
|
||||
File folder = core.getReplayFolder();
|
||||
|
||||
String name = sdf.format(Calendar.getInstance().getTime());
|
||||
File currentFile = new File(folder, name + ".mcpr");
|
||||
File currentFile = new File(folder, Utils.replayNameToFileName(name));
|
||||
ReplayFile replayFile = new ZipReplayFile(new ReplayStudio(), currentFile);
|
||||
|
||||
replayFile.writeModInfo(ModCompat.getInstalledNetworkMods());
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
package com.replaymod.recording.handler;
|
||||
|
||||
import com.replaymod.recording.packet.PacketListener;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.datasync.EntityDataManager;
|
||||
import net.minecraft.network.play.server.*;
|
||||
import net.minecraft.network.play.server.S14PacketEntity.S17PacketEntityLookMove;
|
||||
import net.minecraft.server.integrated.IntegratedServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.minecart.MinecartInteractEvent;
|
||||
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.gameevent.PlayerEvent.ItemPickupEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
@@ -32,24 +30,24 @@ public class RecordingEventHandler {
|
||||
private final PacketListener packetListener;
|
||||
|
||||
private Double lastX, lastY, lastZ;
|
||||
private ItemStack[] playerItems = new ItemStack[5];
|
||||
private ItemStack[] playerItems = new ItemStack[6];
|
||||
private int ticksSinceLastCorrection;
|
||||
private boolean wasSleeping;
|
||||
private int lastRiding = -1;
|
||||
private Integer rotationYawHeadBefore;
|
||||
private boolean wasHandActive;
|
||||
private EnumHand lastActiveHand;
|
||||
|
||||
public RecordingEventHandler(PacketListener packetListener) {
|
||||
this.packetListener = packetListener;
|
||||
}
|
||||
|
||||
public void register() {
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
((RecordingEventSender) mc.renderGlobal).setRecordingEventHandler(this);
|
||||
}
|
||||
|
||||
public void unregister() {
|
||||
FMLCommonHandler.instance().bus().unregister(this);
|
||||
MinecraftForge.EVENT_BUS.unregister(this);
|
||||
RecordingEventSender recordingEventSender = ((RecordingEventSender) mc.renderGlobal);
|
||||
if (recordingEventSender.getRecordingEventHandler() == this) {
|
||||
@@ -59,7 +57,7 @@ public class RecordingEventHandler {
|
||||
|
||||
public void onPlayerJoin() {
|
||||
try {
|
||||
packetListener.save(spawnPlayer(mc.thePlayer));
|
||||
packetListener.save(new SPacketSpawnPlayer(mc.player));
|
||||
} catch(Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
@@ -67,46 +65,35 @@ public class RecordingEventHandler {
|
||||
|
||||
public void onPlayerRespawn() {
|
||||
try {
|
||||
packetListener.save(spawnPlayer(mc.thePlayer));
|
||||
packetListener.save(new SPacketSpawnPlayer(mc.player));
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private S0CPacketSpawnPlayer spawnPlayer(EntityPlayer player) {
|
||||
public void onClientSound(SoundEvent sound, SoundCategory category,
|
||||
double x, double y, double z, float volume, float pitch) {
|
||||
try {
|
||||
S0CPacketSpawnPlayer packet = new S0CPacketSpawnPlayer();
|
||||
|
||||
ByteBuf bb = Unpooled.buffer();
|
||||
PacketBuffer pb = new PacketBuffer(bb);
|
||||
|
||||
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;
|
||||
// Send to all other players in ServerWorldEventHandler#playSoundToAllNearExcept
|
||||
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) {
|
||||
try {
|
||||
// Send to all other players in ServerWorldEventHandler#playEvent
|
||||
packetListener.save(new SPacketEffect(type, pos, data, false));
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerTick(PlayerTickEvent e) {
|
||||
try {
|
||||
if(e.player != mc.thePlayer) return;
|
||||
if(e.player != mc.player) return;
|
||||
|
||||
boolean force = false;
|
||||
if(lastX == null || lastY == null || lastZ == null) {
|
||||
@@ -131,19 +118,14 @@ public class RecordingEventHandler {
|
||||
lastZ = e.player.posZ;
|
||||
|
||||
Packet packet;
|
||||
if(force || Math.abs(dx) > 4.0 || Math.abs(dy) > 4.0 || Math.abs(dz) > 4.0) {
|
||||
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);
|
||||
if (force || Math.abs(dx) > 8.0 || Math.abs(dy) > 8.0 || Math.abs(dz) > 8.0) {
|
||||
packet = new SPacketEntityTeleport(e.player);
|
||||
} else {
|
||||
byte newYaw = (byte) ((int) (e.player.rotationYaw * 256.0F / 360.0F));
|
||||
byte newPitch = (byte) ((int) (e.player.rotationPitch * 256.0F / 360.0F));
|
||||
|
||||
packet = new S17PacketEntityLookMove(e.player.getEntityId(),
|
||||
(byte) Math.round(dx * 32), (byte) Math.round(dy * 32), (byte) Math.round(dz * 32),
|
||||
packet = new SPacketEntity.S17PacketEntityLookMove(e.player.getEntityId(),
|
||||
(short) Math.round(dx * 4096), (short) Math.round(dy * 4096), (short) Math.round(dz * 4096),
|
||||
newYaw, newPitch, e.player.onGround);
|
||||
}
|
||||
|
||||
@@ -153,37 +135,16 @@ public class RecordingEventHandler {
|
||||
int rotationYawHead = ((int)(e.player.rotationYawHead * 256.0F / 360.0F));
|
||||
|
||||
if(!Objects.equals(rotationYawHead, rotationYawHeadBefore)) {
|
||||
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);
|
||||
|
||||
packetListener.save(new SPacketEntityHeadLook(e.player, (byte) rotationYawHead));
|
||||
rotationYawHeadBefore = rotationYawHead;
|
||||
}
|
||||
|
||||
S12PacketEntityVelocity vel = new S12PacketEntityVelocity(e.player.getEntityId(), e.player.motionX, e.player.motionY, e.player.motionZ);
|
||||
packetListener.save(vel);
|
||||
packetListener.save(new SPacketEntityVelocity(e.player.getEntityId(), e.player.motionX, e.player.motionY, e.player.motionZ));
|
||||
|
||||
//Animation Packets
|
||||
//Swing Animation
|
||||
if(e.player.swingProgressInt == 1) {
|
||||
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);
|
||||
if (e.player.isSwingInProgress && e.player.swingProgressInt == -1) {
|
||||
packetListener.save(new SPacketAnimation(e.player, e.player.swingingHand == EnumHand.MAIN_HAND ? 0 : 3));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -207,77 +168,64 @@ public class RecordingEventHandler {
|
||||
*/
|
||||
|
||||
//Inventory Handling
|
||||
if(playerItems[0] != mc.thePlayer.getHeldItem()) {
|
||||
playerItems[0] = mc.thePlayer.getHeldItem();
|
||||
S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 0, playerItems[0]);
|
||||
packetListener.save(pee);
|
||||
if (playerItems[0] != mc.player.getHeldItem(EnumHand.MAIN_HAND)) {
|
||||
playerItems[0] = mc.player.getHeldItem(EnumHand.MAIN_HAND);
|
||||
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.MAINHAND, playerItems[0]));
|
||||
}
|
||||
|
||||
if(playerItems[1] != mc.thePlayer.inventory.armorInventory[0]) {
|
||||
playerItems[1] = mc.thePlayer.inventory.armorInventory[0];
|
||||
S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 1, playerItems[1]);
|
||||
packetListener.save(pee);
|
||||
if (playerItems[1] != mc.player.getHeldItem(EnumHand.OFF_HAND)) {
|
||||
playerItems[1] = mc.player.getHeldItem(EnumHand.OFF_HAND);
|
||||
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.OFFHAND, playerItems[1]));
|
||||
}
|
||||
|
||||
if(playerItems[2] != mc.thePlayer.inventory.armorInventory[1]) {
|
||||
playerItems[2] = mc.thePlayer.inventory.armorInventory[1];
|
||||
S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 2, playerItems[2]);
|
||||
packetListener.save(pee);
|
||||
if (playerItems[2] != mc.player.getItemStackFromSlot(EntityEquipmentSlot.FEET)) {
|
||||
playerItems[2] = mc.player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
|
||||
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.FEET, playerItems[2]));
|
||||
}
|
||||
|
||||
if(playerItems[3] != mc.thePlayer.inventory.armorInventory[2]) {
|
||||
playerItems[3] = mc.thePlayer.inventory.armorInventory[2];
|
||||
S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 3, playerItems[3]);
|
||||
packetListener.save(pee);
|
||||
if (playerItems[3] != mc.player.getItemStackFromSlot(EntityEquipmentSlot.LEGS)) {
|
||||
playerItems[3] = mc.player.getItemStackFromSlot(EntityEquipmentSlot.LEGS);
|
||||
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.LEGS, playerItems[3]));
|
||||
}
|
||||
|
||||
if(playerItems[4] != mc.thePlayer.inventory.armorInventory[3]) {
|
||||
playerItems[4] = mc.thePlayer.inventory.armorInventory[3];
|
||||
S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 4, playerItems[4]);
|
||||
packetListener.save(pee);
|
||||
if (playerItems[4] != mc.player.getItemStackFromSlot(EntityEquipmentSlot.CHEST)) {
|
||||
playerItems[4] = mc.player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.CHEST, playerItems[4]));
|
||||
}
|
||||
|
||||
if (playerItems[5] != mc.player.getItemStackFromSlot(EntityEquipmentSlot.HEAD)) {
|
||||
playerItems[5] = mc.player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
|
||||
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.HEAD, playerItems[5]));
|
||||
}
|
||||
|
||||
//Leaving Ride
|
||||
|
||||
if((!mc.thePlayer.isRiding() && lastRiding != -1) ||
|
||||
(mc.thePlayer.isRiding() && lastRiding != mc.thePlayer.ridingEntity.getEntityId())) {
|
||||
if(!mc.thePlayer.isRiding()) {
|
||||
if((!mc.player.isRiding() && lastRiding != -1) ||
|
||||
(mc.player.isRiding() && lastRiding != mc.player.getRidingEntity().getEntityId())) {
|
||||
if(!mc.player.isRiding()) {
|
||||
lastRiding = -1;
|
||||
} else {
|
||||
lastRiding = mc.thePlayer.ridingEntity.getEntityId();
|
||||
lastRiding = mc.player.getRidingEntity().getEntityId();
|
||||
}
|
||||
|
||||
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);
|
||||
packetListener.save(new SPacketEntityAttach(e.player, e.player.getRidingEntity()));
|
||||
}
|
||||
|
||||
//Sleeping
|
||||
if(!mc.thePlayer.isPlayerSleeping() && wasSleeping) {
|
||||
S0BPacketAnimation pac = new S0BPacketAnimation();
|
||||
|
||||
ByteBuf bb = Unpooled.buffer();
|
||||
PacketBuffer pb = new PacketBuffer(bb);
|
||||
|
||||
pb.writeVarIntToBuffer(e.player.getEntityId());
|
||||
pb.writeByte(2);
|
||||
|
||||
pac.readPacketData(pb);
|
||||
|
||||
packetListener.save(pac);
|
||||
|
||||
if(!mc.player.isPlayerSleeping() && wasSleeping) {
|
||||
packetListener.save(new SPacketAnimation(e.player, 2));
|
||||
wasSleeping = false;
|
||||
}
|
||||
|
||||
// Active hand (e.g. eating, drinking, blocking)
|
||||
if (mc.player.isHandActive() ^ wasHandActive || mc.player.getActiveHand() != lastActiveHand) {
|
||||
wasHandActive = mc.player.isHandActive();
|
||||
lastActiveHand = mc.player.getActiveHand();
|
||||
EntityDataManager dataManager = new EntityDataManager(null);
|
||||
int state = (wasHandActive ? 1 : 0) | (lastActiveHand == EnumHand.OFF_HAND ? 2 : 0);
|
||||
dataManager.register(EntityLiving.HAND_STATES, (byte) state);
|
||||
packetListener.save(new SPacketEntityMetadata(mc.player.getEntityId(), dataManager, true));
|
||||
}
|
||||
|
||||
} catch(Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
@@ -286,27 +234,8 @@ public class RecordingEventHandler {
|
||||
@SubscribeEvent
|
||||
public void onPickupItem(ItemPickupEvent event) {
|
||||
try {
|
||||
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);
|
||||
packetListener.save(new SPacketCollectItem(event.pickedUp.getEntityId(), event.player.getEntityId(),
|
||||
event.pickedUp.getItem().getMaxStackSize()));
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -315,21 +244,11 @@ public class RecordingEventHandler {
|
||||
@SubscribeEvent
|
||||
public void onSleep(PlayerSleepInBedEvent event) {
|
||||
try {
|
||||
if(event.entityPlayer != mc.thePlayer) {
|
||||
if (event.getEntityPlayer() != mc.player) {
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
packetListener.save(new SPacketUseBed(event.getEntityPlayer(), event.getPos()));
|
||||
|
||||
wasSleeping = true;
|
||||
|
||||
@@ -341,33 +260,22 @@ public class RecordingEventHandler {
|
||||
@SubscribeEvent
|
||||
public void enterMinecart(MinecartInteractEvent event) {
|
||||
try {
|
||||
if(event.player != mc.thePlayer) {
|
||||
if(event.getEntity() != mc.player) {
|
||||
return;
|
||||
}
|
||||
|
||||
S1BPacketEntityAttach pea = new S1BPacketEntityAttach();
|
||||
packetListener.save(new SPacketEntityAttach(event.getPlayer(), event.getMinecart()));
|
||||
|
||||
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();
|
||||
lastRiding = event.getMinecart().getEntityId();
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void onBlockBreakAnim(int breakerId, BlockPos pos, int progress) {
|
||||
EntityPlayer thePlayer = mc.thePlayer;
|
||||
EntityPlayer thePlayer = mc.player;
|
||||
if (thePlayer != null && breakerId == thePlayer.getEntityId()) {
|
||||
packetListener.save(new S25PacketBlockBreakAnim(breakerId, pos, progress));
|
||||
packetListener.save(new SPacketBlockBreakAnim(breakerId, pos, progress));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,4 +24,9 @@ public abstract class MixinNetHandlerLoginClient {
|
||||
public void replayModRecording_initiateRecording(CallbackInfo cb) {
|
||||
ReplayModRecording.instance.initiateRecording(networkManager);
|
||||
}
|
||||
|
||||
@Inject(method = "handleLoginSuccess", at=@At("RETURN"))
|
||||
public void replayModRecording_raceConditionWorkAround(CallbackInfo cb) {
|
||||
networkManager.channel().config().setAutoRead(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import com.replaymod.recording.handler.RecordingEventHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||
import net.minecraft.network.play.server.S07PacketRespawn;
|
||||
import net.minecraft.network.play.server.S38PacketPlayerListItem;
|
||||
import net.minecraft.network.play.server.SPacketPlayerListItem;
|
||||
import net.minecraft.network.play.server.SPacketRespawn;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -36,15 +36,15 @@ public abstract class MixinNetHandlerPlayClient {
|
||||
* @param ci Callback info
|
||||
*/
|
||||
@Inject(method = "handlePlayerListItem", at=@At("HEAD"))
|
||||
public void recordOwnJoin(S38PacketPlayerListItem packet, CallbackInfo ci) {
|
||||
if (gameController.thePlayer == null) return;
|
||||
public void recordOwnJoin(SPacketPlayerListItem packet, CallbackInfo ci) {
|
||||
if (gameController.player == null) return;
|
||||
|
||||
RecordingEventHandler handler = getRecordingEventHandler();
|
||||
if (handler != null && packet.getAction() == S38PacketPlayerListItem.Action.ADD_PLAYER) {
|
||||
for (S38PacketPlayerListItem.AddPlayerData data : packet.getEntries()) {
|
||||
if (handler != null && packet.getAction() == SPacketPlayerListItem.Action.ADD_PLAYER) {
|
||||
for (SPacketPlayerListItem.AddPlayerData data : packet.getEntries()) {
|
||||
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
|
||||
if (data.getProfile().getId().equals(Minecraft.getMinecraft().thePlayer.getGameProfile().getId())
|
||||
if (data.getProfile().getId().equals(Minecraft.getMinecraft().player.getGameProfile().getId())
|
||||
&& !playerInfoMap.containsKey(data.getProfile().getId())) {
|
||||
handler.onPlayerJoin();
|
||||
}
|
||||
@@ -55,12 +55,12 @@ public abstract class MixinNetHandlerPlayClient {
|
||||
/**
|
||||
* Record the own player entity respawning.
|
||||
* 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(S38PacketPlayerListItem, CallbackInfo)}.
|
||||
* the first spawn which is already handled by {@link #recordOwnJoin(SPacketPlayerListItem, CallbackInfo)}.
|
||||
* @param packet The packet
|
||||
* @param ci Callback info
|
||||
*/
|
||||
@Inject(method = "handleRespawn", at=@At("RETURN"))
|
||||
public void recordOwnRespawn(S07PacketRespawn packet, CallbackInfo ci) {
|
||||
public void recordOwnRespawn(SPacketRespawn packet, CallbackInfo ci) {
|
||||
RecordingEventHandler handler = getRecordingEventHandler();
|
||||
if (handler != null) {
|
||||
handler.onPlayerRespawn();
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.replaymod.recording.mixin;
|
||||
|
||||
import com.replaymod.recording.handler.FMLHandshakeFilter;
|
||||
import io.netty.channel.ChannelConfig;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import net.minecraft.network.EnumConnectionState;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraftforge.fml.common.network.handshake.FMLHandshakeCodec;
|
||||
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -10,6 +13,7 @@ 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.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(value = NetworkDispatcher.class, remap = false)
|
||||
@@ -43,4 +47,17 @@ public abstract class MixinNetworkDispatcher {
|
||||
"replaymod_filter", new FMLHandshakeFilter());
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "clientListenForServerHandshake", at = @At(value = "INVOKE", remap = true, target =
|
||||
"Lnet/minecraft/network/NetworkManager;setConnectionState(Lnet/minecraft/network/EnumConnectionState;)V"))
|
||||
public void replayModRecording_raceConditionWorkAround1(NetworkManager self, EnumConnectionState ignored) { }
|
||||
|
||||
@Redirect(method = "insertIntoChannel", at = @At(value = "INVOKE", target =
|
||||
"Lio/netty/channel/ChannelConfig;setAutoRead(Z)Lio/netty/channel/ChannelConfig;"))
|
||||
public ChannelConfig replayModRecording_raceConditionWorkAround2(ChannelConfig self, boolean autoRead) {
|
||||
if (side == Side.CLIENT) {
|
||||
autoRead = false;
|
||||
}
|
||||
return self.setAutoRead(autoRead);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
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.player, type, pos, data);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.replaymod.recording.mixin;
|
||||
|
||||
import com.replaymod.recording.handler.RecordingEventHandler;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
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.player) {
|
||||
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.player) {
|
||||
// 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,21 +9,29 @@ import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.DataWatcher;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.EnumConnectionState;
|
||||
import net.minecraft.network.EnumPacketDirection;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.server.*;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.network.datasync.EntityDataManager;
|
||||
import net.minecraft.network.play.server.SPacketCollectItem;
|
||||
import net.minecraft.network.play.server.SPacketCustomPayload;
|
||||
import net.minecraft.network.play.server.SPacketDisconnect;
|
||||
import net.minecraft.network.play.server.SPacketResourcePackSend;
|
||||
import net.minecraft.network.play.server.SPacketSpawnMob;
|
||||
import net.minecraft.network.play.server.SPacketSpawnPlayer;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -84,8 +92,8 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
||||
|
||||
public void save(Packet packet) {
|
||||
try {
|
||||
if(packet instanceof S0CPacketSpawnPlayer) {
|
||||
UUID uuid = ((S0CPacketSpawnPlayer) packet).getPlayer();
|
||||
if(packet instanceof SPacketSpawnPlayer) {
|
||||
UUID uuid = ((SPacketSpawnPlayer) packet).getUniqueId();
|
||||
Set<String> uuids = new HashSet<>(Arrays.asList(metaData.getPlayers()));
|
||||
uuids.add(uuid.toString());
|
||||
metaData.setPlayers(uuids.toArray(new String[uuids.size()]));
|
||||
@@ -151,16 +159,16 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
||||
try {
|
||||
Packet packet = (Packet) msg;
|
||||
|
||||
if(packet instanceof S0DPacketCollectItem) {
|
||||
if(mc.thePlayer != null ||
|
||||
((S0DPacketCollectItem) packet).getEntityID() == mc.thePlayer.getEntityId()) {
|
||||
if(packet instanceof SPacketCollectItem) {
|
||||
if(mc.player != null ||
|
||||
((SPacketCollectItem) packet).getEntityID() == mc.player.getEntityId()) {
|
||||
super.channelRead(ctx, msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (packet instanceof S48PacketResourcePackSend) {
|
||||
save(resourcePackRecorder.handleResourcePack((S48PacketResourcePackSend) packet));
|
||||
if (packet instanceof SPacketResourcePackSend) {
|
||||
save(resourcePackRecorder.handleResourcePack((SPacketResourcePackSend) packet));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -173,10 +181,10 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
||||
|
||||
save(packet);
|
||||
|
||||
if (packet instanceof S3FPacketCustomPayload) {
|
||||
S3FPacketCustomPayload p = (S3FPacketCustomPayload) packet;
|
||||
if (packet instanceof SPacketCustomPayload) {
|
||||
SPacketCustomPayload p = (SPacketCustomPayload) packet;
|
||||
if (Restrictions.PLUGIN_CHANNEL.equals(p.getChannelName())) {
|
||||
packet = new S40PacketDisconnect(new ChatComponentText("Please update to view this replay."));
|
||||
packet = new SPacketDisconnect(new TextComponentString("Please update to view this replay."));
|
||||
save(packet);
|
||||
}
|
||||
}
|
||||
@@ -189,27 +197,31 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
||||
super.channelRead(ctx, msg);
|
||||
}
|
||||
|
||||
private <T> void DataManager_set(EntityDataManager dataManager, EntityDataManager.DataEntry<T> entry) {
|
||||
dataManager.register(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private byte[] getPacketData(Packet packet) throws IOException {
|
||||
if(packet instanceof S0FPacketSpawnMob) {
|
||||
S0FPacketSpawnMob p = (S0FPacketSpawnMob) packet;
|
||||
if (p.field_149043_l == null) {
|
||||
p.field_149043_l = new DataWatcher(null);
|
||||
if(p.func_149027_c() != null) {
|
||||
for(DataWatcher.WatchableObject wo : (List<DataWatcher.WatchableObject>) p.func_149027_c()) {
|
||||
p.field_149043_l.addObject(wo.getDataValueId(), wo.getObject());
|
||||
private byte[] getPacketData(Packet packet) throws Exception {
|
||||
if (packet instanceof SPacketSpawnMob) {
|
||||
SPacketSpawnMob p = (SPacketSpawnMob) packet;
|
||||
if (p.dataManager == null) {
|
||||
p.dataManager = new EntityDataManager(null);
|
||||
if (p.getDataManagerEntries() != null) {
|
||||
for (EntityDataManager.DataEntry<?> entry : p.getDataManagerEntries()) {
|
||||
DataManager_set(p.dataManager, entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(packet instanceof S0CPacketSpawnPlayer) {
|
||||
S0CPacketSpawnPlayer p = (S0CPacketSpawnPlayer) packet;
|
||||
if (packet instanceof SPacketSpawnPlayer) {
|
||||
SPacketSpawnPlayer p = (SPacketSpawnPlayer) packet;
|
||||
if (p.watcher == null) {
|
||||
p.watcher = new DataWatcher(null);
|
||||
if(p.func_148944_c() != null) {
|
||||
for(DataWatcher.WatchableObject wo : p.func_148944_c()) {
|
||||
p.watcher.addObject(wo.getDataValueId(), wo.getObject());
|
||||
p.watcher = new EntityDataManager(null);
|
||||
if (p.getDataManagerEntries() != null) {
|
||||
for (EntityDataManager.DataEntry<?> entry : p.getDataManagerEntries()) {
|
||||
DataManager_set(p.watcher, entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,7 +233,7 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
PacketBuffer packetBuffer = new PacketBuffer(byteBuf);
|
||||
packetBuffer.writeVarIntToBuffer(packetId);
|
||||
packetBuffer.writeVarInt(packetId);
|
||||
packet.writePacketData(packetBuffer);
|
||||
|
||||
byteBuf.readerIndex(0);
|
||||
|
||||
@@ -15,8 +15,8 @@ import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.resources.ResourcePackRepository;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.client.C19PacketResourcePackStatus;
|
||||
import net.minecraft.network.play.server.S48PacketResourcePackSend;
|
||||
import net.minecraft.network.play.client.CPacketResourcePackStatus;
|
||||
import net.minecraft.network.play.server.SPacketResourcePackSend;
|
||||
import net.minecraft.util.HttpUtil;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -74,9 +74,9 @@ public class ResourcePackRecorder {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized S48PacketResourcePackSend handleResourcePack(S48PacketResourcePackSend packet) {
|
||||
public synchronized SPacketResourcePackSend handleResourcePack(SPacketResourcePackSend packet) {
|
||||
final int requestId = nextRequestId++;
|
||||
final NetHandlerPlayClient netHandler = mc.getNetHandler();
|
||||
final NetHandlerPlayClient netHandler = mc.getConnection();
|
||||
final NetworkManager netManager = netHandler.getNetworkManager();
|
||||
final String url = packet.getURL();
|
||||
final String hash = packet.getHash();
|
||||
@@ -87,60 +87,60 @@ public class ResourcePackRecorder {
|
||||
final File levelDir = new File(savesDir, levelName);
|
||||
|
||||
if (levelDir.isFile()) {
|
||||
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.ACCEPTED));
|
||||
Futures.addCallback(mc.getResourcePackRepository().setResourcePackInstance(levelDir), new FutureCallback<Object>() {
|
||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.ACCEPTED));
|
||||
Futures.addCallback(mc.getResourcePackRepository().setServerResourcePack(levelDir), new FutureCallback<Object>() {
|
||||
@Override
|
||||
public void onSuccess(Object result) {
|
||||
recordResourcePack(levelDir, requestId);
|
||||
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.SUCCESSFULLY_LOADED));
|
||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.SUCCESSFULLY_LOADED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@Nonnull Throwable throwable) {
|
||||
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
||||
}
|
||||
} else {
|
||||
final ServerData serverData = mc.getCurrentServerData();
|
||||
if (serverData != null && serverData.getResourceMode() == ServerData.ServerResourceMode.ENABLED) {
|
||||
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.ACCEPTED));
|
||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.ACCEPTED));
|
||||
downloadResourcePackFuture(requestId, url, hash);
|
||||
} else if (serverData != null && serverData.getResourceMode() != ServerData.ServerResourceMode.PROMPT) {
|
||||
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.DECLINED));
|
||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.DECLINED));
|
||||
} else {
|
||||
mc.addScheduledTask(() -> mc.displayGuiScreen(new GuiYesNo((result, id) -> {
|
||||
if (serverData != null) {
|
||||
serverData.setResourceMode(result ? ServerData.ServerResourceMode.ENABLED : ServerData.ServerResourceMode.DISABLED);
|
||||
}
|
||||
if (result) {
|
||||
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.ACCEPTED));
|
||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.ACCEPTED));
|
||||
downloadResourcePackFuture(requestId, url, hash);
|
||||
} else {
|
||||
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.DECLINED));
|
||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.DECLINED));
|
||||
}
|
||||
|
||||
ServerList.func_147414_b(serverData);
|
||||
ServerList.saveSingleServer(serverData);
|
||||
mc.displayGuiScreen(null);
|
||||
}, I18n.format("multiplayer.texturePrompt.line1"), I18n.format("multiplayer.texturePrompt.line2"), 0)));
|
||||
}
|
||||
}
|
||||
|
||||
return new S48PacketResourcePackSend("replay://" + requestId, "");
|
||||
return new SPacketResourcePackSend("replay://" + requestId, "");
|
||||
}
|
||||
|
||||
private void downloadResourcePackFuture(int requestId, String url, final String hash) {
|
||||
Futures.addCallback(downloadResourcePack(requestId, url, hash), new FutureCallback() {
|
||||
@Override
|
||||
public void onSuccess(Object result) {
|
||||
mc.getNetHandler().addToSendQueue(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.SUCCESSFULLY_LOADED));
|
||||
mc.getConnection().sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.SUCCESSFULLY_LOADED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@Nonnull Throwable throwable) {
|
||||
mc.getNetHandler().addToSendQueue(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
||||
mc.getConnection().sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -174,7 +174,7 @@ public class ResourcePackRecorder {
|
||||
String fileHash = Hashing.sha1().hashBytes(Files.toByteArray(file)).toString();
|
||||
if (fileHash.equals(hash)) {
|
||||
recordResourcePack(file, requestId);
|
||||
return repo.setResourcePackInstance(file);
|
||||
return repo.setServerResourcePack(file);
|
||||
}
|
||||
|
||||
logger.warn("File " + file + " had wrong hash (expected " + hash + ", found " + fileHash + "). Deleting it.");
|
||||
@@ -190,13 +190,13 @@ public class ResourcePackRecorder {
|
||||
|
||||
Futures.getUnchecked(mc.addScheduledTask(() -> mc.displayGuiScreen(guiScreen)));
|
||||
|
||||
Map<String, String> sessionInfo = Minecraft.getSessionInfo();
|
||||
Map<String, String> sessionInfo = ResourcePackRepository.getDownloadHeaders();
|
||||
repo.downloadingPacks = HttpUtil.downloadResourcePack(file, url, sessionInfo, 50 * 1024 * 1024, guiScreen, mc.getProxy());
|
||||
Futures.addCallback(repo.downloadingPacks, new FutureCallback<Object>() {
|
||||
@Override
|
||||
public void onSuccess(Object value) {
|
||||
recordResourcePack(file, requestId);
|
||||
repo.setResourcePackInstance(file);
|
||||
repo.setServerResourcePack(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,8 +5,8 @@ import com.replaymod.render.utils.RenderJob;
|
||||
import com.replaymod.replay.events.ReplayCloseEvent;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.util.ReportedException;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
@@ -21,6 +21,7 @@ import java.util.List;
|
||||
@Mod(modid = ReplayModRender.MOD_ID,
|
||||
version = "@MOD_VERSION@",
|
||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||
acceptableRemoteVersions = "*",
|
||||
useMetadata = true)
|
||||
public class ReplayModRender {
|
||||
public static final String MOD_ID = "replaymod-render";
|
||||
@@ -45,7 +46,7 @@ public class ReplayModRender {
|
||||
core = ReplayMod.instance;
|
||||
configuration = new Configuration(event.getSuggestedConfigurationFile());
|
||||
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
core.getSettingsRegistry().register(Setting.class);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.replaymod.render;
|
||||
|
||||
import com.replaymod.render.frame.RGBFrame;
|
||||
import com.replaymod.render.rendering.FrameConsumer;
|
||||
import com.replaymod.render.rendering.VideoRenderer;
|
||||
import com.replaymod.render.utils.ByteBufferPool;
|
||||
import com.replaymod.render.utils.StreamPipe;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -32,6 +33,7 @@ import static org.apache.commons.lang3.Validate.isTrue;
|
||||
|
||||
public class VideoWriter implements FrameConsumer<RGBFrame> {
|
||||
|
||||
private final VideoRenderer renderer;
|
||||
private final RenderSettings settings;
|
||||
private final Process process;
|
||||
private final OutputStream outputStream;
|
||||
@@ -41,8 +43,9 @@ public class VideoWriter implements FrameConsumer<RGBFrame> {
|
||||
|
||||
private ByteArrayOutputStream ffmpegLog = new ByteArrayOutputStream(4096);
|
||||
|
||||
public VideoWriter(final RenderSettings settings) throws IOException {
|
||||
this.settings = settings;
|
||||
public VideoWriter(final VideoRenderer renderer) throws IOException {
|
||||
this.renderer = renderer;
|
||||
this.settings = renderer.getRenderSettings();
|
||||
|
||||
File outputFolder = settings.getOutputFile().getParentFile();
|
||||
FileUtils.forceMkdir(outputFolder);
|
||||
@@ -57,9 +60,13 @@ public class VideoWriter implements FrameConsumer<RGBFrame> {
|
||||
.replace("%FILTERS%", settings.getVideoFilters());
|
||||
|
||||
String executable = settings.getExportCommand().isEmpty() ? findFFmpeg() : settings.getExportCommand();
|
||||
System.out.println("Starting " + executable + " with args: " + commandArgs);
|
||||
LOGGER.info("Starting {} with args: {}", executable, commandArgs);
|
||||
String[] cmdline = new CommandLine(executable).addArguments(commandArgs).toStrings();
|
||||
process = new ProcessBuilder(cmdline).directory(outputFolder).start();
|
||||
try {
|
||||
process = new ProcessBuilder(cmdline).directory(outputFolder).start();
|
||||
} catch (IOException e) {
|
||||
throw new NoFFmpegException(e);
|
||||
}
|
||||
File exportLogFile = new File(Minecraft.getMinecraft().mcDataDir, "export.log");
|
||||
OutputStream exportLogOut = new TeeOutputStream(new FileOutputStream(exportLogFile), ffmpegLog);
|
||||
new StreamPipe(process.getInputStream(), exportLogOut).start();
|
||||
@@ -152,6 +159,16 @@ public class VideoWriter implements FrameConsumer<RGBFrame> {
|
||||
if (aborted) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// Check whether this is a failure right at the beginning of the rendering process
|
||||
// or at some later point (ffmpeg won't print the output file until the first frame
|
||||
// has been written to stdin, so we can't already check for invalid args in <init>).
|
||||
getVideoFile();
|
||||
} catch (FFmpegStartupException e) {
|
||||
// Possibly invalid ffmpeg arguments
|
||||
renderer.setFailure(e);
|
||||
return;
|
||||
}
|
||||
CrashReport report = CrashReport.makeCrashReport(t, "Exporting frame");
|
||||
CrashReportCategory exportDetails = report.makeCategory("Export details");
|
||||
exportDetails.addCrashSection("Export command", settings.getExportCommand());
|
||||
@@ -173,7 +190,7 @@ public class VideoWriter implements FrameConsumer<RGBFrame> {
|
||||
aborted = true;
|
||||
}
|
||||
|
||||
public File getVideoFile() {
|
||||
public File getVideoFile() throws FFmpegStartupException {
|
||||
String log = ffmpegLog.toString();
|
||||
for (String line : log.split("\n")) {
|
||||
if (line.startsWith("Output #0")) {
|
||||
@@ -181,6 +198,30 @@ public class VideoWriter implements FrameConsumer<RGBFrame> {
|
||||
return new File(settings.getOutputFile().getParentFile(), fileName);
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("No output file found.");
|
||||
throw new FFmpegStartupException(settings, log);
|
||||
}
|
||||
|
||||
public static class NoFFmpegException extends IOException {
|
||||
public NoFFmpegException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
|
||||
public static class FFmpegStartupException extends IOException {
|
||||
private final RenderSettings settings;
|
||||
private final String log;
|
||||
|
||||
public FFmpegStartupException(RenderSettings settings, String log) {
|
||||
this.settings = settings;
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
public RenderSettings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
public String getLog() {
|
||||
return log;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
109
src/main/java/com/replaymod/render/gui/GuiExportFailed.java
Normal file
109
src/main/java/com/replaymod/render/gui/GuiExportFailed.java
Normal file
@@ -0,0 +1,109 @@
|
||||
package com.replaymod.render.gui;
|
||||
|
||||
import com.replaymod.render.RenderSettings;
|
||||
import com.replaymod.render.VideoWriter;
|
||||
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.GuiElement;
|
||||
import de.johni0702.minecraft.gui.element.GuiLabel;
|
||||
import de.johni0702.minecraft.gui.layout.CustomLayout;
|
||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||
import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
import net.minecraft.util.ReportedException;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static com.replaymod.render.ReplayModRender.LOGGER;
|
||||
|
||||
public class GuiExportFailed extends GuiScreen {
|
||||
public static GuiExportFailed tryToRecover(VideoWriter.FFmpegStartupException e, Consumer<RenderSettings> doRestart) {
|
||||
// Always log the error first
|
||||
LOGGER.error("Rendering video:", e);
|
||||
|
||||
RenderSettings settings = e.getSettings();
|
||||
// Check whether the user has configured some custom ffmpeg arguments
|
||||
if (settings.getEncodingPreset().getValue().equals(settings.getExportArguments())) {
|
||||
// If they haven't, then this is probably a faulty ffmpeg installation and there's nothing we can do
|
||||
CrashReport crashReport = CrashReport.makeCrashReport(e, "Exporting video");
|
||||
CrashReportCategory details = crashReport.makeCategory("Export details");
|
||||
details.addCrashSection("Settings", settings);
|
||||
details.addCrashSection("FFmpeg log", e.getLog());
|
||||
throw new ReportedException(crashReport);
|
||||
} else {
|
||||
// If they have, ask them whether it was intentional
|
||||
GuiExportFailed gui = new GuiExportFailed(e, doRestart);
|
||||
gui.display();
|
||||
return gui;
|
||||
}
|
||||
}
|
||||
|
||||
private final GuiLabel logLabel = new GuiLabel(this)
|
||||
.setI18nText("replaymod.gui.rendering.error.ffmpeglog");
|
||||
private final GuiVerticalList logList = new GuiVerticalList(this).setDrawShadow(true);
|
||||
private final GuiButton resetButton = new GuiButton().setI18nLabel("gui.yes").setSize(100, 20);
|
||||
private final GuiButton abortButton = new GuiButton().setI18nLabel("gui.no").setSize(100, 20);
|
||||
private final GuiPanel info = new GuiPanel(this)
|
||||
.setLayout(new VerticalLayout().setSpacing(4))
|
||||
.addElements(new VerticalLayout.Data(0.5),
|
||||
new GuiLabel().setI18nText("replaymod.gui.rendering.error.ffmpegargs.1"),
|
||||
new GuiLabel().setI18nText("replaymod.gui.rendering.error.ffmpegargs.2"),
|
||||
new GuiLabel(),
|
||||
new GuiPanel().setLayout(new HorizontalLayout(HorizontalLayout.Alignment.CENTER).setSpacing(5))
|
||||
.addElements(null, resetButton, abortButton)
|
||||
);
|
||||
|
||||
{
|
||||
setLayout(new CustomLayout<GuiScreen>() {
|
||||
@Override
|
||||
protected void layout(GuiScreen container, int width, int height) {
|
||||
pos(info, width/2 - width(info)/2, (height/2 - height(info) - 30) / 2 + 30);
|
||||
pos(logLabel, width/2 - width(logLabel)/2, height/2 + 4);
|
||||
pos(logList, 10, y(logLabel) + height(logLabel) + 4);
|
||||
size(logList, width - 10 - x(logList), height - 10 - y(logList));
|
||||
}
|
||||
});
|
||||
|
||||
setTitle(new GuiLabel().setI18nText("replaymod.gui.rendering.error.title"));
|
||||
setBackground(Background.DIRT);
|
||||
}
|
||||
|
||||
public GuiExportFailed(VideoWriter.FFmpegStartupException e, Consumer<RenderSettings> doRestart) {
|
||||
logList.getListPanel().addElements(null,
|
||||
Arrays.stream(e.getLog().replace("\t", " ").split("\n"))
|
||||
.map(l -> new GuiLabel().setText(l))
|
||||
.toArray(GuiElement[]::new));
|
||||
|
||||
resetButton.onClick(() -> {
|
||||
RenderSettings oldSettings = e.getSettings();
|
||||
doRestart.accept(new RenderSettings(
|
||||
oldSettings.getRenderMethod(),
|
||||
oldSettings.getEncodingPreset(),
|
||||
oldSettings.getVideoWidth(),
|
||||
oldSettings.getVideoHeight(),
|
||||
oldSettings.getFramesPerSecond(),
|
||||
oldSettings.getBitRate(),
|
||||
oldSettings.getOutputFile(),
|
||||
oldSettings.isRenderNameTags(),
|
||||
oldSettings.isStabilizeYaw(),
|
||||
oldSettings.isStabilizePitch(),
|
||||
oldSettings.isStabilizeRoll(),
|
||||
oldSettings.getChromaKeyingColor(),
|
||||
oldSettings.isInject360Metadata(),
|
||||
oldSettings.getAntiAliasing(),
|
||||
oldSettings.getExportCommand(),
|
||||
oldSettings.getEncodingPreset().getValue(),
|
||||
oldSettings.isHighPerformance()
|
||||
));
|
||||
});
|
||||
|
||||
abortButton.onClick(() -> {
|
||||
// Assume they know what they're doing
|
||||
getMinecraft().displayGuiScreen(null);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.replaymod.render.gui;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.replaymod.core.utils.Utils;
|
||||
import com.replaymod.render.ReplayModRender;
|
||||
import com.replaymod.render.VideoWriter;
|
||||
import com.replaymod.render.rendering.VideoRenderer;
|
||||
import com.replaymod.render.utils.RenderJob;
|
||||
import com.replaymod.replay.ReplayHandler;
|
||||
@@ -11,6 +14,7 @@ import com.replaymod.replaystudio.util.I18n;
|
||||
import de.johni0702.minecraft.gui.GuiRenderer;
|
||||
import de.johni0702.minecraft.gui.RenderInfo;
|
||||
import de.johni0702.minecraft.gui.container.AbstractGuiClickableContainer;
|
||||
import de.johni0702.minecraft.gui.container.AbstractGuiScreen;
|
||||
import de.johni0702.minecraft.gui.container.GuiContainer;
|
||||
import de.johni0702.minecraft.gui.container.GuiPanel;
|
||||
import de.johni0702.minecraft.gui.container.GuiVerticalList;
|
||||
@@ -25,12 +29,10 @@ import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
||||
import de.johni0702.minecraft.gui.utils.Colors;
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.util.ReportedException;
|
||||
import org.lwjgl.util.Dimension;
|
||||
import org.lwjgl.util.ReadableDimension;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.replaymod.render.ReplayModRender.LOGGER;
|
||||
@@ -62,7 +64,8 @@ public class GuiRenderQueue extends AbstractGuiPopup<GuiRenderQueue> {
|
||||
renameButton, removeButton),
|
||||
closeButton);
|
||||
|
||||
private final GuiContainer container;
|
||||
private final AbstractGuiScreen container;
|
||||
private final ReplayHandler replayHandler;
|
||||
private Entry selectedEntry;
|
||||
|
||||
{
|
||||
@@ -84,9 +87,10 @@ public class GuiRenderQueue extends AbstractGuiPopup<GuiRenderQueue> {
|
||||
}).addElements(null, title, list, buttonPanel);
|
||||
}
|
||||
|
||||
public GuiRenderQueue(GuiContainer container, GuiRenderSettings guiRenderSettings, ReplayHandler replayHandler, Timeline timeline) {
|
||||
public GuiRenderQueue(AbstractGuiScreen container, GuiRenderSettings guiRenderSettings, ReplayHandler replayHandler, Timeline timeline) {
|
||||
super(container);
|
||||
this.container = container;
|
||||
this.replayHandler = replayHandler;
|
||||
LOGGER.trace("Opening render queue popup");
|
||||
|
||||
setBackgroundColor(Colors.DARK_TRANSPARENT);
|
||||
@@ -188,30 +192,46 @@ public class GuiRenderQueue extends AbstractGuiPopup<GuiRenderQueue> {
|
||||
|
||||
renderButton.onClick(() -> {
|
||||
LOGGER.trace("Render button clicked");
|
||||
// Close all GUIs (so settings in GuiRenderSettings are saved)
|
||||
getMinecraft().displayGuiScreen(null);
|
||||
// Start rendering
|
||||
for (RenderJob renderJob : queue) {
|
||||
LOGGER.info("Starting render job {}", renderJob);
|
||||
try {
|
||||
VideoRenderer videoRenderer = new VideoRenderer(renderJob.getSettings(), replayHandler, renderJob.getTimeline());
|
||||
videoRenderer.renderVideo();
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Rendering video:", e);
|
||||
GuiErrorScreen errorScreen = new GuiErrorScreen(I18n.format("replaymod.gui.rendering.error.title"),
|
||||
I18n.format("replaymod.gui.rendering.error.message"));
|
||||
getMinecraft().displayGuiScreen(errorScreen);
|
||||
return;
|
||||
} catch (Throwable t) {
|
||||
CrashReport crashReport = CrashReport.makeCrashReport(t, "Rendering video");
|
||||
throw new ReportedException(crashReport);
|
||||
}
|
||||
}
|
||||
processQueue(queue);
|
||||
});
|
||||
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
private void processQueue(Iterable<RenderJob> queue) {
|
||||
// Close all GUIs (so settings in GuiRenderSettings are saved)
|
||||
getMinecraft().displayGuiScreen(null);
|
||||
// Start rendering
|
||||
int jobsDone = 0;
|
||||
for (RenderJob renderJob : queue) {
|
||||
LOGGER.info("Starting render job {}", renderJob);
|
||||
try {
|
||||
VideoRenderer videoRenderer = new VideoRenderer(renderJob.getSettings(), replayHandler, renderJob.getTimeline());
|
||||
videoRenderer.renderVideo();
|
||||
} catch (VideoWriter.NoFFmpegException e) {
|
||||
LOGGER.error("Rendering video:", e);
|
||||
GuiErrorScreen errorScreen = new GuiErrorScreen(I18n.format("replaymod.gui.rendering.error.title"),
|
||||
I18n.format("replaymod.gui.rendering.error.message"));
|
||||
getMinecraft().displayGuiScreen(errorScreen);
|
||||
return;
|
||||
} catch (VideoWriter.FFmpegStartupException e) {
|
||||
int jobsToSkip = jobsDone;
|
||||
GuiExportFailed.tryToRecover(e, newSettings -> {
|
||||
// Update current job with fixed ffmpeg arguments
|
||||
renderJob.setSettings(newSettings);
|
||||
// Restart queue, skipping the already completed jobs
|
||||
processQueue(Iterables.skip(queue, jobsToSkip));
|
||||
});
|
||||
return;
|
||||
} catch (Throwable t) {
|
||||
Utils.error(LOGGER, this, CrashReport.makeCrashReport(t, "Rendering video"), () -> {});
|
||||
container.display(); // Re-show the queue popup and the new error popup
|
||||
return;
|
||||
}
|
||||
jobsDone++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
super.open();
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.InstanceCreator;
|
||||
import com.replaymod.render.RenderSettings;
|
||||
import com.replaymod.render.ReplayModRender;
|
||||
import com.replaymod.render.VideoWriter;
|
||||
import com.replaymod.render.rendering.VideoRenderer;
|
||||
import com.replaymod.replay.ReplayHandler;
|
||||
import com.replaymod.replaystudio.pathing.path.Timeline;
|
||||
@@ -29,7 +30,6 @@ import de.johni0702.minecraft.gui.utils.Utils;
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.util.ReportedException;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import org.lwjgl.util.Color;
|
||||
@@ -39,11 +39,13 @@ import org.lwjgl.util.ReadableDimension;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.replaymod.core.utils.Utils.error;
|
||||
import static com.replaymod.render.ReplayModRender.LOGGER;
|
||||
|
||||
public class GuiRenderSettings extends GuiScreen implements Closeable {
|
||||
public final GuiPanel contentPanel = new GuiPanel(this).setBackgroundColor(Colors.DARK_TRANSPARENT);
|
||||
public final GuiVerticalList settingsList = new GuiVerticalList(contentPanel).setDrawSlider(true);
|
||||
@@ -199,15 +201,21 @@ public class GuiRenderSettings extends GuiScreen implements Closeable {
|
||||
try {
|
||||
VideoRenderer videoRenderer = new VideoRenderer(save(false), replayHandler, timeline);
|
||||
videoRenderer.renderVideo();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
} catch (VideoWriter.NoFFmpegException e) {
|
||||
LOGGER.error("Rendering video:", e);
|
||||
GuiErrorScreen errorScreen = new GuiErrorScreen(I18n.format("replaymod.gui.rendering.error.title"),
|
||||
I18n.format("replaymod.gui.rendering.error.message"));
|
||||
getMinecraft().displayGuiScreen(errorScreen);
|
||||
} catch (VideoWriter.FFmpegStartupException e) {
|
||||
GuiExportFailed.tryToRecover(e, newSettings -> {
|
||||
// Update settings with fixed ffmpeg arguments
|
||||
exportArguments.setText(newSettings.getExportArguments());
|
||||
// Restart rendering, this will also save the changed ffmpeg arguments
|
||||
renderButton.onClick();
|
||||
});
|
||||
} catch (Throwable t) {
|
||||
CrashReport crashReport = CrashReport.makeCrashReport(t, "Rendering video");
|
||||
throw new ReportedException(crashReport);
|
||||
error(LOGGER, GuiRenderSettings.this, CrashReport.makeCrashReport(t, "Rendering video"), () -> {});
|
||||
display(); // Re-show the render settings gui and the new error popup
|
||||
}
|
||||
}
|
||||
}).setSize(100, 20).setI18nLabel("replaymod.gui.render");
|
||||
|
||||
@@ -10,7 +10,7 @@ import net.minecraft.client.renderer.chunk.RenderChunk;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.PriorityBlockingQueue;
|
||||
|
||||
public class ChunkLoadingRenderGlobal {
|
||||
|
||||
@@ -27,10 +27,10 @@ public class ChunkLoadingRenderGlobal {
|
||||
this.renderWorker = new CustomChunkRenderWorker(renderDispatcher, new RegionRenderCacheBuilder());
|
||||
|
||||
int workerThreads = renderDispatcher.listThreadedWorkers.size();
|
||||
BlockingQueue<ChunkCompileTaskGenerator> queueChunkUpdates = renderDispatcher.queueChunkUpdates;
|
||||
PriorityBlockingQueue<ChunkCompileTaskGenerator> queueChunkUpdates = renderDispatcher.queueChunkUpdates;
|
||||
workerJailingQueue = new JailingQueue<>(queueChunkUpdates);
|
||||
renderDispatcher.queueChunkUpdates = workerJailingQueue;
|
||||
ChunkCompileTaskGenerator element = new ChunkCompileTaskGenerator(null, null);
|
||||
ChunkCompileTaskGenerator element = new ChunkCompileTaskGenerator(null, null, 0);
|
||||
element.finish();
|
||||
for (int i = 0; i < workerThreads; i++) {
|
||||
queueChunkUpdates.add(element);
|
||||
@@ -68,7 +68,7 @@ public class ChunkLoadingRenderGlobal {
|
||||
|
||||
renderDispatcher.updateChunkNow(renderchunk);
|
||||
|
||||
renderchunk.setNeedsUpdate(false);
|
||||
renderchunk.clearNeedsUpdate();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.coremedia.iso.IsoFile;
|
||||
import com.coremedia.iso.boxes.*;
|
||||
import com.google.common.primitives.Bytes;
|
||||
import com.googlecode.mp4parser.BasicContainer;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
@@ -13,6 +12,8 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import static com.replaymod.render.ReplayModRender.LOGGER;
|
||||
|
||||
public class MetadataInjector {
|
||||
|
||||
private static final String STITCHING_SOFTWARE = "Minecraft ReplayMod";
|
||||
@@ -96,7 +97,7 @@ public class MetadataInjector {
|
||||
videoFileOutputStream = new FileOutputStream(videoFile);
|
||||
tempIsoFile.getBox(videoFileOutputStream.getChannel());
|
||||
} catch(Exception e) {
|
||||
FMLLog.getLogger().error("360 Degree Metadata couldn't be injected", e);
|
||||
LOGGER.error("360 Degree Metadata couldn't be injected", e);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(tempIsoFile);
|
||||
IOUtils.closeQuietly(videoFileOutputStream);
|
||||
|
||||
@@ -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.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.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.util.ReadableColor;
|
||||
import org.lwjgl.util.glu.Project;
|
||||
@@ -118,10 +118,10 @@ public abstract class MixinEntityRenderer implements EntityRendererHandler.IEnti
|
||||
@Shadow
|
||||
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/MovingObjectPosition;IF)V"))
|
||||
private void replayModRender_drawSelectionBox(RenderGlobal instance, EntityPlayer player, MovingObjectPosition mop, int alwaysZero, float partialTicks) {
|
||||
@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"))
|
||||
private void replayModRender_drawSelectionBox(RenderGlobal instance, EntityPlayer player, RayTraceResult rtr, int alwaysZero, float partialTicks) {
|
||||
if (replayModRender_handler == null) {
|
||||
instance.drawSelectionBox(player, mop, alwaysZero, partialTicks);
|
||||
instance.drawSelectionBox(player, rtr, alwaysZero, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
23
src/main/java/com/replaymod/render/mixin/MixinFrustum.java
Normal file
23
src/main/java/com/replaymod/render/mixin/MixinFrustum.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package com.replaymod.render.mixin;
|
||||
|
||||
import com.replaymod.render.hooks.EntityRendererHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
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(Frustum.class)
|
||||
public abstract class MixinFrustum {
|
||||
@Inject(method = "isBoxInFrustum", at = @At("HEAD"), cancellable = true)
|
||||
public void isBoxInFrustum(double minX, double minY, double minZ, double maxX, double maxY, double maxZ, CallbackInfoReturnable<Boolean> ci) {
|
||||
EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) Minecraft.getMinecraft().entityRenderer).replayModRender_getHandler();
|
||||
if (handler != null && handler.omnidirectional && handler.data == null) {
|
||||
// Normally the camera is always facing the direction of the omnidirectional image face that is currently
|
||||
// getting rendered. With ODS however, the camera is always facing forwards and the turning happens in the
|
||||
// vertex shader (non-trivial due to stereo). As such, all chunks need to be rendered all the time for ODS.
|
||||
ci.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.Particle;
|
||||
import net.minecraft.client.particle.ParticleManager;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
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/BufferBuilder;Lnet/minecraft/entity/Entity;FFFFFF)V"))
|
||||
private void renderNormalParticle(Particle particle, BufferBuilder 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/BufferBuilder;Lnet/minecraft/entity/Entity;FFFFFF)V"))
|
||||
private void renderLitParticle(Particle particle, BufferBuilder 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, BufferBuilder 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,15 +7,14 @@ import net.minecraft.entity.Entity;
|
||||
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;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Render.class)
|
||||
public abstract class MixinRender {
|
||||
@Inject(method = "canRenderName", at = @At("HEAD"), cancellable = true)
|
||||
private void replayModRender_areAllNamesHidden(Entity entity, CallbackInfoReturnable<Boolean> ci) {
|
||||
@Inject(method = "renderLivingLabel", at = @At("HEAD"), cancellable = true)
|
||||
private void replayModRender_areAllNamesHidden(Entity entityIn, String str, double x, double y, double z, int maxDistance, CallbackInfo ci) {
|
||||
EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) Minecraft.getMinecraft().entityRenderer).replayModRender_getHandler();
|
||||
if (handler != null && !handler.getSettings().isRenderNameTags()) {
|
||||
ci.setReturnValue(false);
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,16 +3,13 @@ package com.replaymod.render.mixin;
|
||||
import com.replaymod.render.hooks.ChunkLoadingRenderGlobal;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher;
|
||||
import net.minecraft.client.renderer.chunk.RenderChunk;
|
||||
import net.minecraft.client.renderer.culling.ICamera;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(RenderGlobal.class)
|
||||
public abstract class MixinRenderGlobal {
|
||||
@@ -37,6 +34,8 @@ public abstract class MixinRenderGlobal {
|
||||
|
||||
do {
|
||||
setupTerrain(viewEntity, partialTicks, camera, replayModRender_hook.nextFrameId(), playerSpectator);
|
||||
|
||||
replayModRender_hook.updateChunks();
|
||||
} while (displayListEntitiesDirty);
|
||||
|
||||
displayListEntitiesDirty = true;
|
||||
@@ -46,13 +45,6 @@ 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)
|
||||
public void replayModRender_updateChunks(long finishTimeNano, CallbackInfo ci) {
|
||||
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.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(RenderManager.class)
|
||||
public abstract class MixinRenderManager {
|
||||
@@ -19,7 +19,7 @@ public abstract class MixinRenderManager {
|
||||
private float playerViewY;
|
||||
|
||||
@Inject(method = "doRenderEntity", at = @At("HEAD"))
|
||||
private void replayModRender_reorientForCubicRendering(Entity entity, double dx, double dy, double dz, float iDoNotKnow, float partialTicks, boolean iDoNotCare, CallbackInfoReturnable ci) {
|
||||
private void replayModRender_reorientForCubicRendering(Entity entity, double dx, double dy, double dz, float iDoNotKnow, float partialTicks, boolean iDoNotCare, CallbackInfo ci) {
|
||||
EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) Minecraft.getMinecraft().entityRenderer).replayModRender_getHandler();
|
||||
if (handler != null && handler.omnidirectional) {
|
||||
double pitch = -Math.atan2(dy, Math.sqrt(dx * dx + dz * dz));
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
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,6 +1,6 @@
|
||||
package com.replaymod.render.rendering;
|
||||
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import com.replaymod.core.utils.WrappedTimer;
|
||||
import com.replaymod.pathing.player.AbstractTimelinePlayer;
|
||||
import com.replaymod.pathing.player.ReplayTimer;
|
||||
import com.replaymod.pathing.properties.TimestampProperty;
|
||||
@@ -14,17 +14,18 @@ import com.replaymod.render.gui.GuiRenderingDone;
|
||||
import com.replaymod.render.gui.GuiVideoRenderer;
|
||||
import com.replaymod.render.hooks.ChunkLoadingRenderGlobal;
|
||||
import com.replaymod.render.metadata.MetadataInjector;
|
||||
import com.replaymod.render.utils.SoundHandler;
|
||||
import com.replaymod.replay.ReplayHandler;
|
||||
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
||||
import com.replaymod.replaystudio.pathing.path.Path;
|
||||
import com.replaymod.replaystudio.pathing.path.Timeline;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.SoundCategory;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.shader.Framebuffer;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.Timer;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.util.Dimension;
|
||||
@@ -39,6 +40,7 @@ import java.util.concurrent.Future;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
import static com.google.common.collect.Iterables.getLast;
|
||||
import static com.replaymod.render.ReplayModRender.LOGGER;
|
||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
|
||||
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
|
||||
@@ -54,7 +56,7 @@ public class VideoRenderer implements RenderInfo {
|
||||
private int fps;
|
||||
private boolean mouseWasGrabbed;
|
||||
private boolean debugInfoWasShown;
|
||||
private Map originalSoundLevels;
|
||||
private Map<SoundCategory, Float> originalSoundLevels;
|
||||
|
||||
private TimelinePlayer timelinePlayer;
|
||||
private Future<Void> timelinePlayerFuture;
|
||||
@@ -66,6 +68,7 @@ public class VideoRenderer implements RenderInfo {
|
||||
private final GuiVideoRenderer gui;
|
||||
private boolean paused;
|
||||
private boolean cancelled;
|
||||
private volatile Throwable failureCause;
|
||||
|
||||
private Framebuffer guiFramebuffer;
|
||||
private int displayWidth, displayHeight;
|
||||
@@ -76,7 +79,7 @@ public class VideoRenderer implements RenderInfo {
|
||||
this.timeline = timeline;
|
||||
this.gui = new GuiVideoRenderer(this);
|
||||
this.renderingPipeline = Pipelines.newPipeline(settings.getRenderMethod(), this,
|
||||
videoWriter = new VideoWriter(settings) {
|
||||
videoWriter = new VideoWriter(this) {
|
||||
@Override
|
||||
public void consume(RGBFrame frame) {
|
||||
gui.updatePreview(frame);
|
||||
@@ -89,8 +92,8 @@ public class VideoRenderer implements RenderInfo {
|
||||
* Render this video.
|
||||
* @return {@code true} if rendering was successful, {@code false} if the user aborted rendering (or the window was closed)
|
||||
*/
|
||||
public boolean renderVideo() {
|
||||
FMLCommonHandler.instance().bus().post(new ReplayRenderEvent.Pre(this));
|
||||
public boolean renderVideo() throws Throwable {
|
||||
MinecraftForge.EVENT_BUS.post(new ReplayRenderEvent.Pre(this));
|
||||
|
||||
setup();
|
||||
|
||||
@@ -111,8 +114,8 @@ public class VideoRenderer implements RenderInfo {
|
||||
|
||||
if (videoStart > 1000) {
|
||||
int replayTime = videoStart - 1000;
|
||||
timer.elapsedPartialTicks = timer.renderPartialTicks = 0;
|
||||
timer.timerSpeed = 1;
|
||||
timer.renderPartialTicks = 0;
|
||||
timer.tickLength = WrappedTimer.DEFAULT_MS_PER_TICK;
|
||||
while (replayTime < videoStart) {
|
||||
timer.elapsedTicks = 1;
|
||||
replayTime += 50;
|
||||
@@ -136,7 +139,11 @@ public class VideoRenderer implements RenderInfo {
|
||||
|
||||
finish();
|
||||
|
||||
FMLCommonHandler.instance().bus().post(new ReplayRenderEvent.Post(this));
|
||||
MinecraftForge.EVENT_BUS.post(new ReplayRenderEvent.Post(this));
|
||||
|
||||
if (failureCause != null) {
|
||||
throw failureCause;
|
||||
}
|
||||
|
||||
return !cancelled;
|
||||
}
|
||||
@@ -196,9 +203,9 @@ public class VideoRenderer implements RenderInfo {
|
||||
for (SoundCategory category : SoundCategory.values()) {
|
||||
mutedSounds.put(category, 0f);
|
||||
}
|
||||
originalSoundLevels = mc.gameSettings.mapSoundLevels;
|
||||
mutedSounds.put(SoundCategory.MASTER, (Float) originalSoundLevels.get(SoundCategory.MASTER));
|
||||
mc.gameSettings.mapSoundLevels = mutedSounds;
|
||||
originalSoundLevels = mc.gameSettings.soundLevels;
|
||||
mutedSounds.put(SoundCategory.MASTER, originalSoundLevels.get(SoundCategory.MASTER));
|
||||
mc.gameSettings.soundLevels = mutedSounds;
|
||||
|
||||
fps = settings.getFramesPerSecond();
|
||||
|
||||
@@ -219,9 +226,6 @@ public class VideoRenderer implements RenderInfo {
|
||||
|
||||
updateDisplaySize();
|
||||
|
||||
ScaledResolution scaled = new ScaledResolution(mc);
|
||||
gui.toMinecraft().setWorldAndResolution(mc, scaled.getScaledWidth(), scaled.getScaledHeight());
|
||||
|
||||
chunkLoadingRenderGlobal = new ChunkLoadingRenderGlobal(mc.renderGlobal);
|
||||
|
||||
// Set up our own framebuffer to render the GUI to
|
||||
@@ -242,15 +246,21 @@ public class VideoRenderer implements RenderInfo {
|
||||
if (mouseWasGrabbed) {
|
||||
mc.mouseHelper.grabMouseCursor();
|
||||
}
|
||||
mc.gameSettings.mapSoundLevels = originalSoundLevels;
|
||||
mc.gameSettings.soundLevels = originalSoundLevels;
|
||||
mc.displayGuiScreen(null);
|
||||
if (chunkLoadingRenderGlobal != null) {
|
||||
chunkLoadingRenderGlobal.uninstall();
|
||||
}
|
||||
|
||||
ReplayMod.soundHandler.playRenderSuccessSound();
|
||||
new SoundHandler().playRenderSuccessSound();
|
||||
|
||||
new GuiRenderingDone(ReplayModRender.instance, videoWriter.getVideoFile(), totalFrames, settings).display();
|
||||
try {
|
||||
if (!hasFailed()) {
|
||||
new GuiRenderingDone(ReplayModRender.instance, videoWriter.getVideoFile(), totalFrames, settings).display();
|
||||
}
|
||||
} catch (VideoWriter.FFmpegStartupException e) {
|
||||
setFailure(e);
|
||||
}
|
||||
|
||||
// Finally, resize the Minecraft framebuffer to the actual width/height of the window
|
||||
mc.resize(displayWidth, displayHeight);
|
||||
@@ -326,7 +336,7 @@ public class VideoRenderer implements RenderInfo {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} while (paused);
|
||||
} while (paused && !hasFailed());
|
||||
}
|
||||
|
||||
private boolean displaySizeChanged() {
|
||||
@@ -367,6 +377,20 @@ public class VideoRenderer implements RenderInfo {
|
||||
renderingPipeline.cancel();
|
||||
}
|
||||
|
||||
public boolean hasFailed() {
|
||||
return failureCause != null;
|
||||
}
|
||||
|
||||
public synchronized void setFailure(Throwable cause) {
|
||||
if (this.failureCause != null) {
|
||||
LOGGER.error("Further failure during failed rendering: ", cause);
|
||||
} else {
|
||||
LOGGER.error("Failure during rendering: ", cause);
|
||||
this.failureCause = cause;
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private class TimelinePlayer extends AbstractTimelinePlayer {
|
||||
public TimelinePlayer(ReplayHandler replayHandler) {
|
||||
super(replayHandler);
|
||||
|
||||
@@ -2,15 +2,18 @@ package com.replaymod.render.utils;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.PriorityBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class JailingQueue<T> extends AbstractQueue<T> implements BlockingQueue<T> {
|
||||
private final BlockingQueue<T> delegate;
|
||||
public class JailingQueue<T> extends PriorityBlockingQueue<T> {
|
||||
private final PriorityBlockingQueue<T> delegate;
|
||||
private final Set<Thread> jailed = new HashSet<Thread>();
|
||||
|
||||
public JailingQueue(BlockingQueue<T> delegate) {
|
||||
public JailingQueue(PriorityBlockingQueue<T> delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@@ -59,13 +62,13 @@ public class JailingQueue<T> extends AbstractQueue<T> implements BlockingQueue<T
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(T t) throws InterruptedException {
|
||||
public void put(T t) {
|
||||
tryAccess();
|
||||
delegate.put(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean offer(T t, long timeout, TimeUnit unit) throws InterruptedException {
|
||||
public boolean offer(T t, long timeout, TimeUnit unit) {
|
||||
tryAccess();
|
||||
return delegate.offer(t, timeout, unit);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.io.InputStream;
|
||||
|
||||
public class SoundHandler {
|
||||
|
||||
private final ResourceLocation successSoundLocation = new ResourceLocation("replaymod", "renderSuccess.wav");
|
||||
private final ResourceLocation successSoundLocation = new ResourceLocation("replaymod", "render_success.wav");
|
||||
|
||||
public void playRenderSuccessSound() {
|
||||
playSound(successSoundLocation);
|
||||
|
||||
@@ -143,10 +143,11 @@ public class InputReplayTimer extends WrappedTimer {
|
||||
|
||||
// Following are a ton of vanilla keyboard shortcuts, some are removed as they're useless in the
|
||||
// replay viewer as of now
|
||||
// TODO Update maybe add new key bindings
|
||||
// TODO: Translate magic values to Keyboard.KEY_ constants
|
||||
|
||||
if (key == 32 && Keyboard.isKeyDown(61) && mc.ingameGUI != null) {
|
||||
mc.ingameGUI.getChatGUI().clearChatMessages();
|
||||
mc.ingameGUI.getChatGUI().clearChatMessages(false);
|
||||
}
|
||||
|
||||
if (key == 31 && Keyboard.isKeyDown(61)) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.replaymod.replay;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.replaymod.core.utils.Restrictions;
|
||||
import com.replaymod.core.utils.WrappedTimer;
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import com.replaymod.replay.camera.SpectatorCameraController;
|
||||
import com.replaymod.replay.events.ReplayCloseEvent;
|
||||
@@ -23,8 +24,8 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.EnumPacketDirection;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher;
|
||||
import org.lwjgl.opengl.Display;
|
||||
|
||||
@@ -76,7 +77,7 @@ public class ReplayHandler {
|
||||
Preconditions.checkState(mc.isCallingFromMinecraftThread(), "Must be called from Minecraft thread.");
|
||||
this.replayFile = replayFile;
|
||||
|
||||
FMLCommonHandler.instance().bus().post(new ReplayOpenEvent.Pre(this));
|
||||
MinecraftForge.EVENT_BUS.post(new ReplayOpenEvent.Pre(this));
|
||||
|
||||
markers = new ArrayList<>(replayFile.getMarkers().or(Collections.emptySet()));
|
||||
|
||||
@@ -87,7 +88,7 @@ public class ReplayHandler {
|
||||
overlay = new GuiReplayOverlay(this);
|
||||
overlay.setVisible(true);
|
||||
|
||||
FMLCommonHandler.instance().bus().post(new ReplayOpenEvent.Post(this));
|
||||
MinecraftForge.EVENT_BUS.post(new ReplayOpenEvent.Post(this));
|
||||
}
|
||||
|
||||
void restartedReplay() {
|
||||
@@ -101,7 +102,7 @@ public class ReplayHandler {
|
||||
public void endReplay() throws IOException {
|
||||
Preconditions.checkState(mc.isCallingFromMinecraftThread(), "Must be called from Minecraft thread.");
|
||||
|
||||
FMLCommonHandler.instance().bus().post(new ReplayCloseEvent.Pre(this));
|
||||
MinecraftForge.EVENT_BUS.post(new ReplayCloseEvent.Pre(this));
|
||||
|
||||
replaySender.terminateReplay();
|
||||
|
||||
@@ -110,25 +111,27 @@ public class ReplayHandler {
|
||||
|
||||
channel.close().awaitUninterruptibly();
|
||||
|
||||
if (mc.thePlayer instanceof CameraEntity) {
|
||||
mc.thePlayer.setDead();
|
||||
if (mc.player instanceof CameraEntity) {
|
||||
mc.player.setDead();
|
||||
}
|
||||
|
||||
if (mc.theWorld != null) {
|
||||
mc.theWorld.sendQuittingDisconnectingPacket();
|
||||
if (mc.world != null) {
|
||||
mc.world.sendQuittingDisconnectingPacket();
|
||||
mc.loadWorld(null);
|
||||
}
|
||||
|
||||
mc.timer.timerSpeed = 1;
|
||||
mc.timer.tickLength = WrappedTimer.DEFAULT_MS_PER_TICK;
|
||||
overlay.setVisible(false);
|
||||
|
||||
ReplayModReplay.instance.replayHandler = null;
|
||||
|
||||
FMLCommonHandler.instance().bus().post(new ReplayCloseEvent.Post(this));
|
||||
mc.displayGuiScreen(null);
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new ReplayCloseEvent.Post(this));
|
||||
}
|
||||
|
||||
private void setup() {
|
||||
mc.ingameGUI.getChatGUI().clearChatMessages();
|
||||
mc.ingameGUI.getChatGUI().clearChatMessages(true);
|
||||
|
||||
NetworkManager networkManager = new NetworkManager(EnumPacketDirection.CLIENTBOUND) {
|
||||
@Override
|
||||
@@ -141,13 +144,14 @@ public class ReplayHandler {
|
||||
networkManager.setNetHandler(netHandlerPlayClient);
|
||||
FMLClientHandler.instance().setPlayClient(netHandlerPlayClient);
|
||||
|
||||
channel = new EmbeddedChannel(networkManager);
|
||||
channel = new EmbeddedChannel();
|
||||
NetworkDispatcher networkDispatcher = new NetworkDispatcher(networkManager);
|
||||
channel.attr(NetworkDispatcher.FML_DISPATCHER).set(networkDispatcher);
|
||||
|
||||
channel.pipeline().addFirst("ReplayModReplay_replaySender", replaySender);
|
||||
channel.pipeline().addAfter("ReplayModReplay_replaySender", "fml:packet_handler", networkDispatcher);
|
||||
channel.pipeline().addLast("packet_handler", networkManager);
|
||||
channel.pipeline().fireChannelActive();
|
||||
networkDispatcher.clientToServerHandshake();
|
||||
}
|
||||
|
||||
public ReplayFile getReplayFile() {
|
||||
@@ -244,7 +248,7 @@ public class ReplayHandler {
|
||||
* @return {@code true} if the camera is the view entity, {@code false} otherwise
|
||||
*/
|
||||
public boolean isCameraView() {
|
||||
return mc.thePlayer instanceof CameraEntity && mc.thePlayer == mc.getRenderViewEntity();
|
||||
return mc.player instanceof CameraEntity && mc.player == mc.getRenderViewEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,7 +256,7 @@ public class ReplayHandler {
|
||||
* @return The camera entity or {@code null} if it does not yet exist
|
||||
*/
|
||||
public CameraEntity getCameraEntity() {
|
||||
return mc.thePlayer instanceof CameraEntity ? (CameraEntity) mc.thePlayer : null;
|
||||
return mc.player instanceof CameraEntity ? (CameraEntity) mc.player : null;
|
||||
}
|
||||
|
||||
public UUID getSpectatedUUID() {
|
||||
@@ -299,7 +303,7 @@ public class ReplayHandler {
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
drawBackground(0);
|
||||
drawCenteredString(fontRendererObj, I18n.format("replaymod.gui.pleasewait"),
|
||||
drawCenteredString(fontRenderer, I18n.format("replaymod.gui.pleasewait"),
|
||||
width / 2, height / 2, 0xffffffff);
|
||||
}
|
||||
};
|
||||
@@ -331,8 +335,8 @@ public class ReplayHandler {
|
||||
replaySender.setAsyncMode(true);
|
||||
replaySender.setReplaySpeed(0);
|
||||
|
||||
mc.getNetHandler().getNetworkManager().processReceivedPackets();
|
||||
for (Entity entity : mc.theWorld.loadedEntityList) {
|
||||
mc.getConnection().getNetworkManager().processReceivedPackets();
|
||||
for (Entity entity : mc.world.loadedEntityList) {
|
||||
if (entity instanceof EntityOtherPlayerMP) {
|
||||
EntityOtherPlayerMP e = (EntityOtherPlayerMP) entity;
|
||||
e.setPosition(e.otherPlayerMPX, e.otherPlayerMPY, e.otherPlayerMPZ);
|
||||
|
||||
@@ -35,6 +35,7 @@ import java.util.Optional;
|
||||
@Mod(modid = ReplayModReplay.MOD_ID,
|
||||
version = "@MOD_VERSION@",
|
||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||
acceptableRemoteVersions = "*",
|
||||
useMetadata = true)
|
||||
public class ReplayModReplay {
|
||||
public static final String MOD_ID = "replaymod-replay";
|
||||
@@ -46,7 +47,7 @@ public class ReplayModReplay {
|
||||
|
||||
private final CameraControllerRegistry cameraControllerRegistry = new CameraControllerRegistry();
|
||||
|
||||
private Logger logger;
|
||||
public static Logger LOGGER;
|
||||
|
||||
protected ReplayHandler replayHandler;
|
||||
|
||||
@@ -56,7 +57,7 @@ public class ReplayModReplay {
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
logger = event.getModLog();
|
||||
LOGGER = event.getModLog();
|
||||
core = ReplayMod.instance;
|
||||
|
||||
core.getSettingsRegistry().register(Setting.class);
|
||||
@@ -180,6 +181,9 @@ public class ReplayModReplay {
|
||||
}
|
||||
|
||||
public void startReplay(ReplayFile replayFile, boolean checkModCompat) throws IOException {
|
||||
if (replayHandler != null) {
|
||||
replayHandler.endReplay();
|
||||
}
|
||||
if (checkModCompat) {
|
||||
ModCompat.ModInfoDifference modDifference = new ModCompat.ModInfoDifference(replayFile.getModInfo());
|
||||
if (!modDifference.getMissing().isEmpty() || !modDifference.getDiffering().isEmpty()) {
|
||||
@@ -195,7 +199,7 @@ public class ReplayModReplay {
|
||||
}
|
||||
|
||||
public Logger getLogger() {
|
||||
return logger;
|
||||
return LOGGER;
|
||||
}
|
||||
|
||||
public CameraControllerRegistry getCameraControllerRegistry() {
|
||||
|
||||
@@ -2,27 +2,34 @@ package com.replaymod.replay;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.util.concurrent.ListenableFutureTask;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import com.replaymod.core.utils.Restrictions;
|
||||
import com.replaymod.core.utils.WrappedTimer;
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import com.replaymod.replaystudio.replay.ReplayFile;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityOtherPlayerMP;
|
||||
import net.minecraft.client.gui.GuiDownloadTerrain;
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.*;
|
||||
import net.minecraft.network.play.server.*;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.EnumDifficulty;
|
||||
import net.minecraft.world.GameType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldSettings.GameType;
|
||||
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.IOUtils;
|
||||
|
||||
@@ -30,7 +37,6 @@ import java.io.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* Sends replay packets to netty channels.
|
||||
@@ -38,31 +44,26 @@ import java.util.concurrent.Callable;
|
||||
* the replay restart from the beginning.
|
||||
*/
|
||||
@Sharable
|
||||
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;
|
||||
|
||||
public class ReplaySender extends ChannelDuplexHandler {
|
||||
/**
|
||||
* These packets are ignored completely during replay.
|
||||
*/
|
||||
private static final List<Class> BAD_PACKETS = Arrays.<Class>asList(
|
||||
S06PacketUpdateHealth.class,
|
||||
S2DPacketOpenWindow.class,
|
||||
S2EPacketCloseWindow.class,
|
||||
S2FPacketSetSlot.class,
|
||||
S30PacketWindowItems.class,
|
||||
S36PacketSignEditorOpen.class,
|
||||
S37PacketStatistics.class,
|
||||
S1FPacketSetExperience.class,
|
||||
S43PacketCamera.class,
|
||||
S39PacketPlayerAbilities.class,
|
||||
S45PacketTitle.class);
|
||||
// TODO Update possibly more?
|
||||
SPacketRecipeBook.class,
|
||||
SPacketAdvancementInfo.class,
|
||||
SPacketSelectAdvancementsTab.class,
|
||||
SPacketUpdateHealth.class,
|
||||
SPacketOpenWindow.class,
|
||||
SPacketCloseWindow.class,
|
||||
SPacketSetSlot.class,
|
||||
SPacketWindowItems.class,
|
||||
SPacketSignEditorOpen.class,
|
||||
SPacketStatistics.class,
|
||||
SPacketSetExperience.class,
|
||||
SPacketCamera.class,
|
||||
SPacketPlayerAbilities.class,
|
||||
SPacketTitle.class);
|
||||
|
||||
private static int TP_DISTANCE_LIMIT = 128;
|
||||
|
||||
@@ -171,6 +172,8 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
this.asyncMode = asyncMode;
|
||||
this.replayLength = file.getMetaData().getDuration();
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
if (asyncMode) {
|
||||
new Thread(asyncSender, "replaymod-async-sender").start();
|
||||
}
|
||||
@@ -239,14 +242,35 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
*/
|
||||
public void terminateReplay() {
|
||||
terminate = true;
|
||||
MinecraftForge.EVENT_BUS.unregister(this);
|
||||
try {
|
||||
channelInactive(ctx);
|
||||
ctx.channel().pipeline().close();
|
||||
FileUtils.deleteDirectory(tempResourcePackFolder);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@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.world != null) {
|
||||
for (EntityPlayer playerEntity : mc.world.playerEntities) {
|
||||
if (!playerEntity.addedToChunk && playerEntity instanceof EntityOtherPlayerMP) {
|
||||
playerEntity.onLivingUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg)
|
||||
throws Exception {
|
||||
@@ -273,22 +297,22 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
// If we do not give minecraft time to tick, there will be dead entity artifacts left in the world
|
||||
// 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.
|
||||
if (!asyncMode && mc.theWorld != null) {
|
||||
if (p instanceof S0CPacketSpawnPlayer
|
||||
|| p instanceof S0EPacketSpawnObject
|
||||
|| p instanceof S0FPacketSpawnMob
|
||||
|| p instanceof S2CPacketSpawnGlobalEntity
|
||||
|| p instanceof S10PacketSpawnPainting
|
||||
|| p instanceof S11PacketSpawnExperienceOrb
|
||||
|| p instanceof S13PacketDestroyEntities) {
|
||||
World world = mc.theWorld;
|
||||
if (!asyncMode && mc.world != null) {
|
||||
if (p instanceof SPacketSpawnPlayer
|
||||
|| p instanceof SPacketSpawnObject
|
||||
|| p instanceof SPacketSpawnMob
|
||||
|| p instanceof SPacketSpawnGlobalEntity
|
||||
|| p instanceof SPacketSpawnPainting
|
||||
|| p instanceof SPacketSpawnExperienceOrb
|
||||
|| p instanceof SPacketDestroyEntities) {
|
||||
World world = mc.world;
|
||||
for (int i = 0; i < world.loadedEntityList.size(); ++i) {
|
||||
Entity entity = (Entity) world.loadedEntityList.get(i);
|
||||
Entity entity = world.loadedEntityList.get(i);
|
||||
if (entity.isDead) {
|
||||
int chunkX = entity.chunkCoordX;
|
||||
int chunkY = entity.chunkCoordZ;
|
||||
|
||||
if (entity.addedToChunk && world.getChunkProvider().chunkExists(chunkX, chunkY)) {
|
||||
if (entity.addedToChunk && world.getChunkProvider().getLoadedChunk(chunkX, chunkY) != null) {
|
||||
world.getChunkFromChunkCoords(chunkX, chunkY).removeEntity(entity);
|
||||
}
|
||||
|
||||
@@ -312,7 +336,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
ByteBuf bb = Unpooled.wrappedBuffer(bytes);
|
||||
PacketBuffer pb = new PacketBuffer(bb);
|
||||
|
||||
int i = pb.readVarIntFromBuffer();
|
||||
int i = pb.readVarInt();
|
||||
|
||||
Packet p = EnumConnectionState.PLAY.getPacket(EnumPacketDirection.CLIENTBOUND, i);
|
||||
p.readPacketData(pb);
|
||||
@@ -326,8 +350,8 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
* @return The processed packet or {@code null} if no packet shall be sent
|
||||
*/
|
||||
protected Packet processPacket(Packet p) throws Exception {
|
||||
if (p instanceof S3FPacketCustomPayload) {
|
||||
S3FPacketCustomPayload packet = (S3FPacketCustomPayload) p;
|
||||
if (p instanceof SPacketCustomPayload) {
|
||||
SPacketCustomPayload packet = (SPacketCustomPayload) p;
|
||||
if (Restrictions.PLUGIN_CHANNEL.equals(packet.getChannelName())) {
|
||||
final String unknown = replayHandler.getRestrictions().handle(packet);
|
||||
if (unknown == null) {
|
||||
@@ -353,8 +377,8 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (p instanceof S40PacketDisconnect) {
|
||||
IChatComponent reason = ((S40PacketDisconnect) p).getReason();
|
||||
if (p instanceof SPacketDisconnect) {
|
||||
ITextComponent reason = ((SPacketDisconnect) p).getReason();
|
||||
if ("Please update to view this replay.".equals(reason.getUnformattedText())) {
|
||||
// This version of the mod supports replay restrictions so we are allowed
|
||||
// to remove this packet.
|
||||
@@ -364,10 +388,15 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
|
||||
if(BAD_PACKETS.contains(p.getClass())) return null;
|
||||
|
||||
convertLegacyEntityIds(p);
|
||||
if (p instanceof SPacketCustomPayload) {
|
||||
SPacketCustomPayload packet = (SPacketCustomPayload) p;
|
||||
if ("MC|BOpen".equals(packet.getChannelName())) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if(p instanceof S48PacketResourcePackSend) {
|
||||
S48PacketResourcePackSend packet = (S48PacketResourcePackSend) p;
|
||||
if(p instanceof SPacketResourcePackSend) {
|
||||
SPacketResourcePackSend packet = (SPacketResourcePackSend) p;
|
||||
String url = packet.getURL();
|
||||
if (url.startsWith("replay://")) {
|
||||
int id = Integer.parseInt(url.substring("replay://".length()));
|
||||
@@ -379,17 +408,17 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
if (!file.exists()) {
|
||||
IOUtils.copy(replayFile.getResourcePack(hash).get(), new FileOutputStream(file));
|
||||
}
|
||||
mc.getResourcePackRepository().setResourcePackInstance(file);
|
||||
mc.getResourcePackRepository().setServerResourcePack(file);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if(p instanceof S01PacketJoinGame) {
|
||||
S01PacketJoinGame packet = (S01PacketJoinGame) p;
|
||||
if(p instanceof SPacketJoinGame) {
|
||||
SPacketJoinGame packet = (SPacketJoinGame) p;
|
||||
allowMovement = true;
|
||||
int entId = packet.getEntityId();
|
||||
int entId = packet.getPlayerId();
|
||||
actualID = entId;
|
||||
entId = -1789435; // Camera entity id should be negative which is an invalid id and can't be used by servers
|
||||
int dimension = packet.getDimension();
|
||||
@@ -397,21 +426,21 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
int maxPlayers = packet.getMaxPlayers();
|
||||
WorldType worldType = packet.getWorldType();
|
||||
|
||||
p = new S01PacketJoinGame(entId, GameType.SPECTATOR, false, dimension,
|
||||
p = new SPacketJoinGame(entId, GameType.SPECTATOR, false, dimension,
|
||||
difficulty, maxPlayers, worldType, false);
|
||||
}
|
||||
|
||||
if(p instanceof S07PacketRespawn) {
|
||||
S07PacketRespawn respawn = (S07PacketRespawn) p;
|
||||
p = new S07PacketRespawn(respawn.getDimensionID(),
|
||||
if(p instanceof SPacketRespawn) {
|
||||
SPacketRespawn respawn = (SPacketRespawn) p;
|
||||
p = new SPacketRespawn(respawn.getDimensionID(),
|
||||
respawn.getDifficulty(), respawn.getWorldType(), GameType.SPECTATOR);
|
||||
|
||||
allowMovement = true;
|
||||
}
|
||||
|
||||
if(p instanceof S08PacketPlayerPosLook) {
|
||||
if(p instanceof SPacketPlayerPosLook) {
|
||||
if(!hasWorldLoaded) hasWorldLoaded = true;
|
||||
final S08PacketPlayerPosLook ppl = (S08PacketPlayerPosLook) p;
|
||||
final SPacketPlayerPosLook ppl = (SPacketPlayerPosLook) p;
|
||||
|
||||
if (mc.currentScreen instanceof GuiDownloadTerrain) {
|
||||
// Close the world loading screen manually in case we swallow the packet
|
||||
@@ -422,10 +451,10 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
|
||||
CameraEntity cent = replayHandler.getCameraEntity();
|
||||
|
||||
for (Object relative : ppl.func_179834_f()) {
|
||||
if (relative == S08PacketPlayerPosLook.EnumFlags.X
|
||||
|| relative == S08PacketPlayerPosLook.EnumFlags.Y
|
||||
|| relative == S08PacketPlayerPosLook.EnumFlags.Z) {
|
||||
for (SPacketPlayerPosLook.EnumFlags relative : ppl.getFlags()) {
|
||||
if (relative == SPacketPlayerPosLook.EnumFlags.X
|
||||
|| relative == SPacketPlayerPosLook.EnumFlags.Y
|
||||
|| relative == SPacketPlayerPosLook.EnumFlags.Z) {
|
||||
return null; // At least one of the coordinates is relative, so we don't care
|
||||
}
|
||||
}
|
||||
@@ -439,26 +468,23 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
new Callable<Void>() {
|
||||
new Runnable() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Void call() {
|
||||
if (mc.theWorld == null || !mc.isCallingFromMinecraftThread()) {
|
||||
synchronized(mc.scheduledTasks) {
|
||||
mc.scheduledTasks.add(ListenableFutureTask.create(this));
|
||||
}
|
||||
return null;
|
||||
public void run() {
|
||||
if (mc.world == null || !mc.isCallingFromMinecraftThread()) {
|
||||
ReplayMod.instance.runLater(this);
|
||||
return;
|
||||
}
|
||||
|
||||
CameraEntity cent = replayHandler.getCameraEntity();
|
||||
cent.setCameraPosition(ppl.getX(), ppl.getY(), ppl.getZ());
|
||||
return null;
|
||||
}
|
||||
}.call();
|
||||
}.run();
|
||||
}
|
||||
|
||||
if(p instanceof S2BPacketChangeGameState) {
|
||||
S2BPacketChangeGameState pg = (S2BPacketChangeGameState)p;
|
||||
if(p instanceof SPacketChangeGameState) {
|
||||
SPacketChangeGameState pg = (SPacketChangeGameState)p;
|
||||
int reason = pg.getGameState();
|
||||
|
||||
// only allow the following packets:
|
||||
@@ -473,7 +499,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
if (p instanceof S02PacketChat) {
|
||||
if (p instanceof SPacketChat) {
|
||||
if (!ReplayModReplay.instance.getCore().getSettingsRegistry().get(Setting.SHOW_CHAT)) {
|
||||
return null;
|
||||
}
|
||||
@@ -486,14 +512,27 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
this.ctx = ctx;
|
||||
ctx.attr(NetworkManager.attrKeyConnectionState).set(EnumConnectionState.PLAY);
|
||||
ctx.channel().attr(NetworkManager.PROTOCOL_ATTRIBUTE_KEY).set(EnumConnectionState.PLAY);
|
||||
super.channelActive(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
FileUtils.deleteDirectory(tempResourcePackFolder);
|
||||
super.channelInactive(ctx);
|
||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
||||
// The embedded channel's event loop will consider every thread to be in it and as such provides no
|
||||
// guarantees that only one thread is using the pipeline at any one time.
|
||||
// For reading the replay sender (either sync or async) is the only thread ever writing.
|
||||
// For writing it may very well happen that multiple threads want to use the pipline at the same time.
|
||||
// It's unclear whether the EmbeddedChannel is supposed to be thread-safe (the behavior of the event loop
|
||||
// does suggest that). However it seems like it either isn't (likely) or there is a race condition.
|
||||
// See: https://www.replaymod.com/forum/thread/1752#post8045 (https://paste.replaymod.com/lotacatuwo)
|
||||
// To work around this issue, we just outright drop all write/flush requests (they aren't needed anyway).
|
||||
// This still leaves channel handlers upstream with the threading issue but they all seem to cope well with it.
|
||||
promise.setSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush(ChannelHandlerContext ctx) throws Exception {
|
||||
// See write method above
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -501,7 +540,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
* @return {@code true} if it is paused, {@code false} otherwise
|
||||
*/
|
||||
public boolean paused() {
|
||||
return mc.timer.timerSpeed == 0;
|
||||
return mc.timer.tickLength == Float.POSITIVE_INFINITY;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -521,7 +560,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
*/
|
||||
public void setReplaySpeed(final double d) {
|
||||
if(d != 0) this.replaySpeed = d;
|
||||
mc.timer.timerSpeed = (float) d;
|
||||
mc.timer.tickLength = WrappedTimer.DEFAULT_MS_PER_TICK / (float) d;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
@@ -691,10 +730,10 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
protected Packet processPacketAsync(Packet p) {
|
||||
//If hurrying, ignore some packets, except for short durations
|
||||
if(desiredTimeStamp - lastTimeStamp > 1000) {
|
||||
if(p instanceof S2APacketParticles) return null;
|
||||
if(p instanceof SPacketParticles) return null;
|
||||
|
||||
if(p instanceof S0EPacketSpawnObject) {
|
||||
S0EPacketSpawnObject pso = (S0EPacketSpawnObject)p;
|
||||
if(p instanceof SPacketSpawnObject) {
|
||||
SPacketSpawnObject pso = (SPacketSpawnObject)p;
|
||||
int type = pso.getType();
|
||||
if(type == 76) { // Firework rocket
|
||||
return null;
|
||||
@@ -721,6 +760,9 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
synchronized (this) {
|
||||
if (timestamp == lastTimeStamp) { // Do nothing if we're already there
|
||||
return;
|
||||
}
|
||||
if (timestamp < lastTimeStamp) { // Restart the replay if we need to go backwards in time
|
||||
hasWorldLoaded = false;
|
||||
lastTimeStamp = 0;
|
||||
@@ -781,68 +823,6 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
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 final int timestamp;
|
||||
private final byte[] bytes;
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.replaymod.core.events.SettingsChangedEvent;
|
||||
import com.replaymod.core.utils.Utils;
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
import com.replaymod.replay.Setting;
|
||||
import com.replaymod.replay.events.ReplayChatMessageEvent;
|
||||
import com.replaymod.replaystudio.util.Location;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -18,16 +19,19 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.item.EntityItemFrame;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.stats.StatFileWriter;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.stats.RecipeBook;
|
||||
import net.minecraft.stats.StatisticsManager;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.EntityViewRenderEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
@@ -38,7 +42,7 @@ import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* The camera entity used as the main player entity during replay viewing.
|
||||
* During a replay {@link Minecraft#thePlayer} should be an instance of this class.
|
||||
* During a replay {@link Minecraft#player} should be an instance of this class.
|
||||
* Camera movement is controlled by a separate {@link CameraController}.
|
||||
*/
|
||||
public class CameraEntity extends EntityPlayerSP {
|
||||
@@ -65,9 +69,8 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
*/
|
||||
private final EventHandler eventHandler = new EventHandler();
|
||||
|
||||
public CameraEntity(Minecraft mcIn, World worldIn, NetHandlerPlayClient netHandlerPlayClient, StatFileWriter statFileWriter) {
|
||||
super(mcIn, worldIn, netHandlerPlayClient, statFileWriter);
|
||||
FMLCommonHandler.instance().bus().register(eventHandler);
|
||||
public CameraEntity(Minecraft mcIn, World worldIn, NetHandlerPlayClient netHandlerPlayClient, StatisticsManager statisticsManager, RecipeBook recipeBook) {
|
||||
super(mcIn, worldIn, netHandlerPlayClient, statisticsManager, recipeBook);
|
||||
MinecraftForge.EVENT_BUS.register(eventHandler);
|
||||
if (ReplayModReplay.instance.getReplayHandler().getSpectatedUUID() == null) {
|
||||
cameraController = ReplayModReplay.instance.createCameraController(this);
|
||||
@@ -156,9 +159,9 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
// entity is recreated and we have to spectate a new entity
|
||||
UUID spectating = ReplayModReplay.instance.getReplayHandler().getSpectatedUUID();
|
||||
if (spectating != null && (view.getUniqueID() != spectating
|
||||
|| view.worldObj != worldObj)
|
||||
|| worldObj.getEntityByID(view.getEntityId()) != view) {
|
||||
view = worldObj.getPlayerEntityByUUID(spectating);
|
||||
|| view.world != world)
|
||||
|| world.getEntityByID(view.getEntityId()) != view) {
|
||||
view = world.getPlayerEntityByUUID(spectating);
|
||||
if (view != null) {
|
||||
mc.setRenderViewEntity(view);
|
||||
} else {
|
||||
@@ -177,17 +180,17 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
@Override
|
||||
public void preparePlayerToSpawn() {
|
||||
// Make sure our world is up-to-date in case of world changes
|
||||
if (mc.theWorld != null) {
|
||||
worldObj = mc.theWorld;
|
||||
if (mc.world != null) {
|
||||
world = mc.world;
|
||||
}
|
||||
super.preparePlayerToSpawn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAngles(float yaw, float pitch) {
|
||||
public void setRotation(float yaw, float pitch) {
|
||||
if (mc.getRenderViewEntity() == this) {
|
||||
// Only update camera rotation when the camera is the view
|
||||
super.setAngles(yaw, pitch);
|
||||
super.setRotation(yaw, pitch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,12 +292,49 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition rayTrace(double p_174822_1_, float p_174822_3_) {
|
||||
MovingObjectPosition pos = super.rayTrace(p_174822_1_, 1f);
|
||||
public float getCooldownPeriod() {
|
||||
Entity view = mc.getRenderViewEntity();
|
||||
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)
|
||||
if(pos != null && pos.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||
pos.typeOfHit = MovingObjectPosition.MovingObjectType.MISS;
|
||||
if(pos != null && pos.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
pos.typeOfHit = RayTraceResult.Type.MISS;
|
||||
}
|
||||
|
||||
return pos;
|
||||
@@ -309,7 +349,6 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
@Override
|
||||
public void setDead() {
|
||||
super.setDead();
|
||||
FMLCommonHandler.instance().bus().unregister(eventHandler);
|
||||
MinecraftForge.EVENT_BUS.unregister(eventHandler);
|
||||
}
|
||||
|
||||
@@ -348,6 +387,12 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
&& (e instanceof EntityPlayer || e instanceof EntityLiving || e instanceof EntityItemFrame);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(ITextComponent message) {
|
||||
if (MinecraftForge.EVENT_BUS.post(new ReplayChatMessageEvent(this))) return;
|
||||
super.sendMessage(message);
|
||||
}
|
||||
|
||||
private class EventHandler {
|
||||
@SubscribeEvent
|
||||
public void onPreClientTick(TickEvent.ClientTickEvent event) {
|
||||
@@ -367,9 +412,13 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
@SubscribeEvent
|
||||
public void preCrosshairRender(RenderGameOverlayEvent.Pre event) {
|
||||
// The crosshair should only render if targeted entity can actually be spectated
|
||||
if (event.type == RenderGameOverlayEvent.ElementType.CROSSHAIRS) {
|
||||
if (event.getType() == RenderGameOverlayEvent.ElementType.CROSSHAIRS) {
|
||||
event.setCanceled(!canSpectate(mc.pointedEntity));
|
||||
}
|
||||
// Hotbar should never be rendered
|
||||
if (event.getType() == RenderGameOverlayEvent.ElementType.HOTBAR) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -400,13 +449,16 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
if (lastHandRendered != player) {
|
||||
lastHandRendered = player;
|
||||
|
||||
mc.entityRenderer.itemRenderer.prevEquippedProgress = 1;
|
||||
mc.entityRenderer.itemRenderer.equippedProgress = 1;
|
||||
mc.entityRenderer.itemRenderer.itemToRender = player.inventory.getCurrentItem();
|
||||
mc.entityRenderer.itemRenderer.equippedItemSlot = player.inventory.currentItem;
|
||||
mc.entityRenderer.itemRenderer.prevEquippedProgressMainHand = 1;
|
||||
mc.entityRenderer.itemRenderer.prevEquippedProgressOffHand = 1;
|
||||
mc.entityRenderer.itemRenderer.equippedProgressMainHand = 1;
|
||||
mc.entityRenderer.itemRenderer.equippedProgressOffHand = 1;
|
||||
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.renderArmPitch = mc.thePlayer.prevRenderArmPitch = player.rotationPitch;
|
||||
|
||||
mc.player.renderArmYaw = mc.player.prevRenderArmYaw = player.rotationYaw;
|
||||
mc.player.renderArmPitch = mc.player.prevRenderArmPitch = player.rotationPitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -414,8 +466,48 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
@SubscribeEvent
|
||||
public void onEntityViewRenderEvent(EntityViewRenderEvent.CameraSetup event) {
|
||||
if (mc.getRenderViewEntity() == CameraEntity.this) {
|
||||
event.roll = roll;
|
||||
event.setRoll(roll);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean heldItemTooltipsWasTrue;
|
||||
|
||||
@SubscribeEvent
|
||||
public void preRenderGameOverlay(RenderGameOverlayEvent.Pre event) {
|
||||
switch (event.getType()) {
|
||||
case ALL:
|
||||
heldItemTooltipsWasTrue = mc.gameSettings.heldItemTooltips;
|
||||
mc.gameSettings.heldItemTooltips = false;
|
||||
break;
|
||||
case ARMOR:
|
||||
case HEALTH:
|
||||
case FOOD:
|
||||
case AIR:
|
||||
case HOTBAR:
|
||||
case EXPERIENCE:
|
||||
case HEALTHMOUNT:
|
||||
case JUMPBAR:
|
||||
case POTION_ICONS:
|
||||
event.setCanceled(true);
|
||||
break;
|
||||
case HELMET:
|
||||
case PORTAL:
|
||||
case CROSSHAIRS:
|
||||
case BOSSHEALTH:
|
||||
case BOSSINFO:
|
||||
case SUBTITLES:
|
||||
case TEXT:
|
||||
case CHAT:
|
||||
case PLAYER_LIST:
|
||||
case DEBUG:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void postRenderGameOverlay(RenderGameOverlayEvent.Post event) {
|
||||
if (event.getType() != RenderGameOverlayEvent.ElementType.ALL) return;
|
||||
mc.gameSettings.heldItemTooltips = heldItemTooltipsWasTrue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.replaymod.replay.camera;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import org.lwjgl.Sys;
|
||||
|
||||
// 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 DECAY = MAX_SPEED/3;
|
||||
|
||||
private Vec3 direction;
|
||||
private Vec3 dirBefore;
|
||||
private Vec3d direction;
|
||||
private Vec3d dirBefore;
|
||||
private double motion;
|
||||
private long lastCall = Sys.getTime();
|
||||
|
||||
@@ -129,10 +129,10 @@ public class ClassicCameraController implements CameraController {
|
||||
return;
|
||||
}
|
||||
|
||||
Vec3 movement = direction.normalize();
|
||||
Vec3d movement = direction.normalize();
|
||||
double factor = motion * (frac / 1000D);
|
||||
|
||||
camera.moveCamera(movement.xCoord * factor, movement.yCoord * factor, movement.zCoord * factor);
|
||||
camera.moveCamera(movement.x * factor, movement.y * factor, movement.z * factor);
|
||||
}
|
||||
|
||||
private void setMovement(MoveDirection dir) {
|
||||
@@ -158,7 +158,7 @@ public class ClassicCameraController implements CameraController {
|
||||
break;
|
||||
}
|
||||
|
||||
Vec3 dbf = direction;
|
||||
Vec3d dbf = direction;
|
||||
|
||||
if(dirBefore != null) {
|
||||
direction = dirBefore.normalize().add(direction);
|
||||
@@ -169,12 +169,12 @@ public class ClassicCameraController implements CameraController {
|
||||
updateMovement();
|
||||
}
|
||||
|
||||
private Vec3 getVectorForRotation(float pitch, float yaw) {
|
||||
private Vec3d getVectorForRotation(float pitch, float yaw) {
|
||||
float f2 = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI);
|
||||
float f3 = MathHelper.sin(-yaw * 0.017453292F - (float)Math.PI);
|
||||
float f4 = -MathHelper.cos(-pitch * 0.017453292F);
|
||||
float f5 = MathHelper.sin(-pitch * 0.017453292F);
|
||||
return new Vec3((double)(f3 * f4), (double)f5, (double)(f2 * f4));
|
||||
return new Vec3d((double)(f3 * f4), (double)f5, (double)(f2 * f4));
|
||||
}
|
||||
|
||||
public enum MoveDirection {
|
||||
|
||||
@@ -41,8 +41,9 @@ public class SpectatorCameraController implements CameraController {
|
||||
if (view instanceof EntityPlayer) {
|
||||
EntityPlayer viewPlayer = (EntityPlayer) view;
|
||||
camera.inventory = viewPlayer.inventory;
|
||||
camera.itemInUse = viewPlayer.itemInUse;
|
||||
camera.itemInUseCount = viewPlayer.itemInUseCount;
|
||||
camera.itemStackMainHand = viewPlayer.itemStackMainHand;
|
||||
camera.swingingHand = viewPlayer.swingingHand;
|
||||
camera.activeItemStackUseCount = viewPlayer.activeItemStackUseCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.replaymod.replay.events;
|
||||
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
@Cancelable
|
||||
@RequiredArgsConstructor
|
||||
public class ReplayChatMessageEvent extends Event {
|
||||
@Getter
|
||||
private final CameraEntity cameraEntity;
|
||||
}
|
||||
@@ -2,14 +2,14 @@ package com.replaymod.replay.gui.overlay;
|
||||
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import com.replaymod.replay.ReplayHandler;
|
||||
import com.replaymod.replaystudio.data.Marker;
|
||||
import com.replaymod.replaystudio.util.Location;
|
||||
import de.johni0702.minecraft.gui.GuiRenderer;
|
||||
import de.johni0702.minecraft.gui.RenderInfo;
|
||||
import de.johni0702.minecraft.gui.element.advanced.AbstractGuiTimeline;
|
||||
import de.johni0702.minecraft.gui.function.Draggable;
|
||||
import com.replaymod.replaystudio.data.Marker;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import org.lwjgl.util.Point;
|
||||
import org.lwjgl.util.ReadableDimension;
|
||||
import org.lwjgl.util.ReadablePoint;
|
||||
@@ -58,7 +58,7 @@ public class GuiMarkerTimeline extends AbstractGuiTimeline<GuiMarkerTimeline> im
|
||||
|
||||
protected void drawMarker(GuiRenderer renderer, ReadableDimension size, Marker marker) {
|
||||
int visibleLength = (int) (getLength() * getZoom());
|
||||
int markerPos = MathHelper.clamp_int(marker.getTime(), getOffset(), getOffset() + visibleLength);
|
||||
int markerPos = MathHelper.clamp(marker.getTime(), getOffset(), getOffset() + visibleLength);
|
||||
double positionInVisible = markerPos - getOffset();
|
||||
double fractionOfVisible = positionInVisible / visibleLength;
|
||||
int markerX = (int) (BORDER_LEFT + fractionOfVisible * (size.getWidth() - BORDER_LEFT - BORDER_RIGHT));
|
||||
@@ -99,7 +99,7 @@ public class GuiMarkerTimeline extends AbstractGuiTimeline<GuiMarkerTimeline> im
|
||||
int visibleLength = (int) (getLength() * getZoom());
|
||||
int contentWidth = lastSize.getWidth() - BORDER_LEFT - BORDER_RIGHT;
|
||||
for (Marker marker : replayHandler.getMarkers()) {
|
||||
int markerPos = MathHelper.clamp_int(marker.getTime(), getOffset(), getOffset() + visibleLength);
|
||||
int markerPos = MathHelper.clamp(marker.getTime(), getOffset(), getOffset() + visibleLength);
|
||||
double positionInVisible = markerPos - getOffset();
|
||||
double fractionOfVisible = positionInVisible / visibleLength;
|
||||
int markerX = (int) (BORDER_LEFT + fractionOfVisible * contentWidth);
|
||||
|
||||
@@ -16,7 +16,7 @@ import de.johni0702.minecraft.gui.layout.CustomLayout;
|
||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
@@ -138,9 +138,9 @@ public class GuiReplayOverlay extends AbstractGuiOverlay<GuiReplayOverlay> {
|
||||
public void setVisible(boolean visible) {
|
||||
if (isVisible() != visible) {
|
||||
if (visible) {
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
} else {
|
||||
FMLCommonHandler.instance().bus().unregister(this);
|
||||
MinecraftForge.EVENT_BUS.unregister(this);
|
||||
}
|
||||
}
|
||||
super.setVisible(visible);
|
||||
|
||||
@@ -28,13 +28,11 @@ import de.johni0702.minecraft.gui.utils.Consumer;
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.io.IOCase;
|
||||
import org.apache.commons.io.filefilter.SuffixFileFilter;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.core.helpers.Strings;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.util.Dimension;
|
||||
import org.lwjgl.util.ReadableDimension;
|
||||
@@ -47,6 +45,8 @@ import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import static com.replaymod.replay.ReplayModReplay.LOGGER;
|
||||
|
||||
public class GuiReplayViewer extends GuiScreen {
|
||||
private final ReplayModReplay mod;
|
||||
|
||||
@@ -91,7 +91,7 @@ public class GuiReplayViewer extends GuiScreen {
|
||||
obj.consume(() -> new GuiReplayEntry(file, metaData, theThumb));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FMLLog.getLogger().error("Could not load Replay File " + file.getName(), e);
|
||||
LOGGER.error("Could not load Replay File {}", file.getName(), e);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@@ -155,7 +155,7 @@ public class GuiReplayViewer extends GuiScreen {
|
||||
@Override
|
||||
public void run() {
|
||||
final File file = list.getSelected().file;
|
||||
String name = FilenameUtils.getBaseName(file.getName());
|
||||
String name = Utils.fileNameToReplayName(file.getName());
|
||||
final GuiTextField nameField = new GuiTextField().setSize(200, 20).setFocused(true).setText(name);
|
||||
final GuiYesNoPopup popup = GuiYesNoPopup.open(GuiReplayViewer.this,
|
||||
new GuiLabel().setI18nText("replaymod.gui.viewer.rename.name").setColor(Colors.BLACK),
|
||||
@@ -171,16 +171,16 @@ public class GuiReplayViewer extends GuiScreen {
|
||||
}
|
||||
}).onTextChanged(obj -> {
|
||||
popup.getYesButton().setEnabled(!nameField.getText().isEmpty()
|
||||
&& !new File(file.getParentFile(), nameField.getText() + ".mcpr").exists());
|
||||
&& !new File(file.getParentFile(), Utils.replayNameToFileName(nameField.getText())).exists());
|
||||
});
|
||||
Futures.addCallback(popup.getFuture(), new FutureCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean delete) {
|
||||
if (delete) {
|
||||
// Sanitize their input
|
||||
String name = nameField.getText().trim().replace("[^a-zA-Z0-9\\.\\- ]", "_");
|
||||
String name = nameField.getText().trim();
|
||||
// This file is what they want
|
||||
File targetFile = new File(file.getParentFile(), name + ".mcpr");
|
||||
File targetFile = new File(file.getParentFile(), Utils.replayNameToFileName(name));
|
||||
try {
|
||||
// Finally, try to move it
|
||||
FileUtils.moveFile(file, targetFile);
|
||||
@@ -302,7 +302,7 @@ public class GuiReplayViewer extends GuiScreen {
|
||||
public GuiReplayEntry(File file, ReplayMetaData metaData, BufferedImage thumbImage) {
|
||||
this.file = file;
|
||||
|
||||
name.setText(ChatFormatting.UNDERLINE + FilenameUtils.getBaseName(file.getName()));
|
||||
name.setText(ChatFormatting.UNDERLINE + Utils.fileNameToReplayName(file.getName()));
|
||||
if (Strings.isEmpty(metaData.getServerName())) {
|
||||
server.setI18nText("replaymod.gui.iphidden").setColor(Colors.DARK_RED);
|
||||
} else {
|
||||
|
||||
@@ -9,7 +9,6 @@ import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -18,7 +17,7 @@ import java.util.List;
|
||||
|
||||
public class GuiHandler {
|
||||
private static final int BUTTON_EXIT_SERVER = 1;
|
||||
private static final int BUTTON_ACHIEVEMENTS = 5;
|
||||
private static final int BUTTON_ADVANCEMENTS = 5;
|
||||
private static final int BUTTON_STATS = 6;
|
||||
private static final int BUTTON_OPEN_TO_LAN = 7;
|
||||
|
||||
@@ -34,13 +33,12 @@ public class GuiHandler {
|
||||
}
|
||||
|
||||
public void register() {
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void injectIntoIngameMenu(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||
if (!(event.gui instanceof GuiIngameMenu)) {
|
||||
if (!(event.getGui() instanceof GuiIngameMenu)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,8 +47,7 @@ public class GuiHandler {
|
||||
mod.getReplayHandler().getReplaySender().setReplaySpeed(0);
|
||||
|
||||
GuiButton achievements = null, stats = null, openToLan = null;
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GuiButton> buttonList = event.buttonList;
|
||||
List<GuiButton> buttonList = event.getButtonList();
|
||||
for(GuiButton b : new ArrayList<>(buttonList)) {
|
||||
switch (b.id) {
|
||||
// Replace "Exit Server" button with "Exit Replay" button
|
||||
@@ -58,8 +55,8 @@ public class GuiHandler {
|
||||
b.displayString = I18n.format("replaymod.gui.exit");
|
||||
b.id = BUTTON_EXIT_REPLAY;
|
||||
break;
|
||||
// Remove "Achievements", "Stats" and "Open to LAN" buttons
|
||||
case BUTTON_ACHIEVEMENTS:
|
||||
// Remove "Advancements", "Stats" and "Open to LAN" buttons
|
||||
case BUTTON_ADVANCEMENTS:
|
||||
buttonList.remove(achievements = b);
|
||||
break;
|
||||
case BUTTON_STATS:
|
||||
@@ -71,12 +68,12 @@ public class GuiHandler {
|
||||
}
|
||||
}
|
||||
if (achievements != null && stats != null) {
|
||||
moveAllButtonsDirectlyBelowUpwards(buttonList, achievements.yPosition,
|
||||
achievements.xPosition, stats.xPosition + stats.width);
|
||||
moveAllButtonsDirectlyBelowUpwards(buttonList, achievements.y,
|
||||
achievements.x, stats.x + stats.width);
|
||||
}
|
||||
if (openToLan != null) {
|
||||
moveAllButtonsDirectlyBelowUpwards(buttonList, openToLan.yPosition,
|
||||
openToLan.xPosition, openToLan.xPosition + openToLan.width);
|
||||
moveAllButtonsDirectlyBelowUpwards(buttonList, openToLan.y,
|
||||
openToLan.x, openToLan.x + openToLan.width);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,39 +87,37 @@ public class GuiHandler {
|
||||
*/
|
||||
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;
|
||||
if (button.y >= belowY && button.x <= xEnd && button.x + button.width >= xStart) {
|
||||
button.y -= 24;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
||||
if (!(event.gui instanceof GuiMainMenu)) {
|
||||
if (!(event.getGui() instanceof GuiMainMenu)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
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"));
|
||||
GuiButton button = new GuiButton(BUTTON_REPLAY_VIEWER, event.getGui().width / 2 - 100,
|
||||
event.getGui().height / 4 + 10 + 3 * 24, I18n.format("replaymod.gui.replayviewer"));
|
||||
button.width = button.width / 2 - 2;
|
||||
buttonList.add(button);
|
||||
event.getButtonList().add(button);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
||||
if(!event.button.enabled) return;
|
||||
if(!event.getButton().enabled) return;
|
||||
|
||||
if (event.gui instanceof GuiMainMenu) {
|
||||
if (event.button.id == BUTTON_REPLAY_VIEWER) {
|
||||
if (event.getGui() instanceof GuiMainMenu) {
|
||||
if (event.getButton().id == BUTTON_REPLAY_VIEWER) {
|
||||
new GuiReplayViewer(mod).display();
|
||||
}
|
||||
}
|
||||
|
||||
if (event.gui instanceof GuiIngameMenu && mod.getReplayHandler() != null) {
|
||||
if (event.button.id == BUTTON_EXIT_REPLAY) {
|
||||
event.button.enabled = false;
|
||||
if (event.getGui() instanceof GuiIngameMenu && mod.getReplayHandler() != null) {
|
||||
if (event.getButton().id == BUTTON_EXIT_REPLAY) {
|
||||
event.getButton().enabled = false;
|
||||
mc.displayGuiScreen(new GuiMainMenu());
|
||||
try {
|
||||
mod.getReplayHandler().endReplay();
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.replaymod.replay.mixin;
|
||||
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.ArmorStandRenderer;
|
||||
import net.minecraft.entity.item.EntityArmorStand;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
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(ArmorStandRenderer.class)
|
||||
public abstract class MixinArmorStandRenderer {
|
||||
@Inject(method = "canRenderName", at = @At("HEAD"), cancellable = true)
|
||||
private void replayModReplay_canRenderInvisibleName(EntityArmorStand entity, CallbackInfoReturnable<Boolean> ci) {
|
||||
EntityPlayer thePlayer = Minecraft.getMinecraft().thePlayer;
|
||||
if (thePlayer instanceof CameraEntity && entity.isInvisible()) {
|
||||
ci.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,12 +12,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(GuiSpectator.class)
|
||||
public abstract class MixinGuiSpectator {
|
||||
@Shadow
|
||||
private Minecraft field_175268_g;
|
||||
private Minecraft mc;
|
||||
|
||||
@Inject(method = "func_175260_a", at = @At("HEAD"), cancellable = true)
|
||||
@Inject(method = "onHotbarSelected", at = @At("HEAD"), cancellable = true)
|
||||
public void isInReplay(int i, CallbackInfo ci) {
|
||||
// Prevent spectator gui from opening while in a replay
|
||||
if (field_175268_g.thePlayer instanceof CameraEntity) {
|
||||
if (mc.player instanceof CameraEntity) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
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,13 @@
|
||||
package com.replaymod.replay.mixin;
|
||||
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.stats.StatFileWriter;
|
||||
import net.minecraft.stats.RecipeBook;
|
||||
import net.minecraft.stats.StatisticsManager;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -21,20 +22,20 @@ public abstract class MixinPlayerControllerMP {
|
||||
private Minecraft mc;
|
||||
|
||||
@Shadow
|
||||
private NetHandlerPlayClient netClientHandler;
|
||||
private NetHandlerPlayClient connection;
|
||||
|
||||
@Inject(method = "func_178892_a", at=@At("HEAD"), cancellable = true)
|
||||
private void replayModReplay_createReplayCamera(World worldIn, StatFileWriter statFileWriter, CallbackInfoReturnable<EntityPlayerSP> ci) {
|
||||
@Inject(method = "func_192830_a", at=@At("HEAD"), cancellable = true)
|
||||
private void replayModReplay_createReplayCamera(World worldIn, StatisticsManager statisticsManager, RecipeBook recipeBook, CallbackInfoReturnable<EntityPlayerSP> ci) {
|
||||
if (ReplayModReplay.instance.getReplayHandler() != null) {
|
||||
ci.setReturnValue(new CameraEntity(mc, worldIn, netClientHandler, statFileWriter));
|
||||
ci.setReturnValue(new CameraEntity(mc, worldIn, connection, statisticsManager, recipeBook));
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "isSpectator", at=@At("HEAD"), cancellable = true)
|
||||
private void replayModReplay_isSpectator(CallbackInfoReturnable<Boolean> ci) {
|
||||
if (mc.thePlayer instanceof CameraEntity) { // this check should in theory not be required
|
||||
ci.setReturnValue(mc.thePlayer.isSpectator());
|
||||
if (mc.player instanceof CameraEntity) { // this check should in theory not be required
|
||||
ci.setReturnValue(mc.player.isSpectator());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ public abstract class MixinRenderArrow extends Render {
|
||||
super(renderManager);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
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
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.replaymod.replay.mixin;
|
||||
import com.replaymod.replay.ReplayHandler;
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.replaymod.replay.mixin;
|
||||
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.RendererLivingEntity;
|
||||
import net.minecraft.client.renderer.entity.RenderLivingBase;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -11,11 +11,11 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(RendererLivingEntity.class)
|
||||
public abstract class MixinRendererLivingEntity {
|
||||
@Mixin(RenderLivingBase.class)
|
||||
public abstract class MixinRenderLivingBase {
|
||||
@Inject(method = "canRenderName", at = @At("HEAD"), cancellable = true)
|
||||
private void replayModReplay_canRenderInvisibleName(EntityLivingBase entity, CallbackInfoReturnable<Boolean> ci) {
|
||||
EntityPlayer thePlayer = Minecraft.getMinecraft().thePlayer;
|
||||
EntityPlayer thePlayer = Minecraft.getMinecraft().player;
|
||||
if (thePlayer instanceof CameraEntity && entity.isInvisible()) {
|
||||
ci.setReturnValue(false);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user