Search in sources :

Example 1 with AbstractScarecrowTileEntity

use of com.minecolonies.api.tileentities.AbstractScarecrowTileEntity in project minecolonies by Minecolonies.

the class EntityAIWorkFarmer method searchAndAddFields.

/**
 * Searches and adds a field that has not been taken yet for the farmer and then adds it to the list.
 */
private void searchAndAddFields() {
    final IColony colony = worker.getCitizenColonyHandler().getColony();
    if (colony != null) {
        @Nullable final AbstractScarecrowTileEntity newField = colony.getBuildingManager().getFreeField(worker.getCitizenData().getId(), world);
        if (newField != null) {
            newField.setOwner(worker.getCitizenData().getId());
            newField.setTaken(true);
            newField.setChanged();
            final FarmerFieldModule module = getOwnBuilding().getFirstModuleOccurance(FarmerFieldModule.class);
            module.addFarmerFields(newField.getPosition());
        }
    }
}
Also used : AbstractScarecrowTileEntity(com.minecolonies.api.tileentities.AbstractScarecrowTileEntity) IColony(com.minecolonies.api.colony.IColony) FarmerFieldModule(com.minecolonies.coremod.colony.buildings.modules.FarmerFieldModule) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with AbstractScarecrowTileEntity

use of com.minecolonies.api.tileentities.AbstractScarecrowTileEntity in project minecolonies by ldtteam.

the class EntityAIWorkFarmer method searchAndAddFields.

/**
 * Searches and adds a field that has not been taken yet for the farmer and then adds it to the list.
 */
private void searchAndAddFields() {
    final IColony colony = worker.getCitizenColonyHandler().getColony();
    if (colony != null) {
        @Nullable final AbstractScarecrowTileEntity newField = colony.getBuildingManager().getFreeField(worker.getCitizenData().getId(), world);
        if (newField != null) {
            newField.setOwner(worker.getCitizenData().getId());
            newField.setTaken(true);
            newField.setChanged();
            final FarmerFieldModule module = getOwnBuilding().getFirstModuleOccurance(FarmerFieldModule.class);
            module.addFarmerFields(newField.getPosition());
        }
    }
}
Also used : AbstractScarecrowTileEntity(com.minecolonies.api.tileentities.AbstractScarecrowTileEntity) IColony(com.minecolonies.api.colony.IColony) FarmerFieldModule(com.minecolonies.coremod.colony.buildings.modules.FarmerFieldModule) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

IColony (com.minecolonies.api.colony.IColony)2 AbstractScarecrowTileEntity (com.minecolonies.api.tileentities.AbstractScarecrowTileEntity)2 FarmerFieldModule (com.minecolonies.coremod.colony.buildings.modules.FarmerFieldModule)2 Nullable (org.jetbrains.annotations.Nullable)2