feat: protect mod payloads with main-thread ownership in 1.1.17
This commit is contained in:
1 parent
691e949691
commit
763c015103
29 files changed
+1552
-53
No files matched your search
@@ -2,13 +2,11 @@ package dev.modzuozhi;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import dev.modzuozhi.core.compat.SableAssemblyDispatch;
|
||||
import dev.modzuozhi.core.compat.SableMainThreadBridge;
|
||||
import dev.modzuozhi.core.compat.PayloadMainThreadDispatch;
|
||||
import dev.modzuozhi.core.dimthread.DimThreadCore;
|
||||
import dev.modzuozhi.core.dimthread.FineGrainScheduler;
|
||||
import dev.modzuozhi.core.dimthread.FaultGuard;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ClientInformation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
@@ -41,14 +39,14 @@ public final class InteractionFlowRegression {
|
||||
level.setBlockAndUpdate(new BlockPos(x, 100, z), Blocks.AIR.defaultBlockState());
|
||||
}
|
||||
level.setBlockAndUpdate(SOURCE.above(3), Blocks.CHEST.defaultBlockState());
|
||||
var player = new ServerPlayer(server, level, new GameProfile(UUID.randomUUID(), "Regression"),
|
||||
ClientInformation.createDefault()) {
|
||||
@Override public boolean hasDisconnected() { return false; }
|
||||
};
|
||||
// A real listener is now part of the shared dispatch's stale-connection contract.
|
||||
var player = new net.neoforged.neoforge.common.util.FakePlayer(level,
|
||||
new GameProfile(UUID.randomUUID(), "Regression"));
|
||||
startTime = level.getGameTime();
|
||||
DimThreadCore.MANAGER.setPaused(server, false);
|
||||
SableAssemblyDispatch.dispatch(player, () -> {
|
||||
if (!server.isSameThread() || !SableMainThreadBridge.ownsHandoff(level))
|
||||
if (!server.isSameThread() || !PayloadMainThreadDispatch.owns(server)
|
||||
|| DimThreadCore.MANAGER.ownershipLoopsSnapshot().stream().anyMatch(loop -> loop.isTicking()))
|
||||
throw new AssertionError("Interaction did not obtain exclusive server ownership");
|
||||
if (level.getBlockEntity(SOURCE.above(3)) == null)
|
||||
throw new AssertionError("Main-thread block entity lookup silently failed");
|
||||
|
||||
Reference in new issue
Block a user