Search in sources :

Example 1 with StructureStart

use of net.minecraft.world.gen.feature.structure.StructureStart in project BoundingBoxOutlineReloaded by irtimaled.

the class StructureProcessor method addStructures.

private void addStructures(BoundingBoxType type, Map<String, StructureStart> structureMap) {
    StructureStart structureStart = structureMap.get(type.getName());
    if (structureStart == null)
        return;
    MutableBoundingBox bb = structureStart.getBoundingBox();
    if (bb == null)
        return;
    AbstractBoundingBox boundingBox = buildStructure(bb, type);
    if (boundingBoxCache.isCached(boundingBox))
        return;
    Set<AbstractBoundingBox> structureBoundingBoxes = new HashSet<>();
    for (StructurePiece structureComponent : structureStart.getComponents()) {
        structureBoundingBoxes.add(buildStructure(structureComponent.getBoundingBox(), type));
    }
    boundingBoxCache.addBoundingBoxes(boundingBox, structureBoundingBoxes);
}
Also used : MutableBoundingBox(net.minecraft.util.math.MutableBoundingBox) StructurePiece(net.minecraft.world.gen.feature.structure.StructurePiece) StructureStart(net.minecraft.world.gen.feature.structure.StructureStart) AbstractBoundingBox(com.irtimaled.bbor.common.models.AbstractBoundingBox) HashSet(java.util.HashSet)

Example 2 with StructureStart

use of net.minecraft.world.gen.feature.structure.StructureStart in project BoundingBoxOutlineReloaded by irtimaled.

the class CommonInterop method chunkLoaded.

public static void chunkLoaded(Chunk chunk) {
    DimensionId dimensionId = DimensionId.from(chunk.getWorld().getDimension().getType());
    Map<String, StructureStart> structures = chunk.getStructureStarts();
    if (structures.size() > 0)
        EventBus.publish(new StructuresLoaded(structures, dimensionId));
}
Also used : StructureStart(net.minecraft.world.gen.feature.structure.StructureStart) DimensionId(com.irtimaled.bbor.common.models.DimensionId)

Example 3 with StructureStart

use of net.minecraft.world.gen.feature.structure.StructureStart in project BoundingBoxOutlineReloaded by irtimaled.

the class NBTStructureLoader method loadStructures.

void loadStructures(int chunkX, int chunkZ) {
    if (saveHandler == null)
        return;
    if (!loadedChunks.add(String.format("%s,%s", chunkX, chunkZ)))
        return;
    CompoundNBT structureStarts = loadStructureStarts(chunkX, chunkZ);
    if (structureStarts == null || structureStarts.size() == 0)
        return;
    Map<String, StructureStart> structureStartMap = new HashMap<>();
    for (String key : structureStarts.keySet()) {
        CompoundNBT compound = structureStarts.getCompound(key);
        if (compound.contains("BB")) {
            structureStartMap.put(key, new SimpleStructureStart(compound));
        }
    }
    EventBus.publish(new StructuresLoaded(structureStartMap, dimensionId));
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) StructureStart(net.minecraft.world.gen.feature.structure.StructureStart) StructuresLoaded(com.irtimaled.bbor.common.events.StructuresLoaded)

Aggregations

StructureStart (net.minecraft.world.gen.feature.structure.StructureStart)3 StructuresLoaded (com.irtimaled.bbor.common.events.StructuresLoaded)1 AbstractBoundingBox (com.irtimaled.bbor.common.models.AbstractBoundingBox)1 DimensionId (com.irtimaled.bbor.common.models.DimensionId)1 HashSet (java.util.HashSet)1 CompoundNBT (net.minecraft.nbt.CompoundNBT)1 MutableBoundingBox (net.minecraft.util.math.MutableBoundingBox)1 StructurePiece (net.minecraft.world.gen.feature.structure.StructurePiece)1