Search in sources :

Example 1 with TextComponent

use of de.canitzp.tumat.api.components.TextComponent in project TUMAT by canitzp.

the class ActuallyAdditions method renderTileEntity.

@Override
public TooltipComponent renderTileEntity(WorldClient world, EntityPlayerSP player, TileEntity tileEntity, EnumFacing side, TooltipComponent component, boolean shouldCalculate) {
    if (tileEntity instanceof TileEntityCompost) {
        InfoUtil.syncTileEntity(tileEntity, shouldCalculate && InfoUtil.getItemStackInSlot(tileEntity, side, 0) != ItemStack.EMPTY, "ConversionTime");
        int time = ((TileEntityCompost) tileEntity).conversionTime;
        component.add(new TextComponent(TextFormatting.AQUA.toString() + time + "/3000 Ticks"), TooltipComponent.Priority.HIGH);
    } else if (tileEntity instanceof TileEntityDisplayStand) {
        ItemStack stack = InfoUtil.getItemStackInSlot(tileEntity, side, 0);
        if (stack != ItemStack.EMPTY) {
            component.add(new TextComponent(TextFormatting.AQUA.toString() + stack.getDisplayName()), TooltipComponent.Priority.HIGH);
        }
    } else if (tileEntity instanceof TileEntitySmileyCloud) {
        if (!Objects.equals(((TileEntitySmileyCloud) tileEntity).name, ""))
            component.add(new TextComponent(TextFormatting.AQUA.toString() + ((TileEntitySmileyCloud) tileEntity).name), TooltipComponent.Priority.HIGH);
    }
    return component;
}
Also used : TextComponent(de.canitzp.tumat.api.components.TextComponent) TileEntityCompost(de.ellpeck.actuallyadditions.mod.tile.TileEntityCompost) ItemStack(net.minecraft.item.ItemStack) TileEntitySmileyCloud(de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud) TileEntityDisplayStand(de.ellpeck.actuallyadditions.mod.tile.TileEntityDisplayStand)

Example 2 with TextComponent

use of de.canitzp.tumat.api.components.TextComponent in project TUMAT by canitzp.

the class ChiselsAndBits method renderBlock.

@Override
public TooltipComponent renderBlock(WorldClient world, EntityPlayerSP player, BlockPos pos, EnumFacing side, TooltipComponent component, boolean shouldCalculate) {
    IBlockState state = world.getBlockState(pos);
    if (state.getBlock() instanceof IMultiStateBlock) {
        component.setName(new TextComponent(InfoUtil.getBlockName(state)));
        component.add(new TextComponent(L10n.getChiselAndBitsBaseBlock(InfoUtil.getBlockName(((IMultiStateBlock) state.getBlock()).getPrimaryState(world, pos)))), TooltipComponent.Priority.HIGH);
    }
    return component;
}
Also used : IMultiStateBlock(mod.chiselsandbits.api.IMultiStateBlock) TextComponent(de.canitzp.tumat.api.components.TextComponent) IBlockState(net.minecraft.block.state.IBlockState)

Example 3 with TextComponent

use of de.canitzp.tumat.api.components.TextComponent in project TUMAT by canitzp.

the class FluidHandler method renderTileEntity.

@Override
public TooltipComponent renderTileEntity(WorldClient world, EntityPlayerSP player, TileEntity tileEntity, EnumFacing side, TooltipComponent component, boolean shouldCalculate) {
    if (tileEntity.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) {
        IFluidHandler handler = tileEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
        if (handler != null) {
            IFluidTankProperties[] props = handler.getTankProperties();
            if (props != null) {
                for (IFluidTankProperties tank : props) {
                    if (tank != null && tank.getContents() != null) {
                        FluidStack fluidStack = tank.getContents();
                        component.add(new TextComponent(fluidStack.amount + "mB / " + tank.getCapacity() + "mB " + fluidStack.getLocalizedName()), TooltipComponent.Priority.HIGH);
                    }
                }
            }
        }
    }
    return component;
}
Also used : TextComponent(de.canitzp.tumat.api.components.TextComponent) IFluidTankProperties(net.minecraftforge.fluids.capability.IFluidTankProperties) FluidStack(net.minecraftforge.fluids.FluidStack) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler)

Example 4 with TextComponent

use of de.canitzp.tumat.api.components.TextComponent in project TUMAT by canitzp.

the class ForgeUnits method renderTileEntity.

