Search in sources :

Example 1 with BuildingComposter

use of com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingComposter in project minecolonies by ldtteam.

the class EntityAIWorkComposter method decideWhatToDo.

/**
 * Method for the AI to decide what to do. Possible actions: harvest barrels, fill barrels or idle
 *
 * @return the decision it made
 */
private IAIState decideWhatToDo() {
    worker.getCitizenStatusHandler().setLatestStatus(new TranslationTextComponent(COM_MINECOLONIES_COREMOD_STATUS_IDLING));
    worker.getCitizenData().setVisibleStatus(VisibleCitizenStatus.WORKING);
    if (walkToBuilding()) {
        setDelay(2);
        return getState();
    }
    final BuildingComposter building = this.getOwnBuilding();
    for (final BlockPos barrel : building.getBarrels()) {
        final TileEntity te = world.getBlockEntity(barrel);
        if (te instanceof TileEntityBarrel) {
            this.currentTarget = barrel;
            if (((TileEntityBarrel) te).isDone()) {
                setDelay(DECIDE_DELAY);
                worker.getCitizenData().setVisibleStatus(COMPOST);
                return COMPOSTER_HARVEST;
            }
        }
    }
    for (final BlockPos barrel : building.getBarrels()) {
        final TileEntity te = world.getBlockEntity(barrel);
        if (te instanceof TileEntityBarrel && !((TileEntityBarrel) te).checkIfWorking()) {
            this.currentTarget = barrel;
            setDelay(DECIDE_DELAY);
            worker.getCitizenData().setVisibleStatus(COMPOST);
            return COMPOSTER_FILL;
        }
    }
    setDelay(DECIDE_DELAY);
    return START_WORKING;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityBarrel(com.minecolonies.coremod.tileentities.TileEntityBarrel) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) BlockPos(net.minecraft.util.math.BlockPos) BuildingComposter(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingComposter)

Example 2 with BuildingComposter

use of com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingComposter in project minecolonies by Minecolonies.

the class EntityAIWorkComposter method decideWhatToDo.

/**
 * Method for the AI to decide what to do. Possible actions: harvest barrels, fill barrels or idle
 *
 * @return the decision it made
 */
private IAIState decideWhatToDo() {
    worker.getCitizenStatusHandler().setLatestStatus(new TranslationTextComponent(COM_MINECOLONIES_COREMOD_STATUS_IDLING));
    worker.getCitizenData().setVisibleStatus(VisibleCitizenStatus.WORKING);
    if (walkToBuilding()) {
        setDelay(2);
        return getState();
    }
    final BuildingComposter building = this.building;
    for (final BlockPos barrel : building.getBarrels()) {
        final TileEntity te = world.getBlockEntity(barrel);
        if (te instanceof TileEntityBarrel) {
            this.currentTarget = barrel;
            if (((TileEntityBarrel) te).isDone()) {
                setDelay(DECIDE_DELAY);
                worker.getCitizenData().setVisibleStatus(COMPOST);
                return COMPOSTER_HARVEST;
            }
        }
    }
    for (final BlockPos barrel : building.getBarrels()) {
        final TileEntity te = world.getBlockEntity(barrel);
        if (te instanceof TileEntityBarrel && !((TileEntityBarrel) te).checkIfWorking()) {
            this.currentTarget = barrel;
            setDelay(DECIDE_DELAY);
            worker.getCitizenData().setVisibleStatus(COMPOST);
            return COMPOSTER_FILL;
        }
    }
    setDelay(DECIDE_DELAY);
    return START_WORKING;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityBarrel(com.minecolonies.coremod.tileentities.TileEntityBarrel) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) BlockPos(net.minecraft.util.math.BlockPos) BuildingComposter(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingComposter)

Aggregations

BuildingComposter (com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingComposter)2 TileEntityBarrel (com.minecolonies.coremod.tileentities.TileEntityBarrel)2 TileEntity (net.minecraft.tileentity.TileEntity)2 BlockPos (net.minecraft.util.math.BlockPos)2 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)2