Search in sources :

Example 6 with IGreenhouseControllerInternal

use of forestry.greenhouse.multiblock.IGreenhouseControllerInternal in project ForestryMC by ForestryMC.

the class ItemGreenhouseScreen method addInformation.

@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag flag) {
    super.addInformation(stack, world, tooltip, flag);
    boolean previewModeActive = isPreviewModeActive(stack);
    String previewMode = Translator.translateToLocal(previewModeActive ? "for.greenhouse_screen.mode.active" : "for.greenhouse_screen.mode.inactive");
    tooltip.add(Translator.translateToLocal(Translator.translateToLocalFormatted("for.greenhouse_screen.mode", previewMode)));
    boolean isValid = isValid(stack, world);
    BlockPos pos = getGreenhousePos(stack);
    String state = isValid ? Translator.translateToLocalFormatted("for.greenhouse_screen.state.linked", pos.getX(), pos.getY(), pos.getZ()) : Translator.translateToLocal("for.greenhouse_screen.state.fail");
    tooltip.add(Translator.translateToLocalFormatted("for.greenhouse_screen.state", state));
    if (!isValid) {
        return;
    }
    IGreenhouseControllerInternal controller = MultiblockUtil.getController(world, pos, IGreenhouseComponent.class);
    IClimateState climateState = controller.getClimateContainer().getState();
    tooltip.add(Translator.translateToLocalFormatted("for.greenhouse_screen.temperature", TextFormatting.GOLD + StringUtil.floatAsPercent(climateState.getTemperature())));
    tooltip.add(Translator.translateToLocalFormatted("for.greenhouse_screen.humidity", TextFormatting.BLUE + StringUtil.floatAsPercent(climateState.getHumidity())));
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) IGreenhouseControllerInternal(forestry.greenhouse.multiblock.IGreenhouseControllerInternal) IClimateState(forestry.api.climate.IClimateState) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

IGreenhouseControllerInternal (forestry.greenhouse.multiblock.IGreenhouseControllerInternal)6 BlockPos (net.minecraft.util.math.BlockPos)3 IClimateState (forestry.api.climate.IClimateState)2 IClimateHousing (forestry.api.greenhouse.IClimateHousing)2 EnergyManager (forestry.energy.EnergyManager)2 IGreenhouseProvider (forestry.greenhouse.api.greenhouse.IGreenhouseProvider)2 ItemStack (net.minecraft.item.ItemStack)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 IErrorLogic (forestry.api.core.IErrorLogic)1 IGreenhouseComponent (forestry.api.multiblock.IGreenhouseComponent)1 IColoredBlock (forestry.core.blocks.IColoredBlock)1 IClimateContainer (forestry.greenhouse.api.climate.IClimateContainer)1 IGreenhouseLimits (forestry.greenhouse.api.greenhouse.IGreenhouseLimits)1 Position2D (forestry.greenhouse.api.greenhouse.Position2D)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 BlockColors (net.minecraft.client.renderer.color.BlockColors)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 World (net.minecraft.world.World)1