@Override
public TooltipComponent renderTileEntity(WorldClient world, EntityPlayerSP player, TileEntity tileEntity, EnumFacing side, TooltipComponent component, boolean shouldCalculate) {
    if (tileEntity.hasCapability(CapabilityEnergy.ENERGY, side)) {
        IEnergyStorage storage = tileEntity.getCapability(CapabilityEnergy.ENERGY, side);
        if (storage != null) {
            IBlockState state = world.getBlockState(tileEntity.getPos());
            String modid = state.getBlock().getRegistryName().getResourceDomain();
            String name = names.containsKey(modid) ? names.get(modid) : TextFormatting.RED + L10n.ENERGY;
            for (String s : cableString) {
                String toComp = state.getBlock().getUnlocalizedName();
                if (toComp.contains("block_laser_relay")) {
                    component.add(new TextComponent(L10n.ENERGY_MAXTRANSFER + storage.getMaxEnergyStored() + "CF").setColor(InitItems.itemBattery.getRGBDurabilityForDisplay(new ItemStack(InitItems.itemBattery))), TooltipComponent.Priority.HIGH);
                    return component;
                }
                if (toComp.contains(s)) {
                    component.add(new TextComponent(L10n.ENERGY_MAXTRANSFER + name).setFormat(TextFormatting.RED), TooltipComponent.Priority.HIGH);
                    return component;
                }
            }
            Pair<Integer, Integer> energy = SyncUtil.getForgeUnits(tileEntity.getPos(), side);
            if (energy.getRight() > 0) {
                this.render(component, modid, name, energy.getLeft(), energy.getRight());
            }
        }
    }
    return component;
}
Also used : TextComponent(de.canitzp.tumat.api.components.TextComponent) IBlockState(net.minecraft.block.state.IBlockState) IEnergyStorage(net.minecraftforge.energy.IEnergyStorage) ItemStack(net.minecraft.item.ItemStack)

Example 5 with TextComponent

use of de.canitzp.tumat.api.components.TextComponent in project TUMAT by canitzp.

the class IndustrialCraft2 method renderBlock.

@Override
public TooltipComponent renderBlock(WorldClient world, EntityPlayerSP player, BlockPos pos, EnumFacing side, TooltipComponent component, boolean shouldCalculate) {
    IBlockState state = world.getBlockState(pos);
    if (state.getBlock() instanceof BlockTileEntity) {
        if (InfoUtil.hasProperty(state, ((BlockTileEntity) state.getBlock()).typeProperty)) {
            IProperty<MetaTeBlock> property = ((BlockTileEntity) state.getBlock()).typeProperty;
            IBlockState actualState = state.getActualState(world, pos);
            MetaTeBlock teBlock = actualState.getValue(property);
            String name = property.getName(teBlock).replace("_active", "");
            String unlocalized = "ic2.te." + name;
            if (!name.contains("cable")) {
                component.setName(new TextComponent(Localization.translate(unlocalized)));
            }
        }
    }
    return component;
}
Also used : TextComponent(de.canitzp.tumat.api.components.TextComponent) IBlockState(net.minecraft.block.state.IBlockState) BlockTileEntity(ic2.core.block.BlockTileEntity) MetaTeBlock(ic2.core.ref.MetaTeBlock)

Aggregations

TextComponent (de.canitzp.tumat.api.components.TextComponent)13 IBlockState (net.minecraft.block.state.IBlockState)6 DescriptionComponent (de.canitzp.tumat.api.components.DescriptionComponent)5 ItemStack (net.minecraft.item.ItemStack)5 TooltipComponent (de.canitzp.tumat.api.TooltipComponent)4 IWorldRenderer (de.canitzp.tumat.api.IWorldRenderer)3 ArrayList (java.util.ArrayList)2 TileEntityDrawers (com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers)1 EnergyComponent (de.canitzp.tumat.api.components.EnergyComponent)1 TileEntityCompost (de.ellpeck.actuallyadditions.mod.tile.TileEntityCompost)1 TileEntityDisplayStand (de.ellpeck.actuallyadditions.mod.tile.TileEntityDisplayStand)1 TileEntitySmileyCloud (de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud)1 IEnergyStorage (ic2.api.tile.IEnergyStorage)1 BlockTileEntity (ic2.core.block.BlockTileEntity)1 TileEntityBlock (ic2.core.block.TileEntityBlock)1 Energy (ic2.core.block.comp.Energy)1 CableType (ic2.core.block.wiring.CableType)1 TileEntityCable (ic2.core.block.wiring.TileEntityCable)1 TileEntityTransformer (ic2.core.block.wiring.TileEntityTransformer)1 MetaTeBlock (ic2.core.ref.MetaTeBlock)1