moved evaluated region to biome filter
parent
8199461ebc
commit
835fb3fbe6
|
@ -1,13 +1,13 @@
|
|||
package amidst.mojangapi.world.filter;
|
||||
|
||||
import amidst.documentation.Immutable;
|
||||
import amidst.fragment.Fragment;
|
||||
import amidst.mojangapi.world.World;
|
||||
import amidst.mojangapi.world.coordinates.CoordinatesInWorld;
|
||||
import amidst.mojangapi.world.coordinates.Resolution;
|
||||
|
||||
@Immutable
|
||||
public abstract class WorldFilter {
|
||||
private short[][] evaluatedRegion = null;
|
||||
|
||||
protected final long worldFilterSize;
|
||||
protected final long quarterFilterSize;
|
||||
protected final CoordinatesInWorld corner;
|
||||
|
@ -30,18 +30,5 @@ public abstract class WorldFilter {
|
|||
}
|
||||
}
|
||||
|
||||
public final boolean isValid(World world) {
|
||||
return isValid(world, getUpdatedRegion(world));
|
||||
}
|
||||
|
||||
protected abstract boolean isValid(World world, short[][] region);
|
||||
|
||||
private short[][] getUpdatedRegion(World world) {
|
||||
if (this.evaluatedRegion == null) {
|
||||
this.evaluatedRegion = new short[(int) this.quarterFilterSize * 2][(int) this.quarterFilterSize * 2];
|
||||
}
|
||||
|
||||
world.getBiomeDataOracle().populateArray(corner, evaluatedRegion, true);
|
||||
return evaluatedRegion;
|
||||
}
|
||||
public abstract boolean isValid(World world);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import amidst.mojangapi.world.World;
|
|||
import amidst.mojangapi.world.biome.Biome;
|
||||
|
||||
public class WorldFilter_Biome extends WorldFilter {
|
||||
private short[][] evaluatedRegion = null;
|
||||
private final List<Biome> biomes;
|
||||
|
||||
public WorldFilter_Biome(long worldFilterSize, List<String> biomeNames) {
|
||||
|
@ -30,6 +31,19 @@ public class WorldFilter_Biome extends WorldFilter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(World world) {
|
||||
return isValid(world, getUpdatedRegion(world));
|
||||
}
|
||||
|
||||
protected short[][] getUpdatedRegion(World world) {
|
||||
if (this.evaluatedRegion == null) {
|
||||
this.evaluatedRegion = new short[(int) this.quarterFilterSize * 2][(int) this.quarterFilterSize * 2];
|
||||
}
|
||||
|
||||
world.getBiomeDataOracle().populateArray(corner, evaluatedRegion, true);
|
||||
return evaluatedRegion;
|
||||
}
|
||||
|
||||
protected boolean isValid(World world, short[][] region) {
|
||||
for (short[] row : region) {
|
||||
for (short entry : row) {
|
||||
|
|
|
@ -2,8 +2,10 @@ package amidst.mojangapi.world.filter;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import amidst.documentation.Immutable;
|
||||
import amidst.mojangapi.world.World;
|
||||
|
||||
@Immutable
|
||||
public class WorldFilter_MatchAll extends WorldFilter {
|
||||
private final List<WorldFilter> filters;
|
||||
|
||||
|
@ -13,7 +15,7 @@ public class WorldFilter_MatchAll extends WorldFilter {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean isValid(World world, short[][] region) {
|
||||
public boolean isValid(World world) {
|
||||
for (WorldFilter filter : filters) {
|
||||
if (!filter.isValid(world)) {
|
||||
return false;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package amidst.mojangapi.world.filter;
|
||||
|
||||
import amidst.documentation.Immutable;
|
||||
import amidst.mojangapi.world.World;
|
||||
import amidst.mojangapi.world.coordinates.CoordinatesInWorld;
|
||||
import amidst.mojangapi.world.icon.WorldIcon;
|
||||
|
@ -7,6 +8,7 @@ import amidst.mojangapi.world.icon.producer.WorldIconCollector;
|
|||
import amidst.mojangapi.world.icon.producer.WorldIconProducer;
|
||||
import amidst.mojangapi.world.icon.type.DefaultWorldIconTypes;
|
||||
|
||||
@Immutable
|
||||
public class WorldFilter_Structure extends WorldFilter {
|
||||
private final DefaultWorldIconTypes structure;
|
||||
private final int count;
|
||||
|
@ -19,7 +21,7 @@ public class WorldFilter_Structure extends WorldFilter {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean isValid(World world, short[][] region) {
|
||||
public boolean isValid(World world) {
|
||||
WorldIconCollector structureCollector = getCollector();
|
||||
WorldIconProducer<Void> structureProducer = getProducer(world);
|
||||
|
||||
|
@ -71,7 +73,7 @@ public class WorldFilter_Structure extends WorldFilter {
|
|||
}
|
||||
|
||||
private static class TypedWorldIconCollector extends WorldIconCollector {
|
||||
final DefaultWorldIconTypes acceptedStructure;
|
||||
private final DefaultWorldIconTypes acceptedStructure;
|
||||
|
||||
TypedWorldIconCollector(DefaultWorldIconTypes acceptedStructure) {
|
||||
this.acceptedStructure = acceptedStructure;
|
||||
|
|
Loading…
Reference in New Issue