use of net.glowstone.generator.structures.util.StructureBoundingBox in project Glowstone by GlowstoneMC.
the class DungeonPopulator method populate.
@Override
public void populate(World world, Random random, Chunk source) {
SimplexNoiseGenerator noise = new SimplexNoiseGenerator(world);
double density = noise.noise(source.getX(), source.getZ());
if (density > 0.8) {
// TODO later switch to this loop to have 8 attempts of dungeon placement per chunk, once we get caves and ravines
//for (int i = 0; i < 8; i++) {
int x = (source.getX() << 4) + random.nextInt(16);
int z = (source.getZ() << 4) + random.nextInt(16);
int y = random.nextInt(256);
GlowDungeon dungeon = new GlowDungeon(random, new Location(world, x, y, z));
BlockStateDelegate delegate = new BlockStateDelegate();
if (dungeon.generate(world, random, new StructureBoundingBox(new Vector(x - 15, 1, z - 15), new Vector(x + 15, 511, z + 15)), delegate)) {
delegate.updateBlockStates();
}
//}
}
}
use of net.glowstone.generator.structures.util.StructureBoundingBox in project Glowstone by GlowstoneMC.
the class DesertWellDecorator method decorate.
@Override
public void decorate(World world, Random random, Chunk source) {
if (random.nextInt(1000) == 0) {
int x = (source.getX() << 4) + random.nextInt(16);
int z = (source.getZ() << 4) + random.nextInt(16);
int y = world.getHighestBlockYAt(x, z);
GlowDesertWell well = new GlowDesertWell(new Location(world, x, y, z));
BlockStateDelegate delegate = new BlockStateDelegate();
if (well.generate(world, random, new StructureBoundingBox(new Vector(x - 15, 1, z - 15), new Vector(x + 15, 511, z + 15)), delegate)) {
delegate.updateBlockStates();
}
}
}
use of net.glowstone.generator.structures.util.StructureBoundingBox in project Glowstone by GlowstoneMC.
the class StructureStore method save.
/**
* Save information about this structure to the given tag.
*
* @param structure The structure to save.
* @param compound The target tag.
*/
public void save(T structure, CompoundTag compound) {
StructureBoundingBox boundingBox = structure.getBoundingBox();
int[] bb = new int[6];
bb[0] = boundingBox.getMin().getBlockX();
bb[1] = boundingBox.getMin().getBlockY();
bb[2] = boundingBox.getMin().getBlockZ();
bb[3] = boundingBox.getMax().getBlockX();
bb[4] = boundingBox.getMax().getBlockY();
bb[5] = boundingBox.getMax().getBlockZ();
compound.putIntArray("BB", bb);
List<CompoundTag> children = new ArrayList<>();
for (GlowStructurePiece piece : structure.getPieces()) {
CompoundTag tag = new CompoundTag();
StructurePieceStorage.saveStructurePiece(piece, tag);
children.add(tag);
}
compound.putCompoundList("Children", children);
}
use of net.glowstone.generator.structures.util.StructureBoundingBox in project Glowstone by GlowstoneMC.
the class GlowStructure method wrapAllPieces.
public void wrapAllPieces() {
boundingBox = new StructureBoundingBox(new Vector(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE), new Vector(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE));
children.stream().filter(Objects::nonNull).forEach(piece -> boundingBox.expandTo(piece.getBoundingBox()));
}
use of net.glowstone.generator.structures.util.StructureBoundingBox in project Glowstone by GlowstoneMC.
the class GlowStructurePiece method createNewBoundingBox.
private void createNewBoundingBox(Location location, Vector size) {
Vector min = new Vector(location.getBlockX(), location.getBlockY(), location.getBlockZ());
Vector max = new Vector(location.getBlockX() + size.getBlockX() - 1, location.getBlockY() + size.getBlockY() - 1, location.getBlockZ() + size.getBlockZ() - 1);
boundingBox = new StructureBoundingBox(min, max);
}
Aggregations