Search in sources :

Example 1 with BlockFurnace

use of net.minecraft.block.BlockFurnace in project minecolonies by Minecolonies.

the class EntityAIWorkBaker method bake.

/**
 * Prepares the baker for baking and requests ingredients.
 *
 * @return the next AIState
 */
private AIState bake() {
    final BuildingBaker building = getOwnBuilding();
    if (currentFurnace == null || building.getFurnacesWithProduct().get(currentFurnace) != null) {
        return PREPARING;
    }
    if (walkToBlock(currentFurnace)) {
        return BAKER_BAKING;
    }
    final IBlockState furnace = world.getBlockState(currentFurnace);
    final List<BakingProduct> bakingProducts = building.getTasks().get(ProductState.PREPARED);
    if (!(furnace.getBlock() instanceof BlockFurnace)) {
        if (bakingProducts.isEmpty()) {
            building.removeFromTasks(ProductState.PREPARED, null);
        } else {
            building.removeFromFurnaces(currentFurnace);
        }
        return START_WORKING;
    } else if (bakingProducts.isEmpty()) {
        return START_WORKING;
    }
    final BakingProduct bakingProduct = bakingProducts.get(0);
    building.removeFromTasks(ProductState.PREPARED, bakingProduct);
    if (bakingProduct != null && bakingProduct.getState() == ProductState.PREPARED) {
        building.putInFurnace(currentFurnace, bakingProduct);
        bakingProduct.nextState();
        world.setBlockState(currentFurnace, Blocks.LIT_FURNACE.getDefaultState().withProperty(BlockFurnace.FACING, furnace.getValue(BlockFurnace.FACING)));
    }
    return PREPARING;
}
Also used : BlockFurnace(net.minecraft.block.BlockFurnace) IBlockState(net.minecraft.block.state.IBlockState) BuildingBaker(com.minecolonies.coremod.colony.buildings.BuildingBaker)

Example 2 with BlockFurnace

use of net.minecraft.block.BlockFurnace in project minecolonies by Minecolonies.

the class BuildingBaker method checkFurnaces.

/**
 * Checks the furnaces of the baker if they're ready.
 */
private void checkFurnaces() {
    final World worldObj = getColony().getWorld();
    if (worldObj == null) {
        return;
    }
    final List<Map.Entry<BlockPos, BakingProduct>> copyOfList = new ArrayList<>(this.getFurnacesWithProduct().entrySet());
    for (final Map.Entry<BlockPos, BakingProduct> entry : copyOfList) {
        if (!worldObj.isBlockLoaded(entry.getKey())) {
            return;
        }
        final IBlockState furnace = worldObj.getBlockState(entry.getKey());
        if (!(furnace.getBlock() instanceof BlockFurnace)) {
            if (worldObj.getTileEntity(entry.getKey()) instanceof TileEntityFurnace) {
                return;
            }
            Log.getLogger().warn(getColony().getName() + " Removed furnace at: " + entry.getKey() + " because it went missing!");
            this.removeFromFurnaces(entry.getKey());
            continue;
        }
        final BakingProduct bakingProduct = entry.getValue();
        if (bakingProduct != null && bakingProduct.getState() == ProductState.BAKING) {
            bakingProduct.increaseBakingProgress();
            worldObj.setBlockState(entry.getKey(), Blocks.LIT_FURNACE.getDefaultState().withProperty(BlockFurnace.FACING, furnace.getValue(BlockFurnace.FACING)));
        } else {
            worldObj.setBlockState(entry.getKey(), Blocks.FURNACE.getDefaultState().withProperty(BlockFurnace.FACING, furnace.getValue(BlockFurnace.FACING)));
        }
    }
}
Also used : BlockFurnace(net.minecraft.block.BlockFurnace) IBlockState(net.minecraft.block.state.IBlockState) TileEntityFurnace(net.minecraft.tileentity.TileEntityFurnace) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) BakingProduct(com.minecolonies.coremod.entity.ai.citizen.baker.BakingProduct)

