use of forestry.greenhouse.multiblock.blocks.storage.GreenhouseChunk in project ForestryMC by ForestryMC.
the class ChunkManager method createChunk.
public GreenhouseChunk createChunk(long pos) {
GreenhouseChunk chunk = new GreenhouseChunk();
id2ChunkMap.put(pos, chunk);
return chunk;
}
use of forestry.greenhouse.multiblock.blocks.storage.GreenhouseChunk in project ForestryMC by ForestryMC.
the class ChunkManager method unload.
public void unload(int x, int z) {
long pos = ChunkPos.asLong(x, z);
GreenhouseChunk chunk = id2ChunkMap.remove(pos);
if (chunk != null) {
for (IGreenhouseProvider manager : chunk.getProviders()) {
manager.onUnloadChunk(pos);
}
}
}
use of forestry.greenhouse.multiblock.blocks.storage.GreenhouseChunk in project ForestryMC by ForestryMC.
the class GreenhouseBlockManager method markBlockDirty.
@Nullable
public synchronized void markBlockDirty(World world, BlockPos pos) {
long position = ChunkPos.asLong(pos.getX() >> 4, pos.getZ() >> 4);
GreenhouseChunk chunk = getChunk(world, position);
if (chunk != null) {
IGreenhouseBlock block = chunk.get(pos);
if (block != null) {
IGreenhouseProvider provider = block.getProvider();
provider.onBlockChange();
// markChunkDirty(world, position);
// chunk.markProviderDirty(pos);
}
}
}
use of forestry.greenhouse.multiblock.blocks.storage.GreenhouseChunk in project ForestryMC by ForestryMC.
the class GreenhouseBlockManager method markProviderDirty.
@Nullable
public synchronized void markProviderDirty(World world, BlockPos pos, IGreenhouseProvider provider) {
if (provider != null) {
long position = ChunkPos.asLong(pos.getX() >> 4, pos.getZ() >> 4);
GreenhouseChunk chunk = getChunk(world, position);
if (chunk != null) {
markChunkDirty(world, position);
chunk.markProviderDirty(provider);
}
}
}
use of forestry.greenhouse.multiblock.blocks.storage.GreenhouseChunk 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);
}
}
Aggregations