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;
}
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)));
}
}
}
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;
}
Aggregations