use of forestry.api.climate.IClimateState in project ForestryMC by ForestryMC.
the class ClimateWorldManager method getClimateState.
public IClimateState getClimateState(World world, BlockPos pos) {
IClimateState cacheState = stateCache.getIfPresent(pos);
if (cacheState == null) {
IGreenhouseClimateManager climateSourceManager = GreenhouseManager.climateManager;
if (climateSourceManager != null) {
IClimateContainer container = climateSourceManager.getContainer(world, pos);
if (container != null) {
cacheState = container.getState();
}
}
if (cacheState == null) {
cacheState = parent.getBiomeState(world, pos);
}
stateCache.put(pos, cacheState);
}
return cacheState;
}
use of forestry.api.climate.IClimateState 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.api.climate.IClimateState 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.api.climate.IClimateState in project ForestryMC by ForestryMC.
the class GreenhouseController method onMachineAssembled.
/* MultiblockControllerForestry */
@Override
protected void onMachineAssembled() {
super.onMachineAssembled();
BlockPos centerTop = getTopCenterCoord();
centerPos = centerTop.up(CENTER_HEIGHT);
createDefaultState();
limits = createLimits();
if (!climateContainer.getTargetedState().isPresent()) {
IClimateState defaultClimate = getDefaultClimate();
climateContainer.setState(defaultClimate.copy());
climateContainer.setTargetedState(defaultClimate);
}
provider.init(centerPos, limits);
assembleTickCount = getTickCount();
}
use of forestry.api.climate.IClimateState in project ForestryMC by ForestryMC.
the class BlockGreenhouse method colorMultiplier.
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("deprecation")
public int colorMultiplier(IBlockState blockState, @Nullable IBlockAccess world, @Nullable BlockPos pos, int tintIndex) {
if (pos == null || world == null) {
return 16777215;
}
ItemStack camouflageStack = getCamouflageBlock(world, pos);
if (tintIndex == ModelCamouflaged.OVERLAY_COLOR_INDEX + 1) {
BlockGreenhouseType type = getGreenhouseType(blockState);
if (type == BlockGreenhouseType.SCREEN) {
IGreenhouseControllerInternal controller = MultiblockUtil.getController(world, pos, IGreenhouseComponent.class);
if (controller == null || !controller.isAssembled()) {
return 16777215;
}
IClimateContainer container = controller.getClimateContainer();
IClimateState state = container.getState();
return ClimateUtil.getColor(EnumTemperature.getFromValue(state.getTemperature()));
} else if (type == BlockGreenhouseType.BORDER_CENTER) {
boolean isClosed = true;
IGreenhouseControllerInternal controller = MultiblockUtil.getController(world, pos, IGreenhouseComponent.class);
if (controller == null || !controller.isAssembled()) {
isClosed = false;
} else {
IGreenhouseProvider manager = controller.getProvider();
isClosed = manager.isClosed();
}
return isClosed ? 1356406 : 12197655;
}
} else if (tintIndex < ModelCamouflaged.OVERLAY_COLOR_INDEX && !camouflageStack.isEmpty()) {
Block block = Block.getBlockFromItem(camouflageStack.getItem());
if (block != Blocks.AIR) {
IBlockState camouflageState = block.getStateFromMeta(camouflageStack.getItemDamage());
BlockColors blockColors = Minecraft.getMinecraft().getBlockColors();
int color = blockColors.colorMultiplier(camouflageState, world, pos, tintIndex);
if (color != -1) {
return color;
}
}
}
return 16777215;
}
Aggregations