use of dan200.computercraft.api.lua.LuaFunction 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;
}
use of dan200.computercraft.api.lua.LuaFunction in project AdvancedPeripherals by Seniorendi.
the class ColonyPeripheral method getWorkOrderResources.
@LuaFunction(mainThread = true)
public final Object getWorkOrderResources(int id) throws LuaException {
IColony colony = getColony();
IWorkOrder workOrder = colony.getWorkManager().getWorkOrder(id);
if (workOrder == null)
return null;
return MineColonies.builderResourcesToObject(colony, workOrder.getClaimedBy());
}
use of dan200.computercraft.api.lua.LuaFunction in project AdvancedPeripherals by Seniorendi.
the class ColonyPeripheral method getCitizens.
@LuaFunction(mainThread = true)
public final Object getCitizens() throws LuaException {
IColony colony = getColony();
List<Object> list = new ArrayList<>();
colony.getCitizenManager().getCitizens().forEach(citizen -> {
list.add(MineColonies.citizenToObject(citizen));
});
return list;
}
use of dan200.computercraft.api.lua.LuaFunction in project AdvancedPeripherals by Seniorendi.
the class ColonyPeripheral method getWorkOrders.
@LuaFunction(mainThread = true)
public final Object getWorkOrders() throws LuaException {
IColony colony = getColony();
List<Object> worksData = new ArrayList<>();
for (IWorkOrder workOrder : colony.getWorkManager().getWorkOrders().values()) worksData.add(MineColonies.workOrderToObject(workOrder));
return worksData;
}
use of dan200.computercraft.api.lua.LuaFunction in project AdvancedPeripherals by Seniorendi.
the class EnvironmentDetectorPeripheral method scanEntities.
@LuaFunction(mainThread = true)
public final MethodResult scanEntities(@Nonnull IComputerAccess access, @Nonnull IArguments arguments) throws LuaException {
int radius = arguments.getInt(0);
return withOperation(SCAN_ENTITIES, new SphereOperationContext(radius), context -> {
if (radius > SCAN_ENTITIES.getMaxCostRadius()) {
return MethodResult.of(null, "Radius is exceed max value");
}
return null;
}, context -> {
BlockPos pos = owner.getPos();
AxisAlignedBB box = new AxisAlignedBB(pos);
List<Map<String, Object>> entities = new ArrayList<>();
getWorld().getEntities((Entity) null, box.inflate(radius), entity -> entity instanceof LivingEntity).forEach(entity -> entities.add(LuaConverter.completeEntityWithPositionToLua(entity, ItemStack.EMPTY, pos)));
return MethodResult.of(entities);
}, null);
}
Aggregations