docs on reset_chunks

This commit is contained in:
gnembon committed 2020-07-01 14:49:22 -03:00
1 parent a7a37a3975
commit 926375700a
5 files changed
+45 -7

No files matched your search

@@ -9,5 +9,7 @@ public interface ThreadedAnvilChunkStorageInterface
{
Map<String, Integer> regenerateChunkRegion(List<ChunkPos> requestedChunks);
void relightChunk(ChunkPos pos);
void releaseRelightTicket(ChunkPos pos);
}
@@ -227,6 +227,31 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
return future.join();
}
@Override
public void relightChunk(ChunkPos pos)
{
this.addTicket(pos);
this.tickTicketManager();
if (this.currentChunkHolders.get(pos.toLong()).getCompletedChunk() == null) // chunk unloaded
if (WorldTools.canHasChunk(this.world, pos, null, true))
this.currentChunkHolders.get(pos.toLong()).createFuture(ChunkStatus.EMPTY, (ThreadedAnvilChunkStorage) (Object) this);
final Chunk chunk = this.getCurrentChunk(pos);
if (!(chunk.getStatus().isAtLeast(ChunkStatus.LIGHT.getPrevious()))) return;
((ServerLightingProviderInterface) this.serverLightingProvider).removeLightData(chunk);
this.addRelightTicket(pos);
final CompletableFuture<?> lightFuture = this.createChunkRegionFuture(pos, 1, (pos_) -> ChunkStatus.LIGHT)
.thenCompose(
either -> either.map(
list -> ((ServerLightingProviderInterface) this.serverLightingProvider).relight(chunk),
unloaded -> {
this.releaseRelightTicket(pos);
return CompletableFuture.completedFuture(null);
}
)
);
this.waitFor(lightFuture);
}
@Override
public Map<String, Integer> regenerateChunkRegion(final List<ChunkPos> requestedChunksList)
{
@@ -7,7 +7,6 @@ import carpet.fakes.MinecraftServerInterface;
import carpet.fakes.BiomeArrayInterface;
import carpet.fakes.RecipeManagerInterface;
import carpet.fakes.ServerChunkManagerInterface;
import carpet.fakes.ServerLightingProviderInterface;
import carpet.fakes.StatTypeInterface;
import carpet.fakes.ThreadedAnvilChunkStorageInterface;
import carpet.helpers.FeatureGenerator;
@@ -142,7 +141,6 @@ import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.gen.ChunkRandom;
import org.apache.commons.lang3.tuple.Pair;
import java.util.Date;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -3186,9 +3184,8 @@ public class CarpetExpression
BlockArgument locator = BlockArgument.findIn(cc, lv, 0);
BlockPos pos = locator.block.getPos();
ServerWorld world = cc.s.getWorld();
((ServerLightingProviderInterface)world.getChunkManager().getLightingProvider()).resetLight(world.getChunk(pos), new ChunkPos(pos)); //light(world.getChunk(pos), false);
((ThreadedAnvilChunkStorageInterface) world.getChunkManager().threadedAnvilChunkStorage).relightChunk(new ChunkPos(pos));
forceChunkUpdate(pos, world);
world.getChunkManager().getLightingProvider().light(world.getChunk(pos), false);
return LazyValue.TRUE;
});