|
| 1 | +package com.github.gtexpert.gtbm.integration.top.provider; |
| 2 | + |
| 3 | +import net.minecraft.block.state.IBlockState; |
| 4 | +import net.minecraft.entity.player.EntityPlayer; |
| 5 | +import net.minecraft.item.ItemStack; |
| 6 | +import net.minecraft.tileentity.TileEntity; |
| 7 | +import net.minecraft.util.text.TextFormatting; |
| 8 | +import net.minecraft.world.World; |
| 9 | + |
| 10 | +import gregtech.api.GTValues; |
| 11 | +import gregtech.api.metatileentity.MetaTileEntity; |
| 12 | +import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; |
| 13 | +import gregtech.api.util.GTUtility; |
| 14 | +import gregtech.api.util.TextFormattingUtil; |
| 15 | + |
| 16 | +import com.github.gtexpert.gtbm.api.ModValues; |
| 17 | +import com.github.gtexpert.gtbm.integration.gendustry.metatileentities.multiblock.MetaTileEntityMegaApiary; |
| 18 | + |
| 19 | +import mcjty.theoneprobe.api.IProbeHitData; |
| 20 | +import mcjty.theoneprobe.api.IProbeInfo; |
| 21 | +import mcjty.theoneprobe.api.IProbeInfoProvider; |
| 22 | +import mcjty.theoneprobe.api.NumberFormat; |
| 23 | +import mcjty.theoneprobe.api.ProbeMode; |
| 24 | +import mcjty.theoneprobe.api.TextStyleClass; |
| 25 | + |
| 26 | +public class MegaApiaryProvider implements IProbeInfoProvider { |
| 27 | + |
| 28 | + @Override |
| 29 | + public String getID() { |
| 30 | + return ModValues.MODID + ":mega_apiary"; |
| 31 | + } |
| 32 | + |
| 33 | + @Override |
| 34 | + public void addProbeInfo(ProbeMode probeMode, IProbeInfo probeInfo, EntityPlayer entityPlayer, World world, |
| 35 | + IBlockState state, IProbeHitData data) { |
| 36 | + if (state.getBlock().hasTileEntity(state)) { |
| 37 | + TileEntity tileEntity = world.getTileEntity(data.getPos()); |
| 38 | + if (tileEntity instanceof IGregTechTileEntity) { |
| 39 | + MetaTileEntity metaTileEntity = ((IGregTechTileEntity) tileEntity).getMetaTileEntity(); |
| 40 | + if (metaTileEntity instanceof MetaTileEntityMegaApiary && |
| 41 | + ((MetaTileEntityMegaApiary) metaTileEntity).isStructureFormed()) { |
| 42 | + String text = null; |
| 43 | + if (metaTileEntity.isActive()) { |
| 44 | + // Progress Bar |
| 45 | + int currentProgress = ((MetaTileEntityMegaApiary) metaTileEntity).getProgressTicks(); |
| 46 | + int maxProgress = 100; |
| 47 | + if (metaTileEntity.isActive()) { |
| 48 | + currentProgress = Math.round(currentProgress / 20.0F); |
| 49 | + maxProgress = Math.round(maxProgress / 20.0F); |
| 50 | + text = " / " + TextFormattingUtil.formatNumbers(maxProgress) + " s"; |
| 51 | + } |
| 52 | + if (maxProgress > 0) { |
| 53 | + int color = ((MetaTileEntityMegaApiary) metaTileEntity).isWorkingEnabled() ? 0xFF4CBB17 : |
| 54 | + 0xFFBB1C28; |
| 55 | + probeInfo.progress(currentProgress, maxProgress, probeInfo.defaultProgressStyle() |
| 56 | + .suffix(text) |
| 57 | + .filledColor(color) |
| 58 | + .alternateFilledColor(color) |
| 59 | + .borderColor(0xFF555555).numberFormat(NumberFormat.COMMAS)); |
| 60 | + } |
| 61 | + } |
| 62 | + // Energy |
| 63 | + long EUt = ((MetaTileEntityMegaApiary) metaTileEntity).getCurrentConsumption(); |
| 64 | + text = TextFormatting.RED + TextFormattingUtil.formatNumbers(EUt) + TextStyleClass.INFO + |
| 65 | + " EU/t" + TextFormatting.GREEN + |
| 66 | + " (" + GTValues.VNF[GTUtility.getTierByVoltage(EUt)] + TextFormatting.GREEN + ")"; |
| 67 | + probeInfo.text(TextStyleClass.INFO + "{*gregtech.top.energy_consumption*} " + text); |
| 68 | + |
| 69 | + // Queen |
| 70 | + int queenAmount = ((MetaTileEntityMegaApiary) metaTileEntity).getQueenAmount(); |
| 71 | + if (queenAmount > 0) { |
| 72 | + probeInfo.text(TextStyleClass.INFO + "{*gtbm.top.mega_apiary.queen*} " + queenAmount); |
| 73 | + } |
| 74 | + // Product |
| 75 | + if (!entityPlayer.isSneaking()) { |
| 76 | + for (ItemStack stack : ((MetaTileEntityMegaApiary) metaTileEntity).getProductList()) { |
| 77 | + String displayName = stack.getDisplayName(); |
| 78 | + int count = stack.getCount(); |
| 79 | + probeInfo.text( |
| 80 | + TextStyleClass.INFO + displayName + ": " + TextFormatting.GOLD + "x" + count); |
| 81 | + } |
| 82 | + } |
| 83 | + } |
| 84 | + } |
| 85 | + } |
| 86 | + } |
| 87 | +} |
0 commit comments