Search in sources :

Example 1 with MutableBoundingBox

use of net.minecraft.util.math.MutableBoundingBox in project minecolonies by Minecolonies.

the class BuildingManager method guardBuildingChangedAt.

@Override
public void guardBuildingChangedAt(final IBuilding guardBuilding, final int newLevel) {
    final int claimRadius = guardBuilding.getClaimRadius(Math.max(guardBuilding.getBuildingLevel(), newLevel));
    final MutableBoundingBox guardedRegion = BlockPosUtil.getChunkAlignedBB(guardBuilding.getPosition(), claimRadius);
    for (final IBuilding building : getBuildings().values()) {
        if (guardedRegion.isInside(building.getPosition())) {
            building.resetGuardBuildingNear();
        }
    }
}
Also used : MutableBoundingBox(net.minecraft.util.math.MutableBoundingBox) IBuilding(com.minecolonies.api.colony.buildings.IBuilding)

Example 2 with MutableBoundingBox

use of net.minecraft.util.math.MutableBoundingBox 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 3 with MutableBoundingBox

use of net.minecraft.util.math.MutableBoundingBox in project GT-4-Reimagined by Trinsdar.

the class RubberTreeFeature method updateBoundingBox.

private void updateBoundingBox(BlockPos pos, Set<BlockPos> set, MutableBoundingBox boundingBox) {
    int[] coords = { pos.getX(), pos.getY(), pos.getZ(), pos.getX(), pos.getY(), pos.getZ() };
    for (BlockPos bp : set) {
        coords[0] = Math.min(coords[0], bp.getX());
        coords[1] = Math.min(coords[1], bp.getY());
        coords[2] = Math.min(coords[2], bp.getZ());
        coords[3] = Math.max(coords[3], bp.getX());
        coords[4] = Math.max(coords[4], bp.getY());
        coords[5] = Math.max(coords[5], bp.getZ());
    }
    boundingBox.expandTo(new MutableBoundingBox(coords));
}
Also used : MutableBoundingBox(net.minecraft.util.math.MutableBoundingBox) BlockPos(net.minecraft.util.math.BlockPos)

Example 4 with MutableBoundingBox

use of net.minecraft.util.math.MutableBoundingBox in project FrostedHeart by TeamMoegMC.

the class SpacecraftFeature method generate.

@Override
public boolean generate(ISeedReader reader, ChunkGenerator generator, Random rand, BlockPos pos, NoFeatureConfig config) {
    /*  List<Integer> listX = IntStream.rangeClosed(chunkpos.getXStart(), chunkpos.getXEnd()).boxed().collect(Collectors.toList());
        Collections.shuffle(listX, rand);
        List<Integer> listZ = IntStream.rangeClosed(chunkpos.getZStart(), chunkpos.getZEnd()).boxed().collect(Collectors.toList());
        Collections.shuffle(listZ, rand);*/
    // for(Integer integerX : listX) {
    // for(Integer integerZ : listZ) {
    BlockPos start = new BlockPos(pos.getX() - 9, pos.getY() - 1, /*generator.getNoiseHeightMinusOne(pos.getX(),pos.getZ(), Heightmap.Type.WORLD_SURFACE_WG)*/
    pos.getZ() - 7);
    // if (reader.isAirBlock(blockpos$mutable) || reader.getBlockState(blockpos$mutable).getCollisionShapeUncached(reader, blockpos$mutable).isEmpty()) {
    Rotation rot = Rotation.randomRotation(rand);
    PlacementSettings settings = (new PlacementSettings()).setCenterOffset(new BlockPos(/*9*/
    9, 2, 7)).setRotation(rot).setMirror(Mirror.NONE);
    Template template = reader.getWorld().getStructureTemplateManager().getTemplate(new ResourceLocation(FHMain.MODID, "relic/spacecraft"));
    MutableBoundingBox boundingBox = template.getMutableBoundingBox(settings, start);
    Vector3i vector3i = boundingBox.func_215126_f();
    if (template.func_237146_a_(reader, start, new BlockPos(vector3i.getX(), vector3i.getY(), vector3i.getZ()), settings, reader.getRandom(), 2)) {
        FHMain.LOGGER.debug("spacecraft at " + (start.getX()) + " " + start.getY() + " " + (start.getZ()) + " " + rot);
        return true;
    }
    // }
    return false;
}
Also used : MutableBoundingBox(net.minecraft.util.math.MutableBoundingBox) ResourceLocation(net.minecraft.util.ResourceLocation) Vector3i(net.minecraft.util.math.vector.Vector3i) BlockPos(net.minecraft.util.math.BlockPos) PlacementSettings(net.minecraft.world.gen.feature.template.PlacementSettings) Rotation(net.minecraft.util.Rotation) Template(net.minecraft.world.gen.feature.template.Template)

