Search in sources :

Example 1 with ProgressStyle

use of mcjty.theoneprobe.apiimpl.styles.ProgressStyle in project TechReborn by TechReborn.

the class ProbeProvider method addProbeInfo.

@Override
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
    euStyle = new ProgressStyle().backgroundColor(0xFF8B8B8B).borderColor(0xFF373737).alternateFilledColor(PowerSystem.getDisplayPower().altColour).filledColor(PowerSystem.getDisplayPower().colour);
    euStyle.suffix(" " + PowerSystem.getDisplayPower().abbreviation);
    TileEntity tile = world.getTileEntity(data.getPos());
    if (tile instanceof IListInfoProvider) {
        List<String> strs = new ArrayList<>();
        ((IListInfoProvider) tile).addInfo(strs, true);
        for (String string : strs) {
            probeInfo.text(string);
        }
    }
    if (tile instanceof IEnergyInterfaceTile) {
        IEnergyInterfaceTile energy = (IEnergyInterfaceTile) tile;
        if (PowerSystem.getDisplayPower() != PowerSystem.EnergySystem.EU) {
            probeInfo.progress((int) energy.getEnergy() * RebornCoreConfig.euPerFU, (int) energy.getMaxPower() * RebornCoreConfig.euPerFU, euStyle);
        } else {
            probeInfo.progress((int) energy.getEnergy(), (int) energy.getMaxPower(), euStyle);
        }
    }
    if (tile instanceof TileLegacyMachineBase && methodHandle_addStacks != null) {
        TileLegacyMachineBase legacyMachineBase = (TileLegacyMachineBase) tile;
        if (legacyMachineBase.getInventoryForTile().isPresent()) {
            if (player.isSneaking()) {
                probeInfo.text(I18n.translateToLocal("techreborn.tooltip.inventory"));
            }
            Inventory inventory = legacyMachineBase.getInventoryForTile().get();
            if (!inventory.isEmpty()) {
                List<ItemStack> stacks = Arrays.stream(inventory.contents).filter(stack -> !stack.isEmpty()).collect(Collectors.toList());
                try {
                    methodHandle_addStacks.invoke(probeInfo, world, null, stacks, player.isSneaking());
                } catch (Throwable throwable) {
                    throwable.printStackTrace();
                }
            }
        }
        if (!legacyMachineBase.upgradeInventory.isEmpty() && player.isSneaking()) {
            probeInfo.horizontal();
            probeInfo.text(I18n.translateToLocal("techreborn.tooltip.upgrades"));
            List<ItemStack> stacks = Arrays.stream(legacyMachineBase.upgradeInventory.contents).filter(stack -> !stack.isEmpty()).collect(Collectors.toList());
            try {
                methodHandle_addStacks.invoke(probeInfo, world, null, stacks, player.isSneaking());
            } catch (Throwable throwable) {
                throwable.printStackTrace();
            }
        }
    }
}
Also used : MethodHandle(java.lang.invoke.MethodHandle) Arrays(java.util.Arrays) RebornCoreConfig(reborncore.common.RebornCoreConfig) World(net.minecraft.world.World) IEnergyInterfaceTile(reborncore.api.power.IEnergyInterfaceTile) MethodHandles(java.lang.invoke.MethodHandles) ChestInfoTools(mcjty.theoneprobe.apiimpl.providers.ChestInfoTools) IListInfoProvider(reborncore.api.IListInfoProvider) Inventory(reborncore.common.util.Inventory) BlockPos(net.minecraft.util.math.BlockPos) ProgressStyle(mcjty.theoneprobe.apiimpl.styles.ProgressStyle) TileLegacyMachineBase(reborncore.common.tile.TileLegacyMachineBase) Collectors(java.util.stream.Collectors) I18n(net.minecraft.util.text.translation.I18n) ArrayList(java.util.ArrayList) IBlockState(net.minecraft.block.state.IBlockState) ItemStack(net.minecraft.item.ItemStack) List(java.util.List) mcjty.theoneprobe.api(mcjty.theoneprobe.api) EntityPlayer(net.minecraft.entity.player.EntityPlayer) PowerSystem(reborncore.common.powerSystem.PowerSystem) TileEntity(net.minecraft.tileentity.TileEntity) Method(java.lang.reflect.Method) ProgressStyle(mcjty.theoneprobe.apiimpl.styles.ProgressStyle) ArrayList(java.util.ArrayList) IEnergyInterfaceTile(reborncore.api.power.IEnergyInterfaceTile) TileEntity(net.minecraft.tileentity.TileEntity) IListInfoProvider(reborncore.api.IListInfoProvider) TileLegacyMachineBase(reborncore.common.tile.TileLegacyMachineBase) ItemStack(net.minecraft.item.ItemStack) Inventory(reborncore.common.util.Inventory)

Example 2 with ProgressStyle

use of mcjty.theoneprobe.apiimpl.styles.ProgressStyle in project HorsePower by GoryMoon.

the class BlockChopper method addProbeInfo.

// The One Probe Integration
@Optional.Method(modid = "theoneprobe")
@Override
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
    TileEntityChopper tileEntity = getTileEntity(world, data.getPos());
    if (tileEntity != null) {
        double totalWindup = Configs.general.pointsForWindup > 0 ? Configs.general.pointsForWindup : 1;
        probeInfo.progress((long) ((((double) tileEntity.getField(2)) / totalWindup) * 100L), 100L, new ProgressStyle().prefix(Localization.TOP.WINDUP_PROGRESS.translate() + " ").suffix("%"));
        if (tileEntity.getField(0) > 1)
            probeInfo.progress((long) ((((double) tileEntity.getField(1)) / ((double) tileEntity.getField(0))) * 100L), 100L, new ProgressStyle().prefix(Localization.TOP.CHOPPING_PROGRESS.translate() + " ").suffix("%"));
    }
}
Also used : ProgressStyle(mcjty.theoneprobe.apiimpl.styles.ProgressStyle) TileEntityChopper(se.gory_moon.horsepower.tileentity.TileEntityChopper)

Aggregations

ProgressStyle (mcjty.theoneprobe.apiimpl.styles.ProgressStyle)2 MethodHandle (java.lang.invoke.MethodHandle)1 MethodHandles (java.lang.invoke.MethodHandles)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 mcjty.theoneprobe.api (mcjty.theoneprobe.api)1 ChestInfoTools (mcjty.theoneprobe.apiimpl.providers.ChestInfoTools)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1 I18n (net.minecraft.util.text.translation.I18n)1 World (net.minecraft.world.World)1 IListInfoProvider (reborncore.api.IListInfoProvider)1 IEnergyInterfaceTile (reborncore.api.power.IEnergyInterfaceTile)1 RebornCoreConfig (reborncore.common.RebornCoreConfig)1