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
This commit is contained in:
parent
db85419702
commit
8bed7f223e
|
@ -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 @@ public interface IIntegrationModule
|
|||
return true;
|
||||
}
|
||||
|
||||
default void preInit() throws Throwable
|
||||
{
|
||||
}
|
||||
|
||||
default void init() throws Throwable
|
||||
{
|
||||
}
|
||||
|
|
|
@ -94,24 +94,14 @@ final class IntegrationNode
|
|||
|
||||
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 @@ public enum IntegrationType
|
|||
|
||||
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 @@ public enum IntegrationType
|
|||
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 );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* 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 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.core.AppEng;
|
||||
import appeng.integration.modules.theoneprobe.tile.ChargerInfoProvider;
|
||||
import appeng.integration.modules.theoneprobe.tile.CraftingMonitorInfoProvider;
|
||||
import appeng.integration.modules.theoneprobe.tile.ITileProbInfoProvider;
|
||||
import appeng.integration.modules.theoneprobe.tile.PowerStateInfoProvider;
|
||||
import appeng.integration.modules.theoneprobe.tile.PowerStorageInfoProvider;
|
||||
import appeng.tile.AEBaseTile;
|
||||
|
||||
|
||||
public final class TileInfoProvider implements IProbeInfoProvider
|
||||
{
|
||||
private final List<ITileProbInfoProvider> providers;
|
||||
|
||||
public TileInfoProvider()
|
||||
{
|
||||
final ITileProbInfoProvider charger = new ChargerInfoProvider();
|
||||
final ITileProbInfoProvider energyCell = new CraftingMonitorInfoProvider();
|
||||
final ITileProbInfoProvider craftingBlock = new PowerStateInfoProvider();
|
||||
final ITileProbInfoProvider craftingMonitor = new PowerStorageInfoProvider();
|
||||
|
||||
this.providers = Lists.newArrayList( charger, energyCell, craftingBlock, craftingMonitor );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID()
|
||||
{
|
||||
return AppEng.MOD_ID + ":TileInfoProvider";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
final TileEntity tile = world.getTileEntity( data.getPos() );
|
||||
|
||||
if( tile instanceof AEBaseTile )
|
||||
{
|
||||
final AEBaseTile aeBaseTile = (AEBaseTile) tile;
|
||||
|
||||
for( final ITileProbInfoProvider provider : this.providers )
|
||||
{
|
||||
provider.addProbeInfo( aeBaseTile, mode, probeInfo, player, world, blockState, data );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* 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.config;
|
||||
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeConfig;
|
||||
import mcjty.theoneprobe.api.IProbeConfigProvider;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeHitEntityData;
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
|
||||
|
||||
public class AEConfigProvider implements IProbeConfigProvider
|
||||
{
|
||||
|
||||
@Override
|
||||
public void getProbeConfig( IProbeConfig config, EntityPlayer player, World world, Entity entity, IProbeHitEntityData data )
|
||||
{
|
||||
// Still no AE entities.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getProbeConfig( IProbeConfig config, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( world.getTileEntity( data.getPos() ) instanceof AEBaseTile )
|
||||
{
|
||||
config.setRFMode( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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.part;
|
||||
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.parts.networking.PartCableSmart;
|
||||
import appeng.parts.networking.PartDenseCable;
|
||||
|
||||
|
||||
public class ChannelInfoProvider implements IPartProbInfoProvider
|
||||
{
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( part instanceof PartDenseCable || part instanceof PartCableSmart )
|
||||
{
|
||||
final int usedChannels;
|
||||
final int maxChannels = ( part instanceof PartDenseCable ) ? 32 : 8;
|
||||
|
||||
if( part.getGridNode().isActive() )
|
||||
{
|
||||
final NBTTagCompound tmp = new NBTTagCompound();
|
||||
part.writeToNBT( tmp );
|
||||
usedChannels = tmp.getByte( "usedChannels" );
|
||||
}
|
||||
else
|
||||
{
|
||||
usedChannels = 0;
|
||||
}
|
||||
|
||||
final String formattedChannelString = String.format( TheOneProbeText.CHANNELS.getLocal(), usedChannels, maxChannels );
|
||||
|
||||
probeInfo.text( formattedChannelString );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.part;
|
||||
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* Similar to {@link IProbeInfoProvider}, but already providing the {@link IPart} being looked at.
|
||||
*
|
||||
*/
|
||||
public interface IPartProbInfoProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* @see IProbeInfoProvider#addProbeInfo(ProbeMode, IProbeInfo, EntityPlayer, World, IBlockState, IProbeHitData)
|
||||
*/
|
||||
void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data );
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* 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.part;
|
||||
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.p2p.PartP2PTunnel;
|
||||
|
||||
|
||||
public class P2PStateInfoProvider implements IPartProbInfoProvider
|
||||
{
|
||||
|
||||
private static final int STATE_UNLINKED = 0;
|
||||
private static final int STATE_OUTPUT = 1;
|
||||
private static final int STATE_INPUT = 2;
|
||||
public static final String TAG_P2P_STATE = "p2p_state";
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( part instanceof PartP2PTunnel )
|
||||
{
|
||||
final PartP2PTunnel tunnel = (PartP2PTunnel) part;
|
||||
|
||||
// The default state
|
||||
int state = STATE_UNLINKED;
|
||||
int outputCount = 0;
|
||||
|
||||
if( !tunnel.isOutput() )
|
||||
{
|
||||
outputCount = getOutputCount( tunnel );
|
||||
if( outputCount > 0 )
|
||||
{
|
||||
// Only set it to INPUT if we know there are any outputs
|
||||
state = STATE_INPUT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final PartP2PTunnel input = tunnel.getInput();
|
||||
if( input != null )
|
||||
{
|
||||
state = STATE_OUTPUT;
|
||||
}
|
||||
}
|
||||
|
||||
switch( state )
|
||||
{
|
||||
case STATE_UNLINKED:
|
||||
probeInfo.text( TheOneProbeText.P2P_UNLINKED.getLocal() );
|
||||
break;
|
||||
case STATE_OUTPUT:
|
||||
probeInfo.text( TheOneProbeText.P2P_OUTPUT.getLocal() );
|
||||
break;
|
||||
case STATE_INPUT:
|
||||
probeInfo.text( getOutputText( outputCount ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int getOutputCount( PartP2PTunnel tunnel )
|
||||
{
|
||||
try
|
||||
{
|
||||
return Iterators.size( tunnel.getOutputs().iterator() );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// Well... unknown size it is!
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getOutputText( int outputs )
|
||||
{
|
||||
if( outputs <= 1 )
|
||||
{
|
||||
return TheOneProbeText.P2P_INPUT_ONE_OUTPUT.getLocal();
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.format( TheOneProbeText.P2P_INPUT_MANY_OUTPUTS.getLocal(), outputs );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* 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.part;
|
||||
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
|
||||
|
||||
public final class PartAccessor
|
||||
{
|
||||
|
||||
public Optional<IPart> getMaybePart( final TileEntity te, final IProbeHitData data )
|
||||
{
|
||||
if( te instanceof IPartHost )
|
||||
{
|
||||
BlockPos pos = data.getPos();
|
||||
final Vec3d position = data.getHitVec().addVector( -pos.getX(), -pos.getY(), -pos.getZ() );
|
||||
final IPartHost host = (IPartHost) te;
|
||||
final SelectedPart sp = host.selectPart( position );
|
||||
|
||||
if( sp.part != null )
|
||||
{
|
||||
return Optional.of( sp.part );
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* 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.part;
|
||||
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
|
||||
|
||||
public class PowerStateInfoProvider implements IPartProbInfoProvider
|
||||
{
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( part instanceof IPowerChannelState )
|
||||
{
|
||||
final IPowerChannelState state = (IPowerChannelState) part;
|
||||
final String tooltip = this.getToolTip( state.isActive(), state.isPowered() );
|
||||
|
||||
probeInfo.text( tooltip );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String getToolTip( final boolean isActive, final boolean isPowered )
|
||||
{
|
||||
final String result;
|
||||
|
||||
if( isActive && isPowered )
|
||||
{
|
||||
result = TheOneProbeText.DEVICE_ONLINE.getLocal();
|
||||
}
|
||||
else if( isPowered )
|
||||
{
|
||||
result = TheOneProbeText.DEVICE_MISSING_CHANNEL.getLocal();
|
||||
}
|
||||
else
|
||||
{
|
||||
result = TheOneProbeText.DEVICE_OFFLINE.getLocal();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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.part;
|
||||
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.implementations.parts.IPartStorageMonitor;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
|
||||
|
||||
public class StorageMonitorInfoProvider implements IPartProbInfoProvider
|
||||
{
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( part instanceof IPartStorageMonitor )
|
||||
{
|
||||
final IPartStorageMonitor monitor = (IPartStorageMonitor) part;
|
||||
|
||||
final IAEStack<?> displayed = monitor.getDisplayed();
|
||||
final boolean isLocked = monitor.isLocked();
|
||||
|
||||
if( displayed instanceof IAEItemStack )
|
||||
{
|
||||
final IAEItemStack ais = (IAEItemStack) displayed;
|
||||
probeInfo.text( TheOneProbeText.SHOWING.getLocal() + ": " + ais.getItemStack().getDisplayName() );
|
||||
}
|
||||
else if( displayed instanceof IAEFluidStack )
|
||||
{
|
||||
final IAEFluidStack ais = (IAEFluidStack) displayed;
|
||||
probeInfo.text( TheOneProbeText.SHOWING.getLocal() + ": " + ais.getFluid().getLocalizedName( ais.getFluidStack() ) );
|
||||
}
|
||||
|
||||
probeInfo.text( isLocked ? TheOneProbeText.LOCKED.getLocal() : TheOneProbeText.UNLOCKED.getLocal() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* 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.tile;
|
||||
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.ElementAlignment;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.misc.TileCharger;
|
||||
|
||||
|
||||
public class ChargerInfoProvider implements ITileProbInfoProvider
|
||||
{
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( tile instanceof TileCharger )
|
||||
{
|
||||
final TileCharger charger = (TileCharger) tile;
|
||||
final IInventory chargerInventory = charger.getInternalInventory();
|
||||
final ItemStack chargingItem = chargerInventory.getStackInSlot( 0 );
|
||||
|
||||
if( chargingItem != null )
|
||||
{
|
||||
final String currentInventory = chargingItem.getDisplayName();
|
||||
final IProbeInfo centerAlignedHorizontalLayout = probeInfo
|
||||
.horizontal( probeInfo.defaultLayoutStyle().alignment( ElementAlignment.ALIGN_CENTER ) );
|
||||
|
||||
centerAlignedHorizontalLayout.item( chargingItem );
|
||||
centerAlignedHorizontalLayout.text( currentInventory );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* 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.tile;
|
||||
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.ElementAlignment;
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.crafting.TileCraftingMonitorTile;
|
||||
|
||||
|
||||
public class CraftingMonitorInfoProvider implements ITileProbInfoProvider
|
||||
{
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( tile instanceof TileCraftingMonitorTile )
|
||||
{
|
||||
final TileCraftingMonitorTile monitor = (TileCraftingMonitorTile) tile;
|
||||
final IAEItemStack displayStack = monitor.getJobProgress();
|
||||
|
||||
if( displayStack != null )
|
||||
{
|
||||
final ItemStack itemStack = displayStack.getItemStack();
|
||||
final String itemName = itemStack.getDisplayName();
|
||||
final String formattedCrafting = String.format( TheOneProbeText.CRAFTING.getLocal(), itemName );
|
||||
|
||||
final IProbeInfo centerAlignedHorizontalLayout = probeInfo
|
||||
.horizontal( probeInfo.defaultLayoutStyle().alignment( ElementAlignment.ALIGN_CENTER ) );
|
||||
|
||||
centerAlignedHorizontalLayout.item( itemStack );
|
||||
centerAlignedHorizontalLayout.text( formattedCrafting );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* 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.tile;
|
||||
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
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.tile.AEBaseTile;
|
||||
|
||||
/**
|
||||
* Similar to {@link IProbeInfoProvider}, but already providing the {@link AEBaseTile} being looked at.
|
||||
*
|
||||
*/
|
||||
public interface ITileProbInfoProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* @see IProbeInfoProvider#addProbeInfo(ProbeMode, IProbeInfo, EntityPlayer, World, IBlockState, IProbeHitData)
|
||||
*/
|
||||
void addProbeInfo( AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data );
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* 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.tile;
|
||||
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.tile.AEBaseTile;
|
||||
|
||||
|
||||
public class PowerStateInfoProvider implements ITileProbInfoProvider
|
||||
{
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( tile instanceof IPowerChannelState )
|
||||
{
|
||||
final IPowerChannelState state = (IPowerChannelState) tile;
|
||||
|
||||
final boolean isActive = state.isActive();
|
||||
final boolean isPowered = state.isPowered();
|
||||
|
||||
if( isActive && isPowered )
|
||||
{
|
||||
probeInfo.text( TheOneProbeText.DEVICE_ONLINE.getLocal() );
|
||||
}
|
||||
else if( isPowered )
|
||||
{
|
||||
probeInfo.text( TheOneProbeText.DEVICE_MISSING_CHANNEL.getLocal() );
|
||||
}
|
||||
else
|
||||
{
|
||||
probeInfo.text( TheOneProbeText.DEVICE_OFFLINE.getLocal() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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.tile;
|
||||
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcjty.theoneprobe.api.IProbeHitData;
|
||||
import mcjty.theoneprobe.api.IProbeInfo;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
|
||||
import appeng.api.networking.energy.IAEPowerStorage;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class PowerStorageInfoProvider implements ITileProbInfoProvider
|
||||
{
|
||||
|
||||
@Override
|
||||
public void addProbeInfo( AEBaseTile tile, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
|
||||
{
|
||||
if( tile instanceof IAEPowerStorage )
|
||||
{
|
||||
final IAEPowerStorage storage = (IAEPowerStorage) tile;
|
||||
final double maxPower = storage.getAEMaxPower();
|
||||
|
||||
if( maxPower > 0 )
|
||||
{
|
||||
final long internalCurrentPower = (long) ( storage.getAECurrentPower() * 100 );
|
||||
|
||||
if( internalCurrentPower >= 0 )
|
||||
{
|
||||
final long internalMaxPower = (long) ( 100 * maxPower );
|
||||
|
||||
final String formatCurrentPower = Platform.formatPowerLong( internalCurrentPower, false );
|
||||
final String formatMaxPower = Platform.formatPowerLong( internalMaxPower, false );
|
||||
final String formattedString = String.format( TheOneProbeText.STORED_ENERGY.getLocal(), formatCurrentPower, formatMaxPower );
|
||||
|
||||
probeInfo.text( formattedString );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -365,6 +365,22 @@ waila.appliedenergistics2.P2PInputOneOutput=Linked (Input Side)
|
|||
waila.appliedenergistics2.P2PInputManyOutputs=Linked (Input Side) - %d Outputs
|
||||
waila.appliedenergistics2.P2POutput=Linked (Output Side)
|
||||
|
||||
// TheOneProbe
|
||||
theoneprobe.appliedenergistics2.crafting=Crafting: %1$s
|
||||
theoneprobe.appliedenergistics2.device_online=Device Online
|
||||
theoneprobe.appliedenergistics2.device_offline=Device Offline
|
||||
theoneprobe.appliedenergistics2.device_missing_channel=Device Missing Channel
|
||||
theoneprobe.appliedenergistics2.locked=Locked
|
||||
theoneprobe.appliedenergistics2.unlocked=Unlocked
|
||||
theoneprobe.appliedenergistics2.showing=Showing
|
||||
theoneprobe.appliedenergistics2.contains=Contains
|
||||
theoneprobe.appliedenergistics2.channels=%1$d of %2$d Channels
|
||||
theoneprobe.appliedenergistics2.p2p_unlinked=Unlinked
|
||||
theoneprobe.appliedenergistics2.p2p_input_one_output=Linked (Input Side)
|
||||
theoneprobe.appliedenergistics2.p2p_input_many_outputs=Linked (Input Side) - %d Outputs
|
||||
theoneprobe.appliedenergistics2.p2p_output=Linked (Output Side)
|
||||
theoneprobe.appliedenergistics2.stored_energy=%1$d / %2$d
|
||||
|
||||
// Items
|
||||
item.appliedenergistics2.storage_cell_1k.name=1k ME Storage Cell
|
||||
item.appliedenergistics2.storage_cell_4k.name=4k ME Storage Cell
|
||||
|
|
Loading…
Reference in New Issue