Merge branch 1.11-staging into 1.11.2-staging
5257a41Merge branch 1.10.2 into 1.11689f897Merge branch 1.9.4 into 1.10.20aed9c3Merge branch 1.8.9 into 1.9.4f36ebf1Merge branch 1.8 into 1.8.908170b3Downgrade FG to 2.1 because FG 2.2 is 1.9+ only41d2547Update translations00e999fFix replay not being closed when opened via URI scheme handler (fixes #92)767ea29Fix book gui not being suppressed during replay (fixes #90)5b04edbHide ReplayMod app entry from menus on Linux6aff99dFix livelock during netty write to embedded channel (fixes #85)703805fFix infinite loop in mc.scheduledTasks (fixes #86)7a4440cUpdate ReplayStudio0b9c56cFix resource packs not working after first time jumping back in time933ee5f[Compat] Fix camera entity with BetterSprinting prior to 2.0.0 (fixes #78)83b1090Fix hotbar being visible while spectating player (fixes #83)5c73117[Compat] Fix invisible entities with Orange's 1.7 Animations (fixes #78)4704b29Replace the RenderPlayer hook (used subclassing) with a mixin (fixes #79)0c226b0Fix path at end of replay resulting in constant reloading (fixes #56)1b9b13eRename render success sound to all lowercase (required for 1.11) (fixes #66)c2000b3Fix only front-facing chunks visible for ODS rendering (fixes #67)aafeeccFix initial login gui not closing on success (fixes #68)9292addUse percent-encoding for replay file names (fixes #71)8499c0fFix name of invis armor stand with CustomNameVisible not rendering (fixes #72)b9ea572Try to handle invalid ffmpeg arguments more gracefully (fixes #77)a2f8c88Fix compression packets being recorded (fixes #80)19629c3Replace usages of System.out with loggerfe1d9b8Stop Forge from allowing the mod to load on other MC versions (fixes #82)d56fa9bUpdate ReplayStudio/MCProtocolLib (Fixes missing ARMOR_STAND MobType)7c719e0Update ReplayStudio/MCProtocolLib (Fixes missing ARMOR_STAND MobType)1a1e96cFix server with RM installed refusing clients without RM (fixes #76)35eb9caReplace usage of FMLLog with the mod logger
This commit is contained in:
@@ -2,15 +2,16 @@ package com.replaymod.replay;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.util.concurrent.ListenableFutureTask;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import com.replaymod.core.utils.Restrictions;
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import com.replaymod.replaystudio.replay.ReplayFile;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityOtherPlayerMP;
|
||||
import net.minecraft.client.gui.GuiDownloadTerrain;
|
||||
@@ -35,7 +36,6 @@ import java.io.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* Sends replay packets to netty channels.
|
||||
@@ -43,7 +43,7 @@ import java.util.concurrent.Callable;
|
||||
* the replay restart from the beginning.
|
||||
*/
|
||||
@Sharable
|
||||
public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
public class ReplaySender extends ChannelDuplexHandler {
|
||||
/**
|
||||
* These packets are ignored completely during replay.
|
||||
*/
|
||||
@@ -242,6 +242,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
try {
|
||||
channelInactive(ctx);
|
||||
ctx.channel().pipeline().close();
|
||||
FileUtils.deleteDirectory(tempResourcePackFolder);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -383,6 +384,13 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
|
||||
if(BAD_PACKETS.contains(p.getClass())) return null;
|
||||
|
||||
if (p instanceof SPacketCustomPayload) {
|
||||
SPacketCustomPayload packet = (SPacketCustomPayload) p;
|
||||
if ("MC|BOpen".equals(packet.getChannelName())) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if(p instanceof SPacketResourcePackSend) {
|
||||
SPacketResourcePackSend packet = (SPacketResourcePackSend) p;
|
||||
String url = packet.getURL();
|
||||
@@ -456,22 +464,19 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
new Callable<Void>() {
|
||||
new Runnable() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Void call() {
|
||||
public void run() {
|
||||
if (mc.world == null || !mc.isCallingFromMinecraftThread()) {
|
||||
synchronized(mc.scheduledTasks) {
|
||||
mc.scheduledTasks.add(ListenableFutureTask.create(this));
|
||||
}
|
||||
return null;
|
||||
ReplayMod.instance.runLater(this);
|
||||
return;
|
||||
}
|
||||
|
||||
CameraEntity cent = replayHandler.getCameraEntity();
|
||||
cent.setCameraPosition(ppl.getX(), ppl.getY(), ppl.getZ());
|
||||
return null;
|
||||
}
|
||||
}.call();
|
||||
}.run();
|
||||
}
|
||||
|
||||
if(p instanceof SPacketChangeGameState) {
|
||||
@@ -508,9 +513,22 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
FileUtils.deleteDirectory(tempResourcePackFolder);
|
||||
super.channelInactive(ctx);
|
||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
||||
// The embedded channel's event loop will consider every thread to be in it and as such provides no
|
||||
// guarantees that only one thread is using the pipeline at any one time.
|
||||
// For reading the replay sender (either sync or async) is the only thread ever writing.
|
||||
// For writing it may very well happen that multiple threads want to use the pipline at the same time.
|
||||
// It's unclear whether the EmbeddedChannel is supposed to be thread-safe (the behavior of the event loop
|
||||
// does suggest that). However it seems like it either isn't (likely) or there is a race condition.
|
||||
// See: https://www.replaymod.com/forum/thread/1752#post8045 (https://paste.replaymod.com/lotacatuwo)
|
||||
// To work around this issue, we just outright drop all write/flush requests (they aren't needed anyway).
|
||||
// This still leaves channel handlers upstream with the threading issue but they all seem to cope well with it.
|
||||
promise.setSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush(ChannelHandlerContext ctx) throws Exception {
|
||||
// See write method above
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -738,6 +756,9 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
synchronized (this) {
|
||||
if (timestamp == lastTimeStamp) { // Do nothing if we're already there
|
||||
return;
|
||||
}
|
||||
if (timestamp < lastTimeStamp) { // Restart the replay if we need to go backwards in time
|
||||
hasWorldLoaded = false;
|
||||
lastTimeStamp = 0;
|
||||
|
||||
Reference in New Issue
Block a user