Search in sources :

Example 1 with IGreenhouseChunk

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);
    }
}
Also used : IGreenhouseChunk(forestry.greenhouse.api.greenhouse.IGreenhouseChunk) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with IGreenhouseChunk

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);
    }
}
Also used : IGreenhouseChunk(forestry.greenhouse.api.greenhouse.IGreenhouseChunk)

Example 3 with IGreenhouseChunk

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);
    }
}
Also used : IGreenhouseChunk(forestry.greenhouse.api.greenhouse.IGreenhouseChunk)

Example 4 with IGreenhouseChunk

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;
}
Also used : IGreenhouseChunk(forestry.greenhouse.api.greenhouse.IGreenhouseChunk) Position2D(forestry.greenhouse.api.greenhouse.Position2D) IBlankBlock(forestry.greenhouse.api.greenhouse.IBlankBlock) IGreenhouseBlock(forestry.greenhouse.api.greenhouse.IGreenhouseBlock)

Aggregations

IGreenhouseChunk (forestry.greenhouse.api.greenhouse.IGreenhouseChunk)4 IBlankBlock (forestry.greenhouse.api.greenhouse.IBlankBlock)1 IGreenhouseBlock (forestry.greenhouse.api.greenhouse.IGreenhouseBlock)1 Position2D (forestry.greenhouse.api.greenhouse.Position2D)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1