use of org.spongepowered.api.world.gen.PopulatorObject in project SpongeCommon by SpongePowered.
the class MixinWorldGenBigMushroom method populate.
@Override
public void populate(org.spongepowered.api.world.World worldIn, Extent extent, Random random) {
Vector3i min = extent.getBlockMin();
Vector3i size = extent.getBlockSize();
World world = (World) worldIn;
BlockPos chunkPos = new BlockPos(min.getX(), min.getY(), min.getZ());
int x;
int z;
int n = this.mushroomsPerChunk.getFlooredAmount(random);
PopulatorObject type = MushroomTypes.BROWN.getPopulatorObject();
List<PopulatorObject> result;
for (int i = 0; i < n; ++i) {
x = random.nextInt(size.getX());
z = random.nextInt(size.getZ());
BlockPos pos = world.getHeight(chunkPos.add(x, 0, z));
if (this.override != null) {
Location<Extent> pos2 = new Location<>(extent, VecHelper.toVector3i(pos));
type = this.override.apply(pos2);
} else {
result = this.types.get(random);
if (result.isEmpty()) {
continue;
}
type = result.get(0);
}
if (type.canPlaceAt((org.spongepowered.api.world.World) world, pos.getX(), pos.getY(), pos.getZ())) {
type.placeObject((org.spongepowered.api.world.World) world, random, pos.getX(), pos.getY(), pos.getZ());
}
}
}
use of org.spongepowered.api.world.gen.PopulatorObject in project SpongeCommon by SpongePowered.
the class ForestPopulator method populate.
@Override
public void populate(org.spongepowered.api.world.World world, Extent extent, Random random) {
Vector3i min = extent.getBlockMin();
Vector3i size = extent.getBlockSize();
int n = this.count.getFlooredAmount(random);
int x;
int z;
BlockPos pos;
List<PopulatorObject> result;
PopulatorObject type;
for (int i = 0; i < n; i++) {
x = random.nextInt(size.getX());
z = random.nextInt(size.getZ());
pos = ((net.minecraft.world.World) world).getTopSolidOrLiquidBlock(new BlockPos(min.getX() + x, min.getY(), min.getZ() + z));
if (this.override != null) {
Location<Extent> pos2 = new Location<>(extent, VecHelper.toVector3i(pos));
type = this.override.apply(pos2);
} else {
result = this.types.get(random);
if (result.isEmpty()) {
continue;
}
type = result.get(0);
}
if (type.canPlaceAt(world, pos.getX(), pos.getY(), pos.getZ())) {
type.placeObject(world, random, pos.getX(), pos.getY(), pos.getZ());
}
}
}
use of org.spongepowered.api.world.gen.PopulatorObject in project SpongeCommon by SpongePowered.
the class RoofedForestPopulator method populate.
@Override
public void populate(org.spongepowered.api.world.World worldIn, Extent extent, Random random) {
Vector3i min = extent.getBlockMin();
BlockPos pos = new BlockPos(min.getX(), min.getY(), min.getZ());
World world = (World) worldIn;
List<PopulatorObject> results;
PopulatorObject tree = BiomeTreeTypes.CANOPY.getPopulatorObject();
for (int x = 0; x < 4; ++x) {
for (int z = 0; z < 4; ++z) {
int x0 = x * 4 + 1 + random.nextInt(3);
int z0 = z * 4 + 1 + random.nextInt(3);
BlockPos blockpos1 = world.getTopSolidOrLiquidBlock(pos.add(x0, 0, z0));
if (this.override != null) {
Location<Extent> pos2 = new Location<>(extent, VecHelper.toVector3i(blockpos1));
tree = this.override.apply(pos2);
} else {
results = this.trees.get(random);
if (results.isEmpty()) {
continue;
}
tree = results.get(0);
}
if (tree.canPlaceAt(worldIn, blockpos1.getX(), blockpos1.getY(), blockpos1.getZ())) {
tree.placeObject(worldIn, random, blockpos1.getX(), blockpos1.getY(), blockpos1.getZ());
}
}
}
}
use of org.spongepowered.api.world.gen.PopulatorObject in project SpongeCommon by SpongePowered.
the class MushroomTypeRegistryModule method registerDefaults.
@Override
public void registerDefaults() {
register(new SpongeMushroomType("minecraft:brown", "brown", (PopulatorObject) new WorldGenBigMushroom(Blocks.BROWN_MUSHROOM_BLOCK)));
register(new SpongeMushroomType("minecraft:red", "red", (PopulatorObject) new WorldGenBigMushroom(Blocks.RED_MUSHROOM_BLOCK)));
}
Aggregations