Example 5 with MutableBoundingBox

use of net.minecraft.util.math.MutableBoundingBox in project Shrines by Silverminer007.

the class CustomStructureData method savePieces.

public boolean savePieces(ServerWorld serverWorld, MinecraftServer server, String author, boolean includeEntities) {
    ModTemplateManager templatemanager;
    try {
        templatemanager = new ModTemplateManager(Utils.getSaveLocation().getCanonicalFile().toPath(), server.getFixerUpper());
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
    for (ResourceData rd : PIECES_ON_FLY) {
        ResourceLocation location = new ResourceLocation(ShrinesMod.MODID, name + "/" + rd.getName());
        MutableBoundingBox mbb = rd.getBounds();
        BlockPos c0 = new BlockPos(mbb.x0, mbb.y0, mbb.z0);
        BlockPos c1 = new BlockPos(mbb.x1, mbb.y1, mbb.z1);
        Template template;
        try {
            template = templatemanager.getOrCreate(location);
        } catch (ResourceLocationException resourcelocationexception) {
            LOGGER.error(resourcelocationexception);
            return false;
        }
        template.fillFromWorld(serverWorld, c0, c1.subtract(c0), includeEntities, Blocks.STRUCTURE_VOID);
        template.setAuthor(author);
        try {
            if (!templatemanager.save(location)) {
                return false;
            }
        } catch (ResourceLocationException resourcelocationexception) {
            LOGGER.error(resourcelocationexception);
            return false;
        }
    }
    return true;
}
Also used : MutableBoundingBox(net.minecraft.util.math.MutableBoundingBox) ResourceLocation(net.minecraft.util.ResourceLocation) ResourceLocationException(net.minecraft.util.ResourceLocationException) BlockPos(net.minecraft.util.math.BlockPos) IOException(java.io.IOException) ModTemplateManager(com.silverminer.shrines.utils.custom_structures.ModTemplateManager) Template(net.minecraft.world.gen.feature.template.Template)

Aggregations

MutableBoundingBox (net.minecraft.util.math.MutableBoundingBox)27 BlockPos (net.minecraft.util.math.BlockPos)22 StructurePiece (net.minecraft.world.gen.feature.structure.StructurePiece)6 ColorStructurePiece (com.silverminer.shrines.structures.ColorStructurePiece)5 ArrayList (java.util.ArrayList)4 ResourceLocation (net.minecraft.util.ResourceLocation)4 IBuilding (com.minecolonies.api.colony.buildings.IBuilding)2 NewStructureInit (com.silverminer.shrines.init.NewStructureInit)2 Utils (com.silverminer.shrines.utils.custom_structures.Utils)2 List (java.util.List)2 Random (java.util.Random)2 Collectors (java.util.stream.Collectors)2 Blocks (net.minecraft.block.Blocks)2 Rotation (net.minecraft.util.Rotation)2 Category (net.minecraft.world.biome.Biome.Category)2 ChunkGenerator (net.minecraft.world.gen.ChunkGenerator)2 Template (net.minecraft.world.gen.feature.template.Template)2 LogManager (org.apache.logging.log4j.LogManager)2 ImmutableList (com.google.common.collect.ImmutableList)1 Lists (com.google.common.collect.Lists)1