forked from AppliedEnergistics/Applied-Energistics-2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TheOneProbe integration (AppliedEnergistics#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 AppliedEnergistics#2650
- Loading branch information
Showing
23 changed files
with
1,141 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/main/java/appeng/integration/modules/theoneprobe/PartInfoProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ); | ||
} | ||
} | ||
|
||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/appeng/integration/modules/theoneprobe/TheOneProbeModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
src/main/java/appeng/integration/modules/theoneprobe/TheOneProbeText.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.