use of forestry.greenhouse.api.greenhouse.IGreenhouseChunk in project ForestryMC by ForestryMC.
the class GreenhouseBlockStorage method createChunksFromCache.
@SideOnly(Side.CLIENT)
public void createChunksFromCache() {
removeProviderFromChunks();
for (long chunkPos : cache.getPositions().keySet()) {
IGreenhouseChunk chunk = getChunk(chunkPos);
chunk.add(provider);
}
}
use of forestry.greenhouse.api.greenhouse.IGreenhouseChunk in project ForestryMC by ForestryMC.
the class GreenhouseBlockStorage method addProviderToChunks.
public void addProviderToChunks() {
for (long chunkPos : blocks.keySet()) {
IGreenhouseChunk chunk = getChunk(chunkPos);
chunk.add(provider);
}
}
use of forestry.greenhouse.api.greenhouse.IGreenhouseChunk in project ForestryMC by ForestryMC.
the class GreenhouseBlockStorage method removeProviderFromChunks.
public void removeProviderFromChunks() {
for (long chunkPos : blocks.keySet()) {
IGreenhouseChunk chunk = getChunk(chunkPos);
chunk.remove(provider);
}
}
use of forestry.greenhouse.api.greenhouse.IGreenhouseChunk in project ForestryMC by ForestryMC.
the class GreenhouseBlockStorage method setBlock.
public boolean setBlock(BlockPos pos, @Nullable IGreenhouseBlock newBlock) {
IGreenhouseChunk chunk = getChunk(pos);
if (chunk != null) {
IGreenhouseBlock oldBlock;
Long chunkPos = ChunkPos.asLong(pos.getX() >> 4, pos.getZ() >> 4);
HashMap<Position2D, IGreenhouseBlock> chunkBlocks = getChunkBlocks(chunkPos);
if (newBlock == null) {
oldBlock = chunkBlocks.remove(new Position2D(pos));
} else {
oldBlock = chunkBlocks.put(new Position2D(pos), newBlock);
}
// Only count block on the server side
if (!world.isRemote) {
if (newBlock == null) {
if (oldBlock instanceof IBlankBlock) {
blockCount--;
}
} else if (newBlock != null) {
cache.add(chunkPos, pos);
if (newBlock instanceof IBlankBlock) {
blockCount++;
}
}
}
return true;
}
return false;
}
Aggregations