Search in sources :

Example 1 with AbstractBuildingFurnaceUser

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

the class AbstractEntityAIUsesFurnace method getPositionOfOvenToRetrieveFrom.

/**
 * Get the furnace which has finished smeltables.
 * For this check each furnace which has been registered to the building.
 * Check if the furnace is turned off and has something in the result slot
 * or check if the furnace has more than x results.
 * @return the position of the furnace.
 */
protected BlockPos getPositionOfOvenToRetrieveFrom() {
    for (final BlockPos pos : ((AbstractBuildingFurnaceUser) getOwnBuilding()).getFurnaces()) {
        final TileEntity entity = world.getTileEntity(pos);
        if (entity instanceof TileEntityFurnace) {
            final TileEntityFurnace furnace = (TileEntityFurnace) entity;
            final int countInResultSlot = ItemStackUtils.isEmpty(furnace.getStackInSlot(RESULT_SLOT)) ? 0 : furnace.getStackInSlot(RESULT_SLOT).getCount();
            if ((!furnace.isBurning() && countInResultSlot > 0) || countInResultSlot > RETRIEVE_SMELTABLE_IF_MORE_THAN) {
                worker.setLatestStatus(new TextComponentTranslation(COM_MINECOLONIES_COREMOD_STATUS_RETRIEVING));
                return pos;
            }
        }
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) TileEntityFurnace(net.minecraft.tileentity.TileEntityFurnace) BlockPos(net.minecraft.util.math.BlockPos) AbstractBuildingFurnaceUser(com.minecolonies.coremod.colony.buildings.AbstractBuildingFurnaceUser)

Aggregations

AbstractBuildingFurnaceUser (com.minecolonies.coremod.colony.buildings.AbstractBuildingFurnaceUser)1 TileEntity (net.minecraft.tileentity.TileEntity)1 TileEntityFurnace (net.minecraft.tileentity.TileEntityFurnace)1 BlockPos (net.minecraft.util.math.BlockPos)1 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)1