2014-02-20 00:33:36 +01:00
|
|
|
package appeng.integration.modules;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import mcp.mobius.waila.api.IWailaConfigHandler;
|
|
|
|
import mcp.mobius.waila.api.IWailaDataAccessor;
|
|
|
|
import mcp.mobius.waila.api.IWailaDataProvider;
|
|
|
|
import mcp.mobius.waila.api.IWailaRegistrar;
|
2014-02-20 04:16:41 +01:00
|
|
|
import net.minecraft.inventory.IInventory;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2014-05-25 01:22:50 +02:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2014-02-20 04:16:41 +01:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.MovingObjectPosition;
|
|
|
|
import net.minecraft.util.Vec3;
|
|
|
|
import appeng.api.implementations.IPowerChannelState;
|
|
|
|
import appeng.api.implementations.parts.IPartStorageMonitor;
|
|
|
|
import appeng.api.parts.IFacadePart;
|
|
|
|
import appeng.api.parts.IPart;
|
|
|
|
import appeng.api.parts.IPartHost;
|
|
|
|
import appeng.api.parts.SelectedPart;
|
|
|
|
import appeng.api.storage.data.IAEFluidStack;
|
|
|
|
import appeng.api.storage.data.IAEItemStack;
|
|
|
|
import appeng.api.storage.data.IAEStack;
|
2014-02-20 00:33:36 +01:00
|
|
|
import appeng.block.AEBaseBlock;
|
|
|
|
import appeng.core.AppEng;
|
2014-02-20 04:16:41 +01:00
|
|
|
import appeng.core.localization.WailaText;
|
2014-02-20 00:33:36 +01:00
|
|
|
import appeng.integration.BaseModule;
|
2014-02-20 04:16:41 +01:00
|
|
|
import appeng.tile.misc.TileCharger;
|
2014-05-25 01:22:50 +02:00
|
|
|
import appeng.tile.networking.TileEnergyCell;
|
|
|
|
import appeng.util.Platform;
|
2014-02-20 04:16:41 +01:00
|
|
|
import cpw.mods.fml.common.event.FMLInterModComms;
|
|
|
|
|
|
|
|
public class Waila extends BaseModule implements IWailaDataProvider
|
|
|
|
{
|
|
|
|
|
|
|
|
public static Waila instance;
|
2014-02-20 00:33:36 +01:00
|
|
|
|
2014-02-20 04:16:41 +01:00
|
|
|
public static void register(IWailaRegistrar registrar)
|
2014-02-20 00:33:36 +01:00
|
|
|
{
|
2014-02-20 04:16:41 +01:00
|
|
|
// registrar.registerHeadProvider( (Waila) AppEng.instance.getIntegration( "Waila" ), AEBaseBlock.class );
|
|
|
|
registrar.registerBodyProvider( (Waila) AppEng.instance.getIntegration( "Waila" ), AEBaseBlock.class );
|
2014-06-27 03:23:29 +02:00
|
|
|
registrar.registerSyncedNBTKey( "internalCurrentPower", TileEnergyCell.class );
|
2014-02-20 04:16:41 +01:00
|
|
|
// registrar.registerTailProvider( (Waila) AppEng.instance.getIntegration( "Waila" ), AEBaseBlock.class );
|
2014-02-20 00:33:36 +01:00
|
|
|
}
|
2014-02-20 04:16:41 +01:00
|
|
|
|
2014-02-20 00:33:36 +01:00
|
|
|
@Override
|
2014-02-20 04:16:41 +01:00
|
|
|
public void Init() throws Throwable
|
|
|
|
{
|
2014-02-20 00:33:36 +01:00
|
|
|
TestClass( IWailaDataProvider.class );
|
|
|
|
TestClass( IWailaRegistrar.class );
|
2014-02-20 04:16:41 +01:00
|
|
|
FMLInterModComms.sendMessage( "Waila", "register", this.getClass().getName() + ".register" );
|
2014-02-20 00:33:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-20 04:16:41 +01:00
|
|
|
public void PostInit() throws Throwable
|
|
|
|
{
|
|
|
|
// :P
|
2014-02-20 00:33:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-20 04:16:41 +01:00
|
|
|
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config)
|
|
|
|
{
|
|
|
|
|
2014-02-20 00:33:36 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-20 04:16:41 +01:00
|
|
|
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config)
|
|
|
|
{
|
2014-02-20 00:33:36 +01:00
|
|
|
|
|
|
|
return currenttip;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-20 04:16:41 +01:00
|
|
|
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config)
|
|
|
|
{
|
|
|
|
TileEntity te = accessor.getTileEntity();
|
|
|
|
|
|
|
|
Object ThingOfInterest = te;
|
|
|
|
if ( te instanceof IPartHost )
|
|
|
|
{
|
|
|
|
MovingObjectPosition mop = accessor.getPosition();
|
|
|
|
Vec3 Pos = mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ );
|
|
|
|
SelectedPart sp = ((IPartHost) te).selectPart( Pos );
|
|
|
|
if ( sp.facade != null )
|
|
|
|
{
|
|
|
|
IFacadePart fp = sp.facade;
|
|
|
|
ThingOfInterest = fp;
|
|
|
|
}
|
|
|
|
else if ( sp.part != null )
|
|
|
|
{
|
|
|
|
IPart part = sp.part;
|
|
|
|
ThingOfInterest = part;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-25 01:22:50 +02:00
|
|
|
if ( ThingOfInterest instanceof TileEnergyCell )
|
|
|
|
{
|
|
|
|
NBTTagCompound c = accessor.getNBTData();
|
2014-05-25 18:06:59 +02:00
|
|
|
if ( c != null && c.hasKey( "internalCurrentPower" ) )
|
2014-05-25 01:22:50 +02:00
|
|
|
{
|
|
|
|
TileEnergyCell tec = (TileEnergyCell) ThingOfInterest;
|
|
|
|
long power = (long) (100 * c.getDouble( "internalCurrentPower" ));
|
|
|
|
currenttip.add( WailaText.Contains + ": " + Platform.formatPowerLong( power, false ) + " / "
|
|
|
|
+ Platform.formatPowerLong( (long) (100 * tec.getAEMaxPower()), false ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-20 04:16:41 +01:00
|
|
|
if ( ThingOfInterest instanceof IPartStorageMonitor )
|
|
|
|
{
|
|
|
|
IPartStorageMonitor psm = (IPartStorageMonitor) ThingOfInterest;
|
|
|
|
IAEStack stack = psm.getDisplayed();
|
|
|
|
boolean isLocked = psm.isLocked();
|
|
|
|
|
|
|
|
if ( stack instanceof IAEItemStack )
|
|
|
|
{
|
|
|
|
IAEItemStack ais = (IAEItemStack) stack;
|
|
|
|
currenttip.add( WailaText.Showing.getLocal() + ": " + ais.getItemStack().getDisplayName() );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( stack instanceof IAEFluidStack )
|
|
|
|
{
|
|
|
|
IAEFluidStack ais = (IAEFluidStack) stack;
|
|
|
|
currenttip.add( WailaText.Showing.getLocal() + ": " + ais.getFluid().getLocalizedName() );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( isLocked )
|
|
|
|
currenttip.add( WailaText.Locked.getLocal() );
|
|
|
|
else
|
|
|
|
currenttip.add( WailaText.Unlocked.getLocal() );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ThingOfInterest instanceof TileCharger )
|
|
|
|
{
|
|
|
|
TileCharger tc = (TileCharger) ThingOfInterest;
|
|
|
|
IInventory inv = tc.getInternalInventory();
|
|
|
|
ItemStack is = inv.getStackInSlot( 0 );
|
|
|
|
if ( is != null )
|
|
|
|
{
|
|
|
|
currenttip.add( WailaText.Contains + ": " + is.getDisplayName() );
|
|
|
|
is.getItem().addInformation( is, accessor.getPlayer(), currenttip, true );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ThingOfInterest instanceof IPowerChannelState )
|
|
|
|
{
|
|
|
|
IPowerChannelState pbs = (IPowerChannelState) ThingOfInterest;
|
|
|
|
if ( pbs.isActive() && pbs.isPowered() )
|
|
|
|
currenttip.add( WailaText.DeviceOnline.getLocal() );
|
|
|
|
else if ( pbs.isPowered() )
|
|
|
|
currenttip.add( WailaText.DeviceMissingChannel.getLocal() );
|
|
|
|
else
|
|
|
|
currenttip.add( WailaText.DeviceOffline.getLocal() );
|
|
|
|
}
|
|
|
|
|
2014-02-20 00:33:36 +01:00
|
|
|
return currenttip;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-20 04:16:41 +01:00
|
|
|
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config)
|
|
|
|
{
|
2014-02-20 00:33:36 +01:00
|
|
|
|
|
|
|
return currenttip;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|