Rename some BlockQuery classes
This commit is contained in:
parent
7f3fda66a7
commit
150345251c
8 changed files with 39 additions and 22 deletions
|
@ -22,8 +22,8 @@ import biomesoplenty.common.block.BlockBOPMushroom;
|
|||
import biomesoplenty.common.block.BlockBOPPlant;
|
||||
import biomesoplenty.common.enums.BOPGems;
|
||||
import biomesoplenty.common.enums.BOPPlants;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockPosQueryAll;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockPosQueryAny;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockPosQueryAnd;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockPosQueryOr;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockQueryMaterial;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockPosQueryHasWater;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.IBlockPosQuery;
|
||||
|
@ -59,9 +59,9 @@ public class BiomeGenGrassland extends BOPBiome {
|
|||
this.addGenerator("gravel", GeneratorStage.SAND_PASS2, (new GeneratorWaterside.Builder()).amountPerChunk(4).maxRadius(7).with(Blocks.gravel.getDefaultState()).create());
|
||||
|
||||
// other plants
|
||||
IBlockPosQuery canPlaceRiverCane = new BlockPosQueryAll(new BlockPosQueryHasWater(), new BlockPosQueryAny(new BlockQueryMaterial(Material.ground), new BlockQueryMaterial(Material.grass)));
|
||||
IBlockPosQuery canPlaceRiverCane = new BlockPosQueryAnd(new BlockPosQueryHasWater(), new BlockPosQueryOr(new BlockQueryMaterial(Material.ground), new BlockQueryMaterial(Material.grass)));
|
||||
this.addGenerator("river_cane", GeneratorStage.FLOWERS,(new GeneratorColumns.Builder()).amountPerChunk(1.0F).generationAttempts(24).placeOn(canPlaceRiverCane).with(BlockBOPPlant.paging.getVariantState(BOPPlants.RIVERCANE)).minHeight(1).maxHeight(3).create());
|
||||
IBlockPosQuery canPlaceSugarCane = new BlockPosQueryAll(new BlockPosQueryHasWater(), new BlockPosQueryAny(new BlockQueryMaterial(Material.ground), new BlockQueryMaterial(Material.grass), new BlockQueryMaterial(Material.sand)));
|
||||
IBlockPosQuery canPlaceSugarCane = new BlockPosQueryAnd(new BlockPosQueryHasWater(), new BlockPosQueryOr(new BlockQueryMaterial(Material.ground), new BlockQueryMaterial(Material.grass), new BlockQueryMaterial(Material.sand)));
|
||||
this.addGenerator("sugar_cane", GeneratorStage.FLOWERS,(new GeneratorColumns.Builder()).amountPerChunk(4.0F).generationAttempts(24).placeOn(canPlaceSugarCane).with(Blocks.reeds.getDefaultState()).minHeight(1).maxHeight(3).create());
|
||||
this.addGenerator("flax", GeneratorStage.FLOWERS,(new GeneratorDoubleFlora.Builder()).amountPerChunk(0.1F).with(BlockBOPDoublePlant.DoublePlantType.FLAX).generationAttempts(6).create());
|
||||
|
||||
|
|
|
@ -43,14 +43,31 @@ public class BlockQueryUtils
|
|||
public static interface IBlockPosQuery
|
||||
{
|
||||
public boolean matches(World world, BlockPos pos);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// match any position
|
||||
public static class BlockPosQueryAnything implements IBlockPosQuery
|
||||
{
|
||||
@Override
|
||||
public boolean matches(World world, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// match no positions
|
||||
public static class BlockPosQueryNothing implements IBlockPosQuery
|
||||
{
|
||||
@Override
|
||||
public boolean matches(World world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Match a block pos if any of the children match
|
||||
public static class BlockPosQueryAny implements IBlockPosQuery
|
||||
public static class BlockPosQueryOr implements IBlockPosQuery
|
||||
{
|
||||
private ArrayList<IBlockPosQuery> children;
|
||||
public BlockPosQueryAny(IBlockPosQuery... children)
|
||||
public BlockPosQueryOr(IBlockPosQuery... children)
|
||||
{
|
||||
this.children = new ArrayList<IBlockPosQuery>(Arrays.asList(children));
|
||||
}
|
||||
|
@ -77,10 +94,10 @@ public class BlockQueryUtils
|
|||
}
|
||||
|
||||
// Match a block pos if all of the children match
|
||||
public static class BlockPosQueryAll implements IBlockPosQuery
|
||||
public static class BlockPosQueryAnd implements IBlockPosQuery
|
||||
{
|
||||
private ArrayList<IBlockPosQuery> children;
|
||||
public BlockPosQueryAll(IBlockPosQuery... children)
|
||||
public BlockPosQueryAnd(IBlockPosQuery... children)
|
||||
{
|
||||
this.children = new ArrayList<IBlockPosQuery>(Arrays.asList(children));
|
||||
}
|
||||
|
@ -366,7 +383,7 @@ public class BlockQueryUtils
|
|||
// parse the given block query string and return the equivalent IBlockQuery object
|
||||
public static IBlockPosQuery parseQueryString(String spec) throws BlockQueryParseException
|
||||
{
|
||||
BlockPosQueryAny bmAny = new BlockPosQueryAny();
|
||||
BlockPosQueryOr bmAny = new BlockPosQueryOr();
|
||||
String[] subspecs = commaDelimitRegex.split(spec);
|
||||
for (String subspec : subspecs)
|
||||
{
|
||||
|
@ -378,7 +395,7 @@ public class BlockQueryUtils
|
|||
|
||||
private static IBlockPosQuery parseQueryStringSingle(String spec) throws BlockQueryParseException
|
||||
{
|
||||
BlockPosQueryAll bmAll = new BlockPosQueryAll();
|
||||
BlockPosQueryAnd bmAll = new BlockPosQueryAnd();
|
||||
|
||||
Matcher m = nextTokenRegex.matcher(spec);
|
||||
while (spec.length() > 0)
|
||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraft.util.BlockPos;
|
|||
import net.minecraft.world.World;
|
||||
import biomesoplenty.api.biome.generation.BOPGeneratorBase;
|
||||
import biomesoplenty.common.util.biome.GeneratorUtils;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockPosQueryAny;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockPosQueryOr;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockQueryMaterial;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.IBlockPosQuery;
|
||||
import biomesoplenty.common.util.config.BOPConfig.IConfigObj;
|
||||
|
@ -90,7 +90,7 @@ public class GeneratorBigMushroom extends BOPGeneratorBase
|
|||
}
|
||||
}
|
||||
|
||||
private static IBlockPosQuery isLeavesOrAir = new BlockPosQueryAny(new BlockQueryMaterial(Material.leaves), new BlockQueryMaterial(Material.air));
|
||||
private static IBlockPosQuery isLeavesOrAir = new BlockPosQueryOr(new BlockQueryMaterial(Material.leaves), new BlockQueryMaterial(Material.air));
|
||||
|
||||
protected BigMushroomType mushroomType;
|
||||
protected IBlockState mushroomState;
|
||||
|
|
|
@ -20,7 +20,7 @@ import net.minecraft.world.World;
|
|||
import biomesoplenty.api.biome.generation.BOPGeneratorBase;
|
||||
import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockPosQueryAny;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockPosQueryOr;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockQueryMaterial;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockQueryBlock;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockQueryParseException;
|
||||
|
@ -34,7 +34,7 @@ public class GeneratorBlobs extends BOPGeneratorBase
|
|||
public static class Builder implements IGeneratorBuilder<GeneratorBlobs>
|
||||
{
|
||||
protected float amountPerChunk = 1.0F;
|
||||
protected IBlockPosQuery placeOn = new BlockPosQueryAny(new BlockQueryBlock(Blocks.stone), new BlockQueryMaterial(Material.ground), new BlockQueryMaterial(Material.grass));
|
||||
protected IBlockPosQuery placeOn = new BlockPosQueryOr(new BlockQueryBlock(Blocks.stone), new BlockQueryMaterial(Material.ground), new BlockQueryMaterial(Material.grass));
|
||||
protected IBlockState with = Blocks.cobblestone.getDefaultState();
|
||||
protected float minRadius = 2.0F;
|
||||
protected float maxRadius = 5.0F;
|
||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraft.world.World;
|
|||
import biomesoplenty.api.biome.generation.BOPGeneratorBase;
|
||||
import biomesoplenty.common.util.biome.GeneratorUtils;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockPosQueryAny;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockPosQueryOr;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockQueryMaterial;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockQueryBlock;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockQueryParseException;
|
||||
|
@ -33,7 +33,7 @@ public class GeneratorColumns extends BOPGeneratorBase
|
|||
public static class Builder implements IGeneratorBuilder<GeneratorColumns>
|
||||
{
|
||||
protected float amountPerChunk = 1.0F;
|
||||
protected IBlockPosQuery placeOn = new BlockPosQueryAny(new BlockQueryMaterial(Material.ground), new BlockQueryMaterial(Material.grass));
|
||||
protected IBlockPosQuery placeOn = new BlockPosQueryOr(new BlockQueryMaterial(Material.ground), new BlockQueryMaterial(Material.grass));
|
||||
protected IBlockState with = Blocks.cobblestone.getDefaultState();
|
||||
protected int minHeight = 2;
|
||||
protected int maxHeight = 4;
|
||||
|
|
|
@ -23,7 +23,7 @@ import biomesoplenty.api.biome.generation.BOPGeneratorBase;
|
|||
import biomesoplenty.common.block.BlockBOPLog;
|
||||
import biomesoplenty.common.enums.BOPWoods;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockPosQueryAny;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockPosQueryOr;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockQueryBlock;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockQueryMaterial;
|
||||
import biomesoplenty.common.util.block.BlockQueryUtils.BlockQueryParseException;
|
||||
|
@ -38,7 +38,7 @@ public class GeneratorLogs extends BOPGeneratorBase
|
|||
{
|
||||
protected float amountPerChunk = 1.0F;
|
||||
protected IBlockState with = Blocks.log.getDefaultState();
|
||||
protected IBlockPosQuery placeOn = new BlockPosQueryAny(new BlockQueryMaterial(Material.ground), new BlockQueryMaterial(Material.grass));
|
||||
protected IBlockPosQuery placeOn = new BlockPosQueryOr(new BlockQueryMaterial(Material.ground), new BlockQueryMaterial(Material.grass));
|
||||
protected int minLength = 3;
|
||||
protected int maxLength = 5;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public class GeneratorSplotches extends BOPGeneratorBase
|
|||
public static class Builder implements IGeneratorBuilder<GeneratorSplotches>
|
||||
{
|
||||
protected float amountPerChunk = 1.0F;
|
||||
protected IBlockPosQuery replace = new BlockPosQueryAny(new BlockQueryMaterial(Material.grass), new BlockQueryMaterial(Material.ground));
|
||||
protected IBlockPosQuery replace = new BlockPosQueryOr(new BlockQueryMaterial(Material.grass), new BlockQueryMaterial(Material.ground));
|
||||
protected IBlockState with = Blocks.cobblestone.getDefaultState();
|
||||
protected int splotchSize = 8;
|
||||
protected ScatterYMethod scatterYMethod = ScatterYMethod.AT_OR_BELOW_SURFACE;
|
||||
|
|
|
@ -28,7 +28,7 @@ public class GeneratorWaterside extends BOPGeneratorBase
|
|||
{
|
||||
protected float amountPerChunk = 1.0F;
|
||||
protected int maxRadius = 7;
|
||||
protected IBlockPosQuery replace = new BlockPosQueryAny(new BlockQueryMaterial(Material.grass), new BlockQueryMaterial(Material.ground));
|
||||
protected IBlockPosQuery replace = new BlockPosQueryOr(new BlockQueryMaterial(Material.grass), new BlockQueryMaterial(Material.ground));
|
||||
protected IBlockState with = Blocks.gravel.getDefaultState();
|
||||
|
||||
public Builder amountPerChunk(float a) {this.amountPerChunk = a; return this;}
|
||||
|
|
Loading…
Reference in a new issue