Search in sources :

Example 1 with StructureBoundingBox

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();
        }
    //}
    }
}
Also used : BlockStateDelegate(net.glowstone.util.BlockStateDelegate) GlowDungeon(net.glowstone.generator.structures.GlowDungeon) StructureBoundingBox(net.glowstone.generator.structures.util.StructureBoundingBox) SimplexNoiseGenerator(org.bukkit.util.noise.SimplexNoiseGenerator) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location)

Example 2 with StructureBoundingBox

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();
        }
    }
}
Also used : GlowDesertWell(net.glowstone.generator.structures.GlowDesertWell) BlockStateDelegate(net.glowstone.util.BlockStateDelegate) StructureBoundingBox(net.glowstone.generator.structures.util.StructureBoundingBox) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location)

Example 3 with StructureBoundingBox

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);
}
Also used : StructureBoundingBox(net.glowstone.generator.structures.util.StructureBoundingBox) ArrayList(java.util.ArrayList) GlowStructurePiece(net.glowstone.generator.structures.GlowStructurePiece) CompoundTag(net.glowstone.util.nbt.CompoundTag)

Example 4 with StructureBoundingBox

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()));
}
Also used : StructureBoundingBox(net.glowstone.generator.structures.util.StructureBoundingBox) Vector(org.bukkit.util.Vector)

Example 5 with StructureBoundingBox

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);
}
Also used : StructureBoundingBox(net.glowstone.generator.structures.util.StructureBoundingBox) Vector(org.bukkit.util.Vector)

Aggregations

StructureBoundingBox (net.glowstone.generator.structures.util.StructureBoundingBox)8 Vector (org.bukkit.util.Vector)6 BlockStateDelegate (net.glowstone.util.BlockStateDelegate)2 CompoundTag (net.glowstone.util.nbt.CompoundTag)2 Location (org.bukkit.Location)2 ArrayList (java.util.ArrayList)1 GlowDesertWell (net.glowstone.generator.structures.GlowDesertWell)1 GlowDungeon (net.glowstone.generator.structures.GlowDungeon)1 GlowStructurePiece (net.glowstone.generator.structures.GlowStructurePiece)1 SimplexNoiseGenerator (org.bukkit.util.noise.SimplexNoiseGenerator)1