trying to flush the toileight
This commit is contained in:
1 parent
a867c04b11
commit
646be6298e
4 files changed
+73
-6
No files matched your search
@@ -0,0 +1,9 @@
|
|||||||
|
package carpet.fakes;
|
||||||
|
|
||||||
|
import net.minecraft.util.math.ChunkPos;
|
||||||
|
|
||||||
|
public interface ServerLightingProviderInterface
|
||||||
|
{
|
||||||
|
void publicUpdateChunkStatus(ChunkPos pos);
|
||||||
|
void flush();
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package carpet.mixins;
|
||||||
|
|
||||||
|
import carpet.fakes.ServerLightingProviderInterface;
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectList;
|
||||||
|
import net.minecraft.server.world.ServerLightingProvider;
|
||||||
|
import net.minecraft.util.math.ChunkPos;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
import static java.lang.Thread.yield;
|
||||||
|
|
||||||
|
@Mixin(ServerLightingProvider.class)
|
||||||
|
public abstract class ServerLightingProvider_scarpetChunkCreationMixin implements ServerLightingProviderInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
@Shadow protected abstract void updateChunkStatus(ChunkPos pos);
|
||||||
|
|
||||||
|
@Shadow private volatile int taskBatchSize;
|
||||||
|
|
||||||
|
@Shadow public abstract void setTaskBatchSize(int taskBatchSize);
|
||||||
|
|
||||||
|
@Shadow @Final private AtomicBoolean field_18812;
|
||||||
|
|
||||||
|
@Shadow @Final private ObjectList pendingTasks;
|
||||||
|
|
||||||
|
@Shadow protected abstract void runTasks();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void publicUpdateChunkStatus(ChunkPos pos)
|
||||||
|
{
|
||||||
|
updateChunkStatus(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void flush()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
while (!field_18812.compareAndSet(false, true)) yield();
|
||||||
|
if (pendingTasks.size() == 0) return;
|
||||||
|
int prevTaskBatchSize = taskBatchSize;
|
||||||
|
setTaskBatchSize(pendingTasks.size());
|
||||||
|
runTasks();
|
||||||
|
setTaskBatchSize(prevTaskBatchSize);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
this.field_18812.set(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
-6
@@ -1,6 +1,7 @@
|
|||||||
package carpet.mixins;
|
package carpet.mixins;
|
||||||
|
|
||||||
import carpet.fakes.ChunkHolderInterface;
|
import carpet.fakes.ChunkHolderInterface;
|
||||||
|
import carpet.fakes.ServerLightingProviderInterface;
|
||||||
import carpet.fakes.ThreadedAnvilChunkStorageInterface;
|
import carpet.fakes.ThreadedAnvilChunkStorageInterface;
|
||||||
import carpet.script.utils.WorldTools;
|
import carpet.script.utils.WorldTools;
|
||||||
import com.mojang.datafixers.util.Either;
|
import com.mojang.datafixers.util.Either;
|
||||||
@@ -155,7 +156,7 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
|
|||||||
//apparently that doesn't remove them for the client
|
//apparently that doesn't remove them for the client
|
||||||
this.world.unloadEntities(worldChunk);
|
this.world.unloadEntities(worldChunk);
|
||||||
}
|
}
|
||||||
//this.serverLightingProvider.updateChunkStatus(chunk.getPos()); // we might need that as some point
|
((ServerLightingProviderInterface)this.serverLightingProvider).publicUpdateChunkStatus(chunk.getPos()); // we might need that as some point
|
||||||
serverLightingProvider.tick();
|
serverLightingProvider.tick();
|
||||||
worldGenerationProgressListener.setChunkStatus(chunk.getPos(), (ChunkStatus) null);
|
worldGenerationProgressListener.setChunkStatus(chunk.getPos(), (ChunkStatus) null);
|
||||||
}
|
}
|
||||||
@@ -175,6 +176,7 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
|
|||||||
this.chunkHolderListDirty = true;
|
this.chunkHolderListDirty = true;
|
||||||
// not needed right now
|
// not needed right now
|
||||||
mainThreadExecutor.runTasks(() -> mainThreadExecutor.getTaskCount() == 0);
|
mainThreadExecutor.runTasks(() -> mainThreadExecutor.getTaskCount() == 0);
|
||||||
|
((ServerLightingProviderInterface)this.serverLightingProvider).flush();
|
||||||
//worldgenExecutor.
|
//worldgenExecutor.
|
||||||
// save all pending chunks / potentially only one max - ours
|
// save all pending chunks / potentially only one max - ours
|
||||||
// hopefully that would flush all chunk writes, including current chink
|
// hopefully that would flush all chunk writes, including current chink
|
||||||
@@ -187,10 +189,10 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
|
|||||||
{
|
{
|
||||||
report.put("layer_count_"+status.getId(),targetStatus.size());
|
report.put("layer_count_"+status.getId(),targetStatus.size());
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
if (status == ChunkStatus.LIGHT)
|
//if (status == ChunkStatus.LIGHT)
|
||||||
{
|
//{
|
||||||
serverLightingProvider.setTaskBatchSize(targetStatus.size() + 20);
|
// serverLightingProvider.setTaskBatchSize(targetStatus.size() + 20);
|
||||||
}
|
//}
|
||||||
for (ChunkPos chpos : new ArrayList<>(targetStatus.keySet()))
|
for (ChunkPos chpos : new ArrayList<>(targetStatus.keySet()))
|
||||||
{
|
{
|
||||||
if (targetStatus.get(chpos) == status)
|
if (targetStatus.get(chpos) == status)
|
||||||
@@ -201,7 +203,8 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
|
|||||||
}
|
}
|
||||||
if (status == ChunkStatus.LIGHT)
|
if (status == ChunkStatus.LIGHT)
|
||||||
{ // default task batch size after initial generation is done
|
{ // default task batch size after initial generation is done
|
||||||
serverLightingProvider.setTaskBatchSize(5);
|
//serverLightingProvider.setTaskBatchSize(5);
|
||||||
|
((ServerLightingProviderInterface)this.serverLightingProvider).flush();
|
||||||
}
|
}
|
||||||
report.put("layer_time_"+status.getId(), (int) (System.currentTimeMillis()-start));
|
report.put("layer_time_"+status.getId(), (int) (System.currentTimeMillis()-start));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
"ThreadedAnvilChunkStorage_scarpetChunkCreationMixin",
|
"ThreadedAnvilChunkStorage_scarpetChunkCreationMixin",
|
||||||
"ChunkHolder_scarpetChunkCreationMixin",
|
"ChunkHolder_scarpetChunkCreationMixin",
|
||||||
|
"ServerLightingProvider_scarpetChunkCreationMixin",
|
||||||
|
|
||||||
"MobEntityMixin",
|
"MobEntityMixin",
|
||||||
"ServerWorld_unloadedEntityMixin",
|
"ServerWorld_unloadedEntityMixin",
|
||||||
|
|||||||
Reference in new issue
Block a user