Merge pull request #621 from thatsIch/b-304-waila-channels
Fixes #304 WAILA Integration updated and fixed
This commit is contained in:
commit
f0d04699d1
44 changed files with 1514 additions and 330 deletions
|
@ -18,7 +18,7 @@ fmp_version=1.1.0.311
|
|||
code_chicken_lib_version=1.1.1.105
|
||||
code_chicken_core_version=1.0.4.29
|
||||
nei_version=1.0.3.66
|
||||
waila_version=1.5.5_1.7.10
|
||||
waila_version=1.5.7a_1.7.10
|
||||
|
||||
#########################################################
|
||||
# API Stubs #
|
||||
|
|
|
@ -39,7 +39,7 @@ public interface IPartStorageMonitor extends IPartMonitor, IPart, IGridHost, INe
|
|||
* IAEFluidStack the quantity is important remember to use getStackSize() on the IAEStack, and not on the
|
||||
* FluidStack/ItemStack acquired from it.
|
||||
*/
|
||||
IAEStack getDisplayed();
|
||||
IAEStack<?> getDisplayed();
|
||||
|
||||
/**
|
||||
* @return the current locked state of the Storage Monitor
|
||||
|
|
|
@ -22,6 +22,7 @@ import net.minecraft.util.StatCollector;
|
|||
|
||||
public enum WailaText
|
||||
{
|
||||
Crafting,
|
||||
|
||||
DeviceOnline, DeviceOffline, DeviceMissingChannel,
|
||||
|
||||
|
|
|
@ -20,15 +20,15 @@ package appeng.integration;
|
|||
|
||||
public abstract class BaseModule implements IIntegrationModule {
|
||||
|
||||
protected void TestClass( Class clz )
|
||||
protected void testClassExistence( Class<?> clz )
|
||||
{
|
||||
clz.isInstance(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void Init() throws Throwable;
|
||||
public abstract void init() throws Throwable;
|
||||
|
||||
@Override
|
||||
public abstract void PostInit();
|
||||
public abstract void postInit();
|
||||
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@ package appeng.integration;
|
|||
public interface IIntegrationModule
|
||||
{
|
||||
|
||||
void Init() throws Throwable;
|
||||
void init() throws Throwable;
|
||||
|
||||
void PostInit();
|
||||
void postInit();
|
||||
|
||||
}
|
||||
|
|
|
@ -96,12 +96,12 @@ public class IntegrationNode
|
|||
|
||||
break;
|
||||
case INIT:
|
||||
this.mod.Init();
|
||||
this.mod.init();
|
||||
this.state = IntegrationStage.POST_INIT;
|
||||
|
||||
break;
|
||||
case POST_INIT:
|
||||
this.mod.PostInit();
|
||||
this.mod.postInit();
|
||||
this.state = IntegrationStage.READY;
|
||||
|
||||
break;
|
||||
|
|
|
@ -48,7 +48,7 @@ public enum IntegrationType
|
|||
|
||||
CLApi(IntegrationSide.BOTH, "Colored Lights Core", "coloredlightscore"),
|
||||
|
||||
Waila(IntegrationSide.CLIENT, "Waila", "Waila"),
|
||||
Waila(IntegrationSide.BOTH, "Waila", "Waila"),
|
||||
|
||||
InvTweaks(IntegrationSide.CLIENT, "Inventory Tweaks", "inventorytweaks"),
|
||||
|
||||
|
|
|
@ -64,9 +64,9 @@ public class BC extends BaseModule implements IBC
|
|||
public static BC instance;
|
||||
|
||||
public BC() {
|
||||
this.TestClass( IPipeConnection.class );
|
||||
this.TestClass( ItemFacade.class );
|
||||
this.TestClass( IToolWrench.class );
|
||||
this.testClassExistence( IPipeConnection.class );
|
||||
this.testClassExistence( ItemFacade.class );
|
||||
this.testClassExistence( IToolWrench.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -225,7 +225,7 @@ public class BC extends BaseModule implements IBC
|
|||
}
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
public void init()
|
||||
{
|
||||
AEApi.instance().partHelper().registerNewLayer( "appeng.parts.layers.LayerIPipeConnection", "buildcraft.api.transport.IPipeConnection" );
|
||||
AEApi.instance().registries().externalStorage().addExternalStorageInterface( new BCPipeHandler() );
|
||||
|
@ -292,7 +292,7 @@ public class BC extends BaseModule implements IBC
|
|||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
public void postInit()
|
||||
{
|
||||
this.registerPowerP2P();
|
||||
this.registerItemP2P();
|
||||
|
|
|
@ -50,13 +50,13 @@ public class BetterStorage implements IIntegrationModule, IBetterStorage
|
|||
}
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
public void init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
public void postInit()
|
||||
{
|
||||
AEApi.instance().registries().externalStorage().addExternalStorageInterface( new BSCrateHandler() );
|
||||
}
|
||||
|
|
|
@ -28,13 +28,13 @@ public class CLApi extends BaseModule implements ICLApi
|
|||
public static CLApi instance;
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
public void init() throws Throwable
|
||||
{
|
||||
this.TestClass( coloredlightscore.src.api.CLApi.class );
|
||||
this.testClassExistence( coloredlightscore.src.api.CLApi.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
public void postInit()
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
|
|
@ -375,13 +375,13 @@ public class CraftGuide extends CraftGuideAPIObject implements IIntegrationModul
|
|||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
public void init() throws Throwable
|
||||
{
|
||||
StackInfo.addSource( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
public void postInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -48,13 +48,13 @@ public class DSU extends BaseModule implements IDSU
|
|||
}
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
public void init()
|
||||
{
|
||||
this.TestClass( IDeepStorageUnit.class );
|
||||
this.testClassExistence( IDeepStorageUnit.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
public void postInit()
|
||||
{
|
||||
AEApi.instance().registries().externalStorage().addExternalStorageInterface( new MFRDSUHandler() );
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF
|
|||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
public void init() throws Throwable
|
||||
{
|
||||
this.createAndRegister( AEApi.instance().blocks().blockQuartz.block(), 0 );
|
||||
this.createAndRegister( AEApi.instance().blocks().blockQuartzPillar.block(), 0 );
|
||||
|
@ -113,7 +113,7 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF
|
|||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
public void postInit()
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register( new FMPEvent() );
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ public class FZ implements IFZ, IIntegrationModule
|
|||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
public void init() throws Throwable
|
||||
{
|
||||
day_BarrelClass = Class.forName( "factorization.weird.TileEntityDayBarrel" );
|
||||
|
||||
|
@ -172,7 +172,7 @@ public class FZ implements IFZ, IIntegrationModule
|
|||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
public void postInit()
|
||||
{
|
||||
AEApi.instance().registries().externalStorage().addExternalStorageInterface( new FactorizationHandler() );
|
||||
}
|
||||
|
|
|
@ -37,16 +37,16 @@ public class IC2 extends BaseModule implements IIC2
|
|||
public static IC2 instance;
|
||||
|
||||
public IC2() {
|
||||
this.TestClass( IEnergyTile.class );
|
||||
this.testClassExistence( IEnergyTile.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
public void init()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
public void postInit()
|
||||
{
|
||||
IP2PTunnelRegistry reg = AEApi.instance().registries().p2pTunnel();
|
||||
reg.addNewAttunement( this.getItem( "copperCableItem" ), TunnelType.IC2_POWER );
|
||||
|
|
|
@ -50,11 +50,11 @@ public class ImmibisMicroblocks extends BaseModule implements IImmibisMicroblock
|
|||
private Method mergeIntoMicroblockContainer;
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
public void init() throws Throwable
|
||||
{
|
||||
this.TestClass( IMultipartTile.class );
|
||||
this.TestClass( ICoverSystem.class );
|
||||
this.TestClass( IPartContainer.class );
|
||||
this.testClassExistence( IMultipartTile.class );
|
||||
this.testClassExistence( ICoverSystem.class );
|
||||
this.testClassExistence( IPartContainer.class );
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -70,7 +70,7 @@ public class ImmibisMicroblocks extends BaseModule implements IImmibisMicroblock
|
|||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
public void postInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -35,13 +35,13 @@ public class InvTweaks extends BaseModule implements IInvTweaks
|
|||
static InvTweaksAPI api;
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
public void init()
|
||||
{
|
||||
api = (InvTweaksAPI) Loader.instance().getIndexedModList().get( "inventorytweaks" ).getMod();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
public void postInit()
|
||||
{
|
||||
if ( api == null )
|
||||
throw new RuntimeException( "InvTweaks API Instance Failed." );
|
||||
|
|
|
@ -28,17 +28,17 @@ public class MFR extends BaseModule
|
|||
public static MFR instance;
|
||||
|
||||
public MFR() {
|
||||
this.TestClass( IRedNetConnection.class );
|
||||
this.testClassExistence( IRedNetConnection.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
public void init() throws Throwable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
public void postInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class MJ5 extends BaseModule implements IMJ5
|
|||
public static MJ5 instance;
|
||||
|
||||
public MJ5() {
|
||||
this.TestClass( IPowerReceptor.class );
|
||||
this.testClassExistence( IPowerReceptor.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,13 +42,13 @@ public class MJ5 extends BaseModule implements IMJ5
|
|||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
public void init() throws Throwable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
public void postInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -39,18 +39,18 @@ public class MJ6 extends BaseModule implements IMJ6
|
|||
public static MJ6 instance;
|
||||
|
||||
public MJ6() {
|
||||
this.TestClass( IBatteryObject.class );
|
||||
this.TestClass( IBatteryProvider.class );
|
||||
this.TestClass( ISidedBatteryProvider.class );
|
||||
this.testClassExistence( IBatteryObject.class );
|
||||
this.testClassExistence( IBatteryProvider.class );
|
||||
this.testClassExistence( ISidedBatteryProvider.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
public void init() throws Throwable
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
public void postInit()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -31,13 +31,13 @@ public class Mekanism extends BaseModule implements IMekanism
|
|||
public static Mekanism instance;
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
public void init() throws Throwable
|
||||
{
|
||||
this.TestClass( mekanism.api.energy.IStrictEnergyAcceptor.class );
|
||||
this.testClassExistence( mekanism.api.energy.IStrictEnergyAcceptor.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
public void postInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -56,16 +56,16 @@ public class NEI extends BaseModule implements INEI, IContainerTooltipHandler
|
|||
|
||||
public static NEI instance;
|
||||
|
||||
Class API;
|
||||
Class<?> API;
|
||||
|
||||
// recipe handler...
|
||||
Method registerRecipeHandler;
|
||||
Method registerUsageHandler;
|
||||
|
||||
public NEI() throws ClassNotFoundException {
|
||||
this.TestClass( GuiContainerManager.class );
|
||||
this.TestClass( codechicken.nei.recipe.ICraftingHandler.class );
|
||||
this.TestClass( codechicken.nei.recipe.IUsageHandler.class );
|
||||
this.testClassExistence( GuiContainerManager.class );
|
||||
this.testClassExistence( codechicken.nei.recipe.ICraftingHandler.class );
|
||||
this.testClassExistence( codechicken.nei.recipe.IUsageHandler.class );
|
||||
this.API = Class.forName( "codechicken.nei.api.API" );
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ public class NEI extends BaseModule implements INEI, IContainerTooltipHandler
|
|||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
public void init() throws Throwable
|
||||
{
|
||||
this.registerRecipeHandler = this.API.getDeclaredMethod( "registerRecipeHandler", codechicken.nei.recipe.ICraftingHandler.class );
|
||||
this.registerUsageHandler = this.API.getDeclaredMethod( "registerUsageHandler", codechicken.nei.recipe.IUsageHandler.class );
|
||||
|
@ -108,7 +108,7 @@ public class NEI extends BaseModule implements INEI, IContainerTooltipHandler
|
|||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
public void postInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -67,13 +67,13 @@ public class RB extends BaseModule implements IRB
|
|||
public static RB instance;
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
public void init() throws Throwable
|
||||
{
|
||||
this.TestClass( IOrientable.class );
|
||||
this.testClassExistence( IOrientable.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
public void postInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -39,19 +39,19 @@ public class RC extends BaseModule implements IRC
|
|||
}
|
||||
|
||||
public RC() {
|
||||
this.TestClass( RailcraftCraftingManager.class );
|
||||
this.TestClass( IRockCrusherRecipe.class );
|
||||
this.testClassExistence( RailcraftCraftingManager.class );
|
||||
this.testClassExistence( IRockCrusherRecipe.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
public void init()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
public void postInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -33,14 +33,14 @@ public class RF extends BaseModule
|
|||
public static RF instance;
|
||||
|
||||
public RF() {
|
||||
this.TestClass( cofh.api.energy.IEnergyReceiver.class );
|
||||
this.TestClass( cofh.api.energy.IEnergyProvider.class );
|
||||
this.TestClass( cofh.api.energy.IEnergyHandler.class );
|
||||
this.TestClass( cofh.api.energy.IEnergyConnection.class );
|
||||
this.testClassExistence( cofh.api.energy.IEnergyReceiver.class );
|
||||
this.testClassExistence( cofh.api.energy.IEnergyProvider.class );
|
||||
this.testClassExistence( cofh.api.energy.IEnergyHandler.class );
|
||||
this.testClassExistence( cofh.api.energy.IEnergyConnection.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
public void init()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class RF extends BaseModule
|
|||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
public void postInit()
|
||||
{
|
||||
this.RFStack( "ExtraUtilities", "extractor_base", 12 );
|
||||
this.RFStack( "ExtraUtilities", "pipes", 11 );
|
||||
|
|
|
@ -26,17 +26,17 @@ public class RFItem extends BaseModule
|
|||
public static RFItem instance;
|
||||
|
||||
public RFItem() {
|
||||
this.TestClass( cofh.api.energy.IEnergyContainerItem.class );
|
||||
this.testClassExistence( cofh.api.energy.IEnergyContainerItem.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
public void init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
public void postInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -26,17 +26,17 @@ public class RotaryCraft extends BaseModule
|
|||
public static RotaryCraft instance;
|
||||
|
||||
public RotaryCraft() {
|
||||
this.TestClass( Reika.RotaryCraft.API.ShaftPowerReceiver.class );
|
||||
this.testClassExistence( Reika.RotaryCraft.API.ShaftPowerReceiver.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
public void init() throws Throwable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
public void postInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -19,241 +19,46 @@
|
|||
package appeng.integration.modules;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.IWailaFMPAccessor;
|
||||
import mcp.mobius.waila.api.IWailaFMPProvider;
|
||||
import mcp.mobius.waila.api.IWailaRegistrar;
|
||||
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.api.implementations.parts.IPartStorageMonitor;
|
||||
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;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.parts.networking.PartCableSmart;
|
||||
import appeng.parts.networking.PartDenseCable;
|
||||
import appeng.tile.misc.TileCharger;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.tile.networking.TileEnergyCell;
|
||||
import appeng.util.Platform;
|
||||
import appeng.integration.modules.waila.PartWailaDataProvider;
|
||||
import appeng.integration.modules.waila.TileWailaDataProvider;
|
||||
import appeng.tile.AEBaseTile;
|
||||
|
||||
public class Waila extends BaseModule implements IWailaDataProvider, IWailaFMPProvider
|
||||
|
||||
public class Waila extends BaseModule
|
||||
{
|
||||
|
||||
public static Waila instance;
|
||||
|
||||
public static void register(IWailaRegistrar registrar)
|
||||
public static void register( IWailaRegistrar registrar )
|
||||
{
|
||||
Waila w = (Waila) AppEng.instance.getIntegration( IntegrationType.Waila );
|
||||
final IWailaDataProvider partHost = new PartWailaDataProvider();
|
||||
|
||||
registrar.registerBodyProvider( w, AEBaseBlock.class );
|
||||
registrar.registerBodyProvider( w, "ae2_cablebus" );
|
||||
registrar.registerBodyProvider( partHost, AEBaseTile.class );
|
||||
registrar.registerNBTProvider( partHost, AEBaseTile.class );
|
||||
|
||||
registrar.registerSyncedNBTKey( "internalCurrentPower", TileEnergyCell.class );
|
||||
registrar.registerSyncedNBTKey( "extra:6.usedChannels", TileCableBus.class );
|
||||
final IWailaDataProvider tile = new TileWailaDataProvider();
|
||||
|
||||
registrar.registerBodyProvider( tile, AEBaseTile.class );
|
||||
registrar.registerNBTProvider( tile, AEBaseTile.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
public void init() throws Throwable
|
||||
{
|
||||
this.TestClass( IWailaDataProvider.class );
|
||||
this.TestClass( IWailaRegistrar.class );
|
||||
this.testClassExistence( IWailaDataProvider.class );
|
||||
this.testClassExistence( IWailaRegistrar.class );
|
||||
|
||||
FMLInterModComms.sendMessage( "Waila", "register", this.getClass().getName() + ".register" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
public void postInit()
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config)
|
||||
{
|
||||
TileEntity te = accessor.getTileEntity();
|
||||
MovingObjectPosition mop = accessor.getPosition();
|
||||
|
||||
NBTTagCompound nbt = null;
|
||||
|
||||
try
|
||||
{
|
||||
nbt = accessor.getNBTData();
|
||||
}
|
||||
catch (NullPointerException ignored)
|
||||
{
|
||||
}
|
||||
|
||||
return this.getBody( itemStack, currentToolTip, accessor.getPlayer(), nbt, te, mop );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currentToolTip, IWailaFMPAccessor accessor, IWailaConfigHandler config)
|
||||
{
|
||||
TileEntity te = accessor.getTileEntity();
|
||||
MovingObjectPosition mop = accessor.getPosition();
|
||||
|
||||
NBTTagCompound nbt = null;
|
||||
|
||||
try
|
||||
{
|
||||
nbt = accessor.getNBTData();
|
||||
}
|
||||
catch (NullPointerException ignored)
|
||||
{
|
||||
}
|
||||
|
||||
return this.getBody( itemStack, currentToolTip, accessor.getPlayer(), nbt, te, mop );
|
||||
}
|
||||
|
||||
public List<String> getBody(ItemStack itemStack, List<String> currentToolTip, EntityPlayer player, NBTTagCompound nbt, TileEntity te, MovingObjectPosition mop)
|
||||
{
|
||||
|
||||
Object ThingOfInterest = te;
|
||||
if ( te instanceof IPartHost )
|
||||
{
|
||||
Vec3 Pos = mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ );
|
||||
SelectedPart sp = ((IPartHost) te).selectPart( Pos );
|
||||
if ( sp.facade != null )
|
||||
{
|
||||
ThingOfInterest = sp.facade;
|
||||
}
|
||||
else if ( sp.part != null )
|
||||
{
|
||||
ThingOfInterest = sp.part;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if ( ThingOfInterest instanceof PartCableSmart || ThingOfInterest instanceof PartDenseCable )
|
||||
{
|
||||
if ( nbt != null && nbt.hasKey( "extra:6" ) )
|
||||
{
|
||||
NBTTagCompound ic = nbt.getCompoundTag( "extra:6" );
|
||||
if ( ic != null && ic.hasKey( "usedChannels" ) )
|
||||
{
|
||||
int channels = ic.getByte( "usedChannels" );
|
||||
currentToolTip.add( channels + " " + GuiText.Of.getLocal() + ' ' + (ThingOfInterest instanceof PartDenseCable ? 32 : 8) + ' '
|
||||
+ WailaText.Channels.getLocal() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ThingOfInterest instanceof TileEnergyCell )
|
||||
{
|
||||
if ( nbt != null && nbt.hasKey( "internalCurrentPower" ) )
|
||||
{
|
||||
TileEnergyCell tec = (TileEnergyCell) ThingOfInterest;
|
||||
long power = (long) (100 * nbt.getDouble( "internalCurrentPower" ));
|
||||
currentToolTip.add( WailaText.Contains + ": " + Platform.formatPowerLong( power, false ) + " / "
|
||||
+ Platform.formatPowerLong( (long) (100 * tec.getAEMaxPower()), false ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NullPointerException ex)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
if ( ThingOfInterest instanceof IPartStorageMonitor )
|
||||
{
|
||||
IPartStorageMonitor psm = (IPartStorageMonitor) ThingOfInterest;
|
||||
IAEStack stack = psm.getDisplayed();
|
||||
boolean isLocked = psm.isLocked();
|
||||
|
||||
if ( stack instanceof IAEItemStack )
|
||||
{
|
||||
IAEItemStack ais = (IAEItemStack) stack;
|
||||
currentToolTip.add( WailaText.Showing.getLocal() + ": " + ais.getItemStack().getDisplayName() );
|
||||
}
|
||||
|
||||
if ( stack instanceof IAEFluidStack )
|
||||
{
|
||||
IAEFluidStack ais = (IAEFluidStack) stack;
|
||||
currentToolTip.add( WailaText.Showing.getLocal() + ": " + ais.getFluid().getLocalizedName( ais.getFluidStack() ) );
|
||||
}
|
||||
|
||||
if ( isLocked )
|
||||
currentToolTip.add( WailaText.Locked.getLocal() );
|
||||
else
|
||||
currentToolTip.add( WailaText.Unlocked.getLocal() );
|
||||
}
|
||||
|
||||
if ( ThingOfInterest instanceof TileCharger )
|
||||
{
|
||||
TileCharger tc = (TileCharger) ThingOfInterest;
|
||||
IInventory inv = tc.getInternalInventory();
|
||||
ItemStack is = inv.getStackInSlot( 0 );
|
||||
if ( is != null )
|
||||
{
|
||||
currentToolTip.add( WailaText.Contains + ": " + is.getDisplayName() );
|
||||
is.getItem().addInformation( is, player, currentToolTip, true );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ThingOfInterest instanceof IPowerChannelState )
|
||||
{
|
||||
IPowerChannelState pbs = (IPowerChannelState) ThingOfInterest;
|
||||
if ( pbs.isActive() && pbs.isPowered() )
|
||||
currentToolTip.add( WailaText.DeviceOnline.getLocal() );
|
||||
else if ( pbs.isPowered() )
|
||||
currentToolTip.add( WailaText.DeviceMissingChannel.getLocal() );
|
||||
else
|
||||
currentToolTip.add( WailaText.DeviceOffline.getLocal() );
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config)
|
||||
{
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config)
|
||||
{
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currentToolTip, IWailaFMPAccessor accessor, IWailaConfigHandler config)
|
||||
{
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currentToolTip, IWailaFMPAccessor accessor, IWailaConfigHandler config)
|
||||
{
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* 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.waila;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
|
||||
/**
|
||||
* Base implementation for {@link mcp.mobius.waila.api.IWailaDataProvider}
|
||||
*
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public abstract class BaseWailaDataProvider implements IWailaDataProvider
|
||||
{
|
||||
@Override
|
||||
public ItemStack getWailaStack( IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData( EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z )
|
||||
{
|
||||
return tag;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,173 @@
|
|||
/*
|
||||
* 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.waila;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Lists;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.integration.modules.waila.part.ChannelWailaDataProvider;
|
||||
import appeng.integration.modules.waila.part.IPartWailaDataProvider;
|
||||
import appeng.integration.modules.waila.part.PartAccessor;
|
||||
import appeng.integration.modules.waila.part.PowerStateWailaDataProvider;
|
||||
import appeng.integration.modules.waila.part.StorageMonitorWailaDataProvider;
|
||||
import appeng.integration.modules.waila.part.Tracer;
|
||||
|
||||
|
||||
/**
|
||||
* Delegation provider for parts through {@link appeng.integration.modules.waila.part.IPartWailaDataProvider}
|
||||
*
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class PartWailaDataProvider implements IWailaDataProvider
|
||||
{
|
||||
/**
|
||||
* Contains all providers
|
||||
*/
|
||||
private final List<IPartWailaDataProvider> providers;
|
||||
|
||||
/**
|
||||
* Can access parts through view-hits
|
||||
*/
|
||||
private final PartAccessor accessor = new PartAccessor();
|
||||
|
||||
/**
|
||||
* Traces views hit on blocks
|
||||
*/
|
||||
private final Tracer tracer = new Tracer();
|
||||
|
||||
/**
|
||||
* Initializes the provider list with all wanted providers
|
||||
*/
|
||||
public PartWailaDataProvider()
|
||||
{
|
||||
final IPartWailaDataProvider channel = new ChannelWailaDataProvider();
|
||||
final IPartWailaDataProvider storageMonitor = new StorageMonitorWailaDataProvider();
|
||||
final IPartWailaDataProvider powerState = new PowerStateWailaDataProvider();
|
||||
|
||||
this.providers = Lists.newArrayList( channel, storageMonitor, powerState );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack( IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
final MovingObjectPosition mop = accessor.getPosition();
|
||||
|
||||
final Optional<IPart> maybePart = this.accessor.getMaybePart( te, mop );
|
||||
|
||||
if ( maybePart.isPresent() )
|
||||
{
|
||||
final IPart part = maybePart.get();
|
||||
|
||||
for ( IPartWailaDataProvider provider : this.providers )
|
||||
{
|
||||
provider.getWailaHead( part, currentToolTip, accessor, config );
|
||||
}
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
final MovingObjectPosition mop = accessor.getPosition();
|
||||
|
||||
final Optional<IPart> maybePart = this.accessor.getMaybePart( te, mop );
|
||||
|
||||
if ( maybePart.isPresent() )
|
||||
{
|
||||
final IPart part = maybePart.get();
|
||||
|
||||
for ( IPartWailaDataProvider provider : this.providers )
|
||||
{
|
||||
provider.getWailaBody( part, currentToolTip, accessor, config );
|
||||
}
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
final MovingObjectPosition mop = accessor.getPosition();
|
||||
|
||||
final Optional<IPart> maybePart = this.accessor.getMaybePart( te, mop );
|
||||
|
||||
if ( maybePart.isPresent() )
|
||||
{
|
||||
final IPart part = maybePart.get();
|
||||
|
||||
for ( IPartWailaDataProvider provider : this.providers )
|
||||
{
|
||||
provider.getWailaTail( part, currentToolTip, accessor, config );
|
||||
}
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData( EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z )
|
||||
{
|
||||
final MovingObjectPosition mop = this.tracer.retraceBlock( world, player, x, y, z );
|
||||
|
||||
if ( mop != null )
|
||||
{
|
||||
final Optional<IPart> maybePart = this.accessor.getMaybePart( te, mop );
|
||||
|
||||
if ( maybePart.isPresent() )
|
||||
{
|
||||
final IPart part = maybePart.get();
|
||||
|
||||
for ( IPartWailaDataProvider provider : this.providers )
|
||||
{
|
||||
provider.getNBTData( player, part, te, tag, world, x, y, z );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* 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.waila;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
import appeng.integration.modules.waila.tile.ChargerWailaDataProvider;
|
||||
import appeng.integration.modules.waila.tile.CraftingMonitorWailaDataProvider;
|
||||
import appeng.integration.modules.waila.tile.PowerStateWailaDataProvider;
|
||||
import appeng.integration.modules.waila.tile.PowerStorageWailaDataProvider;
|
||||
|
||||
|
||||
/**
|
||||
* Delegation provider for tiles through {@link mcp.mobius.waila.api.IWailaDataProvider}
|
||||
*
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class TileWailaDataProvider implements IWailaDataProvider
|
||||
{
|
||||
/**
|
||||
* Contains all providers
|
||||
*/
|
||||
private final List<IWailaDataProvider> providers;
|
||||
|
||||
/**
|
||||
* Initializes the provider list with all wanted providers
|
||||
*/
|
||||
public TileWailaDataProvider()
|
||||
{
|
||||
final IWailaDataProvider charger = new ChargerWailaDataProvider();
|
||||
final IWailaDataProvider energyCell = new PowerStorageWailaDataProvider();
|
||||
final IWailaDataProvider craftingBlock = new PowerStateWailaDataProvider();
|
||||
final IWailaDataProvider craftingMonitor = new CraftingMonitorWailaDataProvider();
|
||||
|
||||
this.providers = Lists.newArrayList( charger, energyCell, craftingBlock, craftingMonitor );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack( IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
for ( IWailaDataProvider provider : this.providers )
|
||||
{
|
||||
provider.getWailaHead( itemStack, currentToolTip, accessor, config );
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
for ( IWailaDataProvider provider : this.providers )
|
||||
{
|
||||
provider.getWailaBody( itemStack, currentToolTip, accessor, config );
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
for ( IWailaDataProvider provider : this.providers )
|
||||
{
|
||||
provider.getWailaTail( itemStack, currentToolTip, accessor, config );
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData( EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z )
|
||||
{
|
||||
for ( IWailaDataProvider provider : this.providers )
|
||||
{
|
||||
provider.getNBTData( player, te, tag, world, x, y, z );
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.waila.part;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
|
||||
|
||||
/**
|
||||
* Default implementation of {@link appeng.integration.modules.waila.part.IPartWailaDataProvider}
|
||||
*
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public abstract class BasePartWailaDataProvider implements IPartWailaDataProvider
|
||||
{
|
||||
@Override
|
||||
public List<String> getWailaHead( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData( EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z )
|
||||
{
|
||||
return tag;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,162 @@
|
|||
/*
|
||||
* 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.waila.part;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import gnu.trove.map.TObjectByteMap;
|
||||
import gnu.trove.map.hash.TObjectByteHashMap;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.parts.networking.PartCableSmart;
|
||||
import appeng.parts.networking.PartDenseCable;
|
||||
|
||||
|
||||
/**
|
||||
* Channel-information provider for WAILA
|
||||
*
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class ChannelWailaDataProvider extends BasePartWailaDataProvider
|
||||
{
|
||||
/**
|
||||
* Channel key used for the transferred {@link net.minecraft.nbt.NBTTagCompound}
|
||||
*/
|
||||
private static final String ID_USED_CHANNELS = "usedChannels";
|
||||
|
||||
/**
|
||||
* Used cache for channels if the channel was not transmitted through the server.
|
||||
* <p/>
|
||||
* This is useful, when a player just started to look at a tile
|
||||
* and thus just requested the new information from the server.
|
||||
* <p/>
|
||||
* The cache will be updated from the server.
|
||||
*/
|
||||
private final TObjectByteMap<IPart> cache = new TObjectByteHashMap<IPart>();
|
||||
|
||||
/**
|
||||
* Adds the used and max channel to the tool tip
|
||||
*
|
||||
* @param part being looked at part
|
||||
* @param currentToolTip current tool tip
|
||||
* @param accessor wrapper for various world information
|
||||
* @param config config to react to various settings
|
||||
*
|
||||
* @return modified tool tip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
if ( part instanceof PartCableSmart || part instanceof PartDenseCable )
|
||||
{
|
||||
final NBTTagCompound tag = accessor.getNBTData();
|
||||
|
||||
final byte usedChannels = this.getUsedChannels( part, tag, this.cache );
|
||||
final byte maxChannels = ( byte ) ( ( part instanceof PartDenseCable ) ? 32 : 8 );
|
||||
|
||||
currentToolTip.add( usedChannels + " " + GuiText.Of.getLocal() + ' ' + maxChannels + ' ' + WailaText.Channels.getLocal() );
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the source of the channel.
|
||||
* <p/>
|
||||
* If the client received information of the channels on the server, they are used,
|
||||
* else if the cache contains a previous stored value, this will be used.
|
||||
* Default value is 0.
|
||||
*
|
||||
* @param part part to be looked at
|
||||
* @param tag tag maybe containing the channel information
|
||||
* @param cache cache with previous knowledge
|
||||
*
|
||||
* @return used channels on the cable
|
||||
*/
|
||||
private byte getUsedChannels( IPart part, NBTTagCompound tag, TObjectByteMap<IPart> cache )
|
||||
{
|
||||
final byte usedChannels;
|
||||
|
||||
if ( tag.hasKey( ID_USED_CHANNELS ) )
|
||||
{
|
||||
usedChannels = tag.getByte( ID_USED_CHANNELS );
|
||||
this.cache.put( part, usedChannels );
|
||||
}
|
||||
else if ( this.cache.containsKey( part ) )
|
||||
{
|
||||
usedChannels = this.cache.get( part );
|
||||
}
|
||||
else
|
||||
{
|
||||
usedChannels = 0;
|
||||
}
|
||||
|
||||
return usedChannels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on server to transfer information from server to client.
|
||||
* <p/>
|
||||
* If the part is a cable,
|
||||
* it writes the channel information in the {@code #tag}
|
||||
* using the {@code ID_USED_CHANNELS} key.
|
||||
*
|
||||
* @param player player looking at the part
|
||||
* @param part part being looked at
|
||||
* @param te host of the part
|
||||
* @param tag transferred tag which is send to the client
|
||||
* @param world world of the part
|
||||
* @param x x pos of the part
|
||||
* @param y y pos of the part
|
||||
* @param z z pos of the part
|
||||
*
|
||||
* @return tag send to the client
|
||||
*/
|
||||
@Override
|
||||
public NBTTagCompound getNBTData( EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z )
|
||||
{
|
||||
if ( part instanceof PartCableSmart || part instanceof PartDenseCable )
|
||||
{
|
||||
final NBTTagCompound tempTag = new NBTTagCompound();
|
||||
|
||||
part.writeToNBT( tempTag );
|
||||
|
||||
if ( tempTag.hasKey( ID_USED_CHANNELS ) )
|
||||
{
|
||||
final byte usedChannels = tempTag.getByte( ID_USED_CHANNELS );
|
||||
|
||||
tag.setByte( ID_USED_CHANNELS, usedChannels );
|
||||
}
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* 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.waila.part;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
|
||||
|
||||
/**
|
||||
* An abstraction layer of the {@link appeng.integration.modules.waila.part.IPartWailaDataProvider} for {@link appeng.api.parts.IPart}.
|
||||
*
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public interface IPartWailaDataProvider
|
||||
{
|
||||
List<String> getWailaHead( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config );
|
||||
|
||||
List<String> getWailaBody( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config );
|
||||
|
||||
List<String> getWailaTail( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config );
|
||||
|
||||
NBTTagCompound getNBTData(EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z);
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* 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.waila.part;
|
||||
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
|
||||
|
||||
/**
|
||||
* Accessor to access specific parts for WAILA
|
||||
*
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class PartAccessor
|
||||
{
|
||||
/**
|
||||
* Hits a {@link appeng.api.parts.IPartHost} with {@link net.minecraft.util.MovingObjectPosition}.
|
||||
* <p/>
|
||||
* You can derive the looked at {@link appeng.api.parts.IPart} by doing that.
|
||||
* If a facade is being looked at, it is defined as being absent.
|
||||
*
|
||||
* @param te being looked at {@link net.minecraft.tileentity.TileEntity}
|
||||
* @param mop type of raytrace
|
||||
*
|
||||
* @return maybe the looked at {@link appeng.api.parts.IPart}
|
||||
*/
|
||||
public Optional<IPart> getMaybePart( TileEntity te, MovingObjectPosition mop )
|
||||
{
|
||||
if ( te instanceof IPartHost )
|
||||
{
|
||||
final Vec3 position = mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ );
|
||||
final IPartHost host = ( IPartHost ) te;
|
||||
final SelectedPart sp = host.selectPart( position );
|
||||
|
||||
if ( sp.part != null )
|
||||
{
|
||||
return Optional.of( sp.part );
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.absent();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* 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.waila.part;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.core.localization.WailaText;
|
||||
|
||||
|
||||
/**
|
||||
* Power state provider for WAILA
|
||||
*
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class PowerStateWailaDataProvider extends BasePartWailaDataProvider
|
||||
{
|
||||
/**
|
||||
* Adds state to the tooltip
|
||||
*
|
||||
* @param part part with state
|
||||
* @param currentToolTip to be added to tooltip
|
||||
* @param accessor wrapper for various information
|
||||
* @param config config settings
|
||||
*
|
||||
* @return modified tooltip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
if ( part instanceof IPowerChannelState )
|
||||
{
|
||||
final IPowerChannelState state = ( IPowerChannelState ) part;
|
||||
|
||||
currentToolTip.add( this.getToolTip( state.isActive(), state.isPowered() ) );
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the corresponding tool tip for different values of {@code #isActive} and {@code #isPowered}
|
||||
*
|
||||
* @param isActive if part is active
|
||||
* @param isPowered if part is powered
|
||||
*
|
||||
* @return tooltip of the state
|
||||
*/
|
||||
private String getToolTip( boolean isActive, boolean isPowered )
|
||||
{
|
||||
final String result;
|
||||
|
||||
if ( isActive && isPowered )
|
||||
{
|
||||
result = WailaText.DeviceOnline.getLocal();
|
||||
}
|
||||
else if ( isPowered )
|
||||
{
|
||||
result = WailaText.DeviceMissingChannel.getLocal();
|
||||
}
|
||||
else
|
||||
{
|
||||
result = WailaText.DeviceOffline.getLocal();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* 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.waila.part;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
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.core.localization.WailaText;
|
||||
|
||||
|
||||
/**
|
||||
* Storage monitor provider for WAILA
|
||||
*
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class StorageMonitorWailaDataProvider extends BasePartWailaDataProvider
|
||||
{
|
||||
/**
|
||||
* Displays the stack if present and if the monitor is locked.
|
||||
* Can handle fluids and items.
|
||||
*
|
||||
* @param part maybe storage monitor
|
||||
* @param currentToolTip to be written to tooltip
|
||||
* @param accessor information wrapper
|
||||
* @param config config option
|
||||
*
|
||||
* @return modified tooltip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
if ( part instanceof IPartStorageMonitor )
|
||||
{
|
||||
final IPartStorageMonitor monitor = ( IPartStorageMonitor ) part;
|
||||
|
||||
final IAEStack<?> displayed = monitor.getDisplayed();
|
||||
final boolean isLocked = monitor.isLocked();
|
||||
|
||||
if ( displayed instanceof IAEItemStack )
|
||||
{
|
||||
IAEItemStack ais = ( IAEItemStack ) displayed;
|
||||
currentToolTip.add( WailaText.Showing.getLocal() + ": " + ais.getItemStack().getDisplayName() );
|
||||
}
|
||||
else if ( displayed instanceof IAEFluidStack )
|
||||
{
|
||||
IAEFluidStack ais = ( IAEFluidStack ) displayed;
|
||||
currentToolTip.add( WailaText.Showing.getLocal() + ": " + ais.getFluid().getLocalizedName( ais.getFluidStack() ) );
|
||||
}
|
||||
|
||||
currentToolTip.add( ( isLocked ) ? WailaText.Locked.getLocal() : WailaText.Unlocked.getLocal() );
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* 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.waila.part;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
/**
|
||||
* Tracer for players hitting blocks
|
||||
*
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class Tracer
|
||||
{
|
||||
/**
|
||||
* Trace view of players to blocks.
|
||||
* Ignore all which are out of reach.
|
||||
*
|
||||
* @param world word of block
|
||||
* @param player player viewing block
|
||||
* @param x x pos of block
|
||||
* @param y y pos of block
|
||||
* @param z z pos of block
|
||||
*
|
||||
* @return trace movement. Can be null
|
||||
*/
|
||||
public MovingObjectPosition retraceBlock( World world, EntityPlayerMP player, int x, int y, int z )
|
||||
{
|
||||
Block block = world.getBlock( x, y, z );
|
||||
|
||||
Vec3 headVec = this.getCorrectedHeadVec( player );
|
||||
Vec3 lookVec = player.getLook( 1.0F );
|
||||
double reach = this.getBlockReachDistance_server( player );
|
||||
Vec3 endVec = headVec.addVector( lookVec.xCoord * reach, lookVec.yCoord * reach, lookVec.zCoord * reach );
|
||||
|
||||
return block.collisionRayTrace( world, x, y, z, headVec, endVec );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the view point of a player
|
||||
*
|
||||
* @param player player with head
|
||||
*
|
||||
* @return view point of player
|
||||
*/
|
||||
private Vec3 getCorrectedHeadVec( EntityPlayer player )
|
||||
{
|
||||
Vec3 v = Vec3.createVectorHelper( player.posX, player.posY, player.posZ );
|
||||
if ( player.worldObj.isRemote )
|
||||
{
|
||||
//compatibility with eye height changing mods
|
||||
v.yCoord += player.getEyeHeight() - player.getDefaultEyeHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
v.yCoord += player.getEyeHeight();
|
||||
if ( player instanceof EntityPlayerMP && player.isSneaking() )
|
||||
v.yCoord -= 0.08;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player multi-player player
|
||||
*
|
||||
* @return block reach distance of player
|
||||
*/
|
||||
private double getBlockReachDistance_server( EntityPlayerMP player )
|
||||
{
|
||||
return player.theItemInWorldManager.getBlockReachDistance();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* 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.waila.tile;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.integration.modules.waila.BaseWailaDataProvider;
|
||||
import appeng.tile.misc.TileCharger;
|
||||
|
||||
|
||||
/**
|
||||
* Charger provider for WAILA
|
||||
*
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class ChargerWailaDataProvider extends BaseWailaDataProvider
|
||||
{
|
||||
/**
|
||||
* Displays the holding item and its tooltip
|
||||
*
|
||||
* @param itemStack stack of charger
|
||||
* @param currentToolTip unmodified tooltip
|
||||
* @param accessor wrapper information
|
||||
* @param config config option
|
||||
*
|
||||
* @return modified tooltip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
if ( te instanceof TileCharger )
|
||||
{
|
||||
final TileCharger charger = ( TileCharger ) te;
|
||||
final IInventory chargerInventory = charger.getInternalInventory();
|
||||
final ItemStack chargingItem = chargerInventory.getStackInSlot( 0 );
|
||||
|
||||
if ( chargingItem != null )
|
||||
{
|
||||
final String currentInventory = chargingItem.getDisplayName();
|
||||
final EntityPlayer player = accessor.getPlayer();
|
||||
|
||||
currentToolTip.add( WailaText.Contains + ": " + currentInventory );
|
||||
chargingItem.getItem().addInformation( chargingItem, player, currentToolTip, true );
|
||||
}
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* 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.waila.tile;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.integration.modules.waila.BaseWailaDataProvider;
|
||||
import appeng.tile.crafting.TileCraftingMonitorTile;
|
||||
|
||||
|
||||
/**
|
||||
* Crafting-monitor provider for WAILA
|
||||
*
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class CraftingMonitorWailaDataProvider extends BaseWailaDataProvider
|
||||
{
|
||||
/**
|
||||
* Displays the item currently crafted by the CPU cluster
|
||||
*
|
||||
* @param itemStack stack of crafting monitor
|
||||
* @param currentToolTip unmodified tooltip
|
||||
* @param accessor information wrapper
|
||||
* @param config config option
|
||||
*
|
||||
* @return modified tooltip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
if ( te instanceof TileCraftingMonitorTile )
|
||||
{
|
||||
final TileCraftingMonitorTile monitor = ( TileCraftingMonitorTile ) te;
|
||||
final IAEItemStack displayStack = monitor.getJobProgress();
|
||||
|
||||
if ( displayStack != null )
|
||||
{
|
||||
final String currentCrafting = displayStack.getItemStack().getDisplayName();
|
||||
|
||||
currentToolTip.add( WailaText.Crafting.getLocal() + ": " + currentCrafting );
|
||||
}
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* 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.waila.tile;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.integration.modules.waila.BaseWailaDataProvider;
|
||||
|
||||
|
||||
/**
|
||||
* Power state provider for WAILA
|
||||
*
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class PowerStateWailaDataProvider extends BaseWailaDataProvider
|
||||
{
|
||||
/**
|
||||
* Adds state to the tooltip
|
||||
*
|
||||
* @param itemStack stack of power state
|
||||
* @param currentToolTip to be added to tooltip
|
||||
* @param accessor wrapper for various information
|
||||
* @param config config settings
|
||||
*
|
||||
* @return modified tooltip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
|
||||
if ( te instanceof IPowerChannelState )
|
||||
{
|
||||
final IPowerChannelState state = ( IPowerChannelState ) te;
|
||||
|
||||
final boolean isActive = state.isActive();
|
||||
final boolean isPowered = state.isPowered();
|
||||
|
||||
if ( isActive && isPowered )
|
||||
{
|
||||
currentToolTip.add( WailaText.DeviceOnline.getLocal() );
|
||||
}
|
||||
else if ( isPowered )
|
||||
{
|
||||
currentToolTip.add( WailaText.DeviceMissingChannel.getLocal() );
|
||||
}
|
||||
else
|
||||
{
|
||||
currentToolTip.add( WailaText.DeviceOffline.getLocal() );
|
||||
}
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
* 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.waila.tile;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import gnu.trove.map.TObjectLongMap;
|
||||
import gnu.trove.map.hash.TObjectLongHashMap;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.networking.energy.IAEPowerStorage;
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.integration.modules.waila.BaseWailaDataProvider;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
/**
|
||||
* Power storage provider for WAILA
|
||||
*
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class PowerStorageWailaDataProvider extends BaseWailaDataProvider
|
||||
{
|
||||
/**
|
||||
* Power key used for the transferred {@link net.minecraft.nbt.NBTTagCompound}
|
||||
*/
|
||||
private static final String ID_CURRENT_POWER = "currentPower";
|
||||
|
||||
/**
|
||||
* Used cache for power if the power was not transmitted through the server.
|
||||
* <p/>
|
||||
* This is useful, when a player just started to look at a tile
|
||||
* and thus just requested the new information from the server.
|
||||
* <p/>
|
||||
* The cache will be updated from the server.
|
||||
*/
|
||||
private final TObjectLongMap<TileEntity> cache = new TObjectLongHashMap<TileEntity>();
|
||||
|
||||
/**
|
||||
* Adds the current and max power to the tool tip
|
||||
* Will ignore if the tile has an energy buffer ( > 0 )
|
||||
*
|
||||
* @param itemStack stack of power storage
|
||||
* @param currentToolTip current tool tip
|
||||
* @param accessor wrapper for various world information
|
||||
* @param config config to react to various settings
|
||||
*
|
||||
* @return modified tool tip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody( ItemStack itemStack, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config )
|
||||
{
|
||||
final TileEntity te = accessor.getTileEntity();
|
||||
if ( te instanceof IAEPowerStorage )
|
||||
{
|
||||
final IAEPowerStorage storage = ( IAEPowerStorage ) te;
|
||||
|
||||
final double maxPower = storage.getAEMaxPower();
|
||||
if ( maxPower > 0 )
|
||||
{
|
||||
final NBTTagCompound tag = accessor.getNBTData();
|
||||
|
||||
final long internalCurrentPower = this.getInternalCurrentPower( tag, te );
|
||||
final long internalMaxPower = ( long ) ( 100 * maxPower );
|
||||
|
||||
final String formatCurrentPower = Platform.formatPowerLong( internalCurrentPower, false );
|
||||
final String formatMaxPower = Platform.formatPowerLong( internalMaxPower, false );
|
||||
|
||||
currentToolTip.add( WailaText.Contains + ": " + formatCurrentPower + " / " + formatMaxPower );
|
||||
}
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on server to transfer information from server to client.
|
||||
* <p/>
|
||||
* If the {@link net.minecraft.tileentity.TileEntity} is a {@link appeng.api.networking.energy.IAEPowerStorage},
|
||||
* it writes the power information to the {@code #tag}
|
||||
* using the {@code #ID_CURRENT_POWER} key.
|
||||
*
|
||||
* @param player player looking at the power storage
|
||||
* @param te power storage
|
||||
* @param tag transferred tag which is send to the client
|
||||
* @param world world of the power storage
|
||||
* @param x x pos of the power storage
|
||||
* @param y y pos of the power storage
|
||||
* @param z z pos of the power storage
|
||||
*
|
||||
* @return tag send to the client
|
||||
*/
|
||||
@Override
|
||||
public NBTTagCompound getNBTData( EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z )
|
||||
{
|
||||
if ( te instanceof IAEPowerStorage )
|
||||
{
|
||||
final IAEPowerStorage storage = ( IAEPowerStorage ) te;
|
||||
|
||||
if ( storage.getAEMaxPower() > 0 )
|
||||
{
|
||||
final long internalCurrentPower = ( long ) ( 100 * storage.getAECurrentPower() );
|
||||
|
||||
tag.setLong( ID_CURRENT_POWER, internalCurrentPower );
|
||||
}
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the current power.
|
||||
* <p/>
|
||||
* If the client received power information on the server, they are used,
|
||||
* else if the cache contains a previous stored value, this will be used.
|
||||
* Default value is 0.
|
||||
*
|
||||
* @param te te to be looked at
|
||||
* @param tag tag maybe containing the channel information
|
||||
*
|
||||
* @return used channels on the cable
|
||||
*/
|
||||
private long getInternalCurrentPower( NBTTagCompound tag, TileEntity te )
|
||||
{
|
||||
final long internalCurrentPower;
|
||||
|
||||
if ( tag.hasKey( ID_CURRENT_POWER ) )
|
||||
{
|
||||
internalCurrentPower = tag.getLong( ID_CURRENT_POWER );
|
||||
this.cache.put( te, internalCurrentPower );
|
||||
}
|
||||
else if ( this.cache.containsKey( te ) )
|
||||
{
|
||||
internalCurrentPower = this.cache.get( te );
|
||||
}
|
||||
else
|
||||
{
|
||||
internalCurrentPower = 0;
|
||||
}
|
||||
|
||||
return internalCurrentPower;
|
||||
}
|
||||
}
|
|
@ -18,72 +18,71 @@
|
|||
|
||||
package appeng.tile.networking;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkPowerTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
|
||||
|
||||
public class TileEnergyAcceptor extends AENetworkPowerTile
|
||||
{
|
||||
|
||||
final static AppEngInternalInventory INTERNAL_INVENTORY = new AppEngInternalInventory( null, 0 );
|
||||
final int[] sides = new int[] { };
|
||||
final static AppEngInternalInventory inv = new AppEngInternalInventory( null, 0 );
|
||||
|
||||
public TileEnergyAcceptor()
|
||||
{
|
||||
this.gridProxy.setIdlePowerUsage( 0.0 );
|
||||
this.internalMaxPower = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.TICK)
|
||||
public void Tick_TileEnergyAcceptor()
|
||||
@Override
|
||||
public void readFromNBT_AENetwork( NBTTagCompound data )
|
||||
{
|
||||
if ( this.internalCurrentPower > 0 )
|
||||
{
|
||||
try
|
||||
{
|
||||
IEnergyGrid eg = this.gridProxy.getEnergy();
|
||||
double powerRequested = this.internalCurrentPower - eg.injectPower( this.internalCurrentPower, Actionable.SIMULATE );
|
||||
|
||||
if ( powerRequested > 0 )
|
||||
{
|
||||
eg.injectPower( this.extractAEPower( powerRequested, Actionable.MODULATE, PowerMultiplier.ONE ), Actionable.MODULATE );
|
||||
}
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// null net, probably bad.
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Does nothing here since the NBT tag in the parent is not needed anymore
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double getFunnelPowerDemand(double maxRequired)
|
||||
public void writeToNBT_AENetwork( NBTTagCompound data )
|
||||
{
|
||||
/**
|
||||
* Does nothing here since the NBT tag in the parent is not needed anymore
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double getFunnelPowerDemand( double maxRequired )
|
||||
{
|
||||
try
|
||||
{
|
||||
IEnergyGrid grid = this.gridProxy.getEnergy();
|
||||
return grid.getEnergyDemand( maxRequired );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch ( GridAccessException e )
|
||||
{
|
||||
return super.getFunnelPowerDemand( maxRequired );
|
||||
return this.internalMaxPower;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double funnelPowerIntoStorage(double newPower, Actionable mode)
|
||||
protected double funnelPowerIntoStorage( double newPower, Actionable mode )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -93,33 +92,27 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
|
|||
return leftOver;
|
||||
return 0.0;
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch ( GridAccessException e )
|
||||
{
|
||||
return super.funnelPowerIntoStorage( newPower, mode );
|
||||
}
|
||||
}
|
||||
|
||||
public TileEnergyAcceptor() {
|
||||
this.gridProxy.setIdlePowerUsage( 0.0 );
|
||||
this.internalMaxPower = 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInternalInventory()
|
||||
{
|
||||
return inv;
|
||||
return INTERNAL_INVENTORY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added)
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide(ForgeDirection side)
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection side )
|
||||
{
|
||||
return this.sides;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -314,6 +314,7 @@ gui.appliedenergistics2.Red=Red
|
|||
gui.appliedenergistics2.Black=Black
|
||||
gui.appliedenergistics2.Fluix=Fluix
|
||||
|
||||
waila.appliedenergistics2.Crafting=Crafting
|
||||
waila.appliedenergistics2.DeviceOnline=Device Online
|
||||
waila.appliedenergistics2.DeviceOffline=Device Offline
|
||||
waila.appliedenergistics2.DeviceMissingChannel=Device Missing Channel
|
||||
|
|
Loading…
Reference in a new issue