use of com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingPlantation in project minecolonies by Minecolonies.
the class EntityAIWorkPlanter method decide.
@Override
protected IAIState decide() {
final IAIState nextState = super.decide();
if (nextState != START_WORKING && nextState != IDLE) {
return nextState;
}
final BuildingPlantation plantation = getOwnBuilding();
final List<BlockPos> list = plantation.getPosForPhase();
for (final BlockPos pos : list) {
if (isAtLeastThreeHigh(pos)) {
this.workPos = pos;
return PLANTATION_FARM;
}
}
final Item current = plantation.nextPlantPhase();
final int plantInBuilding = InventoryUtils.getCountFromBuilding(getOwnBuilding(), itemStack -> itemStack.sameItem(new ItemStack(current)));
final int plantInInv = InventoryUtils.getItemCountInItemHandler((worker.getInventoryCitizen()), itemStack -> itemStack.sameItem(new ItemStack(current)));
if (plantInBuilding + plantInInv <= 0) {
requestPlantable(current);
return START_WORKING;
}
if (plantInInv == 0 && plantInBuilding > 0) {
needsCurrently = new Tuple<>(itemStack -> itemStack.sameItem(new ItemStack(current)), Math.min(plantInBuilding, PLANT_TO_REQUEST));
return GATHERING_REQUIRED_MATERIALS;
}
for (final BlockPos pos : list) {
if (world.getBlockState(pos.above()).getBlock() instanceof AirBlock) {
this.workPos = pos;
return PLANTATION_PLANT;
}
}
return START_WORKING;
}
use of com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingPlantation in project minecolonies by ldtteam.
the class EntityAIWorkPlanter method decide.
@Override
protected IAIState decide() {
final IAIState nextState = super.decide();
if (nextState != START_WORKING && nextState != IDLE) {
return nextState;
}
final BuildingPlantation plantation = getOwnBuilding();
final List<BlockPos> list = plantation.getPosForPhase();
for (final BlockPos pos : list) {
if (isAtLeastThreeHigh(pos)) {
this.workPos = pos;
return PLANTATION_FARM;
}
}
final Item current = plantation.nextPlantPhase();
final int plantInBuilding = InventoryUtils.getCountFromBuilding(getOwnBuilding(), itemStack -> itemStack.sameItem(new ItemStack(current)));
final int plantInInv = InventoryUtils.getItemCountInItemHandler((worker.getInventoryCitizen()), itemStack -> itemStack.sameItem(new ItemStack(current)));
if (plantInBuilding + plantInInv <= 0) {
requestPlantable(current);
return START_WORKING;
}
if (plantInInv == 0 && plantInBuilding > 0) {
needsCurrently = new Tuple<>(itemStack -> itemStack.sameItem(new ItemStack(current)), Math.min(plantInBuilding, PLANT_TO_REQUEST));
return GATHERING_REQUIRED_MATERIALS;
}
for (final BlockPos pos : list) {
if (world.getBlockState(pos.above()).getBlock() instanceof AirBlock) {
this.workPos = pos;
return PLANTATION_PLANT;
}
}
return START_WORKING;
}
Aggregations