mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-15 11:51:53 +01:00
expose internal and external lighting
This commit is contained in:
parent
c8f96cbb16
commit
6d175c4ff9
@ -315,4 +315,9 @@ public abstract class Chunk implements Block.Getter, Block.Setter, Biome.Getter,
|
||||
protected void unload() {
|
||||
this.loaded = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate the chunk caches
|
||||
*/
|
||||
public abstract void invalidate();
|
||||
}
|
@ -6,7 +6,6 @@ import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import net.minestom.server.coordinate.Vec;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.entity.pathfinding.PFBlock;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.instance.block.BlockHandler;
|
||||
@ -24,7 +23,6 @@ import net.minestom.server.utils.ArrayUtils;
|
||||
import net.minestom.server.utils.MathUtils;
|
||||
import net.minestom.server.utils.ObjectPool;
|
||||
import net.minestom.server.utils.chunk.ChunkUtils;
|
||||
import net.minestom.server.utils.validate.Check;
|
||||
import net.minestom.server.world.biomes.Biome;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -209,6 +207,11 @@ public class DynamicChunk extends Chunk {
|
||||
this.entries.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
this.chunkCache.invalidate();
|
||||
}
|
||||
|
||||
private @NotNull ChunkDataPacket createChunkPacket() {
|
||||
final NBTCompound heightmapsNBT = computeHeightmap();
|
||||
// Data
|
||||
|
@ -358,12 +358,7 @@ public class InstanceContainer extends Instance {
|
||||
if (forkChunk != null) {
|
||||
applyFork(forkChunk, sectionModifier);
|
||||
// Update players
|
||||
if (forkChunk instanceof LightingChunk lightingChunk) {
|
||||
lightingChunk.chunkCache.invalidate();
|
||||
lightingChunk.lightCache.invalidate();
|
||||
} else if (forkChunk instanceof DynamicChunk dynamicChunk) {
|
||||
dynamicChunk.chunkCache.invalidate();
|
||||
}
|
||||
forkChunk.invalidate();
|
||||
forkChunk.sendChunk();
|
||||
} else {
|
||||
final long index = ChunkUtils.getChunkIndex(start);
|
||||
|
@ -80,6 +80,11 @@ public class LightingChunk extends DynamicChunk {
|
||||
Block.LAVA.namespace()
|
||||
);
|
||||
|
||||
public void invalidate() {
|
||||
this.lightCache.invalidate();
|
||||
this.chunkCache.invalidate();
|
||||
}
|
||||
|
||||
public LightingChunk(@NotNull Instance instance, int chunkX, int chunkZ) {
|
||||
super(instance, chunkX, chunkZ);
|
||||
}
|
||||
|
@ -9,13 +9,11 @@ import net.minestom.server.instance.Section;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.instance.block.BlockFace;
|
||||
import net.minestom.server.instance.palette.Palette;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static net.minestom.server.instance.light.LightCompute.*;
|
||||
|
||||
@ -36,6 +34,27 @@ final class BlockLight implements Light {
|
||||
this.blockPalette = blockPalette;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public void setInternalLighting(byte[] content) {
|
||||
this.content = content;
|
||||
this.isValidBorders = true;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public void setExternalLighting(byte[] content) {
|
||||
this.contentPropagation = content;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public byte[] getInternalLighting() {
|
||||
return content;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public byte[] getExternalLighting() {
|
||||
return contentPropagation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Point> flip() {
|
||||
if (this.contentPropagationSwap != null)
|
||||
|
Loading…
Reference in New Issue
Block a user