Search in sources :

Example 6 with IRSComponent

use of com.minecolonies.api.colony.buildings.IRSComponent in project minecolonies by Minecolonies.

the class BuildToolPlaceMessage method setupBuilding.

/**
 * setup the building once it has been placed.
 *
 * @param world    World the hut is being placed into.
 * @param player   Who placed the hut.
 * @param sn       The name of the structure.
 * @param rotation The number of times the structure should be rotated.
 * @param buildPos The location the hut is being placed.
 * @param mirror   Whether or not the structure is mirrored.
 * @param level    the future initial building level.
 * @param complete if pasted.
 */
private static void setupBuilding(@NotNull final World world, @NotNull final PlayerEntity player, final StructureName sn, final int rotation, @NotNull final BlockPos buildPos, final boolean mirror, final int level, final boolean complete) {
    @Nullable final IBuilding building = IColonyManager.getInstance().getBuilding(world, buildPos);
    if (building == null) {
        if (!sn.getHutName().equals(ModBuildings.TOWNHALL_ID)) {
            SoundUtils.playErrorSound(player, player.blockPosition());
            Log.getLogger().error("BuildTool: building is null!", new Exception());
        }
    } else {
        SoundUtils.playSuccessSound(player, player.blockPosition());
        if (building.getTileEntity() != null) {
            final IColony colony = IColonyManager.getInstance().getColonyByPosFromWorld(world, buildPos);
            if (colony == null) {
                Log.getLogger().info("No colony for " + player.getName().getString());
            } else {
                building.getTileEntity().setColony(colony);
            }
        }
        building.setStyle(sn.getStyle());
        building.setBuildingLevel(level);
        if (level > 0) {
            building.setDeconstructed();
        }
        if (!(building instanceof IRSComponent)) {
            ConstructionTapeHelper.placeConstructionTape(building.getCorners(), world);
        }
        building.setIsMirrored(mirror);
        if (complete) {
            building.onUpgradeComplete(building.getBuildingLevel());
        }
    }
}
Also used : IBuilding(com.minecolonies.api.colony.buildings.IBuilding) IColony(com.minecolonies.api.colony.IColony) IRSComponent(com.minecolonies.api.colony.buildings.IRSComponent) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with IRSComponent

use of com.minecolonies.api.colony.buildings.IRSComponent in project minecolonies by ldtteam.

the class BuildToolPlaceMessage method setupBuilding.

/**
 * setup the building once it has been placed.
 *
 * @param world    World the hut is being placed into.
 * @param player   Who placed the hut.
 * @param sn       The name of the structure.
 * @param rotation The number of times the structure should be rotated.
 * @param buildPos The location the hut is being placed.
 * @param mirror   Whether or not the structure is mirrored.
 * @param level    the future initial building level.
 * @param complete if pasted.
 */
private static void setupBuilding(@NotNull final World world, @NotNull final PlayerEntity player, final StructureName sn, final int rotation, @NotNull final BlockPos buildPos, final boolean mirror, final int level, final boolean complete) {
    @Nullable final IBuilding building = IColonyManager.getInstance().getBuilding(world, buildPos);
    if (building == null) {
        if (!sn.getHutName().equals(ModBuildings.TOWNHALL_ID)) {
            SoundUtils.playErrorSound(player, player.blockPosition());
            Log.getLogger().error("BuildTool: building is null!", new Exception());
        }
    } else {
        SoundUtils.playSuccessSound(player, player.blockPosition());
        if (building.getTileEntity() != null) {
            final IColony colony = IColonyManager.getInstance().getColonyByPosFromWorld(world, buildPos);
            if (colony == null) {
                Log.getLogger().info("No colony for " + player.getName().getString());
            } else {
                building.getTileEntity().setColony(colony);
            }
        }
        building.setStyle(sn.getStyle());
        building.setBuildingLevel(level);
        if (level > 0) {
            building.setDeconstructed();
        }
        if (!(building instanceof IRSComponent)) {
            ConstructionTapeHelper.placeConstructionTape(building.getCorners(), world);
        }
        building.setIsMirrored(mirror);
        if (complete) {
            building.onUpgradeComplete(building.getBuildingLevel());
        }
    }
}
Also used : IBuilding(com.minecolonies.api.colony.buildings.IBuilding) IColony(com.minecolonies.api.colony.IColony) IRSComponent(com.minecolonies.api.colony.buildings.IRSComponent) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

IBuilding (com.minecolonies.api.colony.buildings.IBuilding)7 IRSComponent (com.minecolonies.api.colony.buildings.IRSComponent)7 Nullable (org.jetbrains.annotations.Nullable)7 IColony (com.minecolonies.api.colony.IColony)4