Workaround a bug in MC where light is not updated (fixes #209)
MC stores server light data and only applies it during the next frame. Therefore, if there is no frame between receiving the chunk and block changes in it (like when jumping in replays), then the light update from the block change gets lost.
This commit is contained in:
@@ -66,11 +66,14 @@ import de.johni0702.minecraft.gui.versions.callbacks.PreTickCallback;
|
|||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
//#if MC>=11400
|
//#if MC>=11400
|
||||||
|
import com.replaymod.core.versions.MCVer;
|
||||||
|
import net.minecraft.network.packet.s2c.play.ChunkDataS2CPacket;
|
||||||
import net.minecraft.network.packet.s2c.play.PlayerActionResponseS2CPacket;
|
import net.minecraft.network.packet.s2c.play.PlayerActionResponseS2CPacket;
|
||||||
import net.minecraft.network.packet.s2c.play.OpenContainerS2CPacket;
|
import net.minecraft.network.packet.s2c.play.OpenContainerS2CPacket;
|
||||||
import net.minecraft.network.packet.s2c.play.OpenWrittenBookS2CPacket;
|
import net.minecraft.network.packet.s2c.play.OpenWrittenBookS2CPacket;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
|
import net.minecraft.world.chunk.light.LightingProvider;
|
||||||
//#else
|
//#else
|
||||||
//$$ import net.minecraft.client.resources.I18n;
|
//$$ import net.minecraft.client.resources.I18n;
|
||||||
//$$ import net.minecraft.entity.Entity;
|
//$$ import net.minecraft.entity.Entity;
|
||||||
@@ -453,6 +456,24 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
|||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=11400
|
||||||
|
if (p instanceof ChunkDataS2CPacket) {
|
||||||
|
Runnable doLightUpdates = () -> {
|
||||||
|
if (mc.world != null) {
|
||||||
|
LightingProvider provider = mc.world.getChunkManager().getLightingProvider();
|
||||||
|
while (provider.hasUpdates()) {
|
||||||
|
provider.doLightUpdates(Integer.MAX_VALUE, true, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (MCVer.isOnMainThread()) {
|
||||||
|
doLightUpdates.run();
|
||||||
|
} else {
|
||||||
|
MCVer.scheduleOnMainThread(doLightUpdates);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// We'd rather not have a failure parsing one packet screw up the whole replay process
|
// We'd rather not have a failure parsing one packet screw up the whole replay process
|
||||||
|
|||||||
Reference in New Issue
Block a user