Search in sources :

Example 1 with IBuildingManager

use of com.minecolonies.api.colony.managers.interfaces.IBuildingManager in project AdvancedPeripherals by Seniorendi.

the class ColonyPeripheral method getBuildings.

@LuaFunction(mainThread = true)
public final Object getBuildings() throws LuaException {
    IColony colony = getColony();
    IBuildingManager manager = colony.getBuildingManager();
    List<Object> buildingData = new ArrayList<>();
    for (Map.Entry<BlockPos, IBuilding> building : manager.getBuildings().entrySet()) {
        buildingData.add(MineColonies.buildingToObject(manager, building.getValue(), building.getKey()));
    }
    return buildingData;
}
Also used : IBuilding(com.minecolonies.api.colony.buildings.IBuilding) IColony(com.minecolonies.api.colony.IColony) BlockPos(net.minecraft.util.math.BlockPos) IBuildingManager(com.minecolonies.api.colony.managers.interfaces.IBuildingManager) LuaFunction(dan200.computercraft.api.lua.LuaFunction)

Example 2 with IBuildingManager

use of com.minecolonies.api.colony.managers.interfaces.IBuildingManager in project minecolonies by ldtteam.

the class AbstractSchematicProvider method getChildren.

@Override
public Set<BlockPos> getChildren() {
    // Validate childs existance
    final IBuildingManager manager = colony.getBuildingManager();
    List<BlockPos> toRemove = null;
    for (final BlockPos pos : childSchematics) {
        if (manager.getBuilding(pos) == null) {
            if (toRemove == null) {
                toRemove = new ArrayList<>();
            }
            toRemove.add(pos);
        }
    }
    if (toRemove != null) {
        final Set<BlockPos> oldPositions = new HashSet<>(this.childSchematics);
        oldPositions.removeAll(toRemove);
        this.childSchematics = ImmutableSet.copyOf(oldPositions);
    }
    return childSchematics;
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) IBuildingManager(com.minecolonies.api.colony.managers.interfaces.IBuildingManager) HashSet(java.util.HashSet)

Aggregations

IBuildingManager (com.minecolonies.api.colony.managers.interfaces.IBuildingManager)2 BlockPos (net.minecraft.util.math.BlockPos)2 IColony (com.minecolonies.api.colony.IColony)1 IBuilding (com.minecolonies.api.colony.buildings.IBuilding)1 LuaFunction (dan200.computercraft.api.lua.LuaFunction)1 HashSet (java.util.HashSet)1