Search in sources :

Example 1 with CreativeBuildingStructureHandler

use of com.minecolonies.api.util.CreativeBuildingStructureHandler in project minecolonies by Minecolonies.

the class ShipBasedRaiderUtils method canSpawnShipAt.

/**
 * Checks whether a pirate event is possible at this place.
 *
 * @param colony     the colony.
 * @param spawnPoint the spawn point.
 * @param raidLevel  the raid level.
 * @param rotation   the rotation.
 * @return true if successful.
 */
public static boolean canSpawnShipAt(final IColony colony, final BlockPos spawnPoint, final int raidLevel, final int rotation, final String shipName) {
    if (spawnPoint.equals(colony.getCenter()) || spawnPoint.getY() > MineColonies.getConfig().getServer().maxYForBarbarians.get()) {
        return false;
    }
    final World world = colony.getWorld();
    final String shipSize = ShipSize.getShipForRaiderAmount(raidLevel).schematicPrefix + shipName;
    final CreativeBuildingStructureHandler structure = new CreativeBuildingStructureHandler(colony.getWorld(), spawnPoint, Structures.SCHEMATICS_PREFIX + SHIP_FOLDER + shipSize, new PlacementSettings(), true);
    structure.getBluePrint().rotateWithMirror(BlockPosUtil.getRotationFromRotations(rotation), Mirror.NONE, colony.getWorld());
    return canPlaceShipAt(spawnPoint, structure.getBluePrint(), world) || canPlaceShipAt(spawnPoint.below(), structure.getBluePrint(), world);
}
Also used : CreativeBuildingStructureHandler(com.minecolonies.api.util.CreativeBuildingStructureHandler) World(net.minecraft.world.World) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings)

Example 2 with CreativeBuildingStructureHandler

use of com.minecolonies.api.util.CreativeBuildingStructureHandler in project minecolonies by ldtteam.

the class ShipBasedRaiderUtils method canSpawnShipAt.

/**
 * Checks whether a pirate event is possible at this place.
 *
 * @param colony     the colony.
 * @param spawnPoint the spawn point.
 * @param raidLevel  the raid level.
 * @param rotation   the rotation.
 * @return true if successful.
 */
public static boolean canSpawnShipAt(final IColony colony, final BlockPos spawnPoint, final int raidLevel, final int rotation, final String shipName) {
    if (spawnPoint.equals(colony.getCenter()) || spawnPoint.getY() > MineColonies.getConfig().getServer().maxYForBarbarians.get()) {
        return false;
    }
    final World world = colony.getWorld();
    final String shipSize = ShipSize.getShipForRaiderAmount(raidLevel).schematicPrefix + shipName;
    final CreativeBuildingStructureHandler structure = new CreativeBuildingStructureHandler(colony.getWorld(), spawnPoint, Structures.SCHEMATICS_PREFIX + SHIP_FOLDER + shipSize, new PlacementSettings(), true);
    structure.getBluePrint().rotateWithMirror(BlockPosUtil.getRotationFromRotations(rotation), Mirror.NONE, colony.getWorld());
    return canPlaceShipAt(spawnPoint, structure.getBluePrint(), world) || canPlaceShipAt(spawnPoint.below(), structure.getBluePrint(), world);
}
Also used : CreativeBuildingStructureHandler(com.minecolonies.api.util.CreativeBuildingStructureHandler) World(net.minecraft.world.World) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings)

Example 3 with CreativeBuildingStructureHandler

use of com.minecolonies.api.util.CreativeBuildingStructureHandler in project minecolonies by ldtteam.

the class AbstractShipRaidEvent method onStart.

@Override
public void onStart() {
    status = EventStatus.PREPARING;
    daysToGo = MineColonies.getConfig().getServer().daysUntilPirateshipsDespawn.get();
    CreativeBuildingStructureHandler structure = new CreativeBuildingStructureHandler(colony.getWorld(), spawnPoint, Structures.SCHEMATICS_PREFIX + ShipBasedRaiderUtils.SHIP_FOLDER + shipSize.schematicPrefix + this.getShipDesc(), new PlacementSettings(), true);
    structure.getBluePrint().rotateWithMirror(BlockPosUtil.getRotationFromRotations(shipRotation), Mirror.NONE, colony.getWorld());
    if (spawnPathResult.isDone()) {
        final Path path = spawnPathResult.getPath();
        if (path != null && path.canReach()) {
            final BlockPos endpoint = path.getEndNode().asBlockPos().below();
            if (ShipBasedRaiderUtils.canPlaceShipAt(endpoint, structure.getBluePrint(), colony.getWorld())) {
                spawnPoint = endpoint;
                structure = new CreativeBuildingStructureHandler(colony.getWorld(), spawnPoint, Structures.SCHEMATICS_PREFIX + ShipBasedRaiderUtils.SHIP_FOLDER + shipSize.schematicPrefix + this.getShipDesc(), new PlacementSettings(), true);
                structure.getBluePrint().rotateWithMirror(BlockPosUtil.getRotationFromRotations(shipRotation), Mirror.NONE, colony.getWorld());
            }
        }
        this.wayPoints = ShipBasedRaiderUtils.createWaypoints(colony.getWorld(), path, WAYPOINT_SPACING);
    }
    if (!ShipBasedRaiderUtils.canPlaceShipAt(spawnPoint, structure.getBluePrint(), colony.getWorld())) {
        spawnPoint = spawnPoint.below();
    }
    if (!ShipBasedRaiderUtils.spawnPirateShip(spawnPoint, colony.getWorld(), colony, shipSize.schematicPrefix + this.getShipDesc(), this, shipRotation)) {
        // Ship event not successfully started.
        status = EventStatus.CANCELED;
        return;
    }
    updateRaidBar();
    LanguageHandler.sendPlayersMessage(colony.getImportantMessageEntityPlayers(), RAID_EVENT_MESSAGE_PIRATE + shipSize.messageID, BlockPosUtil.calcDirection(colony.getCenter(), spawnPoint), colony.getName());
    colony.markDirty();
}
Also used : CreativeBuildingStructureHandler(com.minecolonies.api.util.CreativeBuildingStructureHandler) Path(net.minecraft.pathfinding.Path) BlockPos(net.minecraft.util.math.BlockPos) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings)

Aggregations

PlacementSettings (com.ldtteam.structurize.util.PlacementSettings)3 CreativeBuildingStructureHandler (com.minecolonies.api.util.CreativeBuildingStructureHandler)3 World (net.minecraft.world.World)2 Path (net.minecraft.pathfinding.Path)1 BlockPos (net.minecraft.util.math.BlockPos)1