Example 3 with BlockFurnace

use of net.minecraft.block.BlockFurnace in project MC-Prefab by Brian-Wuest.

the class StructureAlternateStart method CustomBlockProcessingHandled.

@Override
protected Boolean CustomBlockProcessingHandled(StructureConfiguration configuration, BuildBlock block, World world, BlockPos originalPos, EnumFacing assumedNorth, Block foundBlock, IBlockState blockState, EntityPlayer player) {
    HouseConfiguration houseConfig = (HouseConfiguration) configuration;
    if ((!houseConfig.addBed && foundBlock instanceof BlockBed) || (!houseConfig.addChest && foundBlock instanceof BlockChest) || (!houseConfig.addTorches && foundBlock instanceof BlockTorch) || (!houseConfig.addCraftingTable && (foundBlock instanceof BlockWorkbench || foundBlock instanceof BlockFurnace))) {
        // "handled"
        return true;
    }
    if (foundBlock instanceof BlockFurnace) {
        this.furnacePosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
    } else if (foundBlock instanceof BlockTrapDoor && houseConfig.addMineShaft) {
        // The trap door will still be added, but the mine shaft may not be
        // built.
        this.trapDoorPosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
    } else if (foundBlock instanceof BlockChest && this.chestPosition == null) {
        this.chestPosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
    } else if (foundBlock instanceof BlockStandingSign) {
        this.signPosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
    }
    if (foundBlock.getRegistryName().getResourceDomain().equals(Blocks.STAINED_GLASS.getRegistryName().getResourceDomain()) && foundBlock.getRegistryName().getResourcePath().equals(Blocks.STAINED_GLASS.getRegistryName().getResourcePath())) {
        blockState = blockState.withProperty(BlockStainedGlass.COLOR, houseConfig.glassColor);
        block.setBlockState(blockState);
        this.priorityOneBlocks.add(block);
        return true;
    } else if (foundBlock.getRegistryName().getResourceDomain().equals(Blocks.STAINED_GLASS_PANE.getRegistryName().getResourceDomain()) && foundBlock.getRegistryName().getResourcePath().equals(Blocks.STAINED_GLASS_PANE.getRegistryName().getResourcePath())) {
        block.setBlockState(foundBlock.getStateFromMeta(houseConfig.glassColor.getMetadata()));
        this.priorityOneBlocks.add(block);
        return true;
    }
    return false;
}
Also used : BlockFurnace(net.minecraft.block.BlockFurnace) BlockChest(net.minecraft.block.BlockChest) BlockWorkbench(net.minecraft.block.BlockWorkbench) BlockTrapDoor(net.minecraft.block.BlockTrapDoor) BlockStandingSign(net.minecraft.block.BlockStandingSign) BlockBed(net.minecraft.block.BlockBed) HouseConfiguration(com.wuest.prefab.Config.Structures.HouseConfiguration) BlockTorch(net.minecraft.block.BlockTorch)

Aggregations

BlockFurnace (net.minecraft.block.BlockFurnace)3 IBlockState (net.minecraft.block.state.IBlockState)2 BuildingBaker (com.minecolonies.coremod.colony.buildings.BuildingBaker)1 BakingProduct (com.minecolonies.coremod.entity.ai.citizen.baker.BakingProduct)1 HouseConfiguration (com.wuest.prefab.Config.Structures.HouseConfiguration)1 BlockBed (net.minecraft.block.BlockBed)1 BlockChest (net.minecraft.block.BlockChest)1 BlockStandingSign (net.minecraft.block.BlockStandingSign)1 BlockTorch (net.minecraft.block.BlockTorch)1 BlockTrapDoor (net.minecraft.block.BlockTrapDoor)1 BlockWorkbench (net.minecraft.block.BlockWorkbench)1 TileEntityFurnace (net.minecraft.tileentity.TileEntityFurnace)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1