mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Fix nullable world in regions
This commit is contained in:
parent
39defaea5e
commit
d46af0136b
@ -27,6 +27,7 @@ import com.sk89q.worldedit.regions.iterator.RegionIterator;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.AbstractSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@ -39,9 +40,9 @@ import java.util.Set;
|
||||
public abstract class AbstractRegion extends AbstractSet<BlockVector3> implements Region {
|
||||
//FAWE end
|
||||
|
||||
protected World world;
|
||||
@Nullable protected World world;
|
||||
|
||||
public AbstractRegion(World world) {
|
||||
public AbstractRegion(@Nullable World world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@ -68,7 +69,7 @@ public abstract class AbstractRegion extends AbstractSet<BlockVector3> implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
public @Nullable World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@ -217,11 +218,15 @@ public abstract class AbstractRegion extends AbstractSet<BlockVector3> implement
|
||||
// Sub-class utilities
|
||||
|
||||
protected final int getWorldMinY() {
|
||||
return world == null ? Integer.MIN_VALUE : world.getMinY();
|
||||
//FAWE start > Integer.MIN_VALUE -> 0 (to avoid crazy for loops...) TODO: See if there's a way to find a "server default"
|
||||
return world == null ? 0 : world.getMinY();
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
protected final int getWorldMaxY() {
|
||||
return world == null ? Integer.MAX_VALUE : world.getMaxY();
|
||||
//FAWE start > Integer.MAX_VALUE -> 255 (to avoid crazy for loops...) TODO: See if there's a way to find a "server default"
|
||||
return world == null ? 255 : world.getMaxY();
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
|
@ -752,7 +752,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
char[] arr = set.load(layer);
|
||||
if (trimX || trimZ) {
|
||||
int indexY = 0;
|
||||
for (int y = world.getMinY(); y < 16; y++, indexY += world.getMaxY()) {
|
||||
for (int y = getWorldMinY(); y < 16; y++, indexY += getWorldMaxY()) {
|
||||
int index;
|
||||
if (trimZ) {
|
||||
index = indexY;
|
||||
|
@ -243,7 +243,7 @@ public class EllipsoidRegion extends AbstractRegion {
|
||||
}
|
||||
int cy = y - center.getBlockY();
|
||||
int cy2 = cy * cy;
|
||||
if (radiusSqr.getBlockY() < world.getMaxY() && cy2 > radiusSqr.getBlockY()) {
|
||||
if (radiusSqr.getBlockY() < getWorldMaxY() && cy2 > radiusSqr.getBlockY()) {
|
||||
return false;
|
||||
}
|
||||
if (sphere) {
|
||||
@ -318,7 +318,7 @@ public class EllipsoidRegion extends AbstractRegion {
|
||||
filterSpherePartial(minSection, 0, 15, bx, bz, filter, block, get, set);
|
||||
}
|
||||
|
||||
if (yStart != world.getMinY()) {
|
||||
if (yStart != getWorldMinY()) {
|
||||
filterSpherePartial(minSection, yStart, 15, bx, bz, filter, block, get, set);
|
||||
minSection++;
|
||||
}
|
||||
@ -412,28 +412,28 @@ public class EllipsoidRegion extends AbstractRegion {
|
||||
int cy = center.getBlockY();
|
||||
int diffYFull = MathMan.usqrt(diffY2);
|
||||
|
||||
int yBotFull = Math.max(world.getMinY(), cy - diffYFull);
|
||||
int yTopFull = Math.min(world.getMaxY(), cy + diffYFull);
|
||||
int yBotFull = Math.max(getWorldMinY(), cy - diffYFull);
|
||||
int yTopFull = Math.min(getWorldMaxY(), cy + diffYFull);
|
||||
|
||||
if (yBotFull == yTopFull || yBotFull > yTopFull) {
|
||||
}
|
||||
// Set those layers
|
||||
filter(chunk, filter, block, get, set, yBotFull, yTopFull, full);
|
||||
|
||||
if (yBotFull == world.getMinY() && yTopFull == world.getMaxY()) {
|
||||
if (yBotFull == getWorldMinY() && yTopFull == getWorldMaxY()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int diffYPartial = MathMan.usqrt(radiusLengthSqr - cxMin * cxMin - czMin * czMin);
|
||||
|
||||
//Fill the remaining layers
|
||||
if (yBotFull != world.getMinY()) {
|
||||
int yBotPartial = Math.max(world.getMinY(), cy - diffYPartial);
|
||||
if (yBotFull != getWorldMinY()) {
|
||||
int yBotPartial = Math.max(getWorldMinY(), cy - diffYPartial);
|
||||
filterSpherePartial(yBotPartial, yBotFull - 1, bx, bz, filter, block, get, set);
|
||||
}
|
||||
|
||||
if (yTopFull != world.getMaxY()) {
|
||||
int yTopPartial = Math.min(world.getMaxY(), cy + diffYPartial);
|
||||
if (yTopFull != getWorldMaxY()) {
|
||||
int yTopPartial = Math.min(getWorldMaxY(), cy + diffYPartial);
|
||||
filterSpherePartial(yTopFull + 1, yTopPartial, bx, bz, filter, block, get, set);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user