diff --git a/build.gradle b/build.gradle index 419968b98..221f970b7 100644 --- a/build.gradle +++ b/build.gradle @@ -124,6 +124,7 @@ dependencies { runtime "CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-${config.crafttweaker_version}" compileOnly "com.blamejared:MTLib:${config.mtlib_version}" compileOnly "dan200.computercraft:ComputerCraft:${config.computercraft_version}:api" + compileOnly "mcjty.theoneprobe:TheOneProbe-1.12:${config.top_version}:api" } processResources diff --git a/build.properties b/build.properties index 0c936b0e9..a6bf90550 100644 --- a/build.properties +++ b/build.properties @@ -15,3 +15,4 @@ ic2_version=2.8.9-ex112 crafttweaker_version=4.0.3.247 mtlib_version=3.0.0.1 computercraft_version=1.80pr1 +top_version=1.12-1.4.19-11 \ No newline at end of file diff --git a/src/main/java/mekanism/common/Mekanism.java b/src/main/java/mekanism/common/Mekanism.java index 2349497fb..77fb69da6 100644 --- a/src/main/java/mekanism/common/Mekanism.java +++ b/src/main/java/mekanism/common/Mekanism.java @@ -799,6 +799,9 @@ public class Mekanism //Integrate with Waila FMLInterModComms.sendMessage(MekanismHooks.WAILA_MOD_ID, "register", "mekanism.common.integration.WailaDataProvider.register"); + //Register TOP handler + FMLInterModComms.sendFunctionMessage("theoneprobe", "getTheOneProbe", "mekanism.common.integration.TOPProvider"); + //Integrate with OpenComputers if(Loader.isModLoaded(MekanismHooks.OPENCOMPUTERS_MOD_ID)) { diff --git a/src/main/java/mekanism/common/integration/TOPProvider.java b/src/main/java/mekanism/common/integration/TOPProvider.java new file mode 100644 index 000000000..774a79b0a --- /dev/null +++ b/src/main/java/mekanism/common/integration/TOPProvider.java @@ -0,0 +1,61 @@ +package mekanism.common.integration; + +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.IProbeInfoProvider; +import mcjty.theoneprobe.api.IProgressStyle; +import mcjty.theoneprobe.api.ITheOneProbe; +import mcjty.theoneprobe.api.ProbeMode; +import mcjty.theoneprobe.api.TextStyleClass; +import mekanism.api.gas.GasTankInfo; +import mekanism.api.gas.IGasHandler; +import mekanism.common.capabilities.Capabilities; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import java.util.function.Function; + +@SuppressWarnings("unused")//IMC bound +public class TOPProvider implements Function, IProbeInfoProvider +{ + @Override + public Void apply(ITheOneProbe iTheOneProbe) + { + iTheOneProbe.registerProvider(this); + return null; + } + + @Override + public String getID() + { + return "mekanism"; + } + + @Override + public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) + { + if (mode != ProbeMode.EXTENDED){ + return; + } + + final TileEntity tile = world.getTileEntity( data.getPos() ); + + if (tile != null){ + if (tile.hasCapability(Capabilities.GAS_HANDLER_CAPABILITY, null)){ + IGasHandler handler = tile.getCapability(Capabilities.GAS_HANDLER_CAPABILITY, null); + if (handler != null){ + GasTankInfo[] tanks = handler.getTankInfo(); + for (GasTankInfo tank : tanks){ + if (tank.getGas() != null){ + probeInfo.text(TextStyleClass.NAME + "Gas: " + tank.getGas().getGas().getLocalizedName()); + } + IProgressStyle style = probeInfo.defaultProgressStyle().suffix("mB"); + probeInfo.progress(tank.getStored(), tank.getMaxGas(), style); + } + } + } + } + } +}