Search in sources :

Example 1 with IGreenhouseBlock

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

the class ProxyGreenhouseClient method getFoliageColor.

@SubscribeEvent
public void getFoliageColor(BiomeEvent.GetFoliageColor event) {
    if (COLOR_BLOCK_POSITION != null) {
        IGreenhouseBlock logicBlock = GreenhouseBlockManager.getInstance().getBlock(Minecraft.getMinecraft().world, COLOR_BLOCK_POSITION);
        if (logicBlock != null && logicBlock.getProvider().isClosed()) {
            IClimateContainer container = logicBlock.getProvider().getClimateContainer();
            IClimateState climateState = container.getState();
            double temperature = MathHelper.clamp(climateState.getTemperature(), 0.0F, 1.0F);
            double humidity = MathHelper.clamp(climateState.getHumidity(), 0.0F, 1.0F);
            event.setNewColor(ColorizerGrass.getGrassColor(temperature, humidity));
        }
    }
}
Also used : IClimateContainer(forestry.greenhouse.api.climate.IClimateContainer) IClimateState(forestry.api.climate.IClimateState) IGreenhouseBlock(forestry.greenhouse.api.greenhouse.IGreenhouseBlock) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with IGreenhouseBlock

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

the class ProxyGreenhouseClient method getGrassColor.

@SubscribeEvent
public void getGrassColor(BiomeEvent.GetGrassColor event) {
    if (COLOR_BLOCK_POSITION != null) {
        IGreenhouseBlock logicBlock = GreenhouseBlockManager.getInstance().getBlock(Minecraft.getMinecraft().world, COLOR_BLOCK_POSITION);
        if (logicBlock != null && logicBlock.getProvider().isClosed()) {
            IClimateContainer container = logicBlock.getProvider().getClimateContainer();
            IClimateState climateState = container.getState();
            double temperature = MathHelper.clamp(climateState.getTemperature(), 0.0F, 1.0F);
            double humidity = MathHelper.clamp(climateState.getHumidity(), 0.0F, 1.0F);
            event.setNewColor(ColorizerGrass.getGrassColor(temperature, humidity));
        }
    }
}
Also used : IClimateContainer(forestry.greenhouse.api.climate.IClimateContainer) IClimateState(forestry.api.climate.IClimateState) IGreenhouseBlock(forestry.greenhouse.api.greenhouse.IGreenhouseBlock) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with IGreenhouseBlock

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

the class GreenhouseController method isGoodForExteriorLevel.

/* RectangularMultiblockControllerBase */
@Override
public void isGoodForExteriorLevel(IMultiblockComponent part, int level) throws MultiblockValidationException {
    int maxLevel = getMaximumCoord().getY() - getMinimumCoord().getY();
    if (level == maxLevel && !(part instanceof TileGreenhousePlain)) {
        throw new MultiblockValidationException(Translator.translateToLocal("for.multiblock.greenhouse.error.needPlainOnTop"));
    }
    IGreenhouseBlock logicBlock = GreenhouseBlockManager.getInstance().getBlock(world, part.getCoordinates());
    if (logicBlock != null && logicBlock.getProvider() != getProvider()) {
        throw new MultiblockValidationException(Translator.translateToLocal("for.multiblock.greenhouse.error.needSpace"));
    }
}
Also used : TileGreenhousePlain(forestry.greenhouse.tiles.TileGreenhousePlain) MultiblockValidationException(forestry.core.multiblock.MultiblockValidationException) IGreenhouseBlock(forestry.greenhouse.api.greenhouse.IGreenhouseBlock)

Example 4 with IGreenhouseBlock

use of forestry.greenhouse.api.greenhouse.IGreenhouseBlock 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);
        }
    }
}
Also used : IGreenhouseProvider(forestry.greenhouse.api.greenhouse.IGreenhouseProvider) IGreenhouseChunk(forestry.greenhouse.api.greenhouse.IGreenhouseChunk) GreenhouseChunk(forestry.greenhouse.multiblock.blocks.storage.GreenhouseChunk) IGreenhouseBlock(forestry.greenhouse.api.greenhouse.IGreenhouseBlock) Nullable(javax.annotation.Nullable)

Example 5 with IGreenhouseBlock

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

the class GreenhouseBlockStorage method getBlock.

@Nullable
@Override
public IGreenhouseBlock getBlock(BlockPos pos) {
    long chunkPos = ChunkPos.asLong(pos.getX() >> 4, pos.getZ() >> 4);
    HashMap<Position2D, IGreenhouseBlock> chunkBlocks = getChunkBlocks(chunkPos);
    return chunkBlocks.get(new Position2D(pos));
}
Also used : Position2D(forestry.greenhouse.api.greenhouse.Position2D) IGreenhouseBlock(forestry.greenhouse.api.greenhouse.IGreenhouseBlock) Nullable(javax.annotation.Nullable)

Aggregations

IGreenhouseBlock (forestry.greenhouse.api.greenhouse.IGreenhouseBlock)10 Position2D (forestry.greenhouse.api.greenhouse.Position2D)4 BlockPos (net.minecraft.util.math.BlockPos)3 IClimateState (forestry.api.climate.IClimateState)2 IErrorState (forestry.api.core.IErrorState)2 IClimateContainer (forestry.greenhouse.api.climate.IClimateContainer)2 IBlankBlock (forestry.greenhouse.api.greenhouse.IBlankBlock)2 IGreenhouseBlockHandler (forestry.greenhouse.api.greenhouse.IGreenhouseBlockHandler)2 IGreenhouseChunk (forestry.greenhouse.api.greenhouse.IGreenhouseChunk)2 IGreenhouseProvider (forestry.greenhouse.api.greenhouse.IGreenhouseProvider)2 Nullable (javax.annotation.Nullable)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 IErrorLogic (forestry.api.core.IErrorLogic)1 IGreenhouseController (forestry.api.multiblock.IGreenhouseController)1 MultiblockValidationException (forestry.core.multiblock.MultiblockValidationException)1 GreenhouseLimitsBuilder (forestry.greenhouse.multiblock.GreenhouseLimitsBuilder)1 GreenhouseChunk (forestry.greenhouse.multiblock.blocks.storage.GreenhouseChunk)1 TileGreenhousePlain (forestry.greenhouse.tiles.TileGreenhousePlain)1 LinkedList (java.util.LinkedList)1 Stack (java.util.Stack)1