WIP changes from stream
This commit is contained in:
@@ -7,7 +7,6 @@ import ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemChunk
|
||||
import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkHolderManager;
|
||||
import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler;
|
||||
import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.server.level.ChunkHolder;
|
||||
import net.minecraft.server.level.ChunkMap;
|
||||
import net.minecraft.server.level.ChunkResult;
|
||||
@@ -17,9 +16,7 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.TicketType;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ImposterProtoChunk;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
@@ -41,6 +38,24 @@ public abstract class ChunkHolderMixin extends GenerationChunkHolder implements
|
||||
@Final
|
||||
private ChunkHolder.PlayerProvider playerProvider;
|
||||
|
||||
@Shadow
|
||||
private volatile CompletableFuture<ChunkResult<LevelChunk>> fullChunkFuture;
|
||||
|
||||
@Shadow
|
||||
private volatile CompletableFuture<ChunkResult<LevelChunk>> tickingChunkFuture;
|
||||
|
||||
@Shadow
|
||||
private volatile CompletableFuture<ChunkResult<LevelChunk>> entityTickingChunkFuture;
|
||||
|
||||
@Shadow
|
||||
private CompletableFuture<?> pendingFullStateConfirmation;
|
||||
|
||||
@Shadow
|
||||
private CompletableFuture<?> sendSync;
|
||||
|
||||
@Shadow
|
||||
private CompletableFuture<?> saveSync;
|
||||
|
||||
public ChunkHolderMixin(ChunkPos chunkPos) {
|
||||
super(chunkPos);
|
||||
}
|
||||
@@ -120,6 +135,13 @@ public abstract class ChunkHolderMixin extends GenerationChunkHolder implements
|
||||
)
|
||||
private void initFields(final CallbackInfo ci) {
|
||||
this.playersSentChunkTo = new ReferenceList<>(EMPTY_PLAYER_ARRAY, 0);
|
||||
|
||||
this.fullChunkFuture = null;
|
||||
this.tickingChunkFuture = null;
|
||||
this.entityTickingChunkFuture = null;
|
||||
this.pendingFullStateConfirmation = null;
|
||||
this.sendSync = null;
|
||||
this.saveSync = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,6 +256,24 @@ public abstract class ChunkHolderMixin extends GenerationChunkHolder implements
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Chunk system is not built on futures anymore
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Overwrite
|
||||
public boolean isReadyForSaving() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Chunk system is not built on futures anymore
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Overwrite
|
||||
public void addSaveDependency(final CompletableFuture<?> completableFuture) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason need to reroute getTickingChunk to getChunkToSend, as we do not bring all sent chunks to ticking
|
||||
* @author Spottedleaf
|
||||
|
||||
@@ -10,7 +10,6 @@ import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder;
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.StreamTagVisitor;
|
||||
import net.minecraft.server.level.ChunkGenerationTask;
|
||||
import net.minecraft.server.level.ChunkHolder;
|
||||
import net.minecraft.server.level.ChunkMap;
|
||||
@@ -29,7 +28,6 @@ import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStep;
|
||||
import net.minecraft.world.level.chunk.storage.ChunkScanAccess;
|
||||
import net.minecraft.world.level.chunk.storage.ChunkStorage;
|
||||
import net.minecraft.world.level.chunk.storage.RegionStorageInfo;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
@@ -46,6 +44,7 @@ import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.IntFunction;
|
||||
@@ -76,6 +75,15 @@ public abstract class ChunkMapMixin extends ChunkStorage implements ChunkHolder.
|
||||
@Shadow
|
||||
private int serverViewDistance;
|
||||
|
||||
@Shadow
|
||||
private Long2ObjectLinkedOpenHashMap<ChunkHolder> pendingUnloads;
|
||||
|
||||
@Shadow
|
||||
private List<ChunkGenerationTask> pendingGenerationTasks;
|
||||
|
||||
@Shadow
|
||||
private Queue<Runnable> unloadQueue;
|
||||
|
||||
public ChunkMapMixin(RegionStorageInfo regionStorageInfo, Path path, DataFixer dataFixer, boolean bl) {
|
||||
super(regionStorageInfo, path, dataFixer, bl);
|
||||
}
|
||||
@@ -94,9 +102,12 @@ public abstract class ChunkMapMixin extends ChunkStorage implements ChunkHolder.
|
||||
// intentionally destroy old chunk system hooks
|
||||
this.updatingChunkMap = null;
|
||||
this.visibleChunkMap = null;
|
||||
this.pendingUnloads = null;
|
||||
this.queueSorter = null;
|
||||
this.worldgenMailbox = null;
|
||||
this.mainThreadMailbox = null;
|
||||
this.pendingGenerationTasks = null;
|
||||
this.unloadQueue = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -160,6 +160,15 @@ public abstract class DistanceManagerMixin implements ChunkSystemDistanceManager
|
||||
this.getChunkHolderManager().removeTicketAtLevel(type, pos, ChunkLevel.byStatus(FullChunkStatus.FULL) - radius, identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Remove old chunk system hooks
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Overwrite
|
||||
public SortedArraySet<Ticket<?>> getTickets(final long pos) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Route to new chunk system
|
||||
* @author Spottedleaf
|
||||
@@ -324,6 +333,24 @@ public abstract class DistanceManagerMixin implements ChunkSystemDistanceManager
|
||||
return "No DistanceManager stats available";
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Remove old chunk system hooks
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Overwrite
|
||||
public void dumpTickets(final String file) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Remove old chunk system hooks
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Overwrite
|
||||
public TickingTracker tickingTracker() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason This hack is not required anymore, see {@link MinecraftServerMixin}
|
||||
* @author Spottedleaf
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package ca.spottedleaf.moonrise.mixin.chunk_system;
|
||||
|
||||
import ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemChunkHolder;
|
||||
import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler;
|
||||
import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.server.level.ChunkGenerationTask;
|
||||
@@ -19,8 +18,14 @@ import net.minecraft.world.level.chunk.status.ChunkStep;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
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.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
@Mixin(GenerationChunkHolder.class)
|
||||
public abstract class GenerationChunkHolderMixin {
|
||||
@@ -28,6 +33,35 @@ public abstract class GenerationChunkHolderMixin {
|
||||
@Shadow
|
||||
public abstract int getTicketLevel();
|
||||
|
||||
@Shadow
|
||||
private AtomicReference<ChunkStatus> startedWork;
|
||||
|
||||
@Shadow
|
||||
private AtomicReferenceArray<CompletableFuture<ChunkResult<ChunkAccess>>> futures;
|
||||
|
||||
@Shadow
|
||||
private AtomicReference<ChunkGenerationTask> task;
|
||||
|
||||
@Shadow
|
||||
private AtomicInteger generationRefCount;
|
||||
|
||||
/**
|
||||
* @reason Destroy old chunk system fields
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Inject(
|
||||
method = "<init>",
|
||||
at = @At(
|
||||
value = "RETURN"
|
||||
)
|
||||
)
|
||||
private void init(final CallbackInfo ci) {
|
||||
this.startedWork = null;
|
||||
this.futures = null;
|
||||
this.task = null;
|
||||
this.generationRefCount = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Chunk system is not built on futures anymore
|
||||
* @author Spottedleaf
|
||||
@@ -71,7 +105,16 @@ public abstract class GenerationChunkHolderMixin {
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Overwrite
|
||||
public void removeTask(ChunkGenerationTask chunkGenerationTask) {
|
||||
public void removeTask(final ChunkGenerationTask chunkGenerationTask) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Chunk system is not built on futures anymore
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Overwrite
|
||||
public void rescheduleChunkTask(final ChunkMap chunkMap, final ChunkStatus chunkStatus) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@@ -84,6 +127,60 @@ public abstract class GenerationChunkHolderMixin {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Chunk system is not built on futures anymore
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Overwrite
|
||||
public void failAndClearPendingFuturesBetween(final ChunkStatus from, final ChunkStatus to) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Chunk system is not built on futures anymore
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Overwrite
|
||||
public void failAndClearPendingFuture(final int idx, final CompletableFuture<ChunkResult<ChunkAccess>> expect) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Chunk system is not built on futures anymore
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Overwrite
|
||||
public void completeFuture(final ChunkStatus status, final ChunkAccess chunk) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Chunk system is not built on futures anymore
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Overwrite
|
||||
public ChunkStatus findHighestStatusWithPendingFuture(final ChunkStatus from) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Chunk system is not built on futures anymore
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Overwrite
|
||||
public boolean acquireStatusBump(final ChunkStatus chunkStatus) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Chunk system is not built on futures anymore
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Overwrite
|
||||
public boolean isStatusDisallowed(final ChunkStatus chunkStatus) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Chunk system is not built on futures anymore
|
||||
* @author Spottedleaf
|
||||
|
||||
@@ -54,7 +54,9 @@ public abstract class ServerChunkCacheMixin extends ChunkSource {
|
||||
);
|
||||
|
||||
if (TickThread.isTickThreadFor(this.level, chunkX, chunkZ)) {
|
||||
ChunkTaskScheduler.pushChunkWait(this.level, chunkX, chunkZ);
|
||||
this.mainThreadProcessor.managedBlock(completable::isDone);
|
||||
ChunkTaskScheduler.popChunkWait();
|
||||
}
|
||||
|
||||
final ChunkAccess ret = completable.join();
|
||||
|
||||
@@ -216,4 +216,13 @@ public abstract class ThreadedLevelLightEngineMixin extends LevelLightEngine imp
|
||||
public CompletableFuture<ChunkAccess> lightChunk(final ChunkAccess chunk, final boolean lit) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Destroy old chunk system hooks
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Overwrite
|
||||
public CompletableFuture<?> waitForPendingTasks(final int chunkX, final int chunkZ) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,9 @@ accessible method net/minecraft/server/level/ChunkMap getVisibleChunkIfPresent (
|
||||
accessible method net/minecraft/server/level/ChunkMap getChunkQueueLevel (J)Ljava/util/function/IntSupplier;
|
||||
accessible method net/minecraft/server/level/ChunkMap generator ()Lnet/minecraft/world/level/chunk/ChunkGenerator;
|
||||
mutable field net/minecraft/server/level/ChunkMap updatingChunkMap Lit/unimi/dsi/fastutil/longs/Long2ObjectLinkedOpenHashMap;
|
||||
mutable field net/minecraft/server/level/ChunkMap pendingUnloads Lit/unimi/dsi/fastutil/longs/Long2ObjectLinkedOpenHashMap;
|
||||
mutable field net/minecraft/server/level/ChunkMap pendingGenerationTasks Ljava/util/List;
|
||||
mutable field net/minecraft/server/level/ChunkMap unloadQueue Ljava/util/Queue;
|
||||
mutable field net/minecraft/server/level/ChunkMap queueSorter Lnet/minecraft/server/level/ChunkTaskPriorityQueueSorter;
|
||||
mutable field net/minecraft/server/level/ChunkMap worldgenMailbox Lnet/minecraft/util/thread/ProcessorHandle;
|
||||
mutable field net/minecraft/server/level/ChunkMap mainThreadMailbox Lnet/minecraft/util/thread/ProcessorHandle;
|
||||
@@ -253,4 +256,11 @@ accessible method net/minecraft/client/multiplayer/ClientLevel$EntityCallbacks <
|
||||
|
||||
|
||||
# StructureTemplate$Palette
|
||||
mutable field net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate$Palette cache Ljava/util/Map;
|
||||
mutable field net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate$Palette cache Ljava/util/Map;
|
||||
|
||||
|
||||
# GenerationChunkHolder
|
||||
mutable field net/minecraft/server/level/GenerationChunkHolder startedWork Ljava/util/concurrent/atomic/AtomicReference;
|
||||
mutable field net/minecraft/server/level/GenerationChunkHolder futures Ljava/util/concurrent/atomic/AtomicReferenceArray;
|
||||
mutable field net/minecraft/server/level/GenerationChunkHolder task Ljava/util/concurrent/atomic/AtomicReference;
|
||||
mutable field net/minecraft/server/level/GenerationChunkHolder generationRefCount Ljava/util/concurrent/atomic/AtomicInteger;
|
||||
Reference in New Issue
Block a user