Search in sources :

Example 16 with StructureName

use of com.minecolonies.coremod.colony.StructureName in project minecolonies by Minecolonies.

the class BuildingUtils method getTargetAbleArea.

/**
 * Calculate the Size of the building given a world and a building.
 * @param world the world.
 * @param building the building.
 * @return the AxisAlignedBB box.
 */
public static AxisAlignedBB getTargetAbleArea(final World world, final AbstractBuilding building) {
    final BlockPos location = building.getLocation();
    final int x1;
    final int z1;
    final int x3;
    final int z3;
    final int y1 = location.getY() - 2;
    final int y3;
    if (building.getHeight() == 0) {
        final StructureName sn = new StructureName(Structures.SCHEMATICS_PREFIX, building.getStyle(), building.getSchematicName() + building.getBuildingLevel());
        final String structureName = sn.toString();
        final StructureWrapper wrapper = new StructureWrapper(world, structureName);
        wrapper.rotate(building.getRotation(), world, location, building.isMirrored() ? Mirror.FRONT_BACK : Mirror.NONE);
        final BlockPos pos = location;
        wrapper.setPosition(pos);
        x1 = wrapper.getPosition().getX() - wrapper.getOffset().getX() - 1;
        z1 = wrapper.getPosition().getZ() - wrapper.getOffset().getZ() - 1;
        x3 = wrapper.getPosition().getX() + (wrapper.getWidth() - wrapper.getOffset().getX());
        z3 = wrapper.getPosition().getZ() + (wrapper.getLength() - wrapper.getOffset().getZ());
        y3 = location.getY() + wrapper.getHeight();
        building.setCorners(x1, x3, z1, z3);
        building.setHeight(wrapper.getHeight());
    } else {
        final Tuple<Tuple<Integer, Integer>, Tuple<Integer, Integer>> corners = building.getCorners();
        x1 = corners.getFirst().getFirst();
        x3 = corners.getFirst().getSecond();
        z1 = corners.getSecond().getFirst();
        z3 = corners.getSecond().getSecond();
        y3 = location.getY() + building.getHeight();
    }
    return new AxisAlignedBB(x1, y1, z1, x3, y3, z3);
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) StructureName(com.minecolonies.coremod.colony.StructureName) BlockPos(net.minecraft.util.math.BlockPos) Tuple(net.minecraft.util.Tuple)

Aggregations

StructureName (com.minecolonies.coremod.colony.StructureName)16 DropDownList (com.minecolonies.blockout.views.DropDownList)2 BuildToolPasteMessage (com.minecolonies.coremod.network.messages.BuildToolPasteMessage)2 ArrayList (java.util.ArrayList)2 ItemStack (net.minecraft.item.ItemStack)2 Nullable (org.jetbrains.annotations.Nullable)2 Button (com.minecolonies.blockout.controls.Button)1 ScrollingList (com.minecolonies.blockout.views.ScrollingList)1 AbstractBuilding (com.minecolonies.coremod.colony.buildings.AbstractBuilding)1 WorkOrderBuild (com.minecolonies.coremod.colony.workorders.WorkOrderBuild)1 BuildToolPlaceMessage (com.minecolonies.coremod.network.messages.BuildToolPlaceMessage)1 SchematicRequestMessage (com.minecolonies.coremod.network.messages.SchematicRequestMessage)1 SchematicSaveMessage (com.minecolonies.coremod.network.messages.SchematicSaveMessage)1 StructureWrapper (com.minecolonies.coremod.util.StructureWrapper)1 Structure (com.minecolonies.structures.helpers.Structure)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1