66 lines
1.6 KiB
Java
66 lines
1.6 KiB
Java
package net.minecraft.server.level;
|
|
|
|
import net.minecraft.core.SectionPos;
|
|
import net.minecraft.world.level.lighting.DynamicGraphMinFixedPoint;
|
|
|
|
public abstract class SectionTracker extends DynamicGraphMinFixedPoint {
|
|
protected SectionTracker(int i, int j, int k) {
|
|
super(i, j, k);
|
|
}
|
|
|
|
@Override
|
|
protected void checkNeighborsAfterUpdate(long pos, int level, boolean isDecreasing) {
|
|
if (!isDecreasing || level < this.levelCount - 2) {
|
|
for (int i = -1; i <= 1; i++) {
|
|
for (int j = -1; j <= 1; j++) {
|
|
for (int k = -1; k <= 1; k++) {
|
|
long l = SectionPos.offset(pos, i, j, k);
|
|
if (l != pos) {
|
|
this.checkNeighbor(pos, l, level, isDecreasing);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected int getComputedLevel(long pos, long excludedSourcePos, int level) {
|
|
int i = level;
|
|
|
|
for (int j = -1; j <= 1; j++) {
|
|
for (int k = -1; k <= 1; k++) {
|
|
for (int l = -1; l <= 1; l++) {
|
|
long m = SectionPos.offset(pos, j, k, l);
|
|
if (m == pos) {
|
|
m = Long.MAX_VALUE;
|
|
}
|
|
|
|
if (m != excludedSourcePos) {
|
|
int n = this.computeLevelFromNeighbor(m, pos, this.getLevel(m));
|
|
if (i > n) {
|
|
i = n;
|
|
}
|
|
|
|
if (i == 0) {
|
|
return i;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return i;
|
|
}
|
|
|
|
@Override
|
|
protected int computeLevelFromNeighbor(long startPos, long endPos, int startLevel) {
|
|
return this.isSource(startPos) ? this.getLevelFromSource(endPos) : startLevel + 1;
|
|
}
|
|
|
|
protected abstract int getLevelFromSource(long pos);
|
|
|
|
public void update(long pos, int level, boolean isDecreasing) {
|
|
this.checkEdge(Long.MAX_VALUE, pos, level, isDecreasing);
|
|
}
|
|
}
|