Search in sources :

Example 6 with StructureBoundingBox

use of net.glowstone.generator.structures.util.StructureBoundingBox in project Glowstone by GlowstoneMC.

the class StructurePieceStore method load.

/**
     * Load structure piece data of the appropriate type from the given compound tag.
     *
     * @param structurePiece The target structure piece.
     * @param compound       The structure piece's tag.
     */
public void load(T structurePiece, CompoundTag compound) {
    if (compound.isInt("GD")) {
        structurePiece.setGD(compound.getInt("GD"));
    }
    if (compound.isInt("O")) {
        structurePiece.setNumericOrientation(compound.getInt("O"));
    }
    if (compound.isIntArray("BB")) {
        int[] bb = compound.getIntArray("BB");
        if (bb.length == 6) {
            StructureBoundingBox boundingBox = new StructureBoundingBox(new Vector(bb[0], bb[1], bb[2]), new Vector(bb[3], bb[4], bb[5]));
            structurePiece.setBoundingBox(boundingBox);
        }
    }
}
Also used : StructureBoundingBox(net.glowstone.generator.structures.util.StructureBoundingBox) Vector(org.bukkit.util.Vector)

Example 7 with StructureBoundingBox

use of net.glowstone.generator.structures.util.StructureBoundingBox in project Glowstone by GlowstoneMC.

the class StructurePieceStore method save.

/**
     * Save information about this structure piece to the given tag.
     *
     * @param structurePiece The structure piece to save.
     * @param compound       The target tag.
     */
public void save(T structurePiece, CompoundTag compound) {
    compound.putInt("GD", structurePiece.getGD());
    compound.putInt("O", structurePiece.getNumericOrientation());
    StructureBoundingBox boundingBox = structurePiece.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);
}
Also used : StructureBoundingBox(net.glowstone.generator.structures.util.StructureBoundingBox)

Example 8 with StructureBoundingBox

use of net.glowstone.generator.structures.util.StructureBoundingBox in project Glowstone by GlowstoneMC.

the class StructureStore method load.

/**
     * Load structure data of the appropriate type from the given compound tag.
     *
     * @param structure The target structure.
     * @param compound  The structure's tag.
     */
public void load(T structure, CompoundTag compound) {
    if (compound.isIntArray("BB")) {
        int[] bb = compound.getIntArray("BB");
        if (bb.length == 6) {
            StructureBoundingBox boundingBox = new StructureBoundingBox(new Vector(bb[0], bb[1], bb[2]), new Vector(bb[3], bb[4], bb[5]));
            structure.setBoundingBox(boundingBox);
        }
    }
    if (compound.isList("Children", TagType.COMPOUND)) {
        for (CompoundTag tag : compound.getCompoundList("Children")) {
            structure.addPiece(StructurePieceStorage.loadStructurePiece(tag));
        }
    }
}
Also used : StructureBoundingBox(net.glowstone.generator.structures.util.StructureBoundingBox) Vector(org.bukkit.util.Vector) CompoundTag(net.glowstone.util.nbt.CompoundTag)

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