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));
}
}
}
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));
}
}
}
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"));
}
}
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);
}
}
}
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));
}
Aggregations