Permalink
Browse files

TheOneProbe integration (#2696)

Displayed information is equal to current the WAILA integration.

Added a preInit stage to IIntegrationModule.
Added a factory method to IntegrationType to avoid touching
IntegrationNode for every new integration.

Fixes #2650
  • Loading branch information...
1 parent db85419 commit 8bed7f223e908ee24439863850e5ddee992a09e6 @yueh yueh committed on GitHub Dec 14, 2016
Showing with 1,141 additions and 17 deletions.
  1. +1 −0 gradle.properties
  2. +7 −0 gradle/scripts/dependencies.gradle
  3. +13 −1 gradle/scripts/optional.gradle
  4. +4 −0 src/main/java/appeng/integration/IIntegrationModule.java
  5. +2 −12 src/main/java/appeng/integration/IntegrationNode.java
  6. +45 −4 src/main/java/appeng/integration/IntegrationType.java
  7. +86 −0 src/main/java/appeng/integration/modules/theoneprobe/PartInfoProvider.java
  8. +51 −0 src/main/java/appeng/integration/modules/theoneprobe/TheOneProbeModule.java
  9. +66 −0 src/main/java/appeng/integration/modules/theoneprobe/TheOneProbeText.java
  10. +80 −0 src/main/java/appeng/integration/modules/theoneprobe/TileInfoProvider.java
  11. +53 −0 src/main/java/appeng/integration/modules/theoneprobe/config/AEConfigProvider.java
  12. +66 −0 src/main/java/appeng/integration/modules/theoneprobe/part/ChannelInfoProvider.java
  13. +45 −0 src/main/java/appeng/integration/modules/theoneprobe/part/IPartProbInfoProvider.java
  14. +115 −0 src/main/java/appeng/integration/modules/theoneprobe/part/P2PStateInfoProvider.java
  15. +55 −0 src/main/java/appeng/integration/modules/theoneprobe/part/PartAccessor.java
  16. +71 −0 src/main/java/appeng/integration/modules/theoneprobe/part/PowerStateInfoProvider.java
  17. +66 −0 src/main/java/appeng/integration/modules/theoneprobe/part/StorageMonitorInfoProvider.java
  18. +61 −0 src/main/java/appeng/integration/modules/theoneprobe/tile/ChargerInfoProvider.java
  19. +64 −0 src/main/java/appeng/integration/modules/theoneprobe/tile/CraftingMonitorInfoProvider.java
  20. +44 −0 src/main/java/appeng/integration/modules/theoneprobe/tile/ITileProbInfoProvider.java
  21. +64 −0 src/main/java/appeng/integration/modules/theoneprobe/tile/PowerStateInfoProvider.java
  22. +66 −0 src/main/java/appeng/integration/modules/theoneprobe/tile/PowerStorageInfoProvider.java
  23. +16 −0 src/main/resources/assets/appliedenergistics2/lang/en_US.lang
View
@@ -22,3 +22,4 @@ waila_version=1.7.0-B3_1.9.4
jei_version=3.13.6.391
tesla_version=1.10.2-1.2.1.50
ic2_version=2.6.99-ex110
+top_version=1.10-1.3.3-41
@@ -38,6 +38,11 @@ repositories {
name = "IC2 repo"
url = "http://maven.ic2.player.to"
}
+
+ maven { // TheOneProbe
+ name 'tterrag maven'
+ url "http://maven.tterrag.com/"
+ }
}
configurations {
@@ -48,12 +53,14 @@ dependencies {
// installable runtime dependencies
mods "mcp.mobius.waila:Waila:${waila_version}"
mods "net.industrial-craft:industrialcraft-2:${ic2_version}:dev"
+ mods "mcjty.theoneprobe:TheOneProbe:${top_version}"
// compile against provided APIs
compileOnly "mezz.jei:jei_${minecraft_version}:${jei_version}:api"
compileOnly "mcp.mobius.waila:Waila:${waila_version}"
compileOnly "net.darkhax.tesla:Tesla:${tesla_version}"
compileOnly "net.industrial-craft:industrialcraft-2:${ic2_version}:api"
+ compileOnly "mcjty.theoneprobe:TheOneProbe:${top_version}:api"
// at runtime, use the full JEI jar
runtime "mezz.jei:jei_${minecraft_version}:${jei_version}"
@@ -31,7 +31,7 @@ task deinstallWaila(type: Delete) {
delete fileTree(dir: minecraft.runDir + "/mods", include: "*Waila*.jar")
}
-// IC²
+// IC2
task installIC2(type: Copy, dependsOn: "deinstallIC2") {
from { configurations.mods }
include "**/*industrialcraft-2*.jar"
@@ -41,3 +41,15 @@ task installIC2(type: Copy, dependsOn: "deinstallIC2") {
task deinstallIC2(type: Delete) {
delete fileTree(dir: minecraft.runDir + "/mods", include: "*industrialcraft-2*.jar")
}
+
+// TOP
+task installTop(type: Copy, dependsOn: "deinstallTop") {
+ from { configurations.mods }
+ include "**/*TheOneProbe*.jar"
+ into file(minecraft.runDir + "/mods")
+}
+
+task deinstallTop(type: Delete) {
+ delete fileTree(dir: minecraft.runDir + "/mods", include: "*TheOneProbe*.jar")
+}
+
@@ -27,6 +27,10 @@ default boolean isEnabled()
return true;
}
+ default void preInit() throws Throwable
+ {
+ }
+
default void init() throws Throwable
{
}
@@ -94,24 +94,14 @@ void call( final IntegrationStage stage )
if( enabled )
{
- switch( type )
- {
- case IC2:
- this.mod = Integrations.setIc2( new IC2Module() );
- break;
- case JEI:
- this.mod = Integrations.setJei( new JEIModule() );
- break;
- case Waila:
- this.mod = new WailaModule();
- break;
- }
+ this.mod = type.createInstance();
}
else
{
throw new ModNotInstalled( this.modID );
}
+ this.mod.preInit();
this.setState( IntegrationStage.INIT );
break;
@@ -19,9 +19,22 @@
package appeng.integration;
+import appeng.integration.modules.ic2.IC2Module;
+import appeng.integration.modules.jei.JEIModule;
+import appeng.integration.modules.theoneprobe.TheOneProbeModule;
+import appeng.integration.modules.waila.WailaModule;
+
+
public enum IntegrationType
{
- IC2( IntegrationSide.BOTH, "Industrial Craft 2", "IC2" ),
+ IC2( IntegrationSide.BOTH, "Industrial Craft 2", "IC2" )
+ {
+ @Override
+ public IIntegrationModule createInstance()
+ {
+ return Integrations.setIc2( new IC2Module() );
+ }
+ },
RC( IntegrationSide.BOTH, "Railcraft", "Railcraft" ),
@@ -31,15 +44,38 @@
MFR( IntegrationSide.BOTH, "Mine Factory Reloaded", "MineFactoryReloaded" ),
- Waila( IntegrationSide.BOTH, "Waila", "Waila" ),
+ Waila( IntegrationSide.BOTH, "Waila", "Waila" )
+ {
+ @Override
+ public IIntegrationModule createInstance()
+ {
+ return new WailaModule();
+ }
+ },
InvTweaks( IntegrationSide.CLIENT, "Inventory Tweaks", "inventorytweaks" ),
- JEI( IntegrationSide.CLIENT, "Just Enough Items", "JEI" ),
+ JEI( IntegrationSide.CLIENT, "Just Enough Items", "JEI" )
+ {
+ @Override
+ public IIntegrationModule createInstance()
+ {
+ return Integrations.setJei( new JEIModule() );
+ }
+ },
Mekanism( IntegrationSide.BOTH, "Mekanism", "Mekanism" ),
- OpenComputers( IntegrationSide.BOTH, "OpenComputers", "OpenComputers" );
+ OpenComputers( IntegrationSide.BOTH, "OpenComputers", "OpenComputers" ),
+
+ THE_ONE_PROBE( IntegrationSide.BOTH, "TheOneProbe", "theoneprobe" )
+ {
+ @Override
+ public IIntegrationModule createInstance()
+ {
+ return new TheOneProbeModule();
+ }
+ };
public final IntegrationSide side;
public final String dspName;
@@ -52,4 +88,9 @@
this.modID = modid;
}
+ public IIntegrationModule createInstance()
+ {
+ throw new UnsupportedOperationException();
+ }
+
}
@@ -0,0 +1,86 @@
+/*
+ * This file is part of Applied Energistics 2.
+ * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
+ *
+ * Applied Energistics 2 is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Applied Energistics 2 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
+ */
+
+package appeng.integration.modules.theoneprobe;
+
+
+import java.util.List;
+import java.util.Optional;
+
+import com.google.common.collect.Lists;
+
+import net.minecraft.block.state.IBlockState;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+
+import mcjty.theoneprobe.api.IProbeHitData;
+import mcjty.theoneprobe.api.IProbeInfo;
+import mcjty.theoneprobe.api.IProbeInfoProvider;
+import mcjty.theoneprobe.api.ProbeMode;
+
+import appeng.api.parts.IPart;
+import appeng.core.AppEng;
+import appeng.integration.modules.theoneprobe.part.ChannelInfoProvider;
+import appeng.integration.modules.theoneprobe.part.IPartProbInfoProvider;
+import appeng.integration.modules.theoneprobe.part.P2PStateInfoProvider;
+import appeng.integration.modules.theoneprobe.part.PartAccessor;
+import appeng.integration.modules.theoneprobe.part.PowerStateInfoProvider;
+import appeng.integration.modules.theoneprobe.part.StorageMonitorInfoProvider;
+
+
+public final class PartInfoProvider implements IProbeInfoProvider
+{
+ private final List<IPartProbInfoProvider> providers;
+
+ private final PartAccessor accessor = new PartAccessor();
+
+ public PartInfoProvider()
+ {
+ final IPartProbInfoProvider channel = new ChannelInfoProvider();
+ final IPartProbInfoProvider power = new PowerStateInfoProvider();
+ final IPartProbInfoProvider storageMonitor = new StorageMonitorInfoProvider();
+ final IPartProbInfoProvider p2p = new P2PStateInfoProvider();
+
+ this.providers = Lists.newArrayList( channel, power, p2p, storageMonitor );
+ }
+
+ @Override
+ public String getID()
+ {
+ return AppEng.MOD_ID + ":PartInfoProvider";
+ }
+
+ @Override
+ public void addProbeInfo( ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
+ {
+ final TileEntity te = world.getTileEntity( data.getPos() );
+ final Optional<IPart> maybePart = this.accessor.getMaybePart( te, data );
+
+ if( maybePart.isPresent() )
+ {
+ final IPart part = maybePart.get();
+
+ for( final IPartProbInfoProvider provider : this.providers )
+ {
+ provider.addProbeInfo( part, mode, probeInfo, player, world, blockState, data );
+ }
+ }
+
+ }
+}
@@ -0,0 +1,51 @@
+/*
+ * This file is part of Applied Energistics 2.
+ * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
+ *
+ * Applied Energistics 2 is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Applied Energistics 2 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
+ */
+
+package appeng.integration.modules.theoneprobe;
+
+
+import com.google.common.base.Function;
+
+import net.minecraftforge.fml.common.event.FMLInterModComms;
+
+import mcjty.theoneprobe.api.ITheOneProbe;
+
+import appeng.integration.IIntegrationModule;
+import appeng.integration.modules.theoneprobe.config.AEConfigProvider;
+
+
+public class TheOneProbeModule implements IIntegrationModule, Function<ITheOneProbe, Void>
+{
+ @Override
+ public void preInit() throws Throwable
+ {
+ FMLInterModComms.sendFunctionMessage( "theoneprobe", "getTheOneProbe", this.getClass().getName() );
+ }
+
+ @Override
+ public Void apply( ITheOneProbe input )
+ {
+ input.registerProbeConfigProvider( new AEConfigProvider() );
+
+ input.registerProvider( new TileInfoProvider() );
+
+ input.registerProvider( new PartInfoProvider() );
+
+ return null;
+ }
+}
@@ -0,0 +1,66 @@
+/*
+ * This file is part of Applied Energistics 2.
+ * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
+ *
+ * Applied Energistics 2 is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Applied Energistics 2 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
+ */
+
+package appeng.integration.modules.theoneprobe;
+
+
+import java.util.Locale;
+
+import net.minecraft.util.text.translation.I18n;
+
+
+public enum TheOneProbeText
+{
+ CRAFTING,
+
+ DEVICE_ONLINE,
+ DEVICE_OFFLINE,
+ DEVICE_MISSING_CHANNEL,
+
+ P2P_UNLINKED,
+ P2P_INPUT_ONE_OUTPUT,
+ P2P_INPUT_MANY_OUTPUTS,
+ P2P_OUTPUT,
+
+ LOCKED,
+ UNLOCKED,
+ SHOWING,
+
+ CONTAINS,
+ CHANNELS,
+
+ STORED_ENERGY;
+
+ private final String root;
+
+ TheOneProbeText()
+ {
+ this.root = "theoneprobe.appliedenergistics2";
+ }
+
+ public String getLocal()
+ {
+ return I18n.translateToLocal( this.getUnlocalized() );
+ }
+
+ public String getUnlocalized()
+ {
+ return this.root + '.' + this.name().toLowerCase( Locale.ENGLISH );
+ }
+
+}
Oops, something went wrong.

0 comments on commit 8bed7f2

Please sign in to comment.