Compare commits
36 Commits
1.8-2.0.1
...
1.10.2-2.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96b2904e4b | ||
|
|
6c8c779983 | ||
|
|
aa16e42a4f | ||
|
|
ed566732df | ||
|
|
325d041bd9 | ||
|
|
d9d57e283c | ||
|
|
24c58cbbe7 | ||
|
|
3f52336852 | ||
|
|
c6293bcbb0 | ||
|
|
c8126edbb2 | ||
|
|
c6dec95a57 | ||
|
|
4fdfa9ec87 | ||
|
|
44d4a250eb | ||
|
|
01acbc6f1f | ||
|
|
905ae75330 | ||
|
|
72e1fe0d6c | ||
|
|
372206fdff | ||
|
|
4a1cceaa47 | ||
|
|
9f7ccb9d07 | ||
|
|
ca2bbca7a4 | ||
|
|
75c0e7b77a | ||
|
|
ce313596db | ||
|
|
b1661e359a | ||
|
|
e20dfa6d7f | ||
|
|
7cc0ee523a | ||
|
|
54790d33f9 | ||
|
|
165861764c | ||
|
|
5014edafe0 | ||
|
|
09f167f10e | ||
|
|
21ac84e990 | ||
|
|
8e6eec879f | ||
|
|
5100f36b2c | ||
|
|
7ef6a6d166 | ||
|
|
446b9be384 | ||
|
|
d1ed67f1a0 | ||
|
|
a80a20c37a |
@@ -7,7 +7,6 @@ pipeline:
|
|||||||
commands:
|
commands:
|
||||||
- curl --fail --create-dirs -o $HOME/.gradle/init.d/mirror.gradle https://maven.johni0702.de/config/gradle
|
- curl --fail --create-dirs -o $HOME/.gradle/init.d/mirror.gradle https://maven.johni0702.de/config/gradle
|
||||||
- curl --fail --create-dirs -o $HOME/.m2/settings.xml https://maven.johni0702.de/config/maven
|
- curl --fail --create-dirs -o $HOME/.m2/settings.xml https://maven.johni0702.de/config/maven
|
||||||
- ./gradlew setupCIWorkspace
|
|
||||||
- ./gradlew :build
|
- ./gradlew :build
|
||||||
archive:
|
archive:
|
||||||
image: plugins/s3
|
image: plugins/s3
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
eyJhbGciOiJIUzI1NiJ9.cGlwZWxpbmU6CiAgY2xvbmU6CiAgICBpbWFnZTogcGx1Z2lucy9naXQKICAgIHRhZ3M6IHRydWUKICBidWlsZDoKICAgIGltYWdlOiBtYXZlbjozLjMuOS1qZGstOAogICAgY29tbWFuZHM6CiAgICAgIC0gY3VybCAtLWZhaWwgLS1jcmVhdGUtZGlycyAtbyAkSE9NRS8uZ3JhZGxlL2luaXQuZC9taXJyb3IuZ3JhZGxlIGh0dHBzOi8vbWF2ZW4uam9obmkwNzAyLmRlL2NvbmZpZy9ncmFkbGUKICAgICAgLSBjdXJsIC0tZmFpbCAtLWNyZWF0ZS1kaXJzIC1vICRIT01FLy5tMi9zZXR0aW5ncy54bWwgaHR0cHM6Ly9tYXZlbi5qb2huaTA3MDIuZGUvY29uZmlnL21hdmVuCiAgICAgIC0gLi9ncmFkbGV3IHNldHVwQ0lXb3Jrc3BhY2UKICAgICAgLSAuL2dyYWRsZXcgOmJ1aWxkCiAgYXJjaGl2ZToKICAgIGltYWdlOiBwbHVnaW5zL3MzCiAgICBhY2w6IHB1YmxpYy1yZWFkCiAgICByZWdpb246ICJ1cy1lYXN0LTEiCiAgICBidWNrZXQ6ICJyZXBsYXltb2QiCiAgICBwYXRoX3N0eWxlOiB0cnVlCiAgICBzb3VyY2U6IGJ1aWxkL2xpYnMvKgogICAgc3RyaXBfcHJlZml4OiBidWlsZC9saWJzLwogICAgdGFyZ2V0OiAvCg.riE6lhwfdNUhI7LO2SxEKFOjzjaX40ne7Ae9gyP75KE
|
eyJhbGciOiJIUzI1NiJ9.cGlwZWxpbmU6CiAgY2xvbmU6CiAgICBpbWFnZTogcGx1Z2lucy9naXQKICAgIHRhZ3M6IHRydWUKICBidWlsZDoKICAgIGltYWdlOiBtYXZlbjozLjMuOS1qZGstOAogICAgY29tbWFuZHM6CiAgICAgIC0gY3VybCAtLWZhaWwgLS1jcmVhdGUtZGlycyAtbyAkSE9NRS8uZ3JhZGxlL2luaXQuZC9taXJyb3IuZ3JhZGxlIGh0dHBzOi8vbWF2ZW4uam9obmkwNzAyLmRlL2NvbmZpZy9ncmFkbGUKICAgICAgLSBjdXJsIC0tZmFpbCAtLWNyZWF0ZS1kaXJzIC1vICRIT01FLy5tMi9zZXR0aW5ncy54bWwgaHR0cHM6Ly9tYXZlbi5qb2huaTA3MDIuZGUvY29uZmlnL21hdmVuCiAgICAgIC0gLi9ncmFkbGV3IDpidWlsZAogIGFyY2hpdmU6CiAgICBpbWFnZTogcGx1Z2lucy9zMwogICAgYWNsOiBwdWJsaWMtcmVhZAogICAgcmVnaW9uOiAidXMtZWFzdC0xIgogICAgYnVja2V0OiAicmVwbGF5bW9kIgogICAgcGF0aF9zdHlsZTogdHJ1ZQogICAgc291cmNlOiBidWlsZC9saWJzLyoKICAgIHN0cmlwX3ByZWZpeDogYnVpbGQvbGlicy8KICAgIHRhcmdldDogLwo.Z6rpaLplJKQ4pzB8AjCnplgci42qEu7L4LeS0fGm4SY
|
||||||
Submodule ReplayStudio updated: 44109f11b1...98bbf92b9d
64
build.gradle
64
build.gradle
@@ -17,8 +17,8 @@ buildscript {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT'
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
|
||||||
classpath 'org.spongepowered:mixingradle:0.3-SNAPSHOT'
|
classpath 'org.spongepowered:mixingradle:0.4-SNAPSHOT'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,13 +34,11 @@ archivesBaseName = "replaymod"
|
|||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
coreMod = 'com.replaymod.core.LoadingPlugin'
|
coreMod = 'com.replaymod.core.LoadingPlugin'
|
||||||
version = '1.8-11.14.4.1563'
|
version = '1.10.2-12.18.2.2099'
|
||||||
runDir = "eclipse"
|
runDir = "eclipse"
|
||||||
mappings = "snapshot_nodoc_20141130"
|
mappings = "snapshot_20160518"
|
||||||
replace '@MOD_VERSION@', project.version
|
replace '@MOD_VERSION@', project.version
|
||||||
// Includes intentional whitespace to stop Forge from declaring the mod to be compatible with
|
replace '@MC_VERSION@', project.minecraft.version
|
||||||
// a newer srg-compatible MC version (that may be using a different protocol version)
|
|
||||||
replace '@MC_VERSION@', "[ ${project.minecraft.version} ]"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@@ -117,6 +115,7 @@ jar {
|
|||||||
manifest {
|
manifest {
|
||||||
attributes 'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
|
attributes 'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
|
||||||
'TweakOrder': '0',
|
'TweakOrder': '0',
|
||||||
|
'FMLCorePluginContainsFMLMod': 'true',
|
||||||
'FMLAT': 'replaymod_at.cfg'
|
'FMLAT': 'replaymod_at.cfg'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -185,6 +184,57 @@ setupDecompWorkspace.dependsOn copySrg
|
|||||||
setupDevWorkspace.dependsOn copySrg
|
setupDevWorkspace.dependsOn copySrg
|
||||||
project.tasks.idea.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"]) {
|
task runIntegrationTest(type: JavaExec, dependsOn: ["makeStart", "jar"]) {
|
||||||
main = 'GradleStart'
|
main = 'GradleStart'
|
||||||
standardOutput = System.out
|
standardOutput = System.out
|
||||||
|
|||||||
2
jGui
2
jGui
Submodule jGui updated: 9e84e724aa...e2bd90628e
@@ -50,10 +50,8 @@ public abstract class AbstractTask implements Task {
|
|||||||
public ListenableFuture<Void> execute() {
|
public ListenableFuture<Void> execute() {
|
||||||
future = SettableFuture.create();
|
future = SettableFuture.create();
|
||||||
|
|
||||||
FMLCommonHandler.instance().bus().register(this);
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
addCallback(future, success -> {
|
addCallback(future, success -> {
|
||||||
FMLCommonHandler.instance().bus().unregister(this);
|
|
||||||
MinecraftForge.EVENT_BUS.unregister(this);
|
MinecraftForge.EVENT_BUS.unregister(this);
|
||||||
}, error -> {});
|
}, error -> {});
|
||||||
|
|
||||||
@@ -92,7 +90,7 @@ public abstract class AbstractTask implements Task {
|
|||||||
public void onGuiOpen(TickEvent.RenderTickEvent event) {
|
public void onGuiOpen(TickEvent.RenderTickEvent event) {
|
||||||
if (event.phase != TickEvent.Phase.START) return;
|
if (event.phase != TickEvent.Phase.START) return;
|
||||||
if (currentScreen != mc.currentScreen) {
|
if (currentScreen != mc.currentScreen) {
|
||||||
FMLCommonHandler.instance().bus().unregister(this);
|
MinecraftForge.EVENT_BUS.unregister(this);
|
||||||
onClosed.run();
|
onClosed.run();
|
||||||
} else {
|
} else {
|
||||||
if (framesPassed < timeout) {
|
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) {
|
public void expectPopupClosed(Runnable onClosed) {
|
||||||
@@ -130,7 +128,7 @@ public abstract class AbstractTask implements Task {
|
|||||||
public void onGuiOpen(TickEvent.RenderTickEvent event) {
|
public void onGuiOpen(TickEvent.RenderTickEvent event) {
|
||||||
if (event.phase != TickEvent.Phase.START) return;
|
if (event.phase != TickEvent.Phase.START) return;
|
||||||
if (getPopup(mc.currentScreen) != popup) {
|
if (getPopup(mc.currentScreen) != popup) {
|
||||||
FMLCommonHandler.instance().bus().unregister(this);
|
MinecraftForge.EVENT_BUS.unregister(this);
|
||||||
onClosed.run();
|
onClosed.run();
|
||||||
} else {
|
} else {
|
||||||
if (framesPassed < timeout) {
|
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) {
|
private AbstractGuiPopup getPopup(net.minecraft.client.gui.GuiScreen minecraft) {
|
||||||
@@ -181,7 +179,7 @@ public abstract class AbstractTask implements Task {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FMLCommonHandler.instance().bus().unregister(this);
|
MinecraftForge.EVENT_BUS.unregister(this);
|
||||||
|
|
||||||
Object foundGui = null;
|
Object foundGui = null;
|
||||||
if (AbstractGuiScreen.class.isAssignableFrom(guiClass)) {
|
if (AbstractGuiScreen.class.isAssignableFrom(guiClass)) {
|
||||||
@@ -219,7 +217,7 @@ public abstract class AbstractTask implements Task {
|
|||||||
future.setException(new UnexpectedGuiException(foundGui == null ? currentScreen : foundGui));
|
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) {
|
private void clickNow(int x, int y) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.replaymod.recording;
|
|||||||
import com.replaymod.core.AbstractTask;
|
import com.replaymod.core.AbstractTask;
|
||||||
import net.minecraft.client.gui.GuiCreateWorld;
|
import net.minecraft.client.gui.GuiCreateWorld;
|
||||||
import net.minecraft.client.gui.GuiMainMenu;
|
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.client.event.RenderGameOverlayEvent;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
@@ -13,7 +13,7 @@ public class CreateSPWorld extends AbstractTask {
|
|||||||
protected void init() {
|
protected void init() {
|
||||||
expectGui(GuiMainMenu.class, mainMenu -> {
|
expectGui(GuiMainMenu.class, mainMenu -> {
|
||||||
click("Singleplayer");
|
click("Singleplayer");
|
||||||
expectGui(GuiSelectWorld.class, selectWorld -> {
|
expectGui(GuiWorldSelection.class, selectWorld -> {
|
||||||
click("Create New World");
|
click("Create New World");
|
||||||
expectGui(GuiCreateWorld.class, createWorld -> {
|
expectGui(GuiCreateWorld.class, createWorld -> {
|
||||||
click("Create New World");
|
click("Create New World");
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package com.replaymod.compat;
|
package com.replaymod.compat;
|
||||||
|
|
||||||
import com.replaymod.compat.bettersprinting.DisableBetterSprinting;
|
|
||||||
import com.replaymod.compat.optifine.DisableFastRender;
|
import com.replaymod.compat.optifine.DisableFastRender;
|
||||||
import com.replaymod.compat.oranges17animations.HideInvisibleEntities;
|
|
||||||
import com.replaymod.compat.shaders.ShaderBeginRender;
|
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.Mod;
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.EventBus;
|
import net.minecraftforge.fml.common.eventhandler.EventBus;
|
||||||
@@ -12,18 +10,15 @@ import net.minecraftforge.fml.common.eventhandler.EventBus;
|
|||||||
@Mod(modid = ReplayModCompat.MOD_ID,
|
@Mod(modid = ReplayModCompat.MOD_ID,
|
||||||
version = "@MOD_VERSION@",
|
version = "@MOD_VERSION@",
|
||||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||||
acceptableRemoteVersions = "*",
|
|
||||||
useMetadata = true)
|
useMetadata = true)
|
||||||
public class ReplayModCompat {
|
public class ReplayModCompat {
|
||||||
public static final String MOD_ID = "replaymod-compat";
|
public static final String MOD_ID = "replaymod-compat";
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void init(FMLInitializationEvent event) {
|
public void init(FMLInitializationEvent event) {
|
||||||
EventBus bus = FMLCommonHandler.instance().bus();
|
EventBus bus = MinecraftForge.EVENT_BUS;
|
||||||
bus.register(new ShaderBeginRender());
|
bus.register(new ShaderBeginRender());
|
||||||
bus.register(new DisableFastRender());
|
bus.register(new DisableFastRender());
|
||||||
bus.register(new HideInvisibleEntities());
|
|
||||||
DisableBetterSprinting.register();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,97 +0,0 @@
|
|||||||
package com.replaymod.compat.bettersprinting;
|
|
||||||
|
|
||||||
import com.replaymod.replay.ReplayModReplay;
|
|
||||||
import com.replaymod.replay.events.ReplayChatMessageEvent;
|
|
||||||
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.BlockPos;
|
|
||||||
import net.minecraft.world.IWorldAccess;
|
|
||||||
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 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.theWorld != null) {
|
|
||||||
// During replay, get ready to revert BetterSprinting's overwritten playerController
|
|
||||||
originalController = mc.playerController;
|
|
||||||
mc.theWorld.addWorldAccess(worldAccessHook);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.LOW)
|
|
||||||
public void afterGuiOpenEvent(GuiOpenEvent event) {
|
|
||||||
if (ReplayModReplay.instance.getReplayHandler() != null && mc.theWorld != null) {
|
|
||||||
mc.theWorld.removeWorldAccess(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 IWorldAccess {
|
|
||||||
@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 markBlockForUpdate(BlockPos pos) {}
|
|
||||||
@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 playSound(String soundName, double x, double y, double z, float volume, float pitch) {}
|
|
||||||
@Override public void playSoundToNearExcept(EntityPlayer except, String soundName, double x, double y, double z, float volume, float pitch) {}
|
|
||||||
@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 onEntityAdded(Entity entityIn) {}
|
|
||||||
@Override public void playRecord(String recordName, BlockPos blockPosIn) {}
|
|
||||||
@Override public void broadcastSound(int p_180440_1_, BlockPos p_180440_2_, int p_180440_3_) {}
|
|
||||||
@Override public void playAusSFX(EntityPlayer p_180439_1_, int p_180439_2_, BlockPos blockPosIn, int p_180439_4_) {}
|
|
||||||
@Override public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
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.thePlayer instanceof CameraEntity && event.entity.isInvisible()) {
|
|
||||||
event.setCanceled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,7 +16,6 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
|
|
||||||
public class KeyBindingRegistry {
|
public class KeyBindingRegistry {
|
||||||
private Map<String, KeyBinding> keyBindings = new HashMap<String, KeyBinding>();
|
private Map<String, KeyBinding> keyBindings = new HashMap<String, KeyBinding>();
|
||||||
@@ -86,7 +85,7 @@ public class KeyBindingRegistry {
|
|||||||
CrashReport crashReport = CrashReport.makeCrashReport(cause, "Handling Key Binding");
|
CrashReport crashReport = CrashReport.makeCrashReport(cause, "Handling Key Binding");
|
||||||
CrashReportCategory category = crashReport.makeCategory("Key Binding");
|
CrashReportCategory category = crashReport.makeCategory("Key Binding");
|
||||||
category.addCrashSection("Key Binding", keyBinding);
|
category.addCrashSection("Key Binding", keyBinding);
|
||||||
category.addCrashSectionCallable("Handler", runnable::toString);
|
category.setDetail("Handler", runnable::toString);
|
||||||
throw new ReportedException(crashReport);
|
throw new ReportedException(crashReport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,12 +100,7 @@ public class KeyBindingRegistry {
|
|||||||
CrashReport crashReport = CrashReport.makeCrashReport(cause, "Handling Raw Key Binding");
|
CrashReport crashReport = CrashReport.makeCrashReport(cause, "Handling Raw Key Binding");
|
||||||
CrashReportCategory category = crashReport.makeCategory("Key Binding");
|
CrashReportCategory category = crashReport.makeCategory("Key Binding");
|
||||||
category.addCrashSection("Key Code", keyCode);
|
category.addCrashSection("Key Code", keyCode);
|
||||||
category.addCrashSectionCallable("Handler", new Callable() {
|
category.setDetail("Handler", runnable::toString);
|
||||||
@Override
|
|
||||||
public Object call() throws Exception {
|
|
||||||
return runnable;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
throw new ReportedException(crashReport);
|
throw new ReportedException(crashReport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ public class LoadingPlugin implements IFMLLoadingPlugin {
|
|||||||
Mixins.addConfiguration("mixins.render.replaymod.json");
|
Mixins.addConfiguration("mixins.render.replaymod.json");
|
||||||
Mixins.addConfiguration("mixins.replay.replaymod.json");
|
Mixins.addConfiguration("mixins.replay.replaymod.json");
|
||||||
Mixins.addConfiguration("mixins.compat.shaders.replaymod.json");
|
Mixins.addConfiguration("mixins.compat.shaders.replaymod.json");
|
||||||
Mixins.addConfiguration("mixins.extras.playeroverview.replaymod.json");
|
|
||||||
|
|
||||||
CodeSource codeSource = getClass().getProtectionDomain().getCodeSource();
|
CodeSource codeSource = getClass().getProtectionDomain().getCodeSource();
|
||||||
if (codeSource != null) {
|
if (codeSource != null) {
|
||||||
@@ -30,7 +29,7 @@ public class LoadingPlugin implements IFMLLoadingPlugin {
|
|||||||
if (file.isFile()) {
|
if (file.isFile()) {
|
||||||
// This forces forge to reexamine the jar file for FML mods
|
// This forces forge to reexamine the jar file for FML mods
|
||||||
// Should eventually be handled by Mixin itself, maybe?
|
// Should eventually be handled by Mixin itself, maybe?
|
||||||
CoreModManager.getLoadedCoremods().remove(file.getName());
|
CoreModManager.getIgnoredMods().remove(file.getName());
|
||||||
}
|
}
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import com.replaymod.core.gui.GuiReplaySettings;
|
|||||||
import com.replaymod.core.gui.RestoreReplayGui;
|
import com.replaymod.core.gui.RestoreReplayGui;
|
||||||
import com.replaymod.core.handler.MainMenuHandler;
|
import com.replaymod.core.handler.MainMenuHandler;
|
||||||
import com.replaymod.core.utils.OpenGLUtils;
|
import com.replaymod.core.utils.OpenGLUtils;
|
||||||
import com.replaymod.render.utils.SoundHandler;
|
|
||||||
import com.replaymod.replaystudio.util.I18n;
|
import com.replaymod.replaystudio.util.I18n;
|
||||||
import de.johni0702.minecraft.gui.container.GuiScreen;
|
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -14,10 +13,11 @@ import net.minecraft.client.Minecraft;
|
|||||||
import net.minecraft.client.settings.GameSettings;
|
import net.minecraft.client.settings.GameSettings;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
import net.minecraft.crash.CrashReportCategory;
|
import net.minecraft.crash.CrashReportCategory;
|
||||||
import net.minecraft.util.*;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.text.*;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
|
||||||
import net.minecraftforge.fml.common.Loader;
|
import net.minecraftforge.fml.common.Loader;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||||
@@ -26,21 +26,16 @@ import net.minecraftforge.fml.common.ModContainer;
|
|||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
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 org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Queue;
|
|
||||||
|
|
||||||
@Mod(modid = ReplayMod.MOD_ID,
|
@Mod(modid = ReplayMod.MOD_ID,
|
||||||
useMetadata = true,
|
useMetadata = true,
|
||||||
version = "@MOD_VERSION@",
|
version = "@MOD_VERSION@",
|
||||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||||
acceptableRemoteVersions = "*",
|
|
||||||
updateJSON = "https://raw.githubusercontent.com/ReplayMod/ReplayMod/master/versions.json",
|
updateJSON = "https://raw.githubusercontent.com/ReplayMod/ReplayMod/master/versions.json",
|
||||||
guiFactory = "com.replaymod.core.gui.GuiFactory")
|
guiFactory = "com.replaymod.core.gui.GuiFactory")
|
||||||
public class ReplayMod {
|
public class ReplayMod {
|
||||||
@@ -72,8 +67,6 @@ public class ReplayMod {
|
|||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static Configuration config;
|
public static Configuration config;
|
||||||
@Deprecated
|
|
||||||
public static SoundHandler soundHandler = new SoundHandler();
|
|
||||||
|
|
||||||
private final KeyBindingRegistry keyBindingRegistry = new KeyBindingRegistry();
|
private final KeyBindingRegistry keyBindingRegistry = new KeyBindingRegistry();
|
||||||
private final SettingsRegistry settingsRegistry = new SettingsRegistry();
|
private final SettingsRegistry settingsRegistry = new SettingsRegistry();
|
||||||
@@ -116,7 +109,7 @@ public class ReplayMod {
|
|||||||
|
|
||||||
new MainMenuHandler().register();
|
new MainMenuHandler().register();
|
||||||
|
|
||||||
FMLCommonHandler.instance().bus().register(keyBindingRegistry);
|
MinecraftForge.EVENT_BUS.register(keyBindingRegistry);
|
||||||
|
|
||||||
getKeyBindingRegistry().registerKeyBinding("replaymod.input.settings", 0, () -> {
|
getKeyBindingRegistry().registerKeyBinding("replaymod.input.settings", 0, () -> {
|
||||||
new GuiReplaySettings(null, settingsRegistry).display();
|
new GuiReplaySettings(null, settingsRegistry).display();
|
||||||
@@ -130,150 +123,7 @@ public class ReplayMod {
|
|||||||
if(!FMLClientHandler.instance().hasOptifine())
|
if(!FMLClientHandler.instance().hasOptifine())
|
||||||
GameSettings.Options.RENDER_DISTANCE.setValueMax(64f);
|
GameSettings.Options.RENDER_DISTANCE.setValueMax(64f);
|
||||||
|
|
||||||
if (System.getProperty("replaymod.render.file") != null) {
|
testIfMoeshAndExitMinecraft();
|
||||||
final File file = new File(System.getProperty("replaymod.render.file"));
|
|
||||||
if (!file.exists()) {
|
|
||||||
throw new IOException("File \"" + file.getPath() + "\" not found.");
|
|
||||||
}
|
|
||||||
|
|
||||||
final String path = System.getProperty("replaymod.render.path");
|
|
||||||
String type = System.getProperty("replaymod.render.type");
|
|
||||||
String bitrate = System.getProperty("replaymod.render.bitrate");
|
|
||||||
String fps = System.getProperty("replaymod.render.fps");
|
|
||||||
String waitForChunks = System.getProperty("replaymod.render.waitforchunks");
|
|
||||||
String linearMovement = System.getProperty("replaymod.render.linearmovement");
|
|
||||||
String skyColor = System.getProperty("replaymod.render.skycolor");
|
|
||||||
String width = System.getProperty("replaymod.render.width");
|
|
||||||
String height = System.getProperty("replaymod.render.height");
|
|
||||||
String exportCommand = System.getProperty("replaymod.render.exportcommand");
|
|
||||||
String exportCommandArgs = System.getProperty("replaymod.render.exportcommandargs");
|
|
||||||
/*
|
|
||||||
final RenderOptions options = new RenderOptions();
|
|
||||||
if (bitrate != null) {
|
|
||||||
options.setBitrate(bitrate);
|
|
||||||
}
|
|
||||||
if (fps != null) {
|
|
||||||
options.setFps(Integer.parseInt(fps));
|
|
||||||
}
|
|
||||||
if (waitForChunks != null) {
|
|
||||||
options.setWaitForChunks(Boolean.parseBoolean(waitForChunks));
|
|
||||||
}
|
|
||||||
if (linearMovement != null) {
|
|
||||||
options.setLinearMovement(Boolean.parseBoolean(linearMovement));
|
|
||||||
}
|
|
||||||
if (skyColor != null) {
|
|
||||||
if (skyColor.startsWith("0x")) {
|
|
||||||
options.setSkyColor(Integer.parseInt(skyColor.substring(2), 16));
|
|
||||||
} else {
|
|
||||||
options.setSkyColor(Integer.parseInt(skyColor));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (width != null) {
|
|
||||||
options.setWidth(Integer.parseInt(width));
|
|
||||||
}
|
|
||||||
if (height != null) {
|
|
||||||
options.setHeight(Integer.parseInt(height));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (exportCommand != null) {
|
|
||||||
options.setExportCommand(exportCommand);
|
|
||||||
}
|
|
||||||
if (exportCommandArgs != null) {
|
|
||||||
options.setExportCommandArgs(exportCommandArgs);
|
|
||||||
} else {
|
|
||||||
options.setExportCommandArgs(EncodingPreset.MP4DEFAULT.getCommandLineArgs());
|
|
||||||
}
|
|
||||||
|
|
||||||
options.setOutputFile(new File(String.valueOf(System.currentTimeMillis())));
|
|
||||||
|
|
||||||
Pipelines.Preset pipelinePreset = Pipelines.Preset.DEFAULT;
|
|
||||||
if (type != null) {
|
|
||||||
String[] parts = type.split(":");
|
|
||||||
type = parts[0].toUpperCase();
|
|
||||||
if ("NORMAL".equals(type) || "DEFAULT".equals(type)) {
|
|
||||||
pipelinePreset = Pipelines.Preset.DEFAULT;
|
|
||||||
} else if ("STEREO".equals(type) || "STEREOSCOPIC".equals(type)) {
|
|
||||||
pipelinePreset = Pipelines.Preset.STEREOSCOPIC;
|
|
||||||
} else if ("CUBIC".equals(type)) {
|
|
||||||
if (parts.length < 2) {
|
|
||||||
throw new IllegalArgumentException("Cubic renderer requires boolean for whether it's stable.");
|
|
||||||
}
|
|
||||||
pipelinePreset = Pipelines.Preset.CUBIC;
|
|
||||||
} else if ("EQUIRECTANGULAR".equals(type)) {
|
|
||||||
if (parts.length < 2) {
|
|
||||||
throw new IllegalArgumentException("Equirectangular renderer requires boolean for whether it's stable.");
|
|
||||||
}
|
|
||||||
pipelinePreset = Pipelines.Preset.EQUIRECTANGULAR;
|
|
||||||
} else if ("ODS".equals(type)) {
|
|
||||||
if (parts.length < 2) {
|
|
||||||
throw new IllegalArgumentException("ODS renderer requires boolean for whether it's stable.");
|
|
||||||
}
|
|
||||||
pipelinePreset = Pipelines.Preset.ODS;
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("Unknown type: " + parts[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
options.setMode(pipelinePreset);
|
|
||||||
*/
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Queue<ListenableFutureTask> tasks = mc.scheduledTasks;
|
|
||||||
synchronized (mc.scheduledTasks) {
|
|
||||||
tasks.add(ListenableFutureTask.create(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
String renderDistance = System.getProperty("replaymod.render.mc.renderdistance");
|
|
||||||
String clouds = System.getProperty("replaymod.render.mc.clouds");
|
|
||||||
if (renderDistance != null) {
|
|
||||||
mc.gameSettings.renderDistanceChunks = Integer.parseInt(renderDistance);
|
|
||||||
}
|
|
||||||
if (clouds != null) {
|
|
||||||
mc.gameSettings.clouds = Boolean.parseBoolean(clouds);
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("Loading replay...");
|
|
||||||
// TODO
|
|
||||||
// try {
|
|
||||||
// ReplayHandler.startReplay(file, false);
|
|
||||||
// } catch (Throwable t) {
|
|
||||||
// t.printStackTrace();
|
|
||||||
// FMLCommonHandler.instance().exitJava(1, false);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// int index = 0;
|
|
||||||
// if (path != null) {
|
|
||||||
// for (KeyframeSet set : ReplayHandler.getKeyframeRepository()) {
|
|
||||||
// if (set.getName().equals(path)) {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// index++;
|
|
||||||
// }
|
|
||||||
// if (index >= ReplayHandler.getKeyframeRepository().length) {
|
|
||||||
// throw new IllegalArgumentException("No path named \"" + path + "\".");
|
|
||||||
// }
|
|
||||||
// } else if (ReplayHandler.getKeyframeRepository().length == 0) {
|
|
||||||
// throw new IllegalArgumentException("Replay file has no paths defined.");
|
|
||||||
// }
|
|
||||||
// ReplayHandler.useKeyframePresetFromRepository(index);
|
|
||||||
//
|
|
||||||
// System.out.println("Rendering started...");
|
|
||||||
// try {
|
|
||||||
// ReplayProcess.startReplayProcess(options, true);
|
|
||||||
// } catch (Throwable t) {
|
|
||||||
// t.printStackTrace();
|
|
||||||
// FMLCommonHandler.instance().exitJava(1, false);
|
|
||||||
// }
|
|
||||||
// if (mc.hasCrashed) {
|
|
||||||
// System.out.println(mc.crashReporter.getCompleteReport());
|
|
||||||
// }
|
|
||||||
// System.out.println("Rendering done. Shutting down...");
|
|
||||||
// mc.shutdown();
|
|
||||||
}
|
|
||||||
}, null));
|
|
||||||
}
|
|
||||||
|
|
||||||
testIfMoeshAndExitMinecraft();
|
|
||||||
}
|
|
||||||
|
|
||||||
runLater(() -> {
|
runLater(() -> {
|
||||||
// Cleanup deleted corrupted replays
|
// Cleanup deleted corrupted replays
|
||||||
@@ -309,38 +159,9 @@ 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) {
|
public void runLater(Runnable runnable) {
|
||||||
if (mc.isCallingFromMinecraftThread() && inRunLater) {
|
|
||||||
EventBus bus = FMLCommonHandler.instance().bus();
|
|
||||||
bus.register(new Object() {
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onRenderTick(TickEvent.RenderTickEvent event) {
|
|
||||||
if (event.phase == TickEvent.Phase.START) {
|
|
||||||
runLater(runnable);
|
|
||||||
bus.unregister(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Queue<ListenableFutureTask> tasks = mc.scheduledTasks;
|
|
||||||
synchronized (mc.scheduledTasks) {
|
synchronized (mc.scheduledTasks) {
|
||||||
tasks.add(ListenableFutureTask.create(() -> {
|
mc.scheduledTasks.add(ListenableFutureTask.create(runnable, null));
|
||||||
inRunLater = true;
|
|
||||||
try {
|
|
||||||
runnable.run();
|
|
||||||
} finally {
|
|
||||||
inRunLater = false;
|
|
||||||
}
|
|
||||||
}, null));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,13 +190,13 @@ public class ReplayMod {
|
|||||||
private void printToChat(boolean warning, String message, Object... args) {
|
private void printToChat(boolean warning, String message, Object... args) {
|
||||||
if (getSettingsRegistry().get(Setting.NOTIFICATIONS)) {
|
if (getSettingsRegistry().get(Setting.NOTIFICATIONS)) {
|
||||||
// Some nostalgia: "§8[§6Replay Mod§8]§r Your message goes here"
|
// Some nostalgia: "§8[§6Replay Mod§8]§r Your message goes here"
|
||||||
ChatStyle coloredDarkGray = new ChatStyle().setColor(EnumChatFormatting.DARK_GRAY);
|
Style coloredDarkGray = new Style().setColor(TextFormatting.DARK_GRAY);
|
||||||
ChatStyle coloredGold = new ChatStyle().setColor(EnumChatFormatting.GOLD);
|
Style coloredGold = new Style().setColor(TextFormatting.GOLD);
|
||||||
IChatComponent text = new ChatComponentText("[").setChatStyle(coloredDarkGray)
|
ITextComponent text = new TextComponentString("[").setStyle(coloredDarkGray)
|
||||||
.appendSibling(new ChatComponentTranslation("replaymod.title").setChatStyle(coloredGold))
|
.appendSibling(new TextComponentTranslation("replaymod.title").setStyle(coloredGold))
|
||||||
.appendSibling(new ChatComponentText("] "))
|
.appendSibling(new TextComponentString("] "))
|
||||||
.appendSibling(new ChatComponentTranslation(message, args).setChatStyle(new ChatStyle()
|
.appendSibling(new TextComponentTranslation(message, args).setStyle(new Style()
|
||||||
.setColor(warning ? EnumChatFormatting.RED : EnumChatFormatting.DARK_GREEN)));
|
.setColor(warning ? TextFormatting.RED : TextFormatting.DARK_GREEN)));
|
||||||
// Send message to chat GUI
|
// Send message to chat GUI
|
||||||
// The ingame GUI is initialized at startup, therefore this is possible before the client is connected
|
// The ingame GUI is initialized at startup, therefore this is possible before the client is connected
|
||||||
mc.ingameGUI.getChatGUI().printChatMessage(text);
|
mc.ingameGUI.getChatGUI().printChatMessage(text);
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package com.replaymod.core;
|
|||||||
|
|
||||||
import com.replaymod.core.events.SettingsChangedEvent;
|
import com.replaymod.core.events.SettingsChangedEvent;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
@@ -83,7 +83,7 @@ public class SettingsRegistry {
|
|||||||
throw new IllegalArgumentException("Default type " + key.getDefault().getClass() + " not supported.");
|
throw new IllegalArgumentException("Default type " + key.getDefault().getClass() + " not supported.");
|
||||||
}
|
}
|
||||||
settings.put(key, value);
|
settings.put(key, value);
|
||||||
FMLCommonHandler.instance().bus().post(new SettingsChangedEvent(this, key));
|
MinecraftForge.EVENT_BUS.post(new SettingsChangedEvent(this, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import net.minecraftforge.client.event.GuiScreenEvent;
|
|||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves certain buttons on the main menu upwards so we can inject our own.
|
* Moves certain buttons on the main menu upwards so we can inject our own.
|
||||||
*/
|
*/
|
||||||
@@ -18,14 +16,12 @@ public class MainMenuHandler {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onInit(GuiScreenEvent.InitGuiEvent.Post event) {
|
public void onInit(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||||
if (event.gui instanceof GuiMainMenu) {
|
if (event.getGui() instanceof GuiMainMenu) {
|
||||||
@SuppressWarnings("unchecked")
|
for (GuiButton button : event.getButtonList()) {
|
||||||
List<GuiButton> buttonList = event.buttonList;
|
|
||||||
for (GuiButton button : buttonList) {
|
|
||||||
// Buttons that aren't in a rectangle directly above our space don't need moving
|
// Buttons that aren't in a rectangle directly above our space don't need moving
|
||||||
if (button.xPosition + button.width < event.gui.width / 2 - 100
|
if (button.xPosition + button.width < event.getGui().width / 2 - 100
|
||||||
|| button.xPosition > event.gui.width / 2 + 100
|
|| button.xPosition > event.getGui().width / 2 + 100
|
||||||
|| button.yPosition > event.gui.height / 4 + 10 + 4 * 24) continue;
|
|| button.yPosition > event.getGui().height / 4 + 10 + 4 * 24) continue;
|
||||||
// Move button up to make space for two rows of buttons
|
// Move button up to make space for two rows of buttons
|
||||||
// and then move back down by 10 to compensate for the space to the exit button that was already there
|
// and then move back down by 10 to compensate for the space to the exit button that was already there
|
||||||
button.yPosition -= 2 * 24 - 10;
|
button.yPosition -= 2 * 24 - 10;
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ package com.replaymod.core.utils;
|
|||||||
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
import net.minecraft.client.renderer.WorldRenderer;
|
import net.minecraft.client.renderer.VertexBuffer;
|
||||||
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import org.lwjgl.BufferUtils;
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
@@ -34,14 +35,14 @@ public class OpenGLUtils {
|
|||||||
float f5 = 1.0F / textureHeight;
|
float f5 = 1.0F / textureHeight;
|
||||||
|
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
VertexBuffer vertexBuffer = tessellator.getBuffer();
|
||||||
GlStateManager.translate(x+(width/2), y+(width/2), 0);
|
GlStateManager.translate(x+(width/2), y+(width/2), 0);
|
||||||
GlStateManager.rotate(rotation, 0, 0, 1);
|
GlStateManager.rotate(rotation, 0, 0, 1);
|
||||||
worldrenderer.startDrawingQuads();
|
vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
||||||
worldrenderer.addVertexWithUV(-width / 2, height / 2, 0.0D, (double) (u * f4), (double) ((v + (float) height) * f5));
|
vertexBuffer.pos(-width / 2, height / 2, 0.0D).tex((double) (u * f4), (double) ((v + (float) height) * f5)).endVertex();
|
||||||
worldrenderer.addVertexWithUV(width/2, height/2, 0.0D, (double)((u + (float)width) * f4), (double)((v + (float)height) * f5));
|
vertexBuffer.pos(width/2, height/2, 0.0D).tex((double)((u + (float)width) * f4), (double)((v + (float)height) * f5)).endVertex();
|
||||||
worldrenderer.addVertexWithUV(width/2, -height/2, 0.0D, (double)((u + (float)width) * f4), (double)(v * f5));
|
vertexBuffer.pos(width/2, -height/2, 0.0D).tex((double)((u + (float)width) * f4), (double)(v * f5)).endVertex();
|
||||||
worldrenderer.addVertexWithUV(-width/2, -height/2, 0.0D, (double)(u * f4), (double)(v * f5));
|
vertexBuffer.pos(-width/2, -height/2, 0.0D).tex((double)(u * f4), (double)(v * f5)).endVertex();
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
|
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.replaymod.core.utils;
|
package com.replaymod.core.utils;
|
||||||
|
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraft.network.play.server.S3FPacketCustomPayload;
|
import net.minecraft.network.play.server.SPacketCustomPayload;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restrictions set by the server,
|
* Restrictions set by the server,
|
||||||
@@ -14,7 +14,7 @@ public class Restrictions {
|
|||||||
private boolean onlyFirstPerson;
|
private boolean onlyFirstPerson;
|
||||||
private boolean onlyRecordingPlayer;
|
private boolean onlyRecordingPlayer;
|
||||||
|
|
||||||
public String handle(S3FPacketCustomPayload packet) {
|
public String handle(SPacketCustomPayload packet) {
|
||||||
PacketBuffer buffer = packet.getBufferData();
|
PacketBuffer buffer = packet.getBufferData();
|
||||||
while (buffer.isReadable()) {
|
while (buffer.isReadable()) {
|
||||||
String name = buffer.readStringFromBuffer(64);
|
String name = buffer.readStringFromBuffer(64);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.replaymod.core.utils;
|
package com.replaymod.core.utils;
|
||||||
|
|
||||||
import com.google.common.net.PercentEscaper;
|
|
||||||
import com.google.common.util.concurrent.FutureCallback;
|
import com.google.common.util.concurrent.FutureCallback;
|
||||||
import com.google.common.util.concurrent.Futures;
|
import com.google.common.util.concurrent.Futures;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
@@ -17,14 +16,11 @@ import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
|||||||
import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
||||||
import de.johni0702.minecraft.gui.popup.GuiInfoPopup;
|
import de.johni0702.minecraft.gui.popup.GuiInfoPopup;
|
||||||
import de.johni0702.minecraft.gui.utils.Colors;
|
import de.johni0702.minecraft.gui.utils.Colors;
|
||||||
import lombok.SneakyThrows;
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
import net.minecraft.util.ResourceLocation;
|
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.apache.logging.log4j.Logger;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.util.Dimension;
|
import org.lwjgl.util.Dimension;
|
||||||
@@ -40,8 +36,6 @@ import java.awt.image.BufferedImage;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLDecoder;
|
|
||||||
import java.security.KeyManagementException;
|
import java.security.KeyManagementException;
|
||||||
import java.security.KeyStore;
|
import java.security.KeyStore;
|
||||||
import java.security.KeyStoreException;
|
import java.security.KeyStoreException;
|
||||||
@@ -143,24 +137,8 @@ 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,}))$");
|
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) {
|
public static ResourceLocation getResourceLocationForPlayerUUID(UUID uuid) {
|
||||||
NetworkPlayerInfo info = getMinecraft().getNetHandler().getPlayerInfo(uuid);
|
NetworkPlayerInfo info = getMinecraft().getConnection().getPlayerInfo(uuid);
|
||||||
ResourceLocation skinLocation;
|
ResourceLocation skinLocation;
|
||||||
if (info != null && info.hasLocationSkin()) {
|
if (info != null && info.hasLocationSkin()) {
|
||||||
skinLocation = info.getLocationSkin();
|
skinLocation = info.getLocationSkin();
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class WrappedTimer extends Timer {
|
|||||||
to.elapsedPartialTicks = from.elapsedPartialTicks;
|
to.elapsedPartialTicks = from.elapsedPartialTicks;
|
||||||
to.lastSyncSysClock = from.lastSyncSysClock;
|
to.lastSyncSysClock = from.lastSyncSysClock;
|
||||||
to.lastSyncHRClock = from.lastSyncHRClock;
|
to.lastSyncHRClock = from.lastSyncHRClock;
|
||||||
to.field_74285_i = from.field_74285_i;
|
to.counter = from.counter;
|
||||||
to.timeSyncAdjustment = from.timeSyncAdjustment;
|
to.timeSyncAdjustment = from.timeSyncAdjustment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import org.apache.logging.log4j.Logger;
|
|||||||
@Mod(modid = ReplayModEditor.MOD_ID,
|
@Mod(modid = ReplayModEditor.MOD_ID,
|
||||||
version = "@MOD_VERSION@",
|
version = "@MOD_VERSION@",
|
||||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||||
acceptableRemoteVersions = "*",
|
|
||||||
useMetadata = true)
|
useMetadata = true)
|
||||||
public class ReplayModEditor {
|
public class ReplayModEditor {
|
||||||
public static final String MOD_ID = "replaymod-editor";
|
public static final String MOD_ID = "replaymod-editor";
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
|||||||
import de.johni0702.minecraft.gui.utils.Colors;
|
import de.johni0702.minecraft.gui.utils.Colors;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.lwjgl.util.ReadableDimension;
|
import org.lwjgl.util.ReadableDimension;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -124,7 +125,7 @@ public class GuiReplayEditor extends GuiScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save(File inputFile, PacketStream.FilterInfo...filters) {
|
public void save(File inputFile, PacketStream.FilterInfo...filters) {
|
||||||
save(Utils.fileNameToReplayName(inputFile.getName()), (outputFile) -> {
|
save(FilenameUtils.getBaseName(inputFile.getName()), (outputFile) -> {
|
||||||
Studio studio = new ReplayStudio();
|
Studio studio = new ReplayStudio();
|
||||||
File tmpDir = null;
|
File tmpDir = null;
|
||||||
try {
|
try {
|
||||||
@@ -219,7 +220,7 @@ public class GuiReplayEditor extends GuiScreen {
|
|||||||
Utils.error(LOGGER, GuiReplayEditor.this, CrashReport.makeCrashReport(e, "Getting replay folder"), null);
|
Utils.error(LOGGER, GuiReplayEditor.this, CrashReport.makeCrashReport(e, "Getting replay folder"), null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
File targetFile = new File(replayFolder, Utils.replayNameToFileName(name));
|
File targetFile = new File(replayFolder, name + ".mcpr");
|
||||||
if (targetFile.exists()) {
|
if (targetFile.exists()) {
|
||||||
LOGGER.trace("Selected file already exists, asking for confirmation");
|
LOGGER.trace("Selected file already exists, asking for confirmation");
|
||||||
Futures.addCallback(GuiYesNoPopup.open(GuiReplayEditor.this,
|
Futures.addCallback(GuiYesNoPopup.open(GuiReplayEditor.this,
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
|||||||
import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.io.IOCase;
|
import org.apache.commons.io.IOCase;
|
||||||
import org.apache.commons.io.filefilter.SuffixFileFilter;
|
import org.apache.commons.io.filefilter.SuffixFileFilter;
|
||||||
import org.lwjgl.util.Dimension;
|
import org.lwjgl.util.Dimension;
|
||||||
@@ -51,7 +52,7 @@ public class GuiTrimPanel extends GuiPanel {
|
|||||||
|
|
||||||
public final GuiDropdownMenu<File> inputReplays = new GuiDropdownMenu<File>(this)
|
public final GuiDropdownMenu<File> inputReplays = new GuiDropdownMenu<File>(this)
|
||||||
.setMinSize(new Dimension(200, 20)).onSelection(i -> updateSelectedReplay())
|
.setMinSize(new Dimension(200, 20)).onSelection(i -> updateSelectedReplay())
|
||||||
.setToString(f -> f == NO_REPLAY ? "" : Utils.fileNameToReplayName(f.getName()));
|
.setToString(f -> f == NO_REPLAY ? "" : FilenameUtils.getBaseName(f.getName()));
|
||||||
|
|
||||||
public final GuiNumberField startHour = newGuiNumberField();
|
public final GuiNumberField startHour = newGuiNumberField();
|
||||||
public final GuiNumberField startMin = newGuiNumberField();
|
public final GuiNumberField startMin = newGuiNumberField();
|
||||||
|
|||||||
@@ -8,11 +8,8 @@ import net.minecraft.client.gui.GuiMainMenu;
|
|||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GuiHandler {
|
public class GuiHandler {
|
||||||
private static final int BUTTON_REPLAY_EDITOR = 17890237;
|
private static final int BUTTON_REPLAY_EDITOR = 17890237;
|
||||||
|
|
||||||
@@ -23,31 +20,28 @@ public class GuiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void register() {
|
public void register() {
|
||||||
FMLCommonHandler.instance().bus().register(this);
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
||||||
if (!(event.gui instanceof GuiMainMenu)) {
|
if (!(event.getGui() instanceof GuiMainMenu)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
GuiButton button = new GuiButton(BUTTON_REPLAY_EDITOR, event.getGui().width / 2 + 2,
|
||||||
List<GuiButton> buttonList = event.buttonList;
|
event.getGui().height / 4 + 10 + 3 * 24, I18n.format("replaymod.gui.replayeditor"));
|
||||||
GuiButton button = new GuiButton(BUTTON_REPLAY_EDITOR, event.gui.width / 2 + 2,
|
|
||||||
event.gui.height / 4 + 10 + 3 * 24, I18n.format("replaymod.gui.replayeditor"));
|
|
||||||
button.width = button.width / 2 - 2;
|
button.width = button.width / 2 - 2;
|
||||||
buttonList.add(button);
|
event.getButtonList().add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
||||||
if(!event.button.enabled) return;
|
if(!event.getButton().enabled) return;
|
||||||
|
|
||||||
if (event.gui instanceof GuiMainMenu) {
|
if (event.getGui() instanceof GuiMainMenu) {
|
||||||
if (event.button.id == BUTTON_REPLAY_EDITOR) {
|
if (event.getButton().id == BUTTON_REPLAY_EDITOR) {
|
||||||
new GuiReplayEditor(GuiScreen.wrap(event.gui), mod.getCore()).display();
|
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.element.IGuiImage;
|
||||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||||
import net.minecraft.client.settings.GameSettings;
|
import net.minecraft.client.settings.GameSettings;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
@@ -40,7 +40,7 @@ public class FullBrightness implements Extra {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
FMLCommonHandler.instance().bus().register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import de.johni0702.minecraft.gui.layout.GridLayout;
|
|||||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||||
import de.johni0702.minecraft.gui.layout.LayoutData;
|
import de.johni0702.minecraft.gui.layout.LayoutData;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.util.Dimension;
|
import org.lwjgl.util.Dimension;
|
||||||
@@ -35,7 +35,7 @@ public class HotkeyButtons implements Extra {
|
|||||||
public void register(ReplayMod mod) throws Exception {
|
public void register(ReplayMod mod) throws Exception {
|
||||||
this.mod = mod;
|
this.mod = mod;
|
||||||
|
|
||||||
FMLCommonHandler.instance().bus().register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import com.replaymod.core.ReplayMod;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.resources.IResourcePack;
|
import net.minecraft.client.resources.IResourcePack;
|
||||||
import net.minecraft.client.resources.data.IMetadataSection;
|
import net.minecraft.client.resources.data.IMetadataSection;
|
||||||
import net.minecraft.client.resources.data.IMetadataSerializer;
|
import net.minecraft.client.resources.data.MetadataSerializer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
@@ -99,12 +99,12 @@ public class LocalizationExtra implements Extra {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set getResourceDomains() {
|
public Set<String> getResourceDomains() {
|
||||||
return ImmutableSet.of("replaymod");
|
return ImmutableSet.of("replaymod");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,15 +10,11 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Mod(modid = ReplayModExtras.MOD_ID,
|
@Mod(modid = ReplayModExtras.MOD_ID,
|
||||||
version = "@MOD_VERSION@",
|
version = "@MOD_VERSION@",
|
||||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||||
acceptableRemoteVersions = "*",
|
|
||||||
useMetadata = true)
|
useMetadata = true)
|
||||||
public class ReplayModExtras {
|
public class ReplayModExtras {
|
||||||
public static final String MOD_ID = "replaymod-extras";
|
public static final String MOD_ID = "replaymod-extras";
|
||||||
@@ -36,8 +32,6 @@ public class ReplayModExtras {
|
|||||||
OpenEyeExtra.class
|
OpenEyeExtra.class
|
||||||
);
|
);
|
||||||
|
|
||||||
private final Map<Class<? extends Extra>, Extra> instances = new HashMap<>();
|
|
||||||
|
|
||||||
public static Logger LOGGER;
|
public static Logger LOGGER;
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
@@ -51,14 +45,9 @@ public class ReplayModExtras {
|
|||||||
try {
|
try {
|
||||||
Extra extra = cls.newInstance();
|
Extra extra = cls.newInstance();
|
||||||
extra.register(ReplayMod.instance);
|
extra.register(ReplayMod.instance);
|
||||||
instances.put(cls, extra);
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
LOGGER.warn("Failed to load extra " + cls.getName() + ": ", 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,11 +9,12 @@ import com.replaymod.replay.ReplayModReplay;
|
|||||||
import com.replaymod.replay.camera.CameraEntity;
|
import com.replaymod.replay.camera.CameraEntity;
|
||||||
import com.replaymod.replay.events.ReplayCloseEvent;
|
import com.replaymod.replay.events.ReplayCloseEvent;
|
||||||
import com.replaymod.replay.events.ReplayOpenEvent;
|
import com.replaymod.replay.events.ReplayOpenEvent;
|
||||||
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
|
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraftforge.client.event.RenderHandEvent;
|
import net.minecraftforge.client.event.RenderHandEvent;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
@@ -56,8 +57,13 @@ public class PlayerOverview implements Extra {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
FMLCommonHandler.instance().bus().register(this);
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
|
||||||
|
RenderManager renderManager = mod.getMinecraft().getRenderManager();
|
||||||
|
@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) {
|
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.client.audio.PositionedSoundRecord;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EnumPlayerModelParts;
|
import net.minecraft.entity.player.EnumPlayerModelParts;
|
||||||
import net.minecraft.potion.Potion;
|
import net.minecraft.init.MobEffects;
|
||||||
|
import net.minecraft.init.SoundEvents;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import org.lwjgl.util.Dimension;
|
import org.lwjgl.util.Dimension;
|
||||||
import org.lwjgl.util.ReadableDimension;
|
import org.lwjgl.util.ReadableDimension;
|
||||||
@@ -46,14 +47,14 @@ public class PlayerOverviewGui extends GuiScreen implements Closeable {
|
|||||||
public final GuiCheckbox checkAll = new GuiCheckbox(contentPanel){
|
public final GuiCheckbox checkAll = new GuiCheckbox(contentPanel){
|
||||||
@Override
|
@Override
|
||||||
public void onClick() {
|
public void onClick() {
|
||||||
getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(BUTTON_SOUND, 1.0F));
|
getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
||||||
playersScrollable.forEach(IGuiCheckbox.class).setChecked(true);
|
playersScrollable.forEach(IGuiCheckbox.class).setChecked(true);
|
||||||
}
|
}
|
||||||
}.setLabel("").setChecked(true).setTooltip(new GuiTooltip().setI18nText("replaymod.gui.playeroverview.showall"));
|
}.setLabel("").setChecked(true).setTooltip(new GuiTooltip().setI18nText("replaymod.gui.playeroverview.showall"));
|
||||||
public final GuiCheckbox uncheckAll = new GuiCheckbox(contentPanel){
|
public final GuiCheckbox uncheckAll = new GuiCheckbox(contentPanel){
|
||||||
@Override
|
@Override
|
||||||
public void onClick() {
|
public void onClick() {
|
||||||
getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(BUTTON_SOUND, 1.0F));
|
getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
||||||
playersScrollable.forEach(IGuiCheckbox.class).setChecked(false);
|
playersScrollable.forEach(IGuiCheckbox.class).setChecked(false);
|
||||||
}
|
}
|
||||||
}.setLabel("").setChecked(false).setTooltip(new GuiTooltip().setI18nText("replaymod.gui.playeroverview.hideall"));
|
}.setLabel("").setChecked(false).setTooltip(new GuiTooltip().setI18nText("replaymod.gui.playeroverview.hideall"));
|
||||||
@@ -96,7 +97,7 @@ public class PlayerOverviewGui extends GuiScreen implements Closeable {
|
|||||||
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
|
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
|
||||||
renderer.bindTexture(texture);
|
renderer.bindTexture(texture);
|
||||||
renderer.drawTexturedRect(0, 0, 8, 8, 16, 16, 8, 8, 64, 64);
|
renderer.drawTexturedRect(0, 0, 8, 8, 16, 16, 8, 8, 64, 64);
|
||||||
if (p.func_175148_a(EnumPlayerModelParts.HAT)) {
|
if (p.isWearing(EnumPlayerModelParts.HAT)) {
|
||||||
renderer.drawTexturedRect(0, 0, 40, 8, size.getWidth(), size.getHeight(), 8, 8, 64, 64);
|
renderer.drawTexturedRect(0, 0, 40, 8, size.getWidth(), size.getHeight(), 8, 8, 64, 64);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,7 +146,7 @@ public class PlayerOverviewGui extends GuiScreen implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isSpectator(EntityPlayer e) {
|
private static boolean isSpectator(EntityPlayer e) {
|
||||||
return e.isInvisible() && e.getActivePotionEffect(Potion.invisibility) == null;
|
return e.isInvisible() && e.getActivePotionEffect(MobEffects.INVISIBILITY) == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class PlayerComparator implements Comparator<EntityPlayer> {
|
private static final class PlayerComparator implements Comparator<EntityPlayer> {
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
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,7 +25,6 @@ public class LinuxUriScheme extends UriScheme {
|
|||||||
"Icon=" + iconFile.getAbsolutePath().replace("\\", "\\\\").replace("\"", "\\\"") + "\n" +
|
"Icon=" + iconFile.getAbsolutePath().replace("\\", "\\\\").replace("\"", "\\\"") + "\n" +
|
||||||
"Type=Application\n" +
|
"Type=Application\n" +
|
||||||
"Terminal=false\n" +
|
"Terminal=false\n" +
|
||||||
"NoDisplay=true\n" +
|
|
||||||
"MimeType=x-scheme-handler/replaymod;";
|
"MimeType=x-scheme-handler/replaymod;";
|
||||||
|
|
||||||
FileOutputStream out = new FileOutputStream(file);
|
FileOutputStream out = new FileOutputStream(file);
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ public class YoutubeUpload implements Extra {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onGuiOpen(GuiScreenEvent.InitGuiEvent.Post event) {
|
public void onGuiOpen(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||||
if (GuiScreen.from(event.gui) instanceof GuiRenderingDone) {
|
if (GuiScreen.from(event.getGui()) instanceof GuiRenderingDone) {
|
||||||
GuiRenderingDone gui = (GuiRenderingDone) GuiScreen.from(event.gui);
|
GuiRenderingDone gui = (GuiRenderingDone) GuiScreen.from(event.getGui());
|
||||||
// Check if there already is a youtube button
|
// Check if there already is a youtube button
|
||||||
if (gui.actionsPanel.getChildren().stream().anyMatch(it -> it instanceof YoutubeButton)) {
|
if (gui.actionsPanel.getChildren().stream().anyMatch(it -> it instanceof YoutubeButton)) {
|
||||||
return; // Button already added
|
return; // Button already added
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ import java.security.GeneralSecurityException;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import static com.replaymod.extras.ReplayModExtras.LOGGER;
|
|
||||||
|
|
||||||
public class YoutubeUploader {
|
public class YoutubeUploader {
|
||||||
private static final String CLIENT_ID = "743126594724-mfe7pj1k7e47uu5pk4503c8st9vj9ibu.apps.googleusercontent.com";
|
private static final String CLIENT_ID = "743126594724-mfe7pj1k7e47uu5pk4503c8st9vj9ibu.apps.googleusercontent.com";
|
||||||
private static final String CLIENT_SECRET = "gMwcy3mRYCRamCIjJIYP7rqc";
|
private static final String CLIENT_SECRET = "gMwcy3mRYCRamCIjJIYP7rqc";
|
||||||
@@ -139,7 +137,7 @@ public class YoutubeUploader {
|
|||||||
|
|
||||||
CommandLine commandLine = new CommandLine(settings.getExportCommand());
|
CommandLine commandLine = new CommandLine(settings.getExportCommand());
|
||||||
commandLine.addArguments(args);
|
commandLine.addArguments(args);
|
||||||
LOGGER.info("Re-encoding for ODS with {} {}", settings.getExportCommand(), args);
|
System.out.println("Re-encoding for ODS with " + settings.getExportCommand() + args);
|
||||||
Process process = new ProcessBuilder(commandLine.toStrings()).directory(videoFile.getParentFile()).start();
|
Process process = new ProcessBuilder(commandLine.toStrings()).directory(videoFile.getParentFile()).start();
|
||||||
|
|
||||||
final AtomicBoolean active = new AtomicBoolean(true);
|
final AtomicBoolean active = new AtomicBoolean(true);
|
||||||
@@ -151,7 +149,7 @@ public class YoutubeUploader {
|
|||||||
char c = (char) in.read();
|
char c = (char) in.read();
|
||||||
if (c == '\r') {
|
if (c == '\r') {
|
||||||
String str = sb.toString();
|
String str = sb.toString();
|
||||||
LOGGER.debug("[FFmpeg] {}", str);
|
System.out.println(str);
|
||||||
if (str.startsWith("frame=")) {
|
if (str.startsWith("frame=")) {
|
||||||
str = str.substring(6).trim();
|
str = str.substring(6).trim();
|
||||||
str = str.substring(0, str.indexOf(' '));
|
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.replay.ZipReplayFile;
|
||||||
import com.replaymod.replaystudio.studio.ReplayStudio;
|
import com.replaymod.replaystudio.studio.ReplayStudio;
|
||||||
import de.johni0702.minecraft.gui.container.GuiScreen;
|
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||||
@@ -29,7 +29,6 @@ import static net.minecraft.client.Minecraft.getMinecraft;
|
|||||||
@Mod(modid = ReplayModOnline.MOD_ID,
|
@Mod(modid = ReplayModOnline.MOD_ID,
|
||||||
version = "@MOD_VERSION@",
|
version = "@MOD_VERSION@",
|
||||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||||
acceptableRemoteVersions = "*",
|
|
||||||
useMetadata = true)
|
useMetadata = true)
|
||||||
public class ReplayModOnline {
|
public class ReplayModOnline {
|
||||||
public static final String MOD_ID = "replaymod-online";
|
public static final String MOD_ID = "replaymod-online";
|
||||||
@@ -41,7 +40,7 @@ public class ReplayModOnline {
|
|||||||
|
|
||||||
private ReplayModReplay replayModule;
|
private ReplayModReplay replayModule;
|
||||||
|
|
||||||
public static Logger LOGGER;
|
private Logger logger;
|
||||||
|
|
||||||
private ApiClient apiClient;
|
private ApiClient apiClient;
|
||||||
|
|
||||||
@@ -54,7 +53,7 @@ public class ReplayModOnline {
|
|||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void preInit(FMLPreInitializationEvent event) {
|
public void preInit(FMLPreInitializationEvent event) {
|
||||||
LOGGER = event.getModLog();
|
logger = event.getModLog();
|
||||||
core = ReplayMod.instance;
|
core = ReplayMod.instance;
|
||||||
replayModule = ReplayModReplay.instance;
|
replayModule = ReplayModReplay.instance;
|
||||||
|
|
||||||
@@ -70,12 +69,12 @@ public class ReplayModOnline {
|
|||||||
public void init(FMLInitializationEvent event) {
|
public void init(FMLInitializationEvent event) {
|
||||||
if (!getDownloadsFolder().exists()){
|
if (!getDownloadsFolder().exists()){
|
||||||
if (!getDownloadsFolder().mkdirs()) {
|
if (!getDownloadsFolder().mkdirs()) {
|
||||||
LOGGER.warn("Failed to create downloads folder: " + getDownloadsFolder());
|
logger.warn("Failed to create downloads folder: " + getDownloadsFolder());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new GuiHandler(this).register();
|
new GuiHandler(this).register();
|
||||||
FMLCommonHandler.instance().bus().register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
@@ -83,10 +82,7 @@ public class ReplayModOnline {
|
|||||||
// Initial login prompt
|
// Initial login prompt
|
||||||
if (!core.getSettingsRegistry().get(Setting.SKIP_LOGIN_PROMPT)) {
|
if (!core.getSettingsRegistry().get(Setting.SKIP_LOGIN_PROMPT)) {
|
||||||
if (!isLoggedIn()) {
|
if (!isLoggedIn()) {
|
||||||
core.runLater(() -> {
|
core.runLater(() -> new GuiLoginPrompt(apiClient, GuiScreen.wrap(getMinecraft().currentScreen), null, false).display());
|
||||||
GuiScreen parent = GuiScreen.wrap(getMinecraft().currentScreen);
|
|
||||||
new GuiLoginPrompt(apiClient, parent, parent, false).display();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,7 +96,7 @@ public class ReplayModOnline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Logger getLogger() {
|
public Logger getLogger() {
|
||||||
return LOGGER;
|
return logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiClient getApiClient() {
|
public ApiClient getApiClient() {
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package com.replaymod.online.api.replay.holders;
|
|||||||
|
|
||||||
public enum MinecraftVersion {
|
public enum MinecraftVersion {
|
||||||
|
|
||||||
MC_1_8("Minecraft 1.8", "1.8");
|
MC_1_8("Minecraft 1.8", "1.8"),
|
||||||
|
MC_1_9_4("Minecraft 1.9.4", "1.9.4"),
|
||||||
|
MC_1_10_2("Minecraft 1.10.2", "1.10.2");
|
||||||
|
|
||||||
private String niceName, apiName;
|
private String niceName, apiName;
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
|||||||
import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
||||||
import de.johni0702.minecraft.gui.utils.Colors;
|
import de.johni0702.minecraft.gui.utils.Colors;
|
||||||
import de.johni0702.minecraft.gui.utils.Consumer;
|
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.core.helpers.Strings;
|
||||||
import org.lwjgl.util.Dimension;
|
import org.lwjgl.util.Dimension;
|
||||||
import org.lwjgl.util.ReadableDimension;
|
import org.lwjgl.util.ReadableDimension;
|
||||||
@@ -49,8 +51,6 @@ import java.util.Date;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static com.replaymod.online.ReplayModOnline.LOGGER;
|
|
||||||
|
|
||||||
public class GuiReplayCenter extends GuiScreen {
|
public class GuiReplayCenter extends GuiScreen {
|
||||||
private final ReplayModOnline mod;
|
private final ReplayModOnline mod;
|
||||||
private final ApiClient apiClient;
|
private final ApiClient apiClient;
|
||||||
@@ -336,7 +336,7 @@ public class GuiReplayCenter extends GuiScreen {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Could not load Replay File {}", fileInfo.getId(), e);
|
FMLLog.getLogger().error("Could not load Replay File " + fileInfo.getId(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -417,7 +417,7 @@ public class GuiReplayCenter extends GuiScreen {
|
|||||||
this.downloaded = downloaded;
|
this.downloaded = downloaded;
|
||||||
ReplayMetaData metaData = fileInfo.getMetadata();
|
ReplayMetaData metaData = fileInfo.getMetadata();
|
||||||
|
|
||||||
name.setText(ChatFormatting.UNDERLINE + Utils.fileNameToReplayName(fileInfo.getName()));
|
name.setText(ChatFormatting.UNDERLINE + FilenameUtils.getBaseName(fileInfo.getName()));
|
||||||
author.setI18nText("replaymod.gui.center.author",
|
author.setI18nText("replaymod.gui.center.author",
|
||||||
"" + ChatFormatting.GRAY + ChatFormatting.ITALIC, fileInfo.getOwner());
|
"" + ChatFormatting.GRAY + ChatFormatting.ITALIC, fileInfo.getOwner());
|
||||||
if (Strings.isEmpty(metaData.getServerName())) {
|
if (Strings.isEmpty(metaData.getServerName())) {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.replaymod.online.gui;
|
|||||||
|
|
||||||
import com.google.common.util.concurrent.FutureCallback;
|
import com.google.common.util.concurrent.FutureCallback;
|
||||||
import com.google.common.util.concurrent.Futures;
|
import com.google.common.util.concurrent.Futures;
|
||||||
import com.replaymod.core.utils.Utils;
|
|
||||||
import de.johni0702.minecraft.gui.container.GuiPanel;
|
import de.johni0702.minecraft.gui.container.GuiPanel;
|
||||||
import de.johni0702.minecraft.gui.container.GuiScreen;
|
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||||
import de.johni0702.minecraft.gui.element.GuiButton;
|
import de.johni0702.minecraft.gui.element.GuiButton;
|
||||||
@@ -28,7 +27,7 @@ public class GuiSaveModifiedReplay extends GuiScreen {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
String resultName = name.getText().trim().replace("[^a-zA-Z0-9\\.\\- ]", "_");
|
String resultName = name.getText().trim().replace("[^a-zA-Z0-9\\.\\- ]", "_");
|
||||||
final File resultFile = new File(file.getParentFile(), Utils.replayNameToFileName(resultName));
|
final File resultFile = new File(file.getParentFile(), resultName + ".mcpr");
|
||||||
if (resultFile.exists()) {
|
if (resultFile.exists()) {
|
||||||
Futures.addCallback(GuiYesNoPopup.open(GuiSaveModifiedReplay.this,
|
Futures.addCallback(GuiYesNoPopup.open(GuiSaveModifiedReplay.this,
|
||||||
new GuiLabel().setI18nText("replaymod.gui.replaymodified.warning1", resultName).setColor(Colors.BLACK),
|
new GuiLabel().setI18nText("replaymod.gui.replaymodified.warning1", resultName).setColor(Colors.BLACK),
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import net.minecraft.client.settings.KeyBinding;
|
|||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
import net.minecraft.util.ReportedException;
|
import net.minecraft.util.ReportedException;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -134,7 +135,7 @@ public class GuiUploadReplay extends GuiScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Apply to gui
|
// Apply to gui
|
||||||
name.setText(Utils.fileNameToReplayName(file.getName()));
|
name.setText(FilenameUtils.getBaseName(file.getName()));
|
||||||
int secs = metaData.getDuration() / 1000;
|
int secs = metaData.getDuration() / 1000;
|
||||||
durationLabel.setI18nText("replaymod.gui.upload.duration", secs / 60, secs % 60);
|
durationLabel.setI18nText("replaymod.gui.upload.duration", secs / 60, secs % 60);
|
||||||
hideServerIP.setEnabled(!metaData.isSingleplayer());
|
hideServerIP.setEnabled(!metaData.isSingleplayer());
|
||||||
|
|||||||
@@ -14,11 +14,9 @@ import net.minecraft.client.gui.GuiMainMenu;
|
|||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GuiHandler {
|
public class GuiHandler {
|
||||||
private static final int BUTTON_REPLAY_CENTER = 17890236;
|
private static final int BUTTON_REPLAY_CENTER = 17890236;
|
||||||
@@ -30,26 +28,23 @@ public class GuiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void register() {
|
public void register() {
|
||||||
FMLCommonHandler.instance().bus().register(this);
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
||||||
if (!(event.gui instanceof GuiMainMenu)) {
|
if (!(event.getGui() instanceof GuiMainMenu)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
GuiButton button = new GuiButton(BUTTON_REPLAY_CENTER, event.getGui().width / 2 - 100,
|
||||||
List<GuiButton> buttonList = event.buttonList;
|
event.getGui().height / 4 + 10 + 4 * 24, I18n.format("replaymod.gui.replaycenter"));
|
||||||
GuiButton button = new GuiButton(BUTTON_REPLAY_CENTER, event.gui.width / 2 - 100,
|
event.getButtonList().add(button);
|
||||||
event.gui.height / 4 + 10 + 4 * 24, I18n.format("replaymod.gui.replaycenter"));
|
|
||||||
buttonList.add(button);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void injectIntoReplayViewer(GuiScreenEvent.InitGuiEvent.Post event) {
|
public void injectIntoReplayViewer(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||||
AbstractGuiScreen guiScreen = GuiScreen.from(event.gui);
|
AbstractGuiScreen guiScreen = GuiScreen.from(event.getGui());
|
||||||
if (!(guiScreen instanceof GuiReplayViewer)) {
|
if (!(guiScreen instanceof GuiReplayViewer)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -75,15 +70,15 @@ public class GuiHandler {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
||||||
if(!event.button.enabled) return;
|
if(!event.getButton().enabled) return;
|
||||||
|
|
||||||
if (event.gui instanceof GuiMainMenu) {
|
if (event.getGui() instanceof GuiMainMenu) {
|
||||||
if (event.button.id == BUTTON_REPLAY_CENTER) {
|
if (event.getButton().id == BUTTON_REPLAY_CENTER) {
|
||||||
GuiReplayCenter replayCenter = new GuiReplayCenter(mod);
|
GuiReplayCenter replayCenter = new GuiReplayCenter(mod);
|
||||||
if (mod.isLoggedIn()) {
|
if (mod.isLoggedIn()) {
|
||||||
replayCenter.display();
|
replayCenter.display();
|
||||||
} else {
|
} else {
|
||||||
new GuiLoginPrompt(mod.getApiClient(), GuiScreen.wrap(event.gui), replayCenter, true).display();
|
new GuiLoginPrompt(mod.getApiClient(), GuiScreen.wrap(event.getGui()), replayCenter, true).display();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import com.replaymod.replaystudio.pathing.path.Keyframe;
|
|||||||
import com.replaymod.replaystudio.pathing.path.Path;
|
import com.replaymod.replaystudio.pathing.path.Path;
|
||||||
import com.replaymod.replaystudio.pathing.path.Timeline;
|
import com.replaymod.replaystudio.pathing.path.Timeline;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -65,7 +65,7 @@ public abstract class AbstractTimelinePlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
replayHandler.getReplaySender().setSyncModeAndWait();
|
replayHandler.getReplaySender().setSyncModeAndWait();
|
||||||
FMLCommonHandler.instance().bus().register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
lastTime = 0;
|
lastTime = 0;
|
||||||
mc.timer = new ReplayTimer(mc.timer);
|
mc.timer = new ReplayTimer(mc.timer);
|
||||||
mc.timer.timerSpeed = 1;
|
mc.timer.timerSpeed = 1;
|
||||||
@@ -87,7 +87,7 @@ public abstract class AbstractTimelinePlayer {
|
|||||||
mc.timer = ((ReplayTimer) mc.timer).getWrapped();
|
mc.timer = ((ReplayTimer) mc.timer).getWrapped();
|
||||||
replayHandler.getReplaySender().setReplaySpeed(0);
|
replayHandler.getReplaySender().setReplaySpeed(0);
|
||||||
replayHandler.getReplaySender().setAsyncMode(true);
|
replayHandler.getReplaySender().setAsyncMode(true);
|
||||||
FMLCommonHandler.instance().bus().unregister(this);
|
MinecraftForge.EVENT_BUS.unregister(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long time = getTimePassed();
|
long time = getTimePassed();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package com.replaymod.pathing.player;
|
|||||||
|
|
||||||
import com.replaymod.core.utils.WrappedTimer;
|
import com.replaymod.core.utils.WrappedTimer;
|
||||||
import net.minecraft.util.Timer;
|
import net.minecraft.util.Timer;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,7 +20,7 @@ public class ReplayTimer extends WrappedTimer {
|
|||||||
copy(this, state); // Save our current state
|
copy(this, state); // Save our current state
|
||||||
super.updateTimer(); // Update current state
|
super.updateTimer(); // Update current state
|
||||||
copy(state, this); // Restore our old state
|
copy(state, this); // Restore our old state
|
||||||
FMLCommonHandler.instance().bus().post(new UpdatedEvent());
|
MinecraftForge.EVENT_BUS.post(new UpdatedEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Timer getWrapped() {
|
public Timer getWrapped() {
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import com.replaymod.recording.handler.ConnectionEventHandler;
|
|||||||
import com.replaymod.recording.packet.PacketListener;
|
import com.replaymod.recording.packet.PacketListener;
|
||||||
import io.netty.channel.ChannelDuplexHandler;
|
import io.netty.channel.ChannelDuplexHandler;
|
||||||
import io.netty.channel.ChannelHandler;
|
import io.netty.channel.ChannelHandler;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
@@ -19,7 +19,6 @@ import org.lwjgl.input.Keyboard;
|
|||||||
@Mod(modid = ReplayModRecording.MOD_ID,
|
@Mod(modid = ReplayModRecording.MOD_ID,
|
||||||
version = "@MOD_VERSION@",
|
version = "@MOD_VERSION@",
|
||||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||||
acceptableRemoteVersions = "*",
|
|
||||||
useMetadata = true)
|
useMetadata = true)
|
||||||
public class ReplayModRecording {
|
public class ReplayModRecording {
|
||||||
public static final String MOD_ID = "replaymod-recording";
|
public static final String MOD_ID = "replaymod-recording";
|
||||||
@@ -54,7 +53,7 @@ public class ReplayModRecording {
|
|||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void init(FMLInitializationEvent event) {
|
public void init(FMLInitializationEvent event) {
|
||||||
EventBus bus = FMLCommonHandler.instance().bus();
|
EventBus bus = MinecraftForge.EVENT_BUS;
|
||||||
bus.register(connectionEventHandler = new ConnectionEventHandler(logger, core));
|
bus.register(connectionEventHandler = new ConnectionEventHandler(logger, core));
|
||||||
|
|
||||||
NetworkRegistry.INSTANCE.newChannel(Restrictions.PLUGIN_CHANNEL, new RestrictionsChannelHandler());
|
NetworkRegistry.INSTANCE.newChannel(Restrictions.PLUGIN_CHANNEL, new RestrictionsChannelHandler());
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class GuiRecordingOverlay {
|
|||||||
*/
|
*/
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void renderRecordingIndicator(RenderGameOverlayEvent.Post event) {
|
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)) {
|
if (settingsRegistry.get(Setting.INDICATOR)) {
|
||||||
FontRenderer fontRenderer = mc.fontRendererObj;
|
FontRenderer fontRenderer = mc.fontRendererObj;
|
||||||
fontRenderer.drawString(I18n.format("replaymod.gui.recording").toUpperCase(), 30, 18 - (fontRenderer.FONT_HEIGHT / 2), 0xffffffff);
|
fontRenderer.drawString(I18n.format("replaymod.gui.recording").toUpperCase(), 30, 18 - (fontRenderer.FONT_HEIGHT / 2), 0xffffffff);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.replaymod.recording.handler;
|
|||||||
|
|
||||||
import com.replaymod.core.ReplayMod;
|
import com.replaymod.core.ReplayMod;
|
||||||
import com.replaymod.core.utils.ModCompat;
|
import com.replaymod.core.utils.ModCompat;
|
||||||
import com.replaymod.core.utils.Utils;
|
|
||||||
import com.replaymod.recording.Setting;
|
import com.replaymod.recording.Setting;
|
||||||
import com.replaymod.recording.gui.GuiRecordingOverlay;
|
import com.replaymod.recording.gui.GuiRecordingOverlay;
|
||||||
import com.replaymod.recording.packet.PacketListener;
|
import com.replaymod.recording.packet.PacketListener;
|
||||||
@@ -75,7 +74,7 @@ public class ConnectionEventHandler {
|
|||||||
File folder = core.getReplayFolder();
|
File folder = core.getReplayFolder();
|
||||||
|
|
||||||
String name = sdf.format(Calendar.getInstance().getTime());
|
String name = sdf.format(Calendar.getInstance().getTime());
|
||||||
File currentFile = new File(folder, Utils.replayNameToFileName(name));
|
File currentFile = new File(folder, name + ".mcpr");
|
||||||
ReplayFile replayFile = new ZipReplayFile(new ReplayStudio(), currentFile);
|
ReplayFile replayFile = new ZipReplayFile(new ReplayStudio(), currentFile);
|
||||||
|
|
||||||
replayFile.writeModInfo(ModCompat.getInstalledNetworkMods());
|
replayFile.writeModInfo(ModCompat.getInstalledNetworkMods());
|
||||||
|
|||||||
@@ -1,24 +1,22 @@
|
|||||||
package com.replaymod.recording.handler;
|
package com.replaymod.recording.handler;
|
||||||
|
|
||||||
import com.replaymod.recording.packet.PacketListener;
|
import com.replaymod.recording.packet.PacketListener;
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import io.netty.buffer.Unpooled;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.Packet;
|
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.*;
|
||||||
import net.minecraft.network.play.server.S14PacketEntity.S17PacketEntityLookMove;
|
|
||||||
import net.minecraft.server.integrated.IntegratedServer;
|
import net.minecraft.server.integrated.IntegratedServer;
|
||||||
import net.minecraft.util.BlockPos;
|
import net.minecraft.util.EnumHand;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.SoundCategory;
|
||||||
|
import net.minecraft.util.SoundEvent;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.entity.minecart.MinecartInteractEvent;
|
import net.minecraftforge.event.entity.minecart.MinecartInteractEvent;
|
||||||
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent;
|
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent;
|
||||||
import net.minecraftforge.event.entity.player.PlayerUseItemEvent;
|
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemPickupEvent;
|
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemPickupEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
@@ -32,24 +30,24 @@ public class RecordingEventHandler {
|
|||||||
private final PacketListener packetListener;
|
private final PacketListener packetListener;
|
||||||
|
|
||||||
private Double lastX, lastY, lastZ;
|
private Double lastX, lastY, lastZ;
|
||||||
private ItemStack[] playerItems = new ItemStack[5];
|
private ItemStack[] playerItems = new ItemStack[6];
|
||||||
private int ticksSinceLastCorrection;
|
private int ticksSinceLastCorrection;
|
||||||
private boolean wasSleeping;
|
private boolean wasSleeping;
|
||||||
private int lastRiding = -1;
|
private int lastRiding = -1;
|
||||||
private Integer rotationYawHeadBefore;
|
private Integer rotationYawHeadBefore;
|
||||||
|
private boolean wasHandActive;
|
||||||
|
private EnumHand lastActiveHand;
|
||||||
|
|
||||||
public RecordingEventHandler(PacketListener packetListener) {
|
public RecordingEventHandler(PacketListener packetListener) {
|
||||||
this.packetListener = packetListener;
|
this.packetListener = packetListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register() {
|
public void register() {
|
||||||
FMLCommonHandler.instance().bus().register(this);
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
((RecordingEventSender) mc.renderGlobal).setRecordingEventHandler(this);
|
((RecordingEventSender) mc.renderGlobal).setRecordingEventHandler(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unregister() {
|
public void unregister() {
|
||||||
FMLCommonHandler.instance().bus().unregister(this);
|
|
||||||
MinecraftForge.EVENT_BUS.unregister(this);
|
MinecraftForge.EVENT_BUS.unregister(this);
|
||||||
RecordingEventSender recordingEventSender = ((RecordingEventSender) mc.renderGlobal);
|
RecordingEventSender recordingEventSender = ((RecordingEventSender) mc.renderGlobal);
|
||||||
if (recordingEventSender.getRecordingEventHandler() == this) {
|
if (recordingEventSender.getRecordingEventHandler() == this) {
|
||||||
@@ -59,7 +57,7 @@ public class RecordingEventHandler {
|
|||||||
|
|
||||||
public void onPlayerJoin() {
|
public void onPlayerJoin() {
|
||||||
try {
|
try {
|
||||||
packetListener.save(spawnPlayer(mc.thePlayer));
|
packetListener.save(new SPacketSpawnPlayer(mc.thePlayer));
|
||||||
} catch(Exception e1) {
|
} catch(Exception e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -67,39 +65,28 @@ public class RecordingEventHandler {
|
|||||||
|
|
||||||
public void onPlayerRespawn() {
|
public void onPlayerRespawn() {
|
||||||
try {
|
try {
|
||||||
packetListener.save(spawnPlayer(mc.thePlayer));
|
packetListener.save(new SPacketSpawnPlayer(mc.thePlayer));
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
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 {
|
try {
|
||||||
S0CPacketSpawnPlayer packet = new S0CPacketSpawnPlayer();
|
// Send to all other players in ServerWorldEventHandler#playSoundToAllNearExcept
|
||||||
|
packetListener.save(new SPacketSoundEffect(sound, category, x, y, z, volume, pitch));
|
||||||
ByteBuf bb = Unpooled.buffer();
|
} catch(Exception e) {
|
||||||
PacketBuffer pb = new PacketBuffer(bb);
|
e.printStackTrace();
|
||||||
|
}
|
||||||
pb.writeVarIntToBuffer(player.getEntityId());
|
}
|
||||||
pb.writeUuid(EntityPlayer.getUUID(player.getGameProfile()));
|
|
||||||
|
public void onClientEffect(int type, BlockPos pos, int data) {
|
||||||
pb.writeInt(MathHelper.floor_double(player.posX * 32.0D));
|
try {
|
||||||
pb.writeInt(MathHelper.floor_double(player.posY * 32.0D));
|
// Send to all other players in ServerWorldEventHandler#playEvent
|
||||||
pb.writeInt(MathHelper.floor_double(player.posZ * 32.0D));
|
packetListener.save(new SPacketEffect(type, pos, data, false));
|
||||||
pb.writeByte((byte) ((int) (player.rotationYaw * 256.0F / 360.0F)));
|
|
||||||
pb.writeByte((byte) ((int) (player.rotationPitch * 256.0F / 360.0F)));
|
|
||||||
|
|
||||||
ItemStack itemstack = player.inventory.getCurrentItem();
|
|
||||||
pb.writeShort(itemstack == null ? 0 : Item.getIdFromItem(itemstack.getItem()));
|
|
||||||
|
|
||||||
player.getDataWatcher().writeTo(pb);
|
|
||||||
|
|
||||||
packet.readPacketData(pb);
|
|
||||||
|
|
||||||
return packet;
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,19 +118,14 @@ public class RecordingEventHandler {
|
|||||||
lastZ = e.player.posZ;
|
lastZ = e.player.posZ;
|
||||||
|
|
||||||
Packet packet;
|
Packet packet;
|
||||||
if(force || Math.abs(dx) > 4.0 || Math.abs(dy) > 4.0 || Math.abs(dz) > 4.0) {
|
if (force || Math.abs(dx) > 8.0 || Math.abs(dy) > 8.0 || Math.abs(dz) > 8.0) {
|
||||||
int x = MathHelper.floor_double(e.player.posX * 32.0D);
|
packet = new SPacketEntityTeleport(e.player);
|
||||||
int y = MathHelper.floor_double(e.player.posY * 32.0D);
|
|
||||||
int z = MathHelper.floor_double(e.player.posZ * 32.0D);
|
|
||||||
byte yaw = (byte) ((int) (e.player.rotationYaw * 256.0F / 360.0F));
|
|
||||||
byte pitch = (byte) ((int) (e.player.rotationPitch * 256.0F / 360.0F));
|
|
||||||
packet = new S18PacketEntityTeleport(e.player.getEntityId(), x, y, z, yaw, pitch, e.player.onGround);
|
|
||||||
} else {
|
} else {
|
||||||
byte newYaw = (byte) ((int) (e.player.rotationYaw * 256.0F / 360.0F));
|
byte newYaw = (byte) ((int) (e.player.rotationYaw * 256.0F / 360.0F));
|
||||||
byte newPitch = (byte) ((int) (e.player.rotationPitch * 256.0F / 360.0F));
|
byte newPitch = (byte) ((int) (e.player.rotationPitch * 256.0F / 360.0F));
|
||||||
|
|
||||||
packet = new S17PacketEntityLookMove(e.player.getEntityId(),
|
packet = new SPacketEntity.S17PacketEntityLookMove(e.player.getEntityId(),
|
||||||
(byte) Math.round(dx * 32), (byte) Math.round(dy * 32), (byte) Math.round(dz * 32),
|
(short) Math.round(dx * 4096), (short) Math.round(dy * 4096), (short) Math.round(dz * 4096),
|
||||||
newYaw, newPitch, e.player.onGround);
|
newYaw, newPitch, e.player.onGround);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,37 +135,16 @@ public class RecordingEventHandler {
|
|||||||
int rotationYawHead = ((int)(e.player.rotationYawHead * 256.0F / 360.0F));
|
int rotationYawHead = ((int)(e.player.rotationYawHead * 256.0F / 360.0F));
|
||||||
|
|
||||||
if(!Objects.equals(rotationYawHead, rotationYawHeadBefore)) {
|
if(!Objects.equals(rotationYawHead, rotationYawHeadBefore)) {
|
||||||
S19PacketEntityHeadLook head = new S19PacketEntityHeadLook();
|
packetListener.save(new SPacketEntityHeadLook(e.player, (byte) rotationYawHead));
|
||||||
ByteBuf bb1 = Unpooled.buffer();
|
|
||||||
PacketBuffer pb1 = new PacketBuffer(bb1);
|
|
||||||
|
|
||||||
pb1.writeVarIntToBuffer(e.player.getEntityId());
|
|
||||||
pb1.writeByte(rotationYawHead);
|
|
||||||
|
|
||||||
head.readPacketData(pb1);
|
|
||||||
|
|
||||||
packetListener.save(head);
|
|
||||||
|
|
||||||
rotationYawHeadBefore = rotationYawHead;
|
rotationYawHeadBefore = rotationYawHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
S12PacketEntityVelocity vel = new S12PacketEntityVelocity(e.player.getEntityId(), e.player.motionX, e.player.motionY, e.player.motionZ);
|
packetListener.save(new SPacketEntityVelocity(e.player.getEntityId(), e.player.motionX, e.player.motionY, e.player.motionZ));
|
||||||
packetListener.save(vel);
|
|
||||||
|
|
||||||
//Animation Packets
|
//Animation Packets
|
||||||
//Swing Animation
|
//Swing Animation
|
||||||
if(e.player.swingProgressInt == 1) {
|
if (e.player.isSwingInProgress && e.player.swingProgressInt == -1) {
|
||||||
S0BPacketAnimation pac = new S0BPacketAnimation();
|
packetListener.save(new SPacketAnimation(e.player, e.player.swingingHand == EnumHand.MAIN_HAND ? 0 : 3));
|
||||||
|
|
||||||
ByteBuf bb = Unpooled.buffer();
|
|
||||||
PacketBuffer pb = new PacketBuffer(bb);
|
|
||||||
|
|
||||||
pb.writeVarIntToBuffer(e.player.getEntityId());
|
|
||||||
pb.writeByte(0);
|
|
||||||
|
|
||||||
pac.readPacketData(pb);
|
|
||||||
|
|
||||||
packetListener.save(pac);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -207,77 +168,64 @@ public class RecordingEventHandler {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//Inventory Handling
|
//Inventory Handling
|
||||||
if(playerItems[0] != mc.thePlayer.getHeldItem()) {
|
if (playerItems[0] != mc.thePlayer.getHeldItem(EnumHand.MAIN_HAND)) {
|
||||||
playerItems[0] = mc.thePlayer.getHeldItem();
|
playerItems[0] = mc.thePlayer.getHeldItem(EnumHand.MAIN_HAND);
|
||||||
S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 0, playerItems[0]);
|
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.MAINHAND, playerItems[0]));
|
||||||
packetListener.save(pee);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(playerItems[1] != mc.thePlayer.inventory.armorInventory[0]) {
|
if (playerItems[1] != mc.thePlayer.getHeldItem(EnumHand.OFF_HAND)) {
|
||||||
playerItems[1] = mc.thePlayer.inventory.armorInventory[0];
|
playerItems[1] = mc.thePlayer.getHeldItem(EnumHand.OFF_HAND);
|
||||||
S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 1, playerItems[1]);
|
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.OFFHAND, playerItems[1]));
|
||||||
packetListener.save(pee);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(playerItems[2] != mc.thePlayer.inventory.armorInventory[1]) {
|
if (playerItems[2] != mc.thePlayer.inventory.armorInventory[0]) {
|
||||||
playerItems[2] = mc.thePlayer.inventory.armorInventory[1];
|
playerItems[2] = mc.thePlayer.inventory.armorInventory[0];
|
||||||
S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 2, playerItems[2]);
|
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.FEET, playerItems[2]));
|
||||||
packetListener.save(pee);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(playerItems[3] != mc.thePlayer.inventory.armorInventory[2]) {
|
if (playerItems[3] != mc.thePlayer.inventory.armorInventory[1]) {
|
||||||
playerItems[3] = mc.thePlayer.inventory.armorInventory[2];
|
playerItems[3] = mc.thePlayer.inventory.armorInventory[1];
|
||||||
S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 3, playerItems[3]);
|
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.LEGS, playerItems[3]));
|
||||||
packetListener.save(pee);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(playerItems[4] != mc.thePlayer.inventory.armorInventory[3]) {
|
if (playerItems[4] != mc.thePlayer.inventory.armorInventory[2]) {
|
||||||
playerItems[4] = mc.thePlayer.inventory.armorInventory[3];
|
playerItems[4] = mc.thePlayer.inventory.armorInventory[2];
|
||||||
S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 4, playerItems[4]);
|
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.CHEST, playerItems[4]));
|
||||||
packetListener.save(pee);
|
}
|
||||||
|
|
||||||
|
if (playerItems[5] != mc.thePlayer.inventory.armorInventory[3]) {
|
||||||
|
playerItems[5] = mc.thePlayer.inventory.armorInventory[3];
|
||||||
|
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.HEAD, playerItems[5]));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Leaving Ride
|
//Leaving Ride
|
||||||
|
|
||||||
if((!mc.thePlayer.isRiding() && lastRiding != -1) ||
|
if((!mc.thePlayer.isRiding() && lastRiding != -1) ||
|
||||||
(mc.thePlayer.isRiding() && lastRiding != mc.thePlayer.ridingEntity.getEntityId())) {
|
(mc.thePlayer.isRiding() && lastRiding != mc.thePlayer.getRidingEntity().getEntityId())) {
|
||||||
if(!mc.thePlayer.isRiding()) {
|
if(!mc.thePlayer.isRiding()) {
|
||||||
lastRiding = -1;
|
lastRiding = -1;
|
||||||
} else {
|
} else {
|
||||||
lastRiding = mc.thePlayer.ridingEntity.getEntityId();
|
lastRiding = mc.thePlayer.getRidingEntity().getEntityId();
|
||||||
}
|
}
|
||||||
|
packetListener.save(new SPacketEntityAttach(e.player, e.player.getRidingEntity()));
|
||||||
S1BPacketEntityAttach pea = new S1BPacketEntityAttach();
|
|
||||||
|
|
||||||
ByteBuf buf = Unpooled.buffer();
|
|
||||||
PacketBuffer pbuf = new PacketBuffer(buf);
|
|
||||||
|
|
||||||
pbuf.writeInt(e.player.getEntityId());
|
|
||||||
pbuf.writeInt(lastRiding);
|
|
||||||
pbuf.writeBoolean(false);
|
|
||||||
|
|
||||||
pea.readPacketData(pbuf);
|
|
||||||
|
|
||||||
packetListener.save(pea);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Sleeping
|
//Sleeping
|
||||||
if(!mc.thePlayer.isPlayerSleeping() && wasSleeping) {
|
if(!mc.thePlayer.isPlayerSleeping() && wasSleeping) {
|
||||||
S0BPacketAnimation pac = new S0BPacketAnimation();
|
packetListener.save(new SPacketAnimation(e.player, 2));
|
||||||
|
|
||||||
ByteBuf bb = Unpooled.buffer();
|
|
||||||
PacketBuffer pb = new PacketBuffer(bb);
|
|
||||||
|
|
||||||
pb.writeVarIntToBuffer(e.player.getEntityId());
|
|
||||||
pb.writeByte(2);
|
|
||||||
|
|
||||||
pac.readPacketData(pb);
|
|
||||||
|
|
||||||
packetListener.save(pac);
|
|
||||||
|
|
||||||
wasSleeping = false;
|
wasSleeping = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Active hand (e.g. eating, drinking, blocking)
|
||||||
|
if (mc.thePlayer.isHandActive() ^ wasHandActive || mc.thePlayer.getActiveHand() != lastActiveHand) {
|
||||||
|
wasHandActive = mc.thePlayer.isHandActive();
|
||||||
|
lastActiveHand = mc.thePlayer.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.thePlayer.getEntityId(), dataManager, true));
|
||||||
|
}
|
||||||
|
|
||||||
} catch(Exception e1) {
|
} catch(Exception e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -286,27 +234,7 @@ public class RecordingEventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onPickupItem(ItemPickupEvent event) {
|
public void onPickupItem(ItemPickupEvent event) {
|
||||||
try {
|
try {
|
||||||
packetListener.save(new S0DPacketCollectItem(event.pickedUp.getEntityId(), event.player.getEntityId()));
|
packetListener.save(new SPacketCollectItem(event.pickedUp.getEntityId(), event.player.getEntityId()));
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onStartEating(PlayerUseItemEvent.Start event) {
|
|
||||||
try {
|
|
||||||
if(!event.entityPlayer.isEating()) return;
|
|
||||||
S0BPacketAnimation packet = new S0BPacketAnimation();
|
|
||||||
|
|
||||||
ByteBuf bb = Unpooled.buffer();
|
|
||||||
PacketBuffer pb = new PacketBuffer(bb);
|
|
||||||
|
|
||||||
pb.writeVarIntToBuffer(event.entityPlayer.getEntityId());
|
|
||||||
pb.writeByte(3);
|
|
||||||
|
|
||||||
packet.readPacketData(pb);
|
|
||||||
|
|
||||||
packetListener.save(packet);
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -315,21 +243,11 @@ public class RecordingEventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onSleep(PlayerSleepInBedEvent event) {
|
public void onSleep(PlayerSleepInBedEvent event) {
|
||||||
try {
|
try {
|
||||||
if(event.entityPlayer != mc.thePlayer) {
|
if (event.getEntityPlayer() != mc.thePlayer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
S0APacketUseBed pub = new S0APacketUseBed();
|
packetListener.save(new SPacketUseBed(event.getEntityPlayer(), event.getPos()));
|
||||||
|
|
||||||
ByteBuf buf = Unpooled.buffer();
|
|
||||||
PacketBuffer pbuf = new PacketBuffer(buf);
|
|
||||||
|
|
||||||
pbuf.writeVarIntToBuffer(event.entityPlayer.getEntityId());
|
|
||||||
pbuf.writeBlockPos(event.pos);
|
|
||||||
|
|
||||||
pub.readPacketData(pbuf);
|
|
||||||
|
|
||||||
packetListener.save(pub);
|
|
||||||
|
|
||||||
wasSleeping = true;
|
wasSleeping = true;
|
||||||
|
|
||||||
@@ -341,24 +259,13 @@ public class RecordingEventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void enterMinecart(MinecartInteractEvent event) {
|
public void enterMinecart(MinecartInteractEvent event) {
|
||||||
try {
|
try {
|
||||||
if(event.player != mc.thePlayer) {
|
if(event.getEntity() != mc.thePlayer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
S1BPacketEntityAttach pea = new S1BPacketEntityAttach();
|
packetListener.save(new SPacketEntityAttach(event.getPlayer(), event.getMinecart()));
|
||||||
|
|
||||||
ByteBuf buf = Unpooled.buffer();
|
lastRiding = event.getMinecart().getEntityId();
|
||||||
PacketBuffer pbuf = new PacketBuffer(buf);
|
|
||||||
|
|
||||||
pbuf.writeInt(event.player.getEntityId());
|
|
||||||
pbuf.writeInt(event.minecart.getEntityId());
|
|
||||||
pbuf.writeBoolean(false);
|
|
||||||
|
|
||||||
pea.readPacketData(pbuf);
|
|
||||||
|
|
||||||
packetListener.save(pea);
|
|
||||||
|
|
||||||
lastRiding = event.minecart.getEntityId();
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -367,7 +274,7 @@ public class RecordingEventHandler {
|
|||||||
public void onBlockBreakAnim(int breakerId, BlockPos pos, int progress) {
|
public void onBlockBreakAnim(int breakerId, BlockPos pos, int progress) {
|
||||||
EntityPlayer thePlayer = mc.thePlayer;
|
EntityPlayer thePlayer = mc.thePlayer;
|
||||||
if (thePlayer != null && breakerId == thePlayer.getEntityId()) {
|
if (thePlayer != null && breakerId == thePlayer.getEntityId()) {
|
||||||
packetListener.save(new S25PacketBlockBreakAnim(breakerId, pos, progress));
|
packetListener.save(new SPacketBlockBreakAnim(breakerId, pos, progress));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,15 +4,14 @@ import com.replaymod.recording.handler.RecordingEventHandler;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||||
import net.minecraft.network.play.server.S07PacketRespawn;
|
import net.minecraft.network.play.server.SPacketPlayerListItem;
|
||||||
import net.minecraft.network.play.server.S38PacketPlayerListItem;
|
import net.minecraft.network.play.server.SPacketRespawn;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -37,18 +36,16 @@ public abstract class MixinNetHandlerPlayClient {
|
|||||||
* @param ci Callback info
|
* @param ci Callback info
|
||||||
*/
|
*/
|
||||||
@Inject(method = "handlePlayerListItem", at=@At("HEAD"))
|
@Inject(method = "handlePlayerListItem", at=@At("HEAD"))
|
||||||
public void recordOwnJoin(S38PacketPlayerListItem packet, CallbackInfo ci) {
|
public void recordOwnJoin(SPacketPlayerListItem packet, CallbackInfo ci) {
|
||||||
if (gameController.thePlayer == null) return;
|
if (gameController.thePlayer == null) return;
|
||||||
|
|
||||||
RecordingEventHandler handler = getRecordingEventHandler();
|
RecordingEventHandler handler = getRecordingEventHandler();
|
||||||
if (handler != null && packet.func_179768_b() == S38PacketPlayerListItem.Action.ADD_PLAYER) {
|
if (handler != null && packet.getAction() == SPacketPlayerListItem.Action.ADD_PLAYER) {
|
||||||
@SuppressWarnings("unchecked")
|
for (SPacketPlayerListItem.AddPlayerData data : packet.getEntries()) {
|
||||||
List<S38PacketPlayerListItem.AddPlayerData> dataList = packet.func_179767_a();
|
if (data.getProfile() == null || data.getProfile().getId() == null) continue;
|
||||||
for (S38PacketPlayerListItem.AddPlayerData data : dataList) {
|
|
||||||
if (data.func_179962_a() == null || data.func_179962_a().getId() == null) continue;
|
|
||||||
// Only add spawn packet for our own player and only if he isn't known yet
|
// Only add spawn packet for our own player and only if he isn't known yet
|
||||||
if (data.func_179962_a().getId().equals(Minecraft.getMinecraft().thePlayer.getGameProfile().getId())
|
if (data.getProfile().getId().equals(Minecraft.getMinecraft().thePlayer.getGameProfile().getId())
|
||||||
&& !playerInfoMap.containsKey(data.func_179962_a().getId())) {
|
&& !playerInfoMap.containsKey(data.getProfile().getId())) {
|
||||||
handler.onPlayerJoin();
|
handler.onPlayerJoin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,12 +55,12 @@ public abstract class MixinNetHandlerPlayClient {
|
|||||||
/**
|
/**
|
||||||
* Record the own player entity respawning.
|
* Record the own player entity respawning.
|
||||||
* We cannot use the {@link net.minecraftforge.event.entity.EntityJoinWorldEvent} because that would also include
|
* We cannot use the {@link net.minecraftforge.event.entity.EntityJoinWorldEvent} because that would also include
|
||||||
* the first spawn which is already handled by {@link #recordOwnJoin(S38PacketPlayerListItem, CallbackInfo)}.
|
* the first spawn which is already handled by {@link #recordOwnJoin(SPacketPlayerListItem, CallbackInfo)}.
|
||||||
* @param packet The packet
|
* @param packet The packet
|
||||||
* @param ci Callback info
|
* @param ci Callback info
|
||||||
*/
|
*/
|
||||||
@Inject(method = "handleRespawn", at=@At("RETURN"))
|
@Inject(method = "handleRespawn", at=@At("RETURN"))
|
||||||
public void recordOwnRespawn(S07PacketRespawn packet, CallbackInfo ci) {
|
public void recordOwnRespawn(SPacketRespawn packet, CallbackInfo ci) {
|
||||||
RecordingEventHandler handler = getRecordingEventHandler();
|
RecordingEventHandler handler = getRecordingEventHandler();
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
handler.onPlayerRespawn();
|
handler.onPlayerRespawn();
|
||||||
|
|||||||
@@ -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.thePlayer, type, pos, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ package com.replaymod.recording.mixin;
|
|||||||
|
|
||||||
import com.replaymod.recording.handler.RecordingEventHandler;
|
import com.replaymod.recording.handler.RecordingEventHandler;
|
||||||
import net.minecraft.client.renderer.RenderGlobal;
|
import net.minecraft.client.renderer.RenderGlobal;
|
||||||
import net.minecraft.util.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
|||||||
@@ -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.thePlayer) {
|
||||||
|
RecordingEventHandler handler = replayModRecording_getRecordingEventHandler();
|
||||||
|
if (handler != null) {
|
||||||
|
handler.onClientSound(sound, category, x, y, z, volume, pitch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Same goes for level events (also called effects). E.g. door open, block break, etc.
|
||||||
|
// These are handled in the World class, so we override the method in WorldClient and add our special handling.
|
||||||
|
@Override
|
||||||
|
public void playEvent(EntityPlayer player, int type, BlockPos pos, int data) {
|
||||||
|
if (player == mc.thePlayer) {
|
||||||
|
// We caused this event, the server won't send it to us
|
||||||
|
RecordingEventHandler handler = replayModRecording_getRecordingEventHandler();
|
||||||
|
if (handler != null) {
|
||||||
|
handler.onClientEffect(type, pos, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.playEvent(player, type, pos, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,21 +9,24 @@ import io.netty.buffer.Unpooled;
|
|||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.DataWatcher;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.network.EnumConnectionState;
|
import net.minecraft.network.EnumConnectionState;
|
||||||
import net.minecraft.network.EnumPacketDirection;
|
import net.minecraft.network.EnumPacketDirection;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
import net.minecraft.network.datasync.EntityDataManager;
|
||||||
import net.minecraft.network.play.server.*;
|
import net.minecraft.network.play.server.*;
|
||||||
import net.minecraft.util.ChatComponentText;
|
import net.minecraft.util.text.TextComponentString;
|
||||||
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
|
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
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.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -84,16 +87,13 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
|||||||
|
|
||||||
public void save(Packet packet) {
|
public void save(Packet packet) {
|
||||||
try {
|
try {
|
||||||
if(packet instanceof S0CPacketSpawnPlayer) {
|
if(packet instanceof SPacketSpawnPlayer) {
|
||||||
UUID uuid = ((S0CPacketSpawnPlayer) packet).func_179819_c();
|
UUID uuid = ((SPacketSpawnPlayer) packet).getUniqueId();
|
||||||
Set<String> uuids = new HashSet<>(Arrays.asList(metaData.getPlayers()));
|
Set<String> uuids = new HashSet<>(Arrays.asList(metaData.getPlayers()));
|
||||||
uuids.add(uuid.toString());
|
uuids.add(uuid.toString());
|
||||||
metaData.setPlayers(uuids.toArray(new String[uuids.size()]));
|
metaData.setPlayers(uuids.toArray(new String[uuids.size()]));
|
||||||
saveMetaData();
|
saveMetaData();
|
||||||
}
|
}
|
||||||
if (packet instanceof S46PacketSetCompressionLevel) {
|
|
||||||
return; // Replay data is never compressed on the packet level
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] bytes = getPacketData(packet);
|
byte[] bytes = getPacketData(packet);
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
@@ -154,16 +154,16 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
|||||||
try {
|
try {
|
||||||
Packet packet = (Packet) msg;
|
Packet packet = (Packet) msg;
|
||||||
|
|
||||||
if(packet instanceof S0DPacketCollectItem) {
|
if(packet instanceof SPacketCollectItem) {
|
||||||
if(mc.thePlayer != null ||
|
if(mc.thePlayer != null ||
|
||||||
((S0DPacketCollectItem) packet).func_149353_d() == mc.thePlayer.getEntityId()) {
|
((SPacketCollectItem) packet).getEntityID() == mc.thePlayer.getEntityId()) {
|
||||||
super.channelRead(ctx, msg);
|
super.channelRead(ctx, msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packet instanceof S48PacketResourcePackSend) {
|
if (packet instanceof SPacketResourcePackSend) {
|
||||||
save(resourcePackRecorder.handleResourcePack((S48PacketResourcePackSend) packet));
|
save(resourcePackRecorder.handleResourcePack((SPacketResourcePackSend) packet));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,10 +176,10 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
|||||||
|
|
||||||
save(packet);
|
save(packet);
|
||||||
|
|
||||||
if (packet instanceof S3FPacketCustomPayload) {
|
if (packet instanceof SPacketCustomPayload) {
|
||||||
S3FPacketCustomPayload p = (S3FPacketCustomPayload) packet;
|
SPacketCustomPayload p = (SPacketCustomPayload) packet;
|
||||||
if (Restrictions.PLUGIN_CHANNEL.equals(p.getChannelName())) {
|
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);
|
save(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,27 +192,31 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
|||||||
super.channelRead(ctx, msg);
|
super.channelRead(ctx, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private <T> void DataManager_set(EntityDataManager dataManager, EntityDataManager.DataEntry<T> entry) {
|
||||||
|
dataManager.register(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private byte[] getPacketData(Packet packet) throws IOException {
|
private byte[] getPacketData(Packet packet) throws IOException {
|
||||||
if(packet instanceof S0FPacketSpawnMob) {
|
if (packet instanceof SPacketSpawnMob) {
|
||||||
S0FPacketSpawnMob p = (S0FPacketSpawnMob) packet;
|
SPacketSpawnMob p = (SPacketSpawnMob) packet;
|
||||||
if (p.field_149043_l == null) {
|
if (p.dataManager == null) {
|
||||||
p.field_149043_l = new DataWatcher(null);
|
p.dataManager = new EntityDataManager(null);
|
||||||
if(p.func_149027_c() != null) {
|
if (p.getDataManagerEntries() != null) {
|
||||||
for(DataWatcher.WatchableObject wo : (List<DataWatcher.WatchableObject>) p.func_149027_c()) {
|
for (EntityDataManager.DataEntry<?> entry : p.getDataManagerEntries()) {
|
||||||
p.field_149043_l.addObject(wo.getDataValueId(), wo.getObject());
|
DataManager_set(p.dataManager, entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(packet instanceof S0CPacketSpawnPlayer) {
|
if (packet instanceof SPacketSpawnPlayer) {
|
||||||
S0CPacketSpawnPlayer p = (S0CPacketSpawnPlayer) packet;
|
SPacketSpawnPlayer p = (SPacketSpawnPlayer) packet;
|
||||||
if (p.field_148960_i == null) {
|
if (p.watcher == null) {
|
||||||
p.field_148960_i = new DataWatcher(null);
|
p.watcher = new EntityDataManager(null);
|
||||||
if(p.func_148944_c() != null) {
|
if (p.getDataManagerEntries() != null) {
|
||||||
for(DataWatcher.WatchableObject wo : (List<DataWatcher.WatchableObject>) p.func_148944_c()) {
|
for (EntityDataManager.DataEntry<?> entry : p.getDataManagerEntries()) {
|
||||||
p.field_148960_i.addObject(wo.getDataValueId(), wo.getObject());
|
DataManager_set(p.watcher, entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,15 +9,14 @@ import com.replaymod.replaystudio.replay.ReplayFile;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiScreenWorking;
|
import net.minecraft.client.gui.GuiScreenWorking;
|
||||||
import net.minecraft.client.gui.GuiYesNo;
|
import net.minecraft.client.gui.GuiYesNo;
|
||||||
import net.minecraft.client.gui.GuiYesNoCallback;
|
|
||||||
import net.minecraft.client.multiplayer.ServerData;
|
import net.minecraft.client.multiplayer.ServerData;
|
||||||
import net.minecraft.client.multiplayer.ServerList;
|
import net.minecraft.client.multiplayer.ServerList;
|
||||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.client.resources.ResourcePackRepository;
|
import net.minecraft.client.resources.ResourcePackRepository;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraft.network.play.client.C19PacketResourcePackStatus;
|
import net.minecraft.network.play.client.CPacketResourcePackStatus;
|
||||||
import net.minecraft.network.play.server.S48PacketResourcePackSend;
|
import net.minecraft.network.play.server.SPacketResourcePackSend;
|
||||||
import net.minecraft.util.HttpUtil;
|
import net.minecraft.util.HttpUtil;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
@@ -75,12 +74,12 @@ public class ResourcePackRecorder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized S48PacketResourcePackSend handleResourcePack(S48PacketResourcePackSend packet) {
|
public synchronized SPacketResourcePackSend handleResourcePack(SPacketResourcePackSend packet) {
|
||||||
final int requestId = nextRequestId++;
|
final int requestId = nextRequestId++;
|
||||||
final NetHandlerPlayClient netHandler = mc.getNetHandler();
|
final NetHandlerPlayClient netHandler = mc.getConnection();
|
||||||
final NetworkManager netManager = netHandler.getNetworkManager();
|
final NetworkManager netManager = netHandler.getNetworkManager();
|
||||||
final String url = packet.func_179783_a();
|
final String url = packet.getURL();
|
||||||
final String hash = packet.func_179784_b();
|
final String hash = packet.getHash();
|
||||||
|
|
||||||
if (url.startsWith("level://")) {
|
if (url.startsWith("level://")) {
|
||||||
String levelName = url.substring("level://".length());
|
String levelName = url.substring("level://".length());
|
||||||
@@ -88,65 +87,60 @@ public class ResourcePackRecorder {
|
|||||||
final File levelDir = new File(savesDir, levelName);
|
final File levelDir = new File(savesDir, levelName);
|
||||||
|
|
||||||
if (levelDir.isFile()) {
|
if (levelDir.isFile()) {
|
||||||
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.ACCEPTED));
|
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.ACCEPTED));
|
||||||
Futures.addCallback(mc.getResourcePackRepository().func_177319_a(levelDir), new FutureCallback() {
|
Futures.addCallback(mc.getResourcePackRepository().setResourcePackInstance(levelDir), new FutureCallback<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Object result) {
|
public void onSuccess(Object result) {
|
||||||
recordResourcePack(levelDir, requestId);
|
recordResourcePack(levelDir, requestId);
|
||||||
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.SUCCESSFULLY_LOADED));
|
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.SUCCESSFULLY_LOADED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@Nonnull Throwable throwable) {
|
public void onFailure(@Nonnull Throwable throwable) {
|
||||||
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final ServerData serverData = mc.getCurrentServerData();
|
final ServerData serverData = mc.getCurrentServerData();
|
||||||
if (serverData != null && serverData.getResourceMode() == ServerData.ServerResourceMode.ENABLED) {
|
if (serverData != null && serverData.getResourceMode() == ServerData.ServerResourceMode.ENABLED) {
|
||||||
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.ACCEPTED));
|
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.ACCEPTED));
|
||||||
downloadResourcePackFuture(requestId, url, hash);
|
downloadResourcePackFuture(requestId, url, hash);
|
||||||
} else if (serverData != null && serverData.getResourceMode() != ServerData.ServerResourceMode.PROMPT) {
|
} else if (serverData != null && serverData.getResourceMode() != ServerData.ServerResourceMode.PROMPT) {
|
||||||
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.DECLINED));
|
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.DECLINED));
|
||||||
} else {
|
} else {
|
||||||
// Lambdas MUST NOT be used with methods that need re-obfuscation in FG prior to 2.2 (will result in AbstractMethodError)
|
mc.addScheduledTask(() -> mc.displayGuiScreen(new GuiYesNo((result, id) -> {
|
||||||
//noinspection Convert2Lambda
|
if (serverData != null) {
|
||||||
mc.addScheduledTask(() -> mc.displayGuiScreen(new GuiYesNo(new GuiYesNoCallback() {
|
serverData.setResourceMode(result ? ServerData.ServerResourceMode.ENABLED : ServerData.ServerResourceMode.DISABLED);
|
||||||
@Override
|
|
||||||
public void confirmClicked(boolean result, int id) {
|
|
||||||
if (serverData != null) {
|
|
||||||
serverData.setResourceMode(result ? ServerData.ServerResourceMode.ENABLED : ServerData.ServerResourceMode.DISABLED);
|
|
||||||
}
|
|
||||||
if (result) {
|
|
||||||
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.ACCEPTED));
|
|
||||||
ResourcePackRecorder.this.downloadResourcePackFuture(requestId, url, hash);
|
|
||||||
} else {
|
|
||||||
netManager.sendPacket(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.DECLINED));
|
|
||||||
}
|
|
||||||
|
|
||||||
ServerList.func_147414_b(serverData);
|
|
||||||
mc.displayGuiScreen(null);
|
|
||||||
}
|
}
|
||||||
|
if (result) {
|
||||||
|
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.ACCEPTED));
|
||||||
|
downloadResourcePackFuture(requestId, url, hash);
|
||||||
|
} else {
|
||||||
|
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.DECLINED));
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerList.saveSingleServer(serverData);
|
||||||
|
mc.displayGuiScreen(null);
|
||||||
}, I18n.format("multiplayer.texturePrompt.line1"), I18n.format("multiplayer.texturePrompt.line2"), 0)));
|
}, I18n.format("multiplayer.texturePrompt.line1"), I18n.format("multiplayer.texturePrompt.line2"), 0)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new S48PacketResourcePackSend("replay://" + requestId, "");
|
return new SPacketResourcePackSend("replay://" + requestId, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadResourcePackFuture(int requestId, String url, final String hash) {
|
private void downloadResourcePackFuture(int requestId, String url, final String hash) {
|
||||||
Futures.addCallback(downloadResourcePack(requestId, url, hash), new FutureCallback() {
|
Futures.addCallback(downloadResourcePack(requestId, url, hash), new FutureCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Object result) {
|
public void onSuccess(Object result) {
|
||||||
mc.getNetHandler().addToSendQueue(new C19PacketResourcePackStatus(hash, C19PacketResourcePackStatus.Action.SUCCESSFULLY_LOADED));
|
mc.getConnection().sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.SUCCESSFULLY_LOADED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@Nonnull Throwable throwable) {
|
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));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -171,16 +165,16 @@ public class ResourcePackRecorder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final File file = new File(repo.dirServerResourcepacks, fileName);
|
final File file = new File(repo.dirServerResourcepacks, fileName);
|
||||||
repo.field_177321_h.lock();
|
repo.lock.lock();
|
||||||
try {
|
try {
|
||||||
repo.func_148529_f();
|
repo.clearResourcePack();
|
||||||
|
|
||||||
if (file.exists() && hash.length() == 40) {
|
if (file.exists() && hash.length() == 40) {
|
||||||
try {
|
try {
|
||||||
String fileHash = Hashing.sha1().hashBytes(Files.toByteArray(file)).toString();
|
String fileHash = Hashing.sha1().hashBytes(Files.toByteArray(file)).toString();
|
||||||
if (fileHash.equals(hash)) {
|
if (fileHash.equals(hash)) {
|
||||||
recordResourcePack(file, requestId);
|
recordResourcePack(file, requestId);
|
||||||
return repo.func_177319_a(file);
|
return repo.setResourcePackInstance(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.warn("File " + file + " had wrong hash (expected " + hash + ", found " + fileHash + "). Deleting it.");
|
logger.warn("File " + file + " had wrong hash (expected " + hash + ", found " + fileHash + "). Deleting it.");
|
||||||
@@ -196,13 +190,13 @@ public class ResourcePackRecorder {
|
|||||||
|
|
||||||
Futures.getUnchecked(mc.addScheduledTask(() -> mc.displayGuiScreen(guiScreen)));
|
Futures.getUnchecked(mc.addScheduledTask(() -> mc.displayGuiScreen(guiScreen)));
|
||||||
|
|
||||||
Map sessionInfo = Minecraft.getSessionInfo();
|
Map<String, String> sessionInfo = ResourcePackRepository.func_190115_a();
|
||||||
repo.field_177322_i = HttpUtil.func_180192_a(file, url, sessionInfo, 50 * 1024 * 1024, guiScreen, mc.getProxy());
|
repo.downloadingPacks = HttpUtil.downloadResourcePack(file, url, sessionInfo, 50 * 1024 * 1024, guiScreen, mc.getProxy());
|
||||||
Futures.addCallback(repo.field_177322_i, new FutureCallback() {
|
Futures.addCallback(repo.downloadingPacks, new FutureCallback<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Object value) {
|
public void onSuccess(Object value) {
|
||||||
recordResourcePack(file, requestId);
|
recordResourcePack(file, requestId);
|
||||||
repo.func_177319_a(file);
|
repo.setResourcePackInstance(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -210,9 +204,9 @@ public class ResourcePackRecorder {
|
|||||||
throwable.printStackTrace();
|
throwable.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return repo.field_177322_i;
|
return repo.downloadingPacks;
|
||||||
} finally {
|
} finally {
|
||||||
repo.field_177321_h.unlock();
|
repo.lock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import com.replaymod.render.utils.RenderJob;
|
|||||||
import com.replaymod.replay.events.ReplayCloseEvent;
|
import com.replaymod.replay.events.ReplayCloseEvent;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
import net.minecraft.util.ReportedException;
|
import net.minecraft.util.ReportedException;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
@@ -21,7 +21,6 @@ import java.util.List;
|
|||||||
@Mod(modid = ReplayModRender.MOD_ID,
|
@Mod(modid = ReplayModRender.MOD_ID,
|
||||||
version = "@MOD_VERSION@",
|
version = "@MOD_VERSION@",
|
||||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||||
acceptableRemoteVersions = "*",
|
|
||||||
useMetadata = true)
|
useMetadata = true)
|
||||||
public class ReplayModRender {
|
public class ReplayModRender {
|
||||||
public static final String MOD_ID = "replaymod-render";
|
public static final String MOD_ID = "replaymod-render";
|
||||||
@@ -46,7 +45,7 @@ public class ReplayModRender {
|
|||||||
core = ReplayMod.instance;
|
core = ReplayMod.instance;
|
||||||
configuration = new Configuration(event.getSuggestedConfigurationFile());
|
configuration = new Configuration(event.getSuggestedConfigurationFile());
|
||||||
|
|
||||||
FMLCommonHandler.instance().bus().register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
|
||||||
core.getSettingsRegistry().register(Setting.class);
|
core.getSettingsRegistry().register(Setting.class);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.replaymod.render;
|
|||||||
|
|
||||||
import com.replaymod.render.frame.RGBFrame;
|
import com.replaymod.render.frame.RGBFrame;
|
||||||
import com.replaymod.render.rendering.FrameConsumer;
|
import com.replaymod.render.rendering.FrameConsumer;
|
||||||
import com.replaymod.render.rendering.VideoRenderer;
|
|
||||||
import com.replaymod.render.utils.ByteBufferPool;
|
import com.replaymod.render.utils.ByteBufferPool;
|
||||||
import com.replaymod.render.utils.StreamPipe;
|
import com.replaymod.render.utils.StreamPipe;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
@@ -33,7 +32,6 @@ import static org.apache.commons.lang3.Validate.isTrue;
|
|||||||
|
|
||||||
public class VideoWriter implements FrameConsumer<RGBFrame> {
|
public class VideoWriter implements FrameConsumer<RGBFrame> {
|
||||||
|
|
||||||
private final VideoRenderer renderer;
|
|
||||||
private final RenderSettings settings;
|
private final RenderSettings settings;
|
||||||
private final Process process;
|
private final Process process;
|
||||||
private final OutputStream outputStream;
|
private final OutputStream outputStream;
|
||||||
@@ -43,9 +41,8 @@ public class VideoWriter implements FrameConsumer<RGBFrame> {
|
|||||||
|
|
||||||
private ByteArrayOutputStream ffmpegLog = new ByteArrayOutputStream(4096);
|
private ByteArrayOutputStream ffmpegLog = new ByteArrayOutputStream(4096);
|
||||||
|
|
||||||
public VideoWriter(final VideoRenderer renderer) throws IOException {
|
public VideoWriter(final RenderSettings settings) throws IOException {
|
||||||
this.renderer = renderer;
|
this.settings = settings;
|
||||||
this.settings = renderer.getRenderSettings();
|
|
||||||
|
|
||||||
File outputFolder = settings.getOutputFile().getParentFile();
|
File outputFolder = settings.getOutputFile().getParentFile();
|
||||||
FileUtils.forceMkdir(outputFolder);
|
FileUtils.forceMkdir(outputFolder);
|
||||||
@@ -60,13 +57,9 @@ public class VideoWriter implements FrameConsumer<RGBFrame> {
|
|||||||
.replace("%FILTERS%", settings.getVideoFilters());
|
.replace("%FILTERS%", settings.getVideoFilters());
|
||||||
|
|
||||||
String executable = settings.getExportCommand().isEmpty() ? findFFmpeg() : settings.getExportCommand();
|
String executable = settings.getExportCommand().isEmpty() ? findFFmpeg() : settings.getExportCommand();
|
||||||
LOGGER.info("Starting {} with args: {}", executable, commandArgs);
|
System.out.println("Starting " + executable + " with args: " + commandArgs);
|
||||||
String[] cmdline = new CommandLine(executable).addArguments(commandArgs).toStrings();
|
String[] cmdline = new CommandLine(executable).addArguments(commandArgs).toStrings();
|
||||||
try {
|
process = new ProcessBuilder(cmdline).directory(outputFolder).start();
|
||||||
process = new ProcessBuilder(cmdline).directory(outputFolder).start();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new NoFFmpegException(e);
|
|
||||||
}
|
|
||||||
File exportLogFile = new File(Minecraft.getMinecraft().mcDataDir, "export.log");
|
File exportLogFile = new File(Minecraft.getMinecraft().mcDataDir, "export.log");
|
||||||
OutputStream exportLogOut = new TeeOutputStream(new FileOutputStream(exportLogFile), ffmpegLog);
|
OutputStream exportLogOut = new TeeOutputStream(new FileOutputStream(exportLogFile), ffmpegLog);
|
||||||
new StreamPipe(process.getInputStream(), exportLogOut).start();
|
new StreamPipe(process.getInputStream(), exportLogOut).start();
|
||||||
@@ -159,16 +152,6 @@ public class VideoWriter implements FrameConsumer<RGBFrame> {
|
|||||||
if (aborted) {
|
if (aborted) {
|
||||||
return;
|
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");
|
CrashReport report = CrashReport.makeCrashReport(t, "Exporting frame");
|
||||||
CrashReportCategory exportDetails = report.makeCategory("Export details");
|
CrashReportCategory exportDetails = report.makeCategory("Export details");
|
||||||
exportDetails.addCrashSection("Export command", settings.getExportCommand());
|
exportDetails.addCrashSection("Export command", settings.getExportCommand());
|
||||||
@@ -190,7 +173,7 @@ public class VideoWriter implements FrameConsumer<RGBFrame> {
|
|||||||
aborted = true;
|
aborted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getVideoFile() throws FFmpegStartupException {
|
public File getVideoFile() {
|
||||||
String log = ffmpegLog.toString();
|
String log = ffmpegLog.toString();
|
||||||
for (String line : log.split("\n")) {
|
for (String line : log.split("\n")) {
|
||||||
if (line.startsWith("Output #0")) {
|
if (line.startsWith("Output #0")) {
|
||||||
@@ -198,30 +181,6 @@ public class VideoWriter implements FrameConsumer<RGBFrame> {
|
|||||||
return new File(settings.getOutputFile().getParentFile(), fileName);
|
return new File(settings.getOutputFile().getParentFile(), fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new FFmpegStartupException(settings, log);
|
throw new IllegalStateException("No output file found.");
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,9 +75,9 @@ public class ODSFrameCapturer implements FrameCapturer<ODSOpenGlFrame> {
|
|||||||
linkState(1, "lightMapEnabled");
|
linkState(1, "lightMapEnabled");
|
||||||
linkState(2, "hurtTextureEnabled");
|
linkState(2, "hurtTextureEnabled");
|
||||||
final Program.Uniform uniform = shaderProgram.getUniformVariable("fogEnabled");
|
final Program.Uniform uniform = shaderProgram.getUniformVariable("fogEnabled");
|
||||||
previousFogState = GlStateManager.fogState.field_179049_a;
|
previousFogState = GlStateManager.fogState.fog;
|
||||||
uniform.set(previousFogState.currentState);
|
uniform.set(previousFogState.currentState);
|
||||||
GlStateManager.fogState.field_179049_a = new BooleanState(previousFogState.capability) {
|
GlStateManager.fogState.fog = new BooleanState(previousFogState.capability) {
|
||||||
@Override
|
@Override
|
||||||
public void setState(boolean state) {
|
public void setState(boolean state) {
|
||||||
super.setState(state);
|
super.setState(state);
|
||||||
@@ -135,7 +135,7 @@ public class ODSFrameCapturer implements FrameCapturer<ODSOpenGlFrame> {
|
|||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
GlStateManager.textureState[i].texture2DState = previousStates[i];
|
GlStateManager.textureState[i].texture2DState = previousStates[i];
|
||||||
}
|
}
|
||||||
GlStateManager.fogState.field_179049_a = previousFogState;
|
GlStateManager.fogState.fog = previousFogState;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CubicStereoFrameCapturer extends CubicPboOpenGlFrameCapturer {
|
private class CubicStereoFrameCapturer extends CubicPboOpenGlFrameCapturer {
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
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,11 +1,8 @@
|
|||||||
package com.replaymod.render.gui;
|
package com.replaymod.render.gui;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.common.util.concurrent.FutureCallback;
|
import com.google.common.util.concurrent.FutureCallback;
|
||||||
import com.google.common.util.concurrent.Futures;
|
import com.google.common.util.concurrent.Futures;
|
||||||
import com.replaymod.core.utils.Utils;
|
|
||||||
import com.replaymod.render.ReplayModRender;
|
import com.replaymod.render.ReplayModRender;
|
||||||
import com.replaymod.render.VideoWriter;
|
|
||||||
import com.replaymod.render.rendering.VideoRenderer;
|
import com.replaymod.render.rendering.VideoRenderer;
|
||||||
import com.replaymod.render.utils.RenderJob;
|
import com.replaymod.render.utils.RenderJob;
|
||||||
import com.replaymod.replay.ReplayHandler;
|
import com.replaymod.replay.ReplayHandler;
|
||||||
@@ -14,7 +11,6 @@ import com.replaymod.replaystudio.util.I18n;
|
|||||||
import de.johni0702.minecraft.gui.GuiRenderer;
|
import de.johni0702.minecraft.gui.GuiRenderer;
|
||||||
import de.johni0702.minecraft.gui.RenderInfo;
|
import de.johni0702.minecraft.gui.RenderInfo;
|
||||||
import de.johni0702.minecraft.gui.container.AbstractGuiClickableContainer;
|
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.GuiContainer;
|
||||||
import de.johni0702.minecraft.gui.container.GuiPanel;
|
import de.johni0702.minecraft.gui.container.GuiPanel;
|
||||||
import de.johni0702.minecraft.gui.container.GuiVerticalList;
|
import de.johni0702.minecraft.gui.container.GuiVerticalList;
|
||||||
@@ -29,10 +25,12 @@ import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
|||||||
import de.johni0702.minecraft.gui.utils.Colors;
|
import de.johni0702.minecraft.gui.utils.Colors;
|
||||||
import net.minecraft.client.gui.GuiErrorScreen;
|
import net.minecraft.client.gui.GuiErrorScreen;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
|
import net.minecraft.util.ReportedException;
|
||||||
import org.lwjgl.util.Dimension;
|
import org.lwjgl.util.Dimension;
|
||||||
import org.lwjgl.util.ReadableDimension;
|
import org.lwjgl.util.ReadableDimension;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.replaymod.render.ReplayModRender.LOGGER;
|
import static com.replaymod.render.ReplayModRender.LOGGER;
|
||||||
@@ -64,8 +62,7 @@ public class GuiRenderQueue extends AbstractGuiPopup<GuiRenderQueue> {
|
|||||||
renameButton, removeButton),
|
renameButton, removeButton),
|
||||||
closeButton);
|
closeButton);
|
||||||
|
|
||||||
private final AbstractGuiScreen container;
|
private final GuiContainer container;
|
||||||
private final ReplayHandler replayHandler;
|
|
||||||
private Entry selectedEntry;
|
private Entry selectedEntry;
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -87,10 +84,9 @@ public class GuiRenderQueue extends AbstractGuiPopup<GuiRenderQueue> {
|
|||||||
}).addElements(null, title, list, buttonPanel);
|
}).addElements(null, title, list, buttonPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuiRenderQueue(AbstractGuiScreen container, GuiRenderSettings guiRenderSettings, ReplayHandler replayHandler, Timeline timeline) {
|
public GuiRenderQueue(GuiContainer container, GuiRenderSettings guiRenderSettings, ReplayHandler replayHandler, Timeline timeline) {
|
||||||
super(container);
|
super(container);
|
||||||
this.container = container;
|
this.container = container;
|
||||||
this.replayHandler = replayHandler;
|
|
||||||
LOGGER.trace("Opening render queue popup");
|
LOGGER.trace("Opening render queue popup");
|
||||||
|
|
||||||
setBackgroundColor(Colors.DARK_TRANSPARENT);
|
setBackgroundColor(Colors.DARK_TRANSPARENT);
|
||||||
@@ -192,46 +188,30 @@ public class GuiRenderQueue extends AbstractGuiPopup<GuiRenderQueue> {
|
|||||||
|
|
||||||
renderButton.onClick(() -> {
|
renderButton.onClick(() -> {
|
||||||
LOGGER.trace("Render button clicked");
|
LOGGER.trace("Render button clicked");
|
||||||
processQueue(queue);
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
updateButtons();
|
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
|
@Override
|
||||||
public void open() {
|
public void open() {
|
||||||
super.open();
|
super.open();
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import com.google.gson.GsonBuilder;
|
|||||||
import com.google.gson.InstanceCreator;
|
import com.google.gson.InstanceCreator;
|
||||||
import com.replaymod.render.RenderSettings;
|
import com.replaymod.render.RenderSettings;
|
||||||
import com.replaymod.render.ReplayModRender;
|
import com.replaymod.render.ReplayModRender;
|
||||||
import com.replaymod.render.VideoWriter;
|
|
||||||
import com.replaymod.render.rendering.VideoRenderer;
|
import com.replaymod.render.rendering.VideoRenderer;
|
||||||
import com.replaymod.replay.ReplayHandler;
|
import com.replaymod.replay.ReplayHandler;
|
||||||
import com.replaymod.replaystudio.pathing.path.Timeline;
|
import com.replaymod.replaystudio.pathing.path.Timeline;
|
||||||
@@ -30,6 +29,7 @@ import de.johni0702.minecraft.gui.utils.Utils;
|
|||||||
import net.minecraft.client.gui.GuiErrorScreen;
|
import net.minecraft.client.gui.GuiErrorScreen;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
|
import net.minecraft.util.ReportedException;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
import net.minecraftforge.common.config.Property;
|
import net.minecraftforge.common.config.Property;
|
||||||
import org.lwjgl.util.Color;
|
import org.lwjgl.util.Color;
|
||||||
@@ -39,13 +39,11 @@ import org.lwjgl.util.ReadableDimension;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
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 class GuiRenderSettings extends GuiScreen implements Closeable {
|
||||||
public final GuiPanel contentPanel = new GuiPanel(this).setBackgroundColor(Colors.DARK_TRANSPARENT);
|
public final GuiPanel contentPanel = new GuiPanel(this).setBackgroundColor(Colors.DARK_TRANSPARENT);
|
||||||
public final GuiVerticalList settingsList = new GuiVerticalList(contentPanel).setDrawSlider(true);
|
public final GuiVerticalList settingsList = new GuiVerticalList(contentPanel).setDrawSlider(true);
|
||||||
@@ -201,21 +199,15 @@ public class GuiRenderSettings extends GuiScreen implements Closeable {
|
|||||||
try {
|
try {
|
||||||
VideoRenderer videoRenderer = new VideoRenderer(save(false), replayHandler, timeline);
|
VideoRenderer videoRenderer = new VideoRenderer(save(false), replayHandler, timeline);
|
||||||
videoRenderer.renderVideo();
|
videoRenderer.renderVideo();
|
||||||
} catch (VideoWriter.NoFFmpegException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.error("Rendering video:", e);
|
e.printStackTrace();
|
||||||
|
|
||||||
GuiErrorScreen errorScreen = new GuiErrorScreen(I18n.format("replaymod.gui.rendering.error.title"),
|
GuiErrorScreen errorScreen = new GuiErrorScreen(I18n.format("replaymod.gui.rendering.error.title"),
|
||||||
I18n.format("replaymod.gui.rendering.error.message"));
|
I18n.format("replaymod.gui.rendering.error.message"));
|
||||||
getMinecraft().displayGuiScreen(errorScreen);
|
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) {
|
} catch (Throwable t) {
|
||||||
error(LOGGER, GuiRenderSettings.this, CrashReport.makeCrashReport(t, "Rendering video"), () -> {});
|
CrashReport crashReport = CrashReport.makeCrashReport(t, "Rendering video");
|
||||||
display(); // Re-show the render settings gui and the new error popup
|
throw new ReportedException(crashReport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).setSize(100, 20).setI18nLabel("replaymod.gui.render");
|
}).setSize(100, 20).setI18nLabel("replaymod.gui.render");
|
||||||
|
|||||||
@@ -10,13 +10,13 @@ import net.minecraft.client.renderer.chunk.RenderChunk;
|
|||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.PriorityBlockingQueue;
|
||||||
|
|
||||||
public class ChunkLoadingRenderGlobal {
|
public class ChunkLoadingRenderGlobal {
|
||||||
|
|
||||||
private final RenderGlobal hooked;
|
private final RenderGlobal hooked;
|
||||||
private final ChunkRenderDispatcher renderDispatcher;
|
private final ChunkRenderDispatcher renderDispatcher;
|
||||||
private final JailingQueue<?> workerJailingQueue;
|
private final JailingQueue<ChunkCompileTaskGenerator> workerJailingQueue;
|
||||||
private final CustomChunkRenderWorker renderWorker;
|
private final CustomChunkRenderWorker renderWorker;
|
||||||
private int frame;
|
private int frame;
|
||||||
|
|
||||||
@@ -27,10 +27,10 @@ public class ChunkLoadingRenderGlobal {
|
|||||||
this.renderWorker = new CustomChunkRenderWorker(renderDispatcher, new RegionRenderCacheBuilder());
|
this.renderWorker = new CustomChunkRenderWorker(renderDispatcher, new RegionRenderCacheBuilder());
|
||||||
|
|
||||||
int workerThreads = renderDispatcher.listThreadedWorkers.size();
|
int workerThreads = renderDispatcher.listThreadedWorkers.size();
|
||||||
BlockingQueue<Object> queueChunkUpdates = renderDispatcher.queueChunkUpdates;
|
PriorityBlockingQueue<ChunkCompileTaskGenerator> queueChunkUpdates = renderDispatcher.queueChunkUpdates;
|
||||||
workerJailingQueue = new JailingQueue<>(queueChunkUpdates);
|
workerJailingQueue = new JailingQueue<>(queueChunkUpdates);
|
||||||
renderDispatcher.queueChunkUpdates = workerJailingQueue;
|
renderDispatcher.queueChunkUpdates = workerJailingQueue;
|
||||||
ChunkCompileTaskGenerator element = new ChunkCompileTaskGenerator(null, null);
|
ChunkCompileTaskGenerator element = new ChunkCompileTaskGenerator(null, null, 0);
|
||||||
element.finish();
|
element.finish();
|
||||||
for (int i = 0; i < workerThreads; i++) {
|
for (int i = 0; i < workerThreads; i++) {
|
||||||
queueChunkUpdates.add(element);
|
queueChunkUpdates.add(element);
|
||||||
@@ -51,7 +51,6 @@ public class ChunkLoadingRenderGlobal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void updateChunks() {
|
public void updateChunks() {
|
||||||
while (renderDispatcher.runChunkUploads(0)) {
|
while (renderDispatcher.runChunkUploads(0)) {
|
||||||
hooked.displayListEntitiesDirty = true;
|
hooked.displayListEntitiesDirty = true;
|
||||||
@@ -59,7 +58,7 @@ public class ChunkLoadingRenderGlobal {
|
|||||||
|
|
||||||
while (!renderDispatcher.queueChunkUpdates.isEmpty()) {
|
while (!renderDispatcher.queueChunkUpdates.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
renderWorker.processTask((ChunkCompileTaskGenerator) renderDispatcher.queueChunkUpdates.poll());
|
renderWorker.processTask(renderDispatcher.queueChunkUpdates.poll());
|
||||||
} catch (InterruptedException ignored) { }
|
} catch (InterruptedException ignored) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +68,7 @@ public class ChunkLoadingRenderGlobal {
|
|||||||
|
|
||||||
renderDispatcher.updateChunkNow(renderchunk);
|
renderDispatcher.updateChunkNow(renderchunk);
|
||||||
|
|
||||||
renderchunk.setNeedsUpdate(false);
|
renderchunk.clearNeedsUpdate();
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.coremedia.iso.IsoFile;
|
|||||||
import com.coremedia.iso.boxes.*;
|
import com.coremedia.iso.boxes.*;
|
||||||
import com.google.common.primitives.Bytes;
|
import com.google.common.primitives.Bytes;
|
||||||
import com.googlecode.mp4parser.BasicContainer;
|
import com.googlecode.mp4parser.BasicContainer;
|
||||||
|
import net.minecraftforge.fml.common.FMLLog;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
@@ -12,8 +13,6 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
import static com.replaymod.render.ReplayModRender.LOGGER;
|
|
||||||
|
|
||||||
public class MetadataInjector {
|
public class MetadataInjector {
|
||||||
|
|
||||||
private static final String STITCHING_SOFTWARE = "Minecraft ReplayMod";
|
private static final String STITCHING_SOFTWARE = "Minecraft ReplayMod";
|
||||||
@@ -97,7 +96,7 @@ public class MetadataInjector {
|
|||||||
videoFileOutputStream = new FileOutputStream(videoFile);
|
videoFileOutputStream = new FileOutputStream(videoFile);
|
||||||
tempIsoFile.getBox(videoFileOutputStream.getChannel());
|
tempIsoFile.getBox(videoFileOutputStream.getChannel());
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
LOGGER.error("360 Degree Metadata couldn't be injected", e);
|
FMLLog.getLogger().error("360 Degree Metadata couldn't be injected", e);
|
||||||
} finally {
|
} finally {
|
||||||
IOUtils.closeQuietly(tempIsoFile);
|
IOUtils.closeQuietly(tempIsoFile);
|
||||||
IOUtils.closeQuietly(videoFileOutputStream);
|
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;func_180434_a(Lnet/minecraft/client/renderer/WorldRenderer;Lnet/minecraft/entity/Entity;FFFFFF)V"))
|
|
||||||
private void renderNormalParticle(EntityFX fx, WorldRenderer worldRenderer, Entity view, float partialTicks,
|
|
||||||
float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
|
||||||
renderParticle(fx, worldRenderer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "renderLitParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/EntityFX;func_180434_a(Lnet/minecraft/client/renderer/WorldRenderer;Lnet/minecraft/entity/Entity;FFFFFF)V"))
|
|
||||||
private void renderLitParticle(EntityFX fx, WorldRenderer worldRenderer, Entity view, float partialTicks,
|
|
||||||
float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
|
||||||
renderParticle(fx, worldRenderer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderParticle(EntityFX fx, WorldRenderer worldRenderer, Entity view, float partialTicks,
|
|
||||||
float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
|
||||||
EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) Minecraft.getMinecraft().entityRenderer).replayModRender_getHandler();
|
|
||||||
if (handler != null && handler.omnidirectional) {
|
|
||||||
// Align all particles towards the camera
|
|
||||||
double dx = fx.prevPosX + (fx.posX - fx.prevPosX) * partialTicks - view.posX;
|
|
||||||
double dy = fx.prevPosY + (fx.posY - fx.prevPosY) * partialTicks - view.posY;
|
|
||||||
double dz = fx.prevPosZ + (fx.posZ - fx.prevPosZ) * partialTicks - view.posZ;
|
|
||||||
double pitch = -Math.atan2(dy, Math.sqrt(dx * dx + dz * dz));
|
|
||||||
double yaw = -Math.atan2(dx, dz);
|
|
||||||
|
|
||||||
rotX = (float) Math.cos(yaw);
|
|
||||||
rotZ = (float) Math.sin(yaw);
|
|
||||||
rotXZ = (float) Math.cos(pitch);
|
|
||||||
|
|
||||||
rotYZ = (float) (-rotZ * Math.sin(pitch));
|
|
||||||
rotXY = (float) (rotX * Math.sin(pitch));
|
|
||||||
}
|
|
||||||
fx.func_180434_a(worldRenderer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -12,7 +12,7 @@ import net.minecraft.client.renderer.RenderGlobal;
|
|||||||
import net.minecraft.client.settings.GameSettings;
|
import net.minecraft.client.settings.GameSettings;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
import org.lwjgl.util.ReadableColor;
|
import org.lwjgl.util.ReadableColor;
|
||||||
import org.lwjgl.util.glu.Project;
|
import org.lwjgl.util.glu.Project;
|
||||||
@@ -118,10 +118,10 @@ public abstract class MixinEntityRenderer implements EntityRendererHandler.IEnti
|
|||||||
@Shadow
|
@Shadow
|
||||||
public abstract void renderHand(float partialTicks, int renderPass);
|
public abstract void renderHand(float partialTicks, int renderPass);
|
||||||
|
|
||||||
@Redirect(method = "renderWorldPass", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderGlobal;drawSelectionBox(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/util/MovingObjectPosition;IF)V"))
|
@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, MovingObjectPosition mop, int alwaysZero, float partialTicks) {
|
private void replayModRender_drawSelectionBox(RenderGlobal instance, EntityPlayer player, RayTraceResult rtr, int alwaysZero, float partialTicks) {
|
||||||
if (replayModRender_handler == null) {
|
if (replayModRender_handler == null) {
|
||||||
instance.drawSelectionBox(player, mop, alwaysZero, partialTicks);
|
instance.drawSelectionBox(player, rtr, alwaysZero, partialTicks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
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.VertexBuffer;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
@Mixin(ParticleManager.class)
|
||||||
|
public abstract class MixinParticleManager {
|
||||||
|
@Redirect(method = "renderParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/Particle;renderParticle(Lnet/minecraft/client/renderer/VertexBuffer;Lnet/minecraft/entity/Entity;FFFFFF)V"))
|
||||||
|
private void renderNormalParticle(Particle particle, VertexBuffer vertexBuffer, Entity view, float partialTicks,
|
||||||
|
float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||||
|
renderParticle(particle, vertexBuffer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "renderLitParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/Particle;renderParticle(Lnet/minecraft/client/renderer/VertexBuffer;Lnet/minecraft/entity/Entity;FFFFFF)V"))
|
||||||
|
private void renderLitParticle(Particle particle, VertexBuffer vertexBuffer, Entity view, float partialTicks,
|
||||||
|
float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||||
|
renderParticle(particle, vertexBuffer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderParticle(Particle particle, VertexBuffer vertexBuffer, Entity view, float partialTicks,
|
||||||
|
float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||||
|
EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) Minecraft.getMinecraft().entityRenderer).replayModRender_getHandler();
|
||||||
|
if (handler != null && handler.omnidirectional) {
|
||||||
|
// Align all particles towards the camera
|
||||||
|
double dx = particle.prevPosX + (particle.posX - particle.prevPosX) * partialTicks - view.posX;
|
||||||
|
double dy = particle.prevPosY + (particle.posY - particle.prevPosY) * partialTicks - view.posY;
|
||||||
|
double dz = particle.prevPosZ + (particle.posZ - particle.prevPosZ) * partialTicks - view.posZ;
|
||||||
|
double pitch = -Math.atan2(dy, Math.sqrt(dx * dx + dz * dz));
|
||||||
|
double yaw = -Math.atan2(dx, dz);
|
||||||
|
|
||||||
|
rotX = (float) Math.cos(yaw);
|
||||||
|
rotZ = (float) Math.sin(yaw);
|
||||||
|
rotXZ = (float) Math.cos(pitch);
|
||||||
|
|
||||||
|
rotYZ = (float) (-rotZ * Math.sin(pitch));
|
||||||
|
rotXY = (float) (rotX * Math.sin(pitch));
|
||||||
|
}
|
||||||
|
particle.renderParticle(vertexBuffer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,15 +7,14 @@ import net.minecraft.entity.Entity;
|
|||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
@Mixin(Render.class)
|
@Mixin(Render.class)
|
||||||
public abstract class MixinRender {
|
public abstract class MixinRender {
|
||||||
@Inject(method = "canRenderName", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "renderLivingLabel", at = @At("HEAD"), cancellable = true)
|
||||||
private void replayModRender_areAllNamesHidden(Entity entity, CallbackInfoReturnable<Boolean> ci) {
|
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();
|
EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) Minecraft.getMinecraft().entityRenderer).replayModRender_getHandler();
|
||||||
if (handler != null && !handler.getSettings().isRenderNameTags()) {
|
if (handler != null && !handler.getSettings().isRenderNameTags()) {
|
||||||
ci.setReturnValue(false);
|
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,16 +3,13 @@ package com.replaymod.render.mixin;
|
|||||||
import com.replaymod.render.hooks.ChunkLoadingRenderGlobal;
|
import com.replaymod.render.hooks.ChunkLoadingRenderGlobal;
|
||||||
import net.minecraft.client.renderer.RenderGlobal;
|
import net.minecraft.client.renderer.RenderGlobal;
|
||||||
import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher;
|
import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher;
|
||||||
import net.minecraft.client.renderer.chunk.RenderChunk;
|
|
||||||
import net.minecraft.client.renderer.culling.ICamera;
|
import net.minecraft.client.renderer.culling.ICamera;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.BlockPos;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
||||||
|
|
||||||
@Mixin(RenderGlobal.class)
|
@Mixin(RenderGlobal.class)
|
||||||
public abstract class MixinRenderGlobal {
|
public abstract class MixinRenderGlobal {
|
||||||
@@ -37,6 +34,8 @@ public abstract class MixinRenderGlobal {
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
setupTerrain(viewEntity, partialTicks, camera, replayModRender_hook.nextFrameId(), playerSpectator);
|
setupTerrain(viewEntity, partialTicks, camera, replayModRender_hook.nextFrameId(), playerSpectator);
|
||||||
|
|
||||||
|
replayModRender_hook.updateChunks();
|
||||||
} while (displayListEntitiesDirty);
|
} while (displayListEntitiesDirty);
|
||||||
|
|
||||||
displayListEntitiesDirty = true;
|
displayListEntitiesDirty = true;
|
||||||
@@ -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)
|
@Inject(method = "updateChunks", at = @At("HEAD"), cancellable = true)
|
||||||
public void replayModRender_updateChunks(long finishTimeNano, CallbackInfo ci) {
|
public void replayModRender_updateChunks(long finishTimeNano, CallbackInfo ci) {
|
||||||
if (replayModRender_hook != null) {
|
if (replayModRender_hook != null) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
|||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
@Mixin(RenderManager.class)
|
@Mixin(RenderManager.class)
|
||||||
public abstract class MixinRenderManager {
|
public abstract class MixinRenderManager {
|
||||||
@@ -19,7 +19,7 @@ public abstract class MixinRenderManager {
|
|||||||
private float playerViewY;
|
private float playerViewY;
|
||||||
|
|
||||||
@Inject(method = "doRenderEntity", at = @At("HEAD"))
|
@Inject(method = "doRenderEntity", at = @At("HEAD"))
|
||||||
private void replayModRender_reorientForCubicRendering(Entity entity, double dx, double dy, double dz, float iDoNotKnow, float partialTicks, boolean iDoNotCare, 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();
|
EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) Minecraft.getMinecraft().entityRenderer).replayModRender_getHandler();
|
||||||
if (handler != null && handler.omnidirectional) {
|
if (handler != null && handler.omnidirectional) {
|
||||||
double pitch = -Math.atan2(dy, Math.sqrt(dx * dx + dz * dz));
|
double pitch = -Math.atan2(dy, Math.sqrt(dx * dx + dz * dz));
|
||||||
|
|||||||
@@ -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,5 @@
|
|||||||
package com.replaymod.render.rendering;
|
package com.replaymod.render.rendering;
|
||||||
|
|
||||||
import com.replaymod.core.ReplayMod;
|
|
||||||
import com.replaymod.pathing.player.AbstractTimelinePlayer;
|
import com.replaymod.pathing.player.AbstractTimelinePlayer;
|
||||||
import com.replaymod.pathing.player.ReplayTimer;
|
import com.replaymod.pathing.player.ReplayTimer;
|
||||||
import com.replaymod.pathing.properties.TimestampProperty;
|
import com.replaymod.pathing.properties.TimestampProperty;
|
||||||
@@ -14,17 +13,18 @@ import com.replaymod.render.gui.GuiRenderingDone;
|
|||||||
import com.replaymod.render.gui.GuiVideoRenderer;
|
import com.replaymod.render.gui.GuiVideoRenderer;
|
||||||
import com.replaymod.render.hooks.ChunkLoadingRenderGlobal;
|
import com.replaymod.render.hooks.ChunkLoadingRenderGlobal;
|
||||||
import com.replaymod.render.metadata.MetadataInjector;
|
import com.replaymod.render.metadata.MetadataInjector;
|
||||||
|
import com.replaymod.render.utils.SoundHandler;
|
||||||
import com.replaymod.replay.ReplayHandler;
|
import com.replaymod.replay.ReplayHandler;
|
||||||
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
||||||
import com.replaymod.replaystudio.pathing.path.Path;
|
import com.replaymod.replaystudio.pathing.path.Path;
|
||||||
import com.replaymod.replaystudio.pathing.path.Timeline;
|
import com.replaymod.replaystudio.pathing.path.Timeline;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.audio.SoundCategory;
|
|
||||||
import net.minecraft.client.gui.ScaledResolution;
|
import net.minecraft.client.gui.ScaledResolution;
|
||||||
import net.minecraft.client.renderer.OpenGlHelper;
|
import net.minecraft.client.renderer.OpenGlHelper;
|
||||||
import net.minecraft.client.shader.Framebuffer;
|
import net.minecraft.client.shader.Framebuffer;
|
||||||
|
import net.minecraft.util.SoundCategory;
|
||||||
import net.minecraft.util.Timer;
|
import net.minecraft.util.Timer;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import org.lwjgl.input.Mouse;
|
import org.lwjgl.input.Mouse;
|
||||||
import org.lwjgl.opengl.Display;
|
import org.lwjgl.opengl.Display;
|
||||||
import org.lwjgl.util.Dimension;
|
import org.lwjgl.util.Dimension;
|
||||||
@@ -39,7 +39,6 @@ import java.util.concurrent.Future;
|
|||||||
import java.util.concurrent.FutureTask;
|
import java.util.concurrent.FutureTask;
|
||||||
|
|
||||||
import static com.google.common.collect.Iterables.getLast;
|
import static com.google.common.collect.Iterables.getLast;
|
||||||
import static com.replaymod.render.ReplayModRender.LOGGER;
|
|
||||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||||
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
|
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
|
||||||
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
|
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
|
||||||
@@ -55,7 +54,7 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
private int fps;
|
private int fps;
|
||||||
private boolean mouseWasGrabbed;
|
private boolean mouseWasGrabbed;
|
||||||
private boolean debugInfoWasShown;
|
private boolean debugInfoWasShown;
|
||||||
private Map originalSoundLevels;
|
private Map<SoundCategory, Float> originalSoundLevels;
|
||||||
|
|
||||||
private TimelinePlayer timelinePlayer;
|
private TimelinePlayer timelinePlayer;
|
||||||
private Future<Void> timelinePlayerFuture;
|
private Future<Void> timelinePlayerFuture;
|
||||||
@@ -67,7 +66,6 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
private final GuiVideoRenderer gui;
|
private final GuiVideoRenderer gui;
|
||||||
private boolean paused;
|
private boolean paused;
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
private volatile Throwable failureCause;
|
|
||||||
|
|
||||||
private Framebuffer guiFramebuffer;
|
private Framebuffer guiFramebuffer;
|
||||||
private int displayWidth, displayHeight;
|
private int displayWidth, displayHeight;
|
||||||
@@ -78,7 +76,7 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
this.timeline = timeline;
|
this.timeline = timeline;
|
||||||
this.gui = new GuiVideoRenderer(this);
|
this.gui = new GuiVideoRenderer(this);
|
||||||
this.renderingPipeline = Pipelines.newPipeline(settings.getRenderMethod(), this,
|
this.renderingPipeline = Pipelines.newPipeline(settings.getRenderMethod(), this,
|
||||||
videoWriter = new VideoWriter(this) {
|
videoWriter = new VideoWriter(settings) {
|
||||||
@Override
|
@Override
|
||||||
public void consume(RGBFrame frame) {
|
public void consume(RGBFrame frame) {
|
||||||
gui.updatePreview(frame);
|
gui.updatePreview(frame);
|
||||||
@@ -91,8 +89,8 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
* Render this video.
|
* Render this video.
|
||||||
* @return {@code true} if rendering was successful, {@code false} if the user aborted rendering (or the window was closed)
|
* @return {@code true} if rendering was successful, {@code false} if the user aborted rendering (or the window was closed)
|
||||||
*/
|
*/
|
||||||
public boolean renderVideo() throws Throwable {
|
public boolean renderVideo() {
|
||||||
FMLCommonHandler.instance().bus().post(new ReplayRenderEvent.Pre(this));
|
MinecraftForge.EVENT_BUS.post(new ReplayRenderEvent.Pre(this));
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
@@ -138,11 +136,7 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
|
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
FMLCommonHandler.instance().bus().post(new ReplayRenderEvent.Post(this));
|
MinecraftForge.EVENT_BUS.post(new ReplayRenderEvent.Post(this));
|
||||||
|
|
||||||
if (failureCause != null) {
|
|
||||||
throw failureCause;
|
|
||||||
}
|
|
||||||
|
|
||||||
return !cancelled;
|
return !cancelled;
|
||||||
}
|
}
|
||||||
@@ -202,9 +196,9 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
for (SoundCategory category : SoundCategory.values()) {
|
for (SoundCategory category : SoundCategory.values()) {
|
||||||
mutedSounds.put(category, 0f);
|
mutedSounds.put(category, 0f);
|
||||||
}
|
}
|
||||||
originalSoundLevels = mc.gameSettings.mapSoundLevels;
|
originalSoundLevels = mc.gameSettings.soundLevels;
|
||||||
mutedSounds.put(SoundCategory.MASTER, (Float) originalSoundLevels.get(SoundCategory.MASTER));
|
mutedSounds.put(SoundCategory.MASTER, originalSoundLevels.get(SoundCategory.MASTER));
|
||||||
mc.gameSettings.mapSoundLevels = mutedSounds;
|
mc.gameSettings.soundLevels = mutedSounds;
|
||||||
|
|
||||||
fps = settings.getFramesPerSecond();
|
fps = settings.getFramesPerSecond();
|
||||||
|
|
||||||
@@ -225,9 +219,6 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
|
|
||||||
updateDisplaySize();
|
updateDisplaySize();
|
||||||
|
|
||||||
ScaledResolution scaled = new ScaledResolution(mc, displayWidth, displayHeight);
|
|
||||||
gui.toMinecraft().setWorldAndResolution(mc, scaled.getScaledWidth(), scaled.getScaledHeight());
|
|
||||||
|
|
||||||
chunkLoadingRenderGlobal = new ChunkLoadingRenderGlobal(mc.renderGlobal);
|
chunkLoadingRenderGlobal = new ChunkLoadingRenderGlobal(mc.renderGlobal);
|
||||||
|
|
||||||
// Set up our own framebuffer to render the GUI to
|
// Set up our own framebuffer to render the GUI to
|
||||||
@@ -248,21 +239,15 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
if (mouseWasGrabbed) {
|
if (mouseWasGrabbed) {
|
||||||
mc.mouseHelper.grabMouseCursor();
|
mc.mouseHelper.grabMouseCursor();
|
||||||
}
|
}
|
||||||
mc.gameSettings.mapSoundLevels = originalSoundLevels;
|
mc.gameSettings.soundLevels = originalSoundLevels;
|
||||||
mc.displayGuiScreen(null);
|
mc.displayGuiScreen(null);
|
||||||
if (chunkLoadingRenderGlobal != null) {
|
if (chunkLoadingRenderGlobal != null) {
|
||||||
chunkLoadingRenderGlobal.uninstall();
|
chunkLoadingRenderGlobal.uninstall();
|
||||||
}
|
}
|
||||||
|
|
||||||
ReplayMod.soundHandler.playRenderSuccessSound();
|
new SoundHandler().playRenderSuccessSound();
|
||||||
|
|
||||||
try {
|
new GuiRenderingDone(ReplayModRender.instance, videoWriter.getVideoFile(), totalFrames, settings).display();
|
||||||
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
|
// Finally, resize the Minecraft framebuffer to the actual width/height of the window
|
||||||
mc.resize(displayWidth, displayHeight);
|
mc.resize(displayWidth, displayHeight);
|
||||||
@@ -298,7 +283,7 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
|
|
||||||
mc.entityRenderer.setupOverlayRendering();
|
mc.entityRenderer.setupOverlayRendering();
|
||||||
|
|
||||||
ScaledResolution scaled = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
ScaledResolution scaled = new ScaledResolution(mc);
|
||||||
gui.toMinecraft().setWorldAndResolution(mc, scaled.getScaledWidth(), scaled.getScaledHeight());
|
gui.toMinecraft().setWorldAndResolution(mc, scaled.getScaledWidth(), scaled.getScaledHeight());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -338,7 +323,7 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (paused && !hasFailed());
|
} while (paused);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean displaySizeChanged() {
|
private boolean displaySizeChanged() {
|
||||||
@@ -379,20 +364,6 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
renderingPipeline.cancel();
|
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 {
|
private class TimelinePlayer extends AbstractTimelinePlayer {
|
||||||
public TimelinePlayer(ReplayHandler replayHandler) {
|
public TimelinePlayer(ReplayHandler replayHandler) {
|
||||||
super(replayHandler);
|
super(replayHandler);
|
||||||
|
|||||||
@@ -2,15 +2,18 @@ package com.replaymod.render.utils;
|
|||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Collection;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.PriorityBlockingQueue;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class JailingQueue<T> extends AbstractQueue<T> implements BlockingQueue<T> {
|
public class JailingQueue<T> extends PriorityBlockingQueue<T> {
|
||||||
private final BlockingQueue<T> delegate;
|
private final PriorityBlockingQueue<T> delegate;
|
||||||
private final Set<Thread> jailed = new HashSet<Thread>();
|
private final Set<Thread> jailed = new HashSet<Thread>();
|
||||||
|
|
||||||
public JailingQueue(BlockingQueue<T> delegate) {
|
public JailingQueue(PriorityBlockingQueue<T> delegate) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,13 +62,13 @@ public class JailingQueue<T> extends AbstractQueue<T> implements BlockingQueue<T
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void put(T t) throws InterruptedException {
|
public void put(T t) {
|
||||||
tryAccess();
|
tryAccess();
|
||||||
delegate.put(t);
|
delegate.put(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean offer(T t, long timeout, TimeUnit unit) throws InterruptedException {
|
public boolean offer(T t, long timeout, TimeUnit unit) {
|
||||||
tryAccess();
|
tryAccess();
|
||||||
return delegate.offer(t, timeout, unit);
|
return delegate.offer(t, timeout, unit);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import java.io.InputStream;
|
|||||||
|
|
||||||
public class SoundHandler {
|
public class SoundHandler {
|
||||||
|
|
||||||
private final ResourceLocation successSoundLocation = new ResourceLocation("replaymod", "render_success.wav");
|
private final ResourceLocation successSoundLocation = new ResourceLocation("replaymod", "renderSuccess.wav");
|
||||||
|
|
||||||
public void playRenderSuccessSound() {
|
public void playRenderSuccessSound() {
|
||||||
playSound(successSoundLocation);
|
playSound(successSoundLocation);
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ public class InputReplayTimer extends WrappedTimer {
|
|||||||
|
|
||||||
// Following are a ton of vanilla keyboard shortcuts, some are removed as they're useless in the
|
// Following are a ton of vanilla keyboard shortcuts, some are removed as they're useless in the
|
||||||
// replay viewer as of now
|
// replay viewer as of now
|
||||||
|
// TODO Update maybe add new key bindings
|
||||||
// TODO: Translate magic values to Keyboard.KEY_ constants
|
// TODO: Translate magic values to Keyboard.KEY_ constants
|
||||||
|
|
||||||
if (key == 32 && Keyboard.isKeyDown(61) && mc.ingameGUI != null) {
|
if (key == 32 && Keyboard.isKeyDown(61) && mc.ingameGUI != null) {
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ import javax.imageio.ImageIO;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Queue;
|
|
||||||
import java.util.concurrent.FutureTask;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
@Getter
|
@Getter
|
||||||
@@ -45,7 +43,7 @@ public class NoGuiScreenshot {
|
|||||||
mc.getFramebuffer().bindFramebuffer(true);
|
mc.getFramebuffer().bindFramebuffer(true);
|
||||||
GlStateManager.enableTexture2D();
|
GlStateManager.enableTexture2D();
|
||||||
|
|
||||||
mc.entityRenderer.updateCameraAndRender(mc.timer.renderPartialTicks);
|
mc.entityRenderer.updateCameraAndRender(mc.timer.renderPartialTicks, System.nanoTime());
|
||||||
|
|
||||||
mc.getFramebuffer().unbindFramebuffer();
|
mc.getFramebuffer().unbindFramebuffer();
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
@@ -101,9 +99,7 @@ public class NoGuiScreenshot {
|
|||||||
// of the game loop. We cannot use the addScheduledTask method as it'll run the task if called
|
// of the game loop. We cannot use the addScheduledTask method as it'll run the task if called
|
||||||
// from the minecraft thread which is exactly what we want to avoid.
|
// from the minecraft thread which is exactly what we want to avoid.
|
||||||
synchronized (mc.scheduledTasks) {
|
synchronized (mc.scheduledTasks) {
|
||||||
@SuppressWarnings("unchecked")
|
mc.scheduledTasks.add(ListenableFutureTask.create(runnable, null));
|
||||||
Queue<FutureTask> queue = mc.scheduledTasks;
|
|
||||||
queue.add(ListenableFutureTask.create(runnable, null));
|
|
||||||
}
|
}
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import net.minecraft.entity.Entity;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.network.EnumPacketDirection;
|
import net.minecraft.network.EnumPacketDirection;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
|
||||||
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher;
|
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher;
|
||||||
import org.lwjgl.opengl.Display;
|
import org.lwjgl.opengl.Display;
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ public class ReplayHandler {
|
|||||||
Preconditions.checkState(mc.isCallingFromMinecraftThread(), "Must be called from Minecraft thread.");
|
Preconditions.checkState(mc.isCallingFromMinecraftThread(), "Must be called from Minecraft thread.");
|
||||||
this.replayFile = replayFile;
|
this.replayFile = replayFile;
|
||||||
|
|
||||||
FMLCommonHandler.instance().bus().post(new ReplayOpenEvent.Pre(this));
|
MinecraftForge.EVENT_BUS.post(new ReplayOpenEvent.Pre(this));
|
||||||
|
|
||||||
markers = new ArrayList<>(replayFile.getMarkers().or(Collections.emptySet()));
|
markers = new ArrayList<>(replayFile.getMarkers().or(Collections.emptySet()));
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ public class ReplayHandler {
|
|||||||
overlay = new GuiReplayOverlay(this);
|
overlay = new GuiReplayOverlay(this);
|
||||||
overlay.setVisible(true);
|
overlay.setVisible(true);
|
||||||
|
|
||||||
FMLCommonHandler.instance().bus().post(new ReplayOpenEvent.Post(this));
|
MinecraftForge.EVENT_BUS.post(new ReplayOpenEvent.Post(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void restartedReplay() {
|
void restartedReplay() {
|
||||||
@@ -101,7 +101,7 @@ public class ReplayHandler {
|
|||||||
public void endReplay() throws IOException {
|
public void endReplay() throws IOException {
|
||||||
Preconditions.checkState(mc.isCallingFromMinecraftThread(), "Must be called from Minecraft thread.");
|
Preconditions.checkState(mc.isCallingFromMinecraftThread(), "Must be called from Minecraft thread.");
|
||||||
|
|
||||||
FMLCommonHandler.instance().bus().post(new ReplayCloseEvent.Pre(this));
|
MinecraftForge.EVENT_BUS.post(new ReplayCloseEvent.Pre(this));
|
||||||
|
|
||||||
replaySender.terminateReplay();
|
replaySender.terminateReplay();
|
||||||
|
|
||||||
@@ -124,9 +124,7 @@ public class ReplayHandler {
|
|||||||
|
|
||||||
ReplayModReplay.instance.replayHandler = null;
|
ReplayModReplay.instance.replayHandler = null;
|
||||||
|
|
||||||
mc.displayGuiScreen(null);
|
MinecraftForge.EVENT_BUS.post(new ReplayCloseEvent.Post(this));
|
||||||
|
|
||||||
FMLCommonHandler.instance().bus().post(new ReplayCloseEvent.Post(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setup() {
|
private void setup() {
|
||||||
@@ -316,7 +314,7 @@ public class ReplayHandler {
|
|||||||
mc.getFramebuffer().bindFramebuffer(true);
|
mc.getFramebuffer().bindFramebuffer(true);
|
||||||
mc.entityRenderer.setupOverlayRendering();
|
mc.entityRenderer.setupOverlayRendering();
|
||||||
|
|
||||||
ScaledResolution resolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
ScaledResolution resolution = new ScaledResolution(mc);
|
||||||
guiScreen.setWorldAndResolution(mc, resolution.getScaledWidth(), resolution.getScaledHeight());
|
guiScreen.setWorldAndResolution(mc, resolution.getScaledWidth(), resolution.getScaledHeight());
|
||||||
guiScreen.drawScreen(0, 0, 0);
|
guiScreen.drawScreen(0, 0, 0);
|
||||||
|
|
||||||
@@ -333,10 +331,8 @@ public class ReplayHandler {
|
|||||||
replaySender.setAsyncMode(true);
|
replaySender.setAsyncMode(true);
|
||||||
replaySender.setReplaySpeed(0);
|
replaySender.setReplaySpeed(0);
|
||||||
|
|
||||||
mc.getNetHandler().getNetworkManager().processReceivedPackets();
|
mc.getConnection().getNetworkManager().processReceivedPackets();
|
||||||
@SuppressWarnings("unchecked")
|
for (Entity entity : mc.theWorld.loadedEntityList) {
|
||||||
List<Entity> entities = (List<Entity>) mc.theWorld.loadedEntityList;
|
|
||||||
for (Entity entity : entities) {
|
|
||||||
if (entity instanceof EntityOtherPlayerMP) {
|
if (entity instanceof EntityOtherPlayerMP) {
|
||||||
EntityOtherPlayerMP e = (EntityOtherPlayerMP) entity;
|
EntityOtherPlayerMP e = (EntityOtherPlayerMP) entity;
|
||||||
e.setPosition(e.otherPlayerMPX, e.otherPlayerMPY, e.otherPlayerMPZ);
|
e.setPosition(e.otherPlayerMPX, e.otherPlayerMPY, e.otherPlayerMPZ);
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import java.util.Optional;
|
|||||||
@Mod(modid = ReplayModReplay.MOD_ID,
|
@Mod(modid = ReplayModReplay.MOD_ID,
|
||||||
version = "@MOD_VERSION@",
|
version = "@MOD_VERSION@",
|
||||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||||
acceptableRemoteVersions = "*",
|
|
||||||
useMetadata = true)
|
useMetadata = true)
|
||||||
public class ReplayModReplay {
|
public class ReplayModReplay {
|
||||||
public static final String MOD_ID = "replaymod-replay";
|
public static final String MOD_ID = "replaymod-replay";
|
||||||
@@ -47,7 +46,7 @@ public class ReplayModReplay {
|
|||||||
|
|
||||||
private final CameraControllerRegistry cameraControllerRegistry = new CameraControllerRegistry();
|
private final CameraControllerRegistry cameraControllerRegistry = new CameraControllerRegistry();
|
||||||
|
|
||||||
public static Logger LOGGER;
|
private Logger logger;
|
||||||
|
|
||||||
protected ReplayHandler replayHandler;
|
protected ReplayHandler replayHandler;
|
||||||
|
|
||||||
@@ -57,7 +56,7 @@ public class ReplayModReplay {
|
|||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void preInit(FMLPreInitializationEvent event) {
|
public void preInit(FMLPreInitializationEvent event) {
|
||||||
LOGGER = event.getModLog();
|
logger = event.getModLog();
|
||||||
core = ReplayMod.instance;
|
core = ReplayMod.instance;
|
||||||
|
|
||||||
core.getSettingsRegistry().register(Setting.class);
|
core.getSettingsRegistry().register(Setting.class);
|
||||||
@@ -181,9 +180,6 @@ public class ReplayModReplay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void startReplay(ReplayFile replayFile, boolean checkModCompat) throws IOException {
|
public void startReplay(ReplayFile replayFile, boolean checkModCompat) throws IOException {
|
||||||
if (replayHandler != null) {
|
|
||||||
replayHandler.endReplay();
|
|
||||||
}
|
|
||||||
if (checkModCompat) {
|
if (checkModCompat) {
|
||||||
ModCompat.ModInfoDifference modDifference = new ModCompat.ModInfoDifference(replayFile.getModInfo());
|
ModCompat.ModInfoDifference modDifference = new ModCompat.ModInfoDifference(replayFile.getModInfo());
|
||||||
if (!modDifference.getMissing().isEmpty() || !modDifference.getDiffering().isEmpty()) {
|
if (!modDifference.getMissing().isEmpty() || !modDifference.getDiffering().isEmpty()) {
|
||||||
@@ -199,7 +195,7 @@ public class ReplayModReplay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Logger getLogger() {
|
public Logger getLogger() {
|
||||||
return LOGGER;
|
return logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CameraControllerRegistry getCameraControllerRegistry() {
|
public CameraControllerRegistry getCameraControllerRegistry() {
|
||||||
|
|||||||
@@ -2,28 +2,32 @@ package com.replaymod.replay;
|
|||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import com.replaymod.core.ReplayMod;
|
import com.google.common.util.concurrent.ListenableFutureTask;
|
||||||
import com.replaymod.core.utils.Restrictions;
|
import com.replaymod.core.utils.Restrictions;
|
||||||
import com.replaymod.replay.camera.CameraEntity;
|
import com.replaymod.replay.camera.CameraEntity;
|
||||||
import com.replaymod.replaystudio.replay.ReplayFile;
|
import com.replaymod.replaystudio.replay.ReplayFile;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import io.netty.channel.ChannelDuplexHandler;
|
|
||||||
import io.netty.channel.ChannelHandler.Sharable;
|
import io.netty.channel.ChannelHandler.Sharable;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelPromise;
|
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.entity.EntityOtherPlayerMP;
|
||||||
import net.minecraft.client.gui.GuiDownloadTerrain;
|
import net.minecraft.client.gui.GuiDownloadTerrain;
|
||||||
import net.minecraft.client.gui.GuiErrorScreen;
|
import net.minecraft.client.gui.GuiErrorScreen;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.network.*;
|
import net.minecraft.network.*;
|
||||||
import net.minecraft.network.play.server.*;
|
import net.minecraft.network.play.server.*;
|
||||||
import net.minecraft.util.IChatComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.world.EnumDifficulty;
|
import net.minecraft.world.EnumDifficulty;
|
||||||
|
import net.minecraft.world.GameType;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldSettings.GameType;
|
|
||||||
import net.minecraft.world.WorldType;
|
import net.minecraft.world.WorldType;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
@@ -31,6 +35,7 @@ import java.io.*;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends replay packets to netty channels.
|
* Sends replay packets to netty channels.
|
||||||
@@ -38,31 +43,23 @@ import java.util.Map;
|
|||||||
* the replay restart from the beginning.
|
* the replay restart from the beginning.
|
||||||
*/
|
*/
|
||||||
@Sharable
|
@Sharable
|
||||||
public class ReplaySender extends ChannelDuplexHandler {
|
public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||||
|
|
||||||
/**
|
|
||||||
* Previously packets for the client player were inserted using one fixed entity id (this one).
|
|
||||||
* This is no longer the case however to provide backwards compatibility, we have to convert
|
|
||||||
* these old packets to use the normal entity id.
|
|
||||||
* Need to punch someone? -> CrushedPixel
|
|
||||||
*/
|
|
||||||
public static final int LEGACY_ENTITY_ID = Integer.MIN_VALUE + 9001;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These packets are ignored completely during replay.
|
* These packets are ignored completely during replay.
|
||||||
*/
|
*/
|
||||||
private static final List<Class> BAD_PACKETS = Arrays.<Class>asList(
|
private static final List<Class> BAD_PACKETS = Arrays.<Class>asList(
|
||||||
S06PacketUpdateHealth.class,
|
// TODO Update possibly more?
|
||||||
S2DPacketOpenWindow.class,
|
SPacketUpdateHealth.class,
|
||||||
S2EPacketCloseWindow.class,
|
SPacketOpenWindow.class,
|
||||||
S2FPacketSetSlot.class,
|
SPacketCloseWindow.class,
|
||||||
S30PacketWindowItems.class,
|
SPacketSetSlot.class,
|
||||||
S36PacketSignEditorOpen.class,
|
SPacketWindowItems.class,
|
||||||
S37PacketStatistics.class,
|
SPacketSignEditorOpen.class,
|
||||||
S1FPacketSetExperience.class,
|
SPacketStatistics.class,
|
||||||
S43PacketCamera.class,
|
SPacketSetExperience.class,
|
||||||
S39PacketPlayerAbilities.class,
|
SPacketCamera.class,
|
||||||
S45PacketTitle.class);
|
SPacketPlayerAbilities.class,
|
||||||
|
SPacketTitle.class);
|
||||||
|
|
||||||
private static int TP_DISTANCE_LIMIT = 128;
|
private static int TP_DISTANCE_LIMIT = 128;
|
||||||
|
|
||||||
@@ -171,6 +168,8 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
this.asyncMode = asyncMode;
|
this.asyncMode = asyncMode;
|
||||||
this.replayLength = file.getMetaData().getDuration();
|
this.replayLength = file.getMetaData().getDuration();
|
||||||
|
|
||||||
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
|
||||||
if (asyncMode) {
|
if (asyncMode) {
|
||||||
new Thread(asyncSender, "replaymod-async-sender").start();
|
new Thread(asyncSender, "replaymod-async-sender").start();
|
||||||
}
|
}
|
||||||
@@ -239,15 +238,34 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
*/
|
*/
|
||||||
public void terminateReplay() {
|
public void terminateReplay() {
|
||||||
terminate = true;
|
terminate = true;
|
||||||
|
MinecraftForge.EVENT_BUS.unregister(this);
|
||||||
try {
|
try {
|
||||||
channelInactive(ctx);
|
channelInactive(ctx);
|
||||||
ctx.channel().pipeline().close();
|
ctx.channel().pipeline().close();
|
||||||
FileUtils.deleteDirectory(tempResourcePackFolder);
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
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.theWorld != null) {
|
||||||
|
for (EntityPlayer playerEntity : mc.theWorld.playerEntities) {
|
||||||
|
if (!playerEntity.addedToChunk && playerEntity instanceof EntityOtherPlayerMP) {
|
||||||
|
playerEntity.onLivingUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelRead(ChannelHandlerContext ctx, Object msg)
|
public void channelRead(ChannelHandlerContext ctx, Object msg)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
@@ -275,21 +293,21 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
// Therefore we have to remove all loaded, dead entities manually if we are in sync mode.
|
// Therefore we have to remove all loaded, dead entities manually if we are in sync mode.
|
||||||
// We do this after every SpawnX packet and after the destroy entities packet.
|
// We do this after every SpawnX packet and after the destroy entities packet.
|
||||||
if (!asyncMode && mc.theWorld != null) {
|
if (!asyncMode && mc.theWorld != null) {
|
||||||
if (p instanceof S0CPacketSpawnPlayer
|
if (p instanceof SPacketSpawnPlayer
|
||||||
|| p instanceof S0EPacketSpawnObject
|
|| p instanceof SPacketSpawnObject
|
||||||
|| p instanceof S0FPacketSpawnMob
|
|| p instanceof SPacketSpawnMob
|
||||||
|| p instanceof S2CPacketSpawnGlobalEntity
|
|| p instanceof SPacketSpawnGlobalEntity
|
||||||
|| p instanceof S10PacketSpawnPainting
|
|| p instanceof SPacketSpawnPainting
|
||||||
|| p instanceof S11PacketSpawnExperienceOrb
|
|| p instanceof SPacketSpawnExperienceOrb
|
||||||
|| p instanceof S13PacketDestroyEntities) {
|
|| p instanceof SPacketDestroyEntities) {
|
||||||
World world = mc.theWorld;
|
World world = mc.theWorld;
|
||||||
for (int i = 0; i < world.loadedEntityList.size(); ++i) {
|
for (int i = 0; i < world.loadedEntityList.size(); ++i) {
|
||||||
Entity entity = (Entity) world.loadedEntityList.get(i);
|
Entity entity = world.loadedEntityList.get(i);
|
||||||
if (entity.isDead) {
|
if (entity.isDead) {
|
||||||
int chunkX = entity.chunkCoordX;
|
int chunkX = entity.chunkCoordX;
|
||||||
int chunkY = entity.chunkCoordZ;
|
int chunkY = entity.chunkCoordZ;
|
||||||
|
|
||||||
if (entity.addedToChunk && world.getChunkProvider().chunkExists(chunkX, chunkY)) {
|
if (entity.addedToChunk && world.getChunkProvider().getLoadedChunk(chunkX, chunkY) != null) {
|
||||||
world.getChunkFromChunkCoords(chunkX, chunkY).removeEntity(entity);
|
world.getChunkFromChunkCoords(chunkX, chunkY).removeEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,8 +345,8 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
* @return The processed packet or {@code null} if no packet shall be sent
|
* @return The processed packet or {@code null} if no packet shall be sent
|
||||||
*/
|
*/
|
||||||
protected Packet processPacket(Packet p) throws Exception {
|
protected Packet processPacket(Packet p) throws Exception {
|
||||||
if (p instanceof S3FPacketCustomPayload) {
|
if (p instanceof SPacketCustomPayload) {
|
||||||
S3FPacketCustomPayload packet = (S3FPacketCustomPayload) p;
|
SPacketCustomPayload packet = (SPacketCustomPayload) p;
|
||||||
if (Restrictions.PLUGIN_CHANNEL.equals(packet.getChannelName())) {
|
if (Restrictions.PLUGIN_CHANNEL.equals(packet.getChannelName())) {
|
||||||
final String unknown = replayHandler.getRestrictions().handle(packet);
|
final String unknown = replayHandler.getRestrictions().handle(packet);
|
||||||
if (unknown == null) {
|
if (unknown == null) {
|
||||||
@@ -354,8 +372,8 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (p instanceof S40PacketDisconnect) {
|
if (p instanceof SPacketDisconnect) {
|
||||||
IChatComponent reason = ((S40PacketDisconnect) p).func_149165_c();
|
ITextComponent reason = ((SPacketDisconnect) p).getReason();
|
||||||
if ("Please update to view this replay.".equals(reason.getUnformattedText())) {
|
if ("Please update to view this replay.".equals(reason.getUnformattedText())) {
|
||||||
// This version of the mod supports replay restrictions so we are allowed
|
// This version of the mod supports replay restrictions so we are allowed
|
||||||
// to remove this packet.
|
// to remove this packet.
|
||||||
@@ -365,18 +383,9 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
|
|
||||||
if(BAD_PACKETS.contains(p.getClass())) return null;
|
if(BAD_PACKETS.contains(p.getClass())) return null;
|
||||||
|
|
||||||
if (p instanceof S3FPacketCustomPayload) {
|
if(p instanceof SPacketResourcePackSend) {
|
||||||
S3FPacketCustomPayload packet = (S3FPacketCustomPayload) p;
|
SPacketResourcePackSend packet = (SPacketResourcePackSend) p;
|
||||||
if ("MC|BOpen".equals(packet.getChannelName())) {
|
String url = packet.getURL();
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
convertLegacyEntityIds(p);
|
|
||||||
|
|
||||||
if(p instanceof S48PacketResourcePackSend) {
|
|
||||||
S48PacketResourcePackSend packet = (S48PacketResourcePackSend) p;
|
|
||||||
String url = packet.func_179783_a();
|
|
||||||
if (url.startsWith("replay://")) {
|
if (url.startsWith("replay://")) {
|
||||||
int id = Integer.parseInt(url.substring("replay://".length()));
|
int id = Integer.parseInt(url.substring("replay://".length()));
|
||||||
Map<Integer, String> index = replayFile.getResourcePackIndex();
|
Map<Integer, String> index = replayFile.getResourcePackIndex();
|
||||||
@@ -387,17 +396,17 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
IOUtils.copy(replayFile.getResourcePack(hash).get(), new FileOutputStream(file));
|
IOUtils.copy(replayFile.getResourcePack(hash).get(), new FileOutputStream(file));
|
||||||
}
|
}
|
||||||
mc.getResourcePackRepository().func_177319_a(file);
|
mc.getResourcePackRepository().setResourcePackInstance(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p instanceof S01PacketJoinGame) {
|
if(p instanceof SPacketJoinGame) {
|
||||||
S01PacketJoinGame packet = (S01PacketJoinGame) p;
|
SPacketJoinGame packet = (SPacketJoinGame) p;
|
||||||
allowMovement = true;
|
allowMovement = true;
|
||||||
int entId = packet.getEntityId();
|
int entId = packet.getPlayerId();
|
||||||
actualID = entId;
|
actualID = entId;
|
||||||
entId = -1789435; // Camera entity id should be negative which is an invalid id and can't be used by servers
|
entId = -1789435; // Camera entity id should be negative which is an invalid id and can't be used by servers
|
||||||
int dimension = packet.getDimension();
|
int dimension = packet.getDimension();
|
||||||
@@ -405,21 +414,21 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
int maxPlayers = packet.getMaxPlayers();
|
int maxPlayers = packet.getMaxPlayers();
|
||||||
WorldType worldType = packet.getWorldType();
|
WorldType worldType = packet.getWorldType();
|
||||||
|
|
||||||
p = new S01PacketJoinGame(entId, GameType.SPECTATOR, false, dimension,
|
p = new SPacketJoinGame(entId, GameType.SPECTATOR, false, dimension,
|
||||||
difficulty, maxPlayers, worldType, false);
|
difficulty, maxPlayers, worldType, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p instanceof S07PacketRespawn) {
|
if(p instanceof SPacketRespawn) {
|
||||||
S07PacketRespawn respawn = (S07PacketRespawn) p;
|
SPacketRespawn respawn = (SPacketRespawn) p;
|
||||||
p = new S07PacketRespawn(respawn.func_149082_c(),
|
p = new SPacketRespawn(respawn.getDimensionID(),
|
||||||
respawn.func_149081_d(), respawn.func_149080_f(), GameType.SPECTATOR);
|
respawn.getDifficulty(), respawn.getWorldType(), GameType.SPECTATOR);
|
||||||
|
|
||||||
allowMovement = true;
|
allowMovement = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p instanceof S08PacketPlayerPosLook) {
|
if(p instanceof SPacketPlayerPosLook) {
|
||||||
if(!hasWorldLoaded) hasWorldLoaded = true;
|
if(!hasWorldLoaded) hasWorldLoaded = true;
|
||||||
final S08PacketPlayerPosLook ppl = (S08PacketPlayerPosLook) p;
|
final SPacketPlayerPosLook ppl = (SPacketPlayerPosLook) p;
|
||||||
|
|
||||||
if (mc.currentScreen instanceof GuiDownloadTerrain) {
|
if (mc.currentScreen instanceof GuiDownloadTerrain) {
|
||||||
// Close the world loading screen manually in case we swallow the packet
|
// Close the world loading screen manually in case we swallow the packet
|
||||||
@@ -430,41 +439,44 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
|
|
||||||
CameraEntity cent = replayHandler.getCameraEntity();
|
CameraEntity cent = replayHandler.getCameraEntity();
|
||||||
|
|
||||||
for (Object relative : ppl.func_179834_f()) {
|
for (SPacketPlayerPosLook.EnumFlags relative : ppl.getFlags()) {
|
||||||
if (relative == S08PacketPlayerPosLook.EnumFlags.X
|
if (relative == SPacketPlayerPosLook.EnumFlags.X
|
||||||
|| relative == S08PacketPlayerPosLook.EnumFlags.Y
|
|| relative == SPacketPlayerPosLook.EnumFlags.Y
|
||||||
|| relative == S08PacketPlayerPosLook.EnumFlags.Z) {
|
|| relative == SPacketPlayerPosLook.EnumFlags.Z) {
|
||||||
return null; // At least one of the coordinates is relative, so we don't care
|
return null; // At least one of the coordinates is relative, so we don't care
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cent != null) {
|
if(cent != null) {
|
||||||
if(!allowMovement && !((Math.abs(cent.posX - ppl.func_148932_c()) > TP_DISTANCE_LIMIT) ||
|
if(!allowMovement && !((Math.abs(cent.posX - ppl.getX()) > TP_DISTANCE_LIMIT) ||
|
||||||
(Math.abs(cent.posZ - ppl.func_148933_e()) > TP_DISTANCE_LIMIT))) {
|
(Math.abs(cent.posZ - ppl.getZ()) > TP_DISTANCE_LIMIT))) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
allowMovement = false;
|
allowMovement = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new Runnable() {
|
new Callable<Void>() {
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void run() {
|
public Void call() {
|
||||||
if (mc.theWorld == null || !mc.isCallingFromMinecraftThread()) {
|
if (mc.theWorld == null || !mc.isCallingFromMinecraftThread()) {
|
||||||
ReplayMod.instance.runLater(this);
|
synchronized(mc.scheduledTasks) {
|
||||||
return;
|
mc.scheduledTasks.add(ListenableFutureTask.create(this));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
CameraEntity cent = replayHandler.getCameraEntity();
|
CameraEntity cent = replayHandler.getCameraEntity();
|
||||||
cent.setCameraPosition(ppl.func_148932_c(), ppl.func_148928_d(), ppl.func_148933_e());
|
cent.setCameraPosition(ppl.getX(), ppl.getY(), ppl.getZ());
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}.run();
|
}.call();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p instanceof S2BPacketChangeGameState) {
|
if(p instanceof SPacketChangeGameState) {
|
||||||
S2BPacketChangeGameState pg = (S2BPacketChangeGameState)p;
|
SPacketChangeGameState pg = (SPacketChangeGameState)p;
|
||||||
int reason = pg.func_149138_c();
|
int reason = pg.getGameState();
|
||||||
|
|
||||||
// only allow the following packets:
|
// only allow the following packets:
|
||||||
// 1 - End raining
|
// 1 - End raining
|
||||||
@@ -478,7 +490,7 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p instanceof S02PacketChat) {
|
if (p instanceof SPacketChat) {
|
||||||
if (!ReplayModReplay.instance.getCore().getSettingsRegistry().get(Setting.SHOW_CHAT)) {
|
if (!ReplayModReplay.instance.getCore().getSettingsRegistry().get(Setting.SHOW_CHAT)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -491,27 +503,14 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
ctx.attr(NetworkManager.attrKeyConnectionState).set(EnumConnectionState.PLAY);
|
ctx.attr(NetworkManager.PROTOCOL_ATTRIBUTE_KEY).set(EnumConnectionState.PLAY);
|
||||||
super.channelActive(ctx);
|
super.channelActive(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||||
// The embedded channel's event loop will consider every thread to be in it and as such provides no
|
FileUtils.deleteDirectory(tempResourcePackFolder);
|
||||||
// guarantees that only one thread is using the pipeline at any one time.
|
super.channelInactive(ctx);
|
||||||
// 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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -709,11 +708,11 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
protected Packet processPacketAsync(Packet p) {
|
protected Packet processPacketAsync(Packet p) {
|
||||||
//If hurrying, ignore some packets, except for short durations
|
//If hurrying, ignore some packets, except for short durations
|
||||||
if(desiredTimeStamp - lastTimeStamp > 1000) {
|
if(desiredTimeStamp - lastTimeStamp > 1000) {
|
||||||
if(p instanceof S2APacketParticles) return null;
|
if(p instanceof SPacketParticles) return null;
|
||||||
|
|
||||||
if(p instanceof S0EPacketSpawnObject) {
|
if(p instanceof SPacketSpawnObject) {
|
||||||
S0EPacketSpawnObject pso = (S0EPacketSpawnObject)p;
|
SPacketSpawnObject pso = (SPacketSpawnObject)p;
|
||||||
int type = pso.func_148993_l();
|
int type = pso.getType();
|
||||||
if(type == 76) { // Firework rocket
|
if(type == 76) { // Firework rocket
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -739,9 +738,6 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
synchronized (this) {
|
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
|
if (timestamp < lastTimeStamp) { // Restart the replay if we need to go backwards in time
|
||||||
hasWorldLoaded = false;
|
hasWorldLoaded = false;
|
||||||
lastTimeStamp = 0;
|
lastTimeStamp = 0;
|
||||||
@@ -802,68 +798,6 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
return p; // During synchronous playback everything is sent normally
|
return p; // During synchronous playback everything is sent normally
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This is necessary to convert packets from old replays to new replays.
|
|
||||||
* @param packet The packet to be transformed.
|
|
||||||
* @see #LEGACY_ENTITY_ID
|
|
||||||
*/
|
|
||||||
private void convertLegacyEntityIds(Packet packet) {
|
|
||||||
if (packet instanceof S0CPacketSpawnPlayer) {
|
|
||||||
S0CPacketSpawnPlayer p = (S0CPacketSpawnPlayer) packet;
|
|
||||||
if (p.field_148957_a == LEGACY_ENTITY_ID) {
|
|
||||||
p.field_148957_a = actualID;
|
|
||||||
}
|
|
||||||
} else if (packet instanceof S18PacketEntityTeleport) {
|
|
||||||
S18PacketEntityTeleport p = (S18PacketEntityTeleport) packet;
|
|
||||||
if (p.field_149458_a == LEGACY_ENTITY_ID) {
|
|
||||||
p.field_149458_a = actualID;
|
|
||||||
}
|
|
||||||
} else if (packet instanceof S14PacketEntity.S17PacketEntityLookMove) {
|
|
||||||
S14PacketEntity.S17PacketEntityLookMove p = (S14PacketEntity.S17PacketEntityLookMove) packet;
|
|
||||||
if (p.field_149074_a == LEGACY_ENTITY_ID) {
|
|
||||||
p.field_149074_a = actualID;
|
|
||||||
}
|
|
||||||
} else if (packet instanceof S19PacketEntityHeadLook) {
|
|
||||||
S19PacketEntityHeadLook p = (S19PacketEntityHeadLook) packet;
|
|
||||||
if (p.field_149384_a == LEGACY_ENTITY_ID) {
|
|
||||||
p.field_149384_a = actualID;
|
|
||||||
}
|
|
||||||
} else if (packet instanceof S12PacketEntityVelocity) {
|
|
||||||
S12PacketEntityVelocity p = (S12PacketEntityVelocity) packet;
|
|
||||||
if (p.field_149417_a == LEGACY_ENTITY_ID) {
|
|
||||||
p.field_149417_a = actualID;
|
|
||||||
}
|
|
||||||
} else if (packet instanceof S0BPacketAnimation) {
|
|
||||||
S0BPacketAnimation p = (S0BPacketAnimation) packet;
|
|
||||||
if (p.entityId == LEGACY_ENTITY_ID) {
|
|
||||||
p.entityId = actualID;
|
|
||||||
}
|
|
||||||
} else if (packet instanceof S04PacketEntityEquipment) {
|
|
||||||
S04PacketEntityEquipment p = (S04PacketEntityEquipment) packet;
|
|
||||||
if (p.field_149394_a == LEGACY_ENTITY_ID) {
|
|
||||||
p.field_149394_a = actualID;
|
|
||||||
}
|
|
||||||
} else if (packet instanceof S1BPacketEntityAttach) {
|
|
||||||
S1BPacketEntityAttach p = (S1BPacketEntityAttach) packet;
|
|
||||||
if (p.field_149408_a == LEGACY_ENTITY_ID) {
|
|
||||||
p.field_149408_a = actualID;
|
|
||||||
}
|
|
||||||
if (p.field_149406_b == LEGACY_ENTITY_ID) {
|
|
||||||
p.field_149406_b = actualID;
|
|
||||||
}
|
|
||||||
} else if (packet instanceof S0DPacketCollectItem) {
|
|
||||||
S0DPacketCollectItem p = (S0DPacketCollectItem) packet;
|
|
||||||
if (p.field_149356_b == LEGACY_ENTITY_ID) {
|
|
||||||
p.field_149356_b = actualID;
|
|
||||||
}
|
|
||||||
} else if (packet instanceof S13PacketDestroyEntities) {
|
|
||||||
S13PacketDestroyEntities p = (S13PacketDestroyEntities) packet;
|
|
||||||
if (p.field_149100_a.length == 1 && p.field_149100_a[0] == LEGACY_ENTITY_ID) {
|
|
||||||
p.field_149100_a[0] = actualID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final class PacketData {
|
private static final class PacketData {
|
||||||
private final int timestamp;
|
private final int timestamp;
|
||||||
private final byte[] bytes;
|
private final byte[] bytes;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.replaymod.core.events.SettingsChangedEvent;
|
|||||||
import com.replaymod.core.utils.Utils;
|
import com.replaymod.core.utils.Utils;
|
||||||
import com.replaymod.replay.ReplayModReplay;
|
import com.replaymod.replay.ReplayModReplay;
|
||||||
import com.replaymod.replay.Setting;
|
import com.replaymod.replay.Setting;
|
||||||
import com.replaymod.replay.events.ReplayChatMessageEvent;
|
|
||||||
import com.replaymod.replaystudio.util.Location;
|
import com.replaymod.replaystudio.util.Location;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -19,17 +18,17 @@ import net.minecraft.entity.Entity;
|
|||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.entity.item.EntityItemFrame;
|
import net.minecraft.entity.item.EntityItemFrame;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.stats.StatFileWriter;
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.stats.StatisticsManager;
|
||||||
import net.minecraft.util.IChatComponent;
|
import net.minecraft.util.EnumHand;
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.client.event.EntityViewRenderEvent;
|
import net.minecraftforge.client.event.EntityViewRenderEvent;
|
||||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||||
import net.minecraftforge.client.event.RenderHandEvent;
|
import net.minecraftforge.client.event.RenderHandEvent;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
@@ -67,9 +66,8 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
*/
|
*/
|
||||||
private final EventHandler eventHandler = new EventHandler();
|
private final EventHandler eventHandler = new EventHandler();
|
||||||
|
|
||||||
public CameraEntity(Minecraft mcIn, World worldIn, NetHandlerPlayClient netHandlerPlayClient, StatFileWriter statFileWriter) {
|
public CameraEntity(Minecraft mcIn, World worldIn, NetHandlerPlayClient netHandlerPlayClient, StatisticsManager statisticsManager) {
|
||||||
super(mcIn, worldIn, netHandlerPlayClient, statFileWriter);
|
super(mcIn, worldIn, netHandlerPlayClient, statisticsManager);
|
||||||
FMLCommonHandler.instance().bus().register(eventHandler);
|
|
||||||
MinecraftForge.EVENT_BUS.register(eventHandler);
|
MinecraftForge.EVENT_BUS.register(eventHandler);
|
||||||
if (ReplayModReplay.instance.getReplayHandler().getSpectatedUUID() == null) {
|
if (ReplayModReplay.instance.getReplayHandler().getSpectatedUUID() == null) {
|
||||||
cameraController = ReplayModReplay.instance.createCameraController(this);
|
cameraController = ReplayModReplay.instance.createCameraController(this);
|
||||||
@@ -291,12 +289,49 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MovingObjectPosition rayTrace(double p_174822_1_, float p_174822_3_) {
|
public float getCooldownPeriod() {
|
||||||
MovingObjectPosition pos = super.rayTrace(p_174822_1_, 1f);
|
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)
|
// Make sure we can never look at blocks (-> no outline)
|
||||||
if(pos != null && pos.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
if(pos != null && pos.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||||
pos.typeOfHit = MovingObjectPosition.MovingObjectType.MISS;
|
pos.typeOfHit = RayTraceResult.Type.MISS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
@@ -311,7 +346,6 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
@Override
|
@Override
|
||||||
public void setDead() {
|
public void setDead() {
|
||||||
super.setDead();
|
super.setDead();
|
||||||
FMLCommonHandler.instance().bus().unregister(eventHandler);
|
|
||||||
MinecraftForge.EVENT_BUS.unregister(eventHandler);
|
MinecraftForge.EVENT_BUS.unregister(eventHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,12 +384,6 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
&& (e instanceof EntityPlayer || e instanceof EntityLiving || e instanceof EntityItemFrame);
|
&& (e instanceof EntityPlayer || e instanceof EntityLiving || e instanceof EntityItemFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addChatMessage(IChatComponent message) {
|
|
||||||
if (MinecraftForge.EVENT_BUS.post(new ReplayChatMessageEvent(this))) return;
|
|
||||||
super.addChatMessage(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class EventHandler {
|
private class EventHandler {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onPreClientTick(TickEvent.ClientTickEvent event) {
|
public void onPreClientTick(TickEvent.ClientTickEvent event) {
|
||||||
@@ -375,9 +403,13 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void preCrosshairRender(RenderGameOverlayEvent.Pre event) {
|
public void preCrosshairRender(RenderGameOverlayEvent.Pre event) {
|
||||||
// The crosshair should only render if targeted entity can actually be spectated
|
// The crosshair should only render if targeted entity can actually be spectated
|
||||||
if (event.type == RenderGameOverlayEvent.ElementType.CROSSHAIRS) {
|
if (event.getType() == RenderGameOverlayEvent.ElementType.CROSSHAIRS) {
|
||||||
event.setCanceled(!canSpectate(mc.pointedEntity));
|
event.setCanceled(!canSpectate(mc.pointedEntity));
|
||||||
}
|
}
|
||||||
|
// Hotbar should never be rendered
|
||||||
|
if (event.getType() == RenderGameOverlayEvent.ElementType.HOTBAR) {
|
||||||
|
event.setCanceled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
@@ -408,10 +440,13 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
if (lastHandRendered != player) {
|
if (lastHandRendered != player) {
|
||||||
lastHandRendered = player;
|
lastHandRendered = player;
|
||||||
|
|
||||||
mc.entityRenderer.itemRenderer.prevEquippedProgress = 1;
|
mc.entityRenderer.itemRenderer.prevEquippedProgressMainHand = 1;
|
||||||
mc.entityRenderer.itemRenderer.equippedProgress = 1;
|
mc.entityRenderer.itemRenderer.prevEquippedProgressOffHand = 1;
|
||||||
mc.entityRenderer.itemRenderer.itemToRender = player.inventory.getCurrentItem();
|
mc.entityRenderer.itemRenderer.equippedProgressMainHand = 1;
|
||||||
mc.entityRenderer.itemRenderer.equippedItemSlot = player.inventory.currentItem;
|
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.renderArmYaw = mc.thePlayer.prevRenderArmYaw = player.rotationYaw;
|
||||||
mc.thePlayer.renderArmPitch = mc.thePlayer.prevRenderArmPitch = player.rotationPitch;
|
mc.thePlayer.renderArmPitch = mc.thePlayer.prevRenderArmPitch = player.rotationPitch;
|
||||||
@@ -422,45 +457,8 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onEntityViewRenderEvent(EntityViewRenderEvent.CameraSetup event) {
|
public void onEntityViewRenderEvent(EntityViewRenderEvent.CameraSetup event) {
|
||||||
if (mc.getRenderViewEntity() == CameraEntity.this) {
|
if (mc.getRenderViewEntity() == CameraEntity.this) {
|
||||||
event.roll = roll;
|
event.setRoll(roll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean heldItemTooltipsWasTrue;
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void preRenderGameOverlay(RenderGameOverlayEvent.Pre event) {
|
|
||||||
switch (event.type) {
|
|
||||||
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:
|
|
||||||
event.setCanceled(true);
|
|
||||||
break;
|
|
||||||
case HELMET:
|
|
||||||
case PORTAL:
|
|
||||||
case CROSSHAIRS:
|
|
||||||
case BOSSHEALTH:
|
|
||||||
case TEXT:
|
|
||||||
case CHAT:
|
|
||||||
case PLAYER_LIST:
|
|
||||||
case DEBUG:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void postRenderGameOverlay(RenderGameOverlayEvent.Post event) {
|
|
||||||
if (event.type != 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.Minecraft;
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import org.lwjgl.Sys;
|
import org.lwjgl.Sys;
|
||||||
|
|
||||||
// TODO: Marius is responsible for this. Please, someone clean it up.
|
// TODO: Marius is responsible for this. Please, someone clean it up.
|
||||||
@@ -18,8 +18,8 @@ public class ClassicCameraController implements CameraController {
|
|||||||
private double THRESHOLD = MAX_SPEED / 20;
|
private double THRESHOLD = MAX_SPEED / 20;
|
||||||
private double DECAY = MAX_SPEED/3;
|
private double DECAY = MAX_SPEED/3;
|
||||||
|
|
||||||
private Vec3 direction;
|
private Vec3d direction;
|
||||||
private Vec3 dirBefore;
|
private Vec3d dirBefore;
|
||||||
private double motion;
|
private double motion;
|
||||||
private long lastCall = Sys.getTime();
|
private long lastCall = Sys.getTime();
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ public class ClassicCameraController implements CameraController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3 movement = direction.normalize();
|
Vec3d movement = direction.normalize();
|
||||||
double factor = motion * (frac / 1000D);
|
double factor = motion * (frac / 1000D);
|
||||||
|
|
||||||
camera.moveCamera(movement.xCoord * factor, movement.yCoord * factor, movement.zCoord * factor);
|
camera.moveCamera(movement.xCoord * factor, movement.yCoord * factor, movement.zCoord * factor);
|
||||||
@@ -158,7 +158,7 @@ public class ClassicCameraController implements CameraController {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3 dbf = direction;
|
Vec3d dbf = direction;
|
||||||
|
|
||||||
if(dirBefore != null) {
|
if(dirBefore != null) {
|
||||||
direction = dirBefore.normalize().add(direction);
|
direction = dirBefore.normalize().add(direction);
|
||||||
@@ -169,12 +169,12 @@ public class ClassicCameraController implements CameraController {
|
|||||||
updateMovement();
|
updateMovement();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vec3 getVectorForRotation(float pitch, float yaw) {
|
private Vec3d getVectorForRotation(float pitch, float yaw) {
|
||||||
float f2 = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI);
|
float f2 = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI);
|
||||||
float f3 = MathHelper.sin(-yaw * 0.017453292F - (float)Math.PI);
|
float f3 = MathHelper.sin(-yaw * 0.017453292F - (float)Math.PI);
|
||||||
float f4 = -MathHelper.cos(-pitch * 0.017453292F);
|
float f4 = -MathHelper.cos(-pitch * 0.017453292F);
|
||||||
float f5 = MathHelper.sin(-pitch * 0.017453292F);
|
float f5 = MathHelper.sin(-pitch * 0.017453292F);
|
||||||
return new Vec3((double)(f3 * f4), (double)f5, (double)(f2 * f4));
|
return new Vec3d((double)(f3 * f4), (double)f5, (double)(f2 * f4));
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum MoveDirection {
|
public enum MoveDirection {
|
||||||
|
|||||||
@@ -41,8 +41,9 @@ public class SpectatorCameraController implements CameraController {
|
|||||||
if (view instanceof EntityPlayer) {
|
if (view instanceof EntityPlayer) {
|
||||||
EntityPlayer viewPlayer = (EntityPlayer) view;
|
EntityPlayer viewPlayer = (EntityPlayer) view;
|
||||||
camera.inventory = viewPlayer.inventory;
|
camera.inventory = viewPlayer.inventory;
|
||||||
camera.itemInUse = viewPlayer.itemInUse;
|
camera.itemStackMainHand = viewPlayer.itemStackMainHand;
|
||||||
camera.itemInUseCount = viewPlayer.itemInUseCount;
|
camera.swingingHand = viewPlayer.swingingHand;
|
||||||
|
camera.activeItemStackUseCount = viewPlayer.activeItemStackUseCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
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.core.ReplayMod;
|
||||||
import com.replaymod.replay.ReplayHandler;
|
import com.replaymod.replay.ReplayHandler;
|
||||||
|
import com.replaymod.replaystudio.data.Marker;
|
||||||
import com.replaymod.replaystudio.util.Location;
|
import com.replaymod.replaystudio.util.Location;
|
||||||
import de.johni0702.minecraft.gui.GuiRenderer;
|
import de.johni0702.minecraft.gui.GuiRenderer;
|
||||||
import de.johni0702.minecraft.gui.RenderInfo;
|
import de.johni0702.minecraft.gui.RenderInfo;
|
||||||
import de.johni0702.minecraft.gui.element.advanced.AbstractGuiTimeline;
|
import de.johni0702.minecraft.gui.element.advanced.AbstractGuiTimeline;
|
||||||
import de.johni0702.minecraft.gui.function.Draggable;
|
import de.johni0702.minecraft.gui.function.Draggable;
|
||||||
import com.replaymod.replaystudio.data.Marker;
|
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import org.lwjgl.util.Point;
|
import org.lwjgl.util.Point;
|
||||||
import org.lwjgl.util.ReadableDimension;
|
import org.lwjgl.util.ReadableDimension;
|
||||||
import org.lwjgl.util.ReadablePoint;
|
import org.lwjgl.util.ReadablePoint;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import de.johni0702.minecraft.gui.layout.CustomLayout;
|
|||||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.client.settings.GameSettings;
|
import net.minecraft.client.settings.GameSettings;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
@@ -138,9 +138,9 @@ public class GuiReplayOverlay extends AbstractGuiOverlay<GuiReplayOverlay> {
|
|||||||
public void setVisible(boolean visible) {
|
public void setVisible(boolean visible) {
|
||||||
if (isVisible() != visible) {
|
if (isVisible() != visible) {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
FMLCommonHandler.instance().bus().register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
} else {
|
} else {
|
||||||
FMLCommonHandler.instance().bus().unregister(this);
|
MinecraftForge.EVENT_BUS.unregister(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.setVisible(visible);
|
super.setVisible(visible);
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ import de.johni0702.minecraft.gui.utils.Consumer;
|
|||||||
import net.minecraft.client.gui.GuiErrorScreen;
|
import net.minecraft.client.gui.GuiErrorScreen;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.util.Util;
|
import net.minecraft.util.Util;
|
||||||
|
import net.minecraftforge.fml.common.FMLLog;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.io.IOCase;
|
import org.apache.commons.io.IOCase;
|
||||||
import org.apache.commons.io.filefilter.SuffixFileFilter;
|
import org.apache.commons.io.filefilter.SuffixFileFilter;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
@@ -45,8 +47,6 @@ import java.io.IOException;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import static com.replaymod.replay.ReplayModReplay.LOGGER;
|
|
||||||
|
|
||||||
public class GuiReplayViewer extends GuiScreen {
|
public class GuiReplayViewer extends GuiScreen {
|
||||||
private final ReplayModReplay mod;
|
private final ReplayModReplay mod;
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ public class GuiReplayViewer extends GuiScreen {
|
|||||||
obj.consume(() -> new GuiReplayEntry(file, metaData, theThumb));
|
obj.consume(() -> new GuiReplayEntry(file, metaData, theThumb));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Could not load Replay File {}", file.getName(), e);
|
FMLLog.getLogger().error("Could not load Replay File " + file.getName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -155,7 +155,7 @@ public class GuiReplayViewer extends GuiScreen {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final File file = list.getSelected().file;
|
final File file = list.getSelected().file;
|
||||||
String name = Utils.fileNameToReplayName(file.getName());
|
String name = FilenameUtils.getBaseName(file.getName());
|
||||||
final GuiTextField nameField = new GuiTextField().setSize(200, 20).setFocused(true).setText(name);
|
final GuiTextField nameField = new GuiTextField().setSize(200, 20).setFocused(true).setText(name);
|
||||||
final GuiYesNoPopup popup = GuiYesNoPopup.open(GuiReplayViewer.this,
|
final GuiYesNoPopup popup = GuiYesNoPopup.open(GuiReplayViewer.this,
|
||||||
new GuiLabel().setI18nText("replaymod.gui.viewer.rename.name").setColor(Colors.BLACK),
|
new GuiLabel().setI18nText("replaymod.gui.viewer.rename.name").setColor(Colors.BLACK),
|
||||||
@@ -171,16 +171,16 @@ public class GuiReplayViewer extends GuiScreen {
|
|||||||
}
|
}
|
||||||
}).onTextChanged(obj -> {
|
}).onTextChanged(obj -> {
|
||||||
popup.getYesButton().setEnabled(!nameField.getText().isEmpty()
|
popup.getYesButton().setEnabled(!nameField.getText().isEmpty()
|
||||||
&& !new File(file.getParentFile(), Utils.replayNameToFileName(nameField.getText())).exists());
|
&& !new File(file.getParentFile(), nameField.getText() + ".mcpr").exists());
|
||||||
});
|
});
|
||||||
Futures.addCallback(popup.getFuture(), new FutureCallback<Boolean>() {
|
Futures.addCallback(popup.getFuture(), new FutureCallback<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Boolean delete) {
|
public void onSuccess(Boolean delete) {
|
||||||
if (delete) {
|
if (delete) {
|
||||||
// Sanitize their input
|
// Sanitize their input
|
||||||
String name = nameField.getText().trim();
|
String name = nameField.getText().trim().replace("[^a-zA-Z0-9\\.\\- ]", "_");
|
||||||
// This file is what they want
|
// This file is what they want
|
||||||
File targetFile = new File(file.getParentFile(), Utils.replayNameToFileName(name));
|
File targetFile = new File(file.getParentFile(), name + ".mcpr");
|
||||||
try {
|
try {
|
||||||
// Finally, try to move it
|
// Finally, try to move it
|
||||||
FileUtils.moveFile(file, targetFile);
|
FileUtils.moveFile(file, targetFile);
|
||||||
@@ -302,7 +302,7 @@ public class GuiReplayViewer extends GuiScreen {
|
|||||||
public GuiReplayEntry(File file, ReplayMetaData metaData, BufferedImage thumbImage) {
|
public GuiReplayEntry(File file, ReplayMetaData metaData, BufferedImage thumbImage) {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
|
|
||||||
name.setText(ChatFormatting.UNDERLINE + Utils.fileNameToReplayName(file.getName()));
|
name.setText(ChatFormatting.UNDERLINE + FilenameUtils.getBaseName(file.getName()));
|
||||||
if (Strings.isEmpty(metaData.getServerName())) {
|
if (Strings.isEmpty(metaData.getServerName())) {
|
||||||
server.setI18nText("replaymod.gui.iphidden").setColor(Colors.DARK_RED);
|
server.setI18nText("replaymod.gui.iphidden").setColor(Colors.DARK_RED);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import net.minecraft.client.gui.GuiMainMenu;
|
|||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -34,13 +33,12 @@ public class GuiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void register() {
|
public void register() {
|
||||||
FMLCommonHandler.instance().bus().register(this);
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void injectIntoIngameMenu(GuiScreenEvent.InitGuiEvent.Post event) {
|
public void injectIntoIngameMenu(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||||
if (!(event.gui instanceof GuiIngameMenu)) {
|
if (!(event.getGui() instanceof GuiIngameMenu)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,8 +47,7 @@ public class GuiHandler {
|
|||||||
mod.getReplayHandler().getReplaySender().setReplaySpeed(0);
|
mod.getReplayHandler().getReplaySender().setReplaySpeed(0);
|
||||||
|
|
||||||
GuiButton achievements = null, stats = null, openToLan = null;
|
GuiButton achievements = null, stats = null, openToLan = null;
|
||||||
@SuppressWarnings("unchecked")
|
List<GuiButton> buttonList = event.getButtonList();
|
||||||
List<GuiButton> buttonList = event.buttonList;
|
|
||||||
for(GuiButton b : new ArrayList<>(buttonList)) {
|
for(GuiButton b : new ArrayList<>(buttonList)) {
|
||||||
switch (b.id) {
|
switch (b.id) {
|
||||||
// Replace "Exit Server" button with "Exit Replay" button
|
// Replace "Exit Server" button with "Exit Replay" button
|
||||||
@@ -98,31 +95,29 @@ public class GuiHandler {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
||||||
if (!(event.gui instanceof GuiMainMenu)) {
|
if (!(event.getGui() instanceof GuiMainMenu)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
GuiButton button = new GuiButton(BUTTON_REPLAY_VIEWER, event.getGui().width / 2 - 100,
|
||||||
List<GuiButton> buttonList = event.buttonList;
|
event.getGui().height / 4 + 10 + 3 * 24, I18n.format("replaymod.gui.replayviewer"));
|
||||||
GuiButton button = new GuiButton(BUTTON_REPLAY_VIEWER, event.gui.width / 2 - 100,
|
|
||||||
event.gui.height / 4 + 10 + 3 * 24, I18n.format("replaymod.gui.replayviewer"));
|
|
||||||
button.width = button.width / 2 - 2;
|
button.width = button.width / 2 - 2;
|
||||||
buttonList.add(button);
|
event.getButtonList().add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
||||||
if(!event.button.enabled) return;
|
if(!event.getButton().enabled) return;
|
||||||
|
|
||||||
if (event.gui instanceof GuiMainMenu) {
|
if (event.getGui() instanceof GuiMainMenu) {
|
||||||
if (event.button.id == BUTTON_REPLAY_VIEWER) {
|
if (event.getButton().id == BUTTON_REPLAY_VIEWER) {
|
||||||
new GuiReplayViewer(mod).display();
|
new GuiReplayViewer(mod).display();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.gui instanceof GuiIngameMenu && mod.getReplayHandler() != null) {
|
if (event.getGui() instanceof GuiIngameMenu && mod.getReplayHandler() != null) {
|
||||||
if (event.button.id == BUTTON_EXIT_REPLAY) {
|
if (event.getButton().id == BUTTON_EXIT_REPLAY) {
|
||||||
event.button.enabled = false;
|
event.getButton().enabled = false;
|
||||||
mc.displayGuiScreen(new GuiMainMenu());
|
mc.displayGuiScreen(new GuiMainMenu());
|
||||||
try {
|
try {
|
||||||
mod.getReplayHandler().endReplay();
|
mod.getReplayHandler().endReplay();
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
@Mixin(GuiSpectator.class)
|
@Mixin(GuiSpectator.class)
|
||||||
public abstract class MixinGuiSpectator {
|
public abstract class MixinGuiSpectator {
|
||||||
@Shadow
|
@Shadow
|
||||||
private Minecraft 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) {
|
public void isInReplay(int i, CallbackInfo ci) {
|
||||||
// Prevent spectator gui from opening while in a replay
|
// Prevent spectator gui from opening while in a replay
|
||||||
if (field_175268_g.thePlayer instanceof CameraEntity) {
|
if (mc.thePlayer instanceof CameraEntity) {
|
||||||
ci.cancel();
|
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,12 @@
|
|||||||
package com.replaymod.replay.mixin;
|
package com.replaymod.replay.mixin;
|
||||||
|
|
||||||
import com.replaymod.replay.camera.CameraEntity;
|
|
||||||
import com.replaymod.replay.ReplayModReplay;
|
import com.replaymod.replay.ReplayModReplay;
|
||||||
|
import com.replaymod.replay.camera.CameraEntity;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||||
import net.minecraft.stats.StatFileWriter;
|
import net.minecraft.stats.StatisticsManager;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
@@ -21,12 +21,12 @@ public abstract class MixinPlayerControllerMP {
|
|||||||
private Minecraft mc;
|
private Minecraft mc;
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
private NetHandlerPlayClient netClientHandler;
|
private NetHandlerPlayClient connection;
|
||||||
|
|
||||||
@Inject(method = "func_178892_a", at=@At("HEAD"), cancellable = true)
|
@Inject(method = "createClientPlayer", at=@At("HEAD"), cancellable = true)
|
||||||
private void replayModReplay_createReplayCamera(World worldIn, StatFileWriter statFileWriter, CallbackInfoReturnable<EntityPlayerSP> ci) {
|
private void replayModReplay_createReplayCamera(World worldIn, StatisticsManager statisticsManager, CallbackInfoReturnable<EntityPlayerSP> ci) {
|
||||||
if (ReplayModReplay.instance.getReplayHandler() != null) {
|
if (ReplayModReplay.instance.getReplayHandler() != null) {
|
||||||
ci.setReturnValue(new CameraEntity(mc, worldIn, netClientHandler, statFileWriter));
|
ci.setReturnValue(new CameraEntity(mc, worldIn, connection, statisticsManager));
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.replaymod.replay.mixin;
|
||||||
|
|
||||||
|
import com.replaymod.replay.camera.CameraEntity;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.entity.RenderArmorStand;
|
||||||
|
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(RenderArmorStand.class)
|
||||||
|
public abstract class MixinRenderArmorStand {
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@ public abstract class MixinRenderArrow extends Render {
|
|||||||
super(renderManager);
|
super(renderManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldRender(Entity entity, ICamera camera, double camX, double camY, double camZ) {
|
public boolean shouldRender(Entity entity, ICamera camera, double camX, double camY, double camZ) {
|
||||||
// Force arrows to always render, otherwise they stop rendering when you get close to them
|
// Force arrows to always render, otherwise they stop rendering when you get close to them
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.replaymod.replay.mixin;
|
|||||||
import com.replaymod.replay.ReplayHandler;
|
import com.replaymod.replay.ReplayHandler;
|
||||||
import com.replaymod.replay.ReplayModReplay;
|
import com.replaymod.replay.ReplayModReplay;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.entity.RenderItem;
|
import net.minecraft.client.renderer.RenderItem;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package com.replaymod.replay.mixin;
|
|||||||
|
|
||||||
import com.replaymod.replay.camera.CameraEntity;
|
import com.replaymod.replay.camera.CameraEntity;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.entity.RendererLivingEntity;
|
import net.minecraft.client.renderer.entity.RenderLivingBase;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -11,8 +11,8 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
@Mixin(RendererLivingEntity.class)
|
@Mixin(RenderLivingBase.class)
|
||||||
public abstract class MixinRendererLivingEntity {
|
public abstract class MixinRenderLivingBase {
|
||||||
@Inject(method = "canRenderName", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "canRenderName", at = @At("HEAD"), cancellable = true)
|
||||||
private void replayModReplay_canRenderInvisibleName(EntityLivingBase entity, CallbackInfoReturnable<Boolean> ci) {
|
private void replayModReplay_canRenderInvisibleName(EntityLivingBase entity, CallbackInfoReturnable<Boolean> ci) {
|
||||||
EntityPlayer thePlayer = Minecraft.getMinecraft().thePlayer;
|
EntityPlayer thePlayer = Minecraft.getMinecraft().thePlayer;
|
||||||
@@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
|||||||
|
|
||||||
@Mixin(TileEntityEndPortalRenderer.class)
|
@Mixin(TileEntityEndPortalRenderer.class)
|
||||||
public class MixinTileEntityEndPortalRenderer {
|
public class MixinTileEntityEndPortalRenderer {
|
||||||
@Redirect(method = "func_180544_a", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getSystemTime()J"))
|
@Redirect(method = "renderTileEntityAt", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getSystemTime()J"))
|
||||||
private long replayModReplay_getEnchantmentTime() {
|
private long replayModReplay_getEnchantmentTime() {
|
||||||
ReplayHandler replayHandler = ReplayModReplay.instance.getReplayHandler();
|
ReplayHandler replayHandler = ReplayModReplay.instance.getReplayHandler();
|
||||||
if (replayHandler != null) {
|
if (replayHandler != null) {
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import net.minecraft.client.renderer.RenderGlobal;
|
|||||||
import net.minecraft.client.renderer.ViewFrustum;
|
import net.minecraft.client.renderer.ViewFrustum;
|
||||||
import net.minecraft.client.renderer.chunk.IRenderChunkFactory;
|
import net.minecraft.client.renderer.chunk.IRenderChunkFactory;
|
||||||
import net.minecraft.client.renderer.chunk.RenderChunk;
|
import net.minecraft.client.renderer.chunk.RenderChunk;
|
||||||
import net.minecraft.util.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
@@ -31,7 +31,7 @@ public abstract class MixinViewFrustum {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instead of calling {@link RenderChunk#setPosition(BlockPos)} we recreate the render chunk
|
* Instead of calling {@link RenderChunk#setOrigin(int, int, int)} we recreate the render chunk
|
||||||
* which seems to solve the problem that chunks are invisible when you leave an area and return
|
* which seems to solve the problem that chunks are invisible when you leave an area and return
|
||||||
* to it.
|
* to it.
|
||||||
* Any better fixes are welcome.
|
* Any better fixes are welcome.
|
||||||
@@ -48,17 +48,18 @@ public abstract class MixinViewFrustum {
|
|||||||
int k = this.countChunksX * 16;
|
int k = this.countChunksX * 16;
|
||||||
|
|
||||||
for (int l = 0; l < this.countChunksX; ++l) {
|
for (int l = 0; l < this.countChunksX; ++l) {
|
||||||
int i1 = this.func_178157_a(i, k, l);
|
int i1 = this.getBaseCoordinate(i, k, l);
|
||||||
for (int j1 = 0; j1 < this.countChunksZ; ++j1) {
|
for (int j1 = 0; j1 < this.countChunksZ; ++j1) {
|
||||||
int k1 = this.func_178157_a(j, k, j1);
|
int k1 = this.getBaseCoordinate(j, k, j1);
|
||||||
for (int l1 = 0; l1 < this.countChunksY; ++l1) {
|
for (int l1 = 0; l1 < this.countChunksY; ++l1) {
|
||||||
int i2 = l1 * 16;
|
int i2 = l1 * 16;
|
||||||
RenderChunk renderchunk = this.renderChunks[(j1 * this.countChunksY + l1) * this.countChunksX + l];
|
RenderChunk renderchunk = this.renderChunks[(j1 * this.countChunksY + l1) * this.countChunksX + l];
|
||||||
BlockPos blockpos = new BlockPos(i1, i2, k1);
|
BlockPos blockpos = new BlockPos(i1, i2, k1);
|
||||||
if (!blockpos.equals(renderchunk.getPosition())) {
|
if (!blockpos.equals(renderchunk.getPosition())) {
|
||||||
// Recreate render chunk instead of setting its position
|
// Recreate render chunk instead of setting its position
|
||||||
renderChunks[(j1 * this.countChunksY + l1) * this.countChunksX + l] =
|
(renderChunks[(j1 * this.countChunksY + l1) * this.countChunksX + l] =
|
||||||
renderChunkFactory.makeRenderChunk(world, renderGlobal, blockpos, 0);
|
renderChunkFactory.create(world, renderGlobal, 0)
|
||||||
|
).setOrigin(blockpos.getX(), blockpos.getY(), blockpos.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,5 +67,5 @@ public abstract class MixinViewFrustum {
|
|||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Shadow abstract int func_178157_a(int p_178157_1_, int p_178157_2_, int p_178157_3_);
|
@Shadow abstract int getBaseCoordinate(int p_178157_1_, int p_178157_2_, int p_178157_3_);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import com.replaymod.simplepathing.SPTimeline.SPPath;
|
|||||||
import com.replaymod.simplepathing.gui.GuiPathing;
|
import com.replaymod.simplepathing.gui.GuiPathing;
|
||||||
import com.replaymod.simplepathing.preview.PathPreview;
|
import com.replaymod.simplepathing.preview.PathPreview;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
@@ -19,7 +19,6 @@ import org.lwjgl.input.Keyboard;
|
|||||||
@Mod(modid = ReplayModSimplePathing.MOD_ID,
|
@Mod(modid = ReplayModSimplePathing.MOD_ID,
|
||||||
version = "@MOD_VERSION@",
|
version = "@MOD_VERSION@",
|
||||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||||
acceptableRemoteVersions = "*",
|
|
||||||
useMetadata = true)
|
useMetadata = true)
|
||||||
public class ReplayModSimplePathing {
|
public class ReplayModSimplePathing {
|
||||||
public static final String MOD_ID = "replaymod-simplepathing";
|
public static final String MOD_ID = "replaymod-simplepathing";
|
||||||
@@ -40,7 +39,7 @@ public class ReplayModSimplePathing {
|
|||||||
|
|
||||||
core.getSettingsRegistry().register(Setting.class);
|
core.getSettingsRegistry().register(Setting.class);
|
||||||
|
|
||||||
FMLCommonHandler.instance().bus().register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
|
||||||
PathPreview pathPreview = new PathPreview(this);
|
PathPreview pathPreview = new PathPreview(this);
|
||||||
pathPreview.register();
|
pathPreview.register();
|
||||||
|
|||||||
@@ -658,7 +658,7 @@ public class SPTimeline implements PathingRegistry {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
CrashReport crash = CrashReport.makeCrashReport(e, "Serializing interpolator");
|
CrashReport crash = CrashReport.makeCrashReport(e, "Serializing interpolator");
|
||||||
CrashReportCategory category = crash.makeCategory("Serializing interpolator");
|
CrashReportCategory category = crash.makeCategory("Serializing interpolator");
|
||||||
category.addCrashSectionCallable("Interpolator", interpolator::toString);
|
category.setDetail("Interpolator", interpolator::toString);
|
||||||
throw new ReportedException(crash);
|
throw new ReportedException(crash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import com.replaymod.replay.events.ReplayCloseEvent;
|
|||||||
import com.replaymod.replay.events.ReplayOpenEvent;
|
import com.replaymod.replay.events.ReplayOpenEvent;
|
||||||
import com.replaymod.simplepathing.ReplayModSimplePathing;
|
import com.replaymod.simplepathing.ReplayModSimplePathing;
|
||||||
import com.replaymod.simplepathing.Setting;
|
import com.replaymod.simplepathing.Setting;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ public class PathPreview {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void register() {
|
public void register() {
|
||||||
FMLCommonHandler.instance().bus().register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
|
||||||
ReplayMod core = mod.getCore();
|
ReplayMod core = mod.getCore();
|
||||||
mod.getCore().getKeyBindingRegistry().registerKeyBinding("replaymod.input.pathpreview", Keyboard.KEY_H, () -> {
|
mod.getCore().getKeyBindingRegistry().registerKeyBinding("replaymod.input.pathpreview", Keyboard.KEY_H, () -> {
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ import com.replaymod.simplepathing.gui.GuiPathing;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
import net.minecraft.client.renderer.WorldRenderer;
|
import net.minecraft.client.renderer.VertexBuffer;
|
||||||
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||||
@@ -203,26 +204,35 @@ public class PathPreviewRenderer {
|
|||||||
if (distanceSquared(view, pos2) > renderDistanceSquared) return;
|
if (distanceSquared(view, pos2) > renderDistanceSquared) return;
|
||||||
|
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
WorldRenderer renderer = tessellator.getWorldRenderer();
|
VertexBuffer vertexBuffer = tessellator.getBuffer();
|
||||||
renderer.setTranslation(-view.getLeft(), -view.getMiddle(), -view.getRight());
|
vertexBuffer.setTranslation(-view.getLeft(), -view.getMiddle(), -view.getRight());
|
||||||
|
|
||||||
renderer.startDrawing(GL11.GL_LINES);
|
vertexBuffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
|
||||||
renderer.setColorRGBA_I(color, 255);
|
|
||||||
|
|
||||||
renderer.addVertex(pos1.getLeft(), pos1.getMiddle(), pos1.getRight());
|
vertexBuffer.pos(pos1.getLeft(), pos1.getMiddle(), pos1.getRight()).color(
|
||||||
renderer.addVertex(pos2.getLeft(), pos2.getMiddle(), pos2.getRight());
|
color >> 16 & 0xff,
|
||||||
|
color >> 8 & 0xff,
|
||||||
|
color & 0xff,
|
||||||
|
255
|
||||||
|
).endVertex();
|
||||||
|
vertexBuffer.pos(pos2.getLeft(), pos2.getMiddle(), pos2.getRight()).color(
|
||||||
|
color >> 16 & 0xff,
|
||||||
|
color >> 8 & 0xff,
|
||||||
|
color & 0xff,
|
||||||
|
255
|
||||||
|
).endVertex();
|
||||||
|
|
||||||
GL11.glLineWidth(3);
|
GL11.glLineWidth(3);
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
renderer.setTranslation(0, 0, 0);
|
vertexBuffer.setTranslation(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawPoint(Triple<Double, Double, Double> view,
|
private void drawPoint(Triple<Double, Double, Double> view,
|
||||||
Triple<Double, Double, Double> pos,
|
Triple<Double, Double, Double> pos,
|
||||||
Keyframe keyframe) {
|
Keyframe keyframe) {
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
WorldRenderer renderer = tessellator.getWorldRenderer();
|
VertexBuffer vertexBuffer = tessellator.getBuffer();
|
||||||
renderer.setTranslation(0, 0, 0);
|
vertexBuffer.setTranslation(0, 0, 0);
|
||||||
|
|
||||||
mc.renderEngine.bindTexture(TEXTURE);
|
mc.renderEngine.bindTexture(TEXTURE);
|
||||||
|
|
||||||
@@ -243,12 +253,12 @@ public class PathPreviewRenderer {
|
|||||||
float maxX = 0.5f;
|
float maxX = 0.5f;
|
||||||
float maxY = 0.5f;
|
float maxY = 0.5f;
|
||||||
|
|
||||||
renderer.startDrawingQuads();
|
vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
||||||
|
|
||||||
renderer.addVertexWithUV(minX, minY, 0, posX + size, posY + size);
|
vertexBuffer.pos(minX, minY, 0).tex(posX + size, posY + size).endVertex();
|
||||||
renderer.addVertexWithUV(minX, maxY, 0, posX + size, posY);
|
vertexBuffer.pos(minX, maxY, 0).tex(posX + size, posY).endVertex();
|
||||||
renderer.addVertexWithUV(maxX, maxY, 0, posX, posY);
|
vertexBuffer.pos(maxX, maxY, 0).tex(posX, posY).endVertex();
|
||||||
renderer.addVertexWithUV(maxX, minY, 0, posX, posY + size);
|
vertexBuffer.pos(maxX, minY, 0).tex(posX, posY + size).endVertex();
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
|
|
||||||
@@ -270,8 +280,8 @@ public class PathPreviewRenderer {
|
|||||||
Triple<Double, Double, Double> pos,
|
Triple<Double, Double, Double> pos,
|
||||||
Triple<Float, Float, Float> rot) {
|
Triple<Float, Float, Float> rot) {
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
WorldRenderer renderer = tessellator.getWorldRenderer();
|
VertexBuffer vertexBuffer = tessellator.getBuffer();
|
||||||
renderer.setTranslation(0, 0, 0);
|
vertexBuffer.setTranslation(0, 0, 0);
|
||||||
|
|
||||||
mc.renderEngine.bindTexture(CAMERA_HEAD);
|
mc.renderEngine.bindTexture(CAMERA_HEAD);
|
||||||
|
|
||||||
@@ -289,12 +299,10 @@ public class PathPreviewRenderer {
|
|||||||
|
|
||||||
//draw the position line
|
//draw the position line
|
||||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||||
renderer.startDrawing(GL11.GL_LINES);
|
vertexBuffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
|
||||||
|
|
||||||
renderer.setColorRGBA_I(0x00ff00, 170);
|
vertexBuffer.pos(0, 0, 0).color(0, 255, 0, 170).endVertex();
|
||||||
|
vertexBuffer.pos(0, 0, 2).color(0, 255, 0, 170).endVertex();
|
||||||
renderer.addVertex(0, 0, 0);
|
|
||||||
renderer.addVertex(0, 0, 2);
|
|
||||||
|
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
|
|
||||||
@@ -305,45 +313,43 @@ public class PathPreviewRenderer {
|
|||||||
|
|
||||||
double r = -cubeSize/2;
|
double r = -cubeSize/2;
|
||||||
|
|
||||||
renderer.startDrawingQuads();
|
vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||||
|
|
||||||
renderer.setColorRGBA_I(0xffffff, 200);
|
|
||||||
|
|
||||||
//back
|
//back
|
||||||
renderer.addVertexWithUV(r, r + cubeSize, r, 3 * 8 / 64f, 8 / 64f);
|
vertexBuffer.pos(r, r + cubeSize, r).tex(3 * 8 / 64f, 8 / 64f).color(255, 255, 255, 200).endVertex();
|
||||||
renderer.addVertexWithUV(r + cubeSize, r + cubeSize, r, 4*8/64f, 8/64f);
|
vertexBuffer.pos(r + cubeSize, r + cubeSize, r).tex(4*8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
||||||
renderer.addVertexWithUV(r + cubeSize, r, r, 4*8/64f, 2*8/64f);
|
vertexBuffer.pos(r + cubeSize, r, r).tex(4*8/64f, 2*8/64f).color(255, 255, 255, 200).endVertex();
|
||||||
renderer.addVertexWithUV(r, r, r, 3*8/64f, 2*8/64f);
|
vertexBuffer.pos(r, r, r).tex(3*8/64f, 2*8/64f).color(255, 255, 255, 200).endVertex();
|
||||||
|
|
||||||
//front
|
//front
|
||||||
renderer.addVertexWithUV(r + cubeSize, r, r + cubeSize, 2 * 8 / 64f, 2*8/64f);
|
vertexBuffer.pos(r + cubeSize, r, r + cubeSize).tex(2 * 8 / 64f, 2*8/64f).color(255, 255, 255, 200).endVertex();
|
||||||
renderer.addVertexWithUV(r + cubeSize, r + cubeSize, r + cubeSize, 2 * 8 / 64f, 8/64f);
|
vertexBuffer.pos(r + cubeSize, r + cubeSize, r + cubeSize).tex(2 * 8 / 64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
||||||
renderer.addVertexWithUV(r, r + cubeSize, r + cubeSize, 8 / 64f, 8 / 64f);
|
vertexBuffer.pos(r, r + cubeSize, r + cubeSize).tex(8 / 64f, 8 / 64f).color(255, 255, 255, 200).endVertex();
|
||||||
renderer.addVertexWithUV(r, r, r + cubeSize, 8 / 64f, 2*8/64f);
|
vertexBuffer.pos(r, r, r + cubeSize).tex(8 / 64f, 2*8/64f).color(255, 255, 255, 200).endVertex();
|
||||||
|
|
||||||
//left
|
//left
|
||||||
renderer.addVertexWithUV(r + cubeSize, r + cubeSize, r, 0, 8/64f);
|
vertexBuffer.pos(r + cubeSize, r + cubeSize, r).tex(0, 8/64f).color(255, 255, 255, 200).endVertex();
|
||||||
renderer.addVertexWithUV(r + cubeSize, r + cubeSize, r + cubeSize, 8/64f, 8/64f);
|
vertexBuffer.pos(r + cubeSize, r + cubeSize, r + cubeSize).tex(8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
||||||
renderer.addVertexWithUV(r + cubeSize, r, r + cubeSize, 8/64f, 2*8/64f);
|
vertexBuffer.pos(r + cubeSize, r, r + cubeSize).tex(8/64f, 2*8/64f).color(255, 255, 255, 200).endVertex();
|
||||||
renderer.addVertexWithUV(r+cubeSize, r, r, 0, 2*8/64f);
|
vertexBuffer.pos(r+cubeSize, r, r).tex(0, 2*8/64f).color(255, 255, 255, 200).endVertex();
|
||||||
|
|
||||||
//right
|
//right
|
||||||
renderer.addVertexWithUV(r, r + cubeSize, r + cubeSize, 2*8/64f, 8/64f);
|
vertexBuffer.pos(r, r + cubeSize, r + cubeSize).tex(2*8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
||||||
renderer.addVertexWithUV(r, r + cubeSize, r, 3*8/64f, 8/64f);
|
vertexBuffer.pos(r, r + cubeSize, r).tex(3*8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
||||||
renderer.addVertexWithUV(r, r, r, 3*8/64f, 2*8/64f);
|
vertexBuffer.pos(r, r, r).tex(3*8/64f, 2*8/64f).color(255, 255, 255, 200).endVertex();
|
||||||
renderer.addVertexWithUV(r, r, r + cubeSize, 2 * 8 / 64f, 2 * 8 / 64f);
|
vertexBuffer.pos(r, r, r + cubeSize).tex(2 * 8 / 64f, 2 * 8 / 64f).color(255, 255, 255, 200).endVertex();
|
||||||
|
|
||||||
//bottom
|
//bottom
|
||||||
renderer.addVertexWithUV(r + cubeSize, r, r, 3*8/64f, 0);
|
vertexBuffer.pos(r + cubeSize, r, r).tex(3*8/64f, 0).color(255, 255, 255, 200).endVertex();
|
||||||
renderer.addVertexWithUV(r + cubeSize, r, r + cubeSize, 3*8/64f, 8/64f);
|
vertexBuffer.pos(r + cubeSize, r, r + cubeSize).tex(3*8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
||||||
renderer.addVertexWithUV(r, r, r + cubeSize, 2*8/64f, 8/64f);
|
vertexBuffer.pos(r, r, r + cubeSize).tex(2*8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
||||||
renderer.addVertexWithUV(r, r, r, 2 * 8 / 64f, 0);
|
vertexBuffer.pos(r, r, r).tex(2 * 8 / 64f, 0).color(255, 255, 255, 200).endVertex();
|
||||||
|
|
||||||
//top
|
//top
|
||||||
renderer.addVertexWithUV(r, r + cubeSize, r, 8/64f, 0);
|
vertexBuffer.pos(r, r + cubeSize, r).tex(8/64f, 0).color(255, 255, 255, 200).endVertex();
|
||||||
renderer.addVertexWithUV(r, r + cubeSize, r + cubeSize, 8/64f, 8/64f);
|
vertexBuffer.pos(r, r + cubeSize, r + cubeSize).tex(8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
||||||
renderer.addVertexWithUV(r + cubeSize, r + cubeSize, r + cubeSize, 2*8/64f, 8/64f);
|
vertexBuffer.pos(r + cubeSize, r + cubeSize, r + cubeSize).tex(2*8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
||||||
renderer.addVertexWithUV(r + cubeSize, r + cubeSize, r, 2 * 8 / 64f, 0);
|
vertexBuffer.pos(r + cubeSize, r + cubeSize, r).tex(2 * 8 / 64f, 0).color(255, 255, 255, 200).endVertex();
|
||||||
|
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# To apply changes in this file run: ./gradlew clean setupDecompWorkspace idea
|
# To apply changes in this file run: ./gradlew clean setupDecompWorkspace idea
|
||||||
|
|
||||||
# Minecraft
|
# Minecraft
|
||||||
public net.minecraft.client.Minecraft field_71428_T # timer
|
public-f net.minecraft.client.Minecraft field_71428_T # timer
|
||||||
public net.minecraft.client.Minecraft field_83002_am # debugCrashKeyPressTime
|
public net.minecraft.client.Minecraft field_83002_am # debugCrashKeyPressTime
|
||||||
public net.minecraft.client.Minecraft field_71467_ac # rightClickDelayTimer
|
public net.minecraft.client.Minecraft field_71467_ac # rightClickDelayTimer
|
||||||
public net.minecraft.client.Minecraft field_71423_H # systemTime
|
public net.minecraft.client.Minecraft field_71423_H # systemTime
|
||||||
@@ -21,23 +21,23 @@ public net.minecraft.client.Minecraft func_147112_ai()V # middleClickMouse
|
|||||||
public net.minecraft.client.Minecraft func_147115_a(Z)V # sendClickBlockToController
|
public net.minecraft.client.Minecraft func_147115_a(Z)V # sendClickBlockToController
|
||||||
|
|
||||||
# Packets
|
# Packets
|
||||||
public net.minecraft.network.play.server.S0FPacketSpawnMob field_149043_l # dataWatcher
|
public net.minecraft.network.play.server.SPacketSpawnMob field_149043_l # dataManager
|
||||||
|
public net.minecraft.network.play.server.SPacketSpawnPlayer field_148960_i # watcher
|
||||||
#public net.minecraft.network.play.server.S38PacketPlayerListItem field_179964_d # profile
|
#public net.minecraft.network.play.server.S38PacketPlayerListItem field_179964_d # profile
|
||||||
public net.minecraft.network.play.server.S1DPacketEntityEffect field_149434_a # entityId
|
# public net.minecraft.network.play.server.S1DPacketEntityEffect field_149434_a # entityId
|
||||||
public net.minecraft.network.play.server.S1CPacketEntityMetadata field_149379_a # entityId
|
# public net.minecraft.network.play.server.S1CPacketEntityMetadata field_149379_a # entityId
|
||||||
public net.minecraft.network.play.server.S1CPacketEntityMetadata field_149378_b # list
|
# public net.minecraft.network.play.server.S1CPacketEntityMetadata field_149378_b # list
|
||||||
public net.minecraft.network.play.server.S0BPacketAnimation field_148981_a # entityId
|
# public net.minecraft.network.play.server.S0BPacketAnimation field_148981_a # entityId
|
||||||
public net.minecraft.network.play.server.S02PacketChat field_179842_b # position
|
# public net.minecraft.network.play.server.S02PacketChat field_179842_b # position
|
||||||
public net.minecraft.network.play.server.S19PacketEntityStatus field_149164_a # entityId
|
# public net.minecraft.network.play.server.S19PacketEntityStatus field_149164_a # entityId
|
||||||
public net.minecraft.network.play.server.S0CPacketSpawnPlayer *
|
# public net.minecraft.network.play.server.S18PacketEntityTeleport *
|
||||||
public net.minecraft.network.play.server.S18PacketEntityTeleport *
|
# public net.minecraft.network.play.server.S14PacketEntity *
|
||||||
public net.minecraft.network.play.server.S14PacketEntity *
|
# public net.minecraft.network.play.server.S19PacketEntityHeadLook *
|
||||||
public net.minecraft.network.play.server.S19PacketEntityHeadLook *
|
# public net.minecraft.network.play.server.S12PacketEntityVelocity *
|
||||||
public net.minecraft.network.play.server.S12PacketEntityVelocity *
|
# public net.minecraft.network.play.server.S04PacketEntityEquipment *
|
||||||
public net.minecraft.network.play.server.S04PacketEntityEquipment *
|
# public net.minecraft.network.play.server.S1BPacketEntityAttach *
|
||||||
public net.minecraft.network.play.server.S1BPacketEntityAttach *
|
# public net.minecraft.network.play.server.S0DPacketCollectItem *
|
||||||
public net.minecraft.network.play.server.S0DPacketCollectItem *
|
# public net.minecraft.network.play.server.S13PacketDestroyEntities *
|
||||||
public net.minecraft.network.play.server.S13PacketDestroyEntities *
|
|
||||||
|
|
||||||
# GuiTextField
|
# GuiTextField
|
||||||
public net.minecraft.client.gui.GuiTextField field_146216_j # text
|
public net.minecraft.client.gui.GuiTextField field_146216_j # text
|
||||||
@@ -61,7 +61,7 @@ public net.minecraft.client.renderer.RenderGlobal field_175009_l # chunksToUpdat
|
|||||||
public net.minecraft.client.renderer.RenderGlobal field_72755_R # renderInfos
|
public net.minecraft.client.renderer.RenderGlobal field_72755_R # renderInfos
|
||||||
public net.minecraft.client.renderer.RenderGlobal field_175009_l # chunksToUpdate
|
public net.minecraft.client.renderer.RenderGlobal field_175009_l # chunksToUpdate
|
||||||
public net.minecraft.client.renderer.RenderGlobal field_72740_G # renderEntitiesStartupCounter
|
public net.minecraft.client.renderer.RenderGlobal field_72740_G # renderEntitiesStartupCounter
|
||||||
public net.minecraft.client.renderer.RenderGlobal func_174983_a(Lnet.minecraft.util.BlockPos;Lnet.minecraft.client.renderer.chunk.RenderChunk;)Z # isPositionInRenderChunk
|
# public net.minecraft.client.renderer.RenderGlobal func_174983_a(Lnet.minecraft.util.BlockPos;Lnet.minecraft.client.renderer.chunk.RenderChunk;)Z # isPositionInRenderChunk
|
||||||
|
|
||||||
public net.minecraft.client.renderer.RenderGlobal$ContainerLocalRenderInformation
|
public net.minecraft.client.renderer.RenderGlobal$ContainerLocalRenderInformation
|
||||||
#public net.minecraft.client.renderer.RenderGlobal$ContainerLocalRenderInformation field_178553_a # renderChunk
|
#public net.minecraft.client.renderer.RenderGlobal$ContainerLocalRenderInformation field_178553_a # renderChunk
|
||||||
@@ -88,17 +88,17 @@ public net.minecraft.entity.player.EntityPlayer *
|
|||||||
public net.minecraft.client.entity.EntityOtherPlayerMP *
|
public net.minecraft.client.entity.EntityOtherPlayerMP *
|
||||||
|
|
||||||
# EffectRenderer
|
# EffectRenderer
|
||||||
public net.minecraft.client.particle.EffectRenderer field_110737_b # particleTextures
|
# public net.minecraft.client.particle.EffectRenderer field_110737_b # particleTextures
|
||||||
public net.minecraft.client.particle.EffectRenderer field_78876_b # fxLayers
|
# public net.minecraft.client.particle.EffectRenderer field_78876_b # fxLayers
|
||||||
|
|
||||||
# IntegratedServer
|
# IntegratedServer
|
||||||
public net.minecraft.server.integrated.IntegratedServer field_71348_o # isGamePaused
|
public net.minecraft.server.integrated.IntegratedServer field_71348_o # isGamePaused
|
||||||
|
|
||||||
# GameSettings
|
# GameSettings
|
||||||
public net.minecraft.client.settings.GameSettings field_151446_aD # mapSoundLevels
|
public-f net.minecraft.client.settings.GameSettings field_186714_aM # soundLevels
|
||||||
|
|
||||||
# Frustum
|
# Frustum
|
||||||
public net.minecraft.client.renderer.culling.Frustum field_78552_a # clippingHelper
|
public-f net.minecraft.client.renderer.culling.Frustum field_78552_a # clippingHelper
|
||||||
|
|
||||||
# CrashReportCategory
|
# CrashReportCategory
|
||||||
public net.minecraft.crash.CrashReportCategory field_85077_c # children
|
public net.minecraft.crash.CrashReportCategory field_85077_c # children
|
||||||
@@ -117,5 +117,12 @@ public net.minecraft.client.renderer.GlStateManager$FogState
|
|||||||
public net.minecraft.client.renderer.GlStateManager$BooleanState
|
public net.minecraft.client.renderer.GlStateManager$BooleanState
|
||||||
public net.minecraft.client.renderer.GlStateManager$BooleanState *
|
public net.minecraft.client.renderer.GlStateManager$BooleanState *
|
||||||
|
|
||||||
|
# EntityLivingBase
|
||||||
|
public net.minecraft.entity.EntityLivingBase field_184621_as # HAND_STATES
|
||||||
|
public net.minecraft.entity.EntityLivingBase field_184628_bn # activeItemStackUseCount
|
||||||
|
|
||||||
|
# EntityLivingBase
|
||||||
|
public net.minecraft.client.particle.Particle *
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
# public net.minecraft.package.ClassName func_some_id(Ljava/lang/Class;IZS)V # methodName
|
# public net.minecraft.package.ClassName func_some_id(Ljava/lang/Class;IZS)V # methodName
|
||||||
|
|||||||
Submodule src/main/resources/assets/replaymod/lang updated: 8d77fe0697...da6f6f8d12
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user