Search in sources :

Example 6 with IGreenhouseProvider

use of forestry.greenhouse.api.greenhouse.IGreenhouseProvider in project ForestryMC by ForestryMC.

the class ChunkThread method handleDirtyChunks.

private static void handleDirtyChunks(World world) {
    if (world == null || world.provider == null) {
        return;
    }
    GreenhouseBlockManager manager = GreenhouseBlockManager.getInstance();
    synchronized (manager) {
        List<Long> dirtyChunks = manager.getDirtyChunks(world);
        Iterator<Long> dirtyChunksIterator = dirtyChunks.iterator();
        while (dirtyChunksIterator.hasNext()) {
            Long chunkPos = dirtyChunksIterator.next();
            GreenhouseChunk chunk = manager.getChunk(world, chunkPos);
            if (chunk != null) {
                synchronized (chunk) {
                    Collection<IGreenhouseProvider> providers = chunk.getDirtyProviders();
                    Iterator<IGreenhouseProvider> dirtyProviders = providers.iterator();
                    while (dirtyProviders.hasNext()) {
                        IGreenhouseProvider provider = dirtyProviders.next();
                        provider.recreate();
                        dirtyProviders.remove();
                    }
                }
            }
            dirtyChunksIterator.remove();
        }
        manager.tickUpdates(world);
    }
}
Also used : IGreenhouseProvider(forestry.greenhouse.api.greenhouse.IGreenhouseProvider) GreenhouseChunk(forestry.greenhouse.multiblock.blocks.storage.GreenhouseChunk)

Example 7 with IGreenhouseProvider

use of forestry.greenhouse.api.greenhouse.IGreenhouseProvider in project ForestryMC by ForestryMC.

the class BlankBlockHandler method checkBlockFacing.

private IErrorState checkBlockFacing(IGreenhouseBlockStorage storage, IBlankBlock blockToCheck, BlockPos rootPos, EnumFacing facing, List<IGreenhouseBlock> newBlocksToCheck) {
    if (!blockToCheck.isFaceTested(facing)) {
        BlockPos facingPosition = rootPos.offset(facing);
        IGreenhouseProvider provider = storage.getProvider();
        IErrorState errorState = provider.checkPosition(facingPosition);
        if (errorState != null) {
            return errorState;
        }
        IGreenhouseBlock logicBlock = storage.getBlock(facingPosition);
        for (IGreenhouseBlockHandler handler : provider.getHandlers()) {
            if (handler.onCheckPosition(storage, blockToCheck, facingPosition, facing, logicBlock, newBlocksToCheck)) {
                break;
            }
        }
    }
    return null;
}
Also used : IErrorState(forestry.api.core.IErrorState) BlockPos(net.minecraft.util.math.BlockPos) IGreenhouseProvider(forestry.greenhouse.api.greenhouse.IGreenhouseProvider) IGreenhouseBlockHandler(forestry.greenhouse.api.greenhouse.IGreenhouseBlockHandler) IGreenhouseBlock(forestry.greenhouse.api.greenhouse.IGreenhouseBlock)

Aggregations

IGreenhouseProvider (forestry.greenhouse.api.greenhouse.IGreenhouseProvider)7 GreenhouseChunk (forestry.greenhouse.multiblock.blocks.storage.GreenhouseChunk)3 IGreenhouseBlock (forestry.greenhouse.api.greenhouse.IGreenhouseBlock)2 IGreenhouseControllerInternal (forestry.greenhouse.multiblock.IGreenhouseControllerInternal)2 ItemStack (net.minecraft.item.ItemStack)2 BlockPos (net.minecraft.util.math.BlockPos)2 IClimateState (forestry.api.climate.IClimateState)1 IErrorState (forestry.api.core.IErrorState)1 IGreenhouseComponent (forestry.api.multiblock.IGreenhouseComponent)1 IColoredBlock (forestry.core.blocks.IColoredBlock)1 IClimateContainer (forestry.greenhouse.api.climate.IClimateContainer)1 IGreenhouseBlockHandler (forestry.greenhouse.api.greenhouse.IGreenhouseBlockHandler)1 IGreenhouseChunk (forestry.greenhouse.api.greenhouse.IGreenhouseChunk)1 IGreenhouseLimits (forestry.greenhouse.api.greenhouse.IGreenhouseLimits)1 IGreenhouseProviderListener (forestry.greenhouse.api.greenhouse.IGreenhouseProviderListener)1 IWallBlock (forestry.greenhouse.api.greenhouse.IWallBlock)1 Position2D (forestry.greenhouse.api.greenhouse.Position2D)1 Nullable (javax.annotation.Nullable)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1