Re-Added original Waila integration and fixed compilation issues against new API.

This commit is contained in:
Sebastian Hartte 2016-10-02 00:35:38 +02:00
parent b4ab401f98
commit 895a1a18d8
18 changed files with 1551 additions and 3 deletions

View file

@ -100,6 +100,7 @@ configurations {
dependencies {
// installable
mods "mcp.mobius.waila:Waila:${waila_version}_1.9.4:dev"
// mods "mcp.mobius.jabba:Jabba:${jabba_version}_${minecraft_version}:dev"
// mods "codechicken:EnderStorage:${minecraft_version}-${enderstorage_version}:dev"
// mods "codechicken:Translocator:${minecraft_version}-${translocator_version}:dev"
@ -140,8 +141,9 @@ dependencies {
// compile(group: 'api', name: 'railcraft', version: "${api_railcraft_version}")
// compile(group: 'api', name: 'rf', version: "${api_rf_version}")
// compile against the JEI API
compile "mezz.jei:jei_1.10.2:${jei_version}:api"
// compile against various APIs
compileOnly "mezz.jei:jei_1.10.2:${jei_version}:api"
compileOnly "mcp.mobius.waila:Waila:${waila_version}_1.9.4:dev"
// at runtime, use the full JEI jar
runtime "mezz.jei:jei_1.10.2:${jei_version}"

View file

@ -5,7 +5,6 @@ idea {
inheritOutputDirs = true
// excludes integration due to not being available upon port
excludeDirs += file('src/main/java/appeng/integration/modules/')
excludeDirs += file('src/main/java/appeng/fmp/')
excludeDirs += file('src/main/java/appeng/parts/layers/')
}

View file

@ -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;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.IWailaRegistrar;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
import appeng.integration.modules.waila.PartWailaDataProvider;
import appeng.integration.modules.waila.TileWailaDataProvider;
import appeng.tile.AEBaseTile;
public class Waila implements IIntegrationModule
{
@Reflected
public static Waila instance;
@Reflected
public Waila()
{
IntegrationHelper.testClassExistence( this, mcp.mobius.waila.api.IWailaDataProvider.class );
IntegrationHelper.testClassExistence( this, mcp.mobius.waila.api.IWailaRegistrar.class );
IntegrationHelper.testClassExistence( this, mcp.mobius.waila.api.IWailaConfigHandler.class );
IntegrationHelper.testClassExistence( this, mcp.mobius.waila.api.IWailaDataAccessor.class );
IntegrationHelper.testClassExistence( this, mcp.mobius.waila.api.ITaggedList.class );
}
public static void register( final IWailaRegistrar registrar )
{
final IWailaDataProvider partHost = new PartWailaDataProvider();
registrar.registerStackProvider( partHost, AEBaseTile.class );
registrar.registerBodyProvider( partHost, AEBaseTile.class );
registrar.registerNBTProvider( partHost, AEBaseTile.class );
final IWailaDataProvider tile = new TileWailaDataProvider();
registrar.registerBodyProvider( tile, AEBaseTile.class );
registrar.registerNBTProvider( tile, AEBaseTile.class );
}
@Override
public void init() throws Throwable
{
FMLInterModComms.sendMessage( "Waila", "register", this.getClass().getName() + ".register" );
}
@Override
public void postInit()
{
}
}

View file

@ -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.math.BlockPos;
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( final IWailaDataAccessor accessor, final IWailaConfigHandler config )
{
return null;
}
@Override
public List<String> getWailaHead( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
{
return currentToolTip;
}
@Override
public List<String> getWailaBody( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
{
return currentToolTip;
}
@Override
public List<String> getWailaTail( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
{
return currentToolTip;
}
@Override
public NBTTagCompound getNBTData( EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos )
{
return tag;
}
}

View file

@ -0,0 +1,196 @@
/*
* 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 java.util.Optional;
import com.google.common.collect.Lists;
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.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
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.PartStackWailaDataProvider;
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 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();
final IPartWailaDataProvider partStack = new PartStackWailaDataProvider();
this.providers = Lists.newArrayList( channel, storageMonitor, powerState, partStack );
}
@Override
public ItemStack getWailaStack( final IWailaDataAccessor accessor, final IWailaConfigHandler config )
{
final TileEntity te = accessor.getTileEntity();
final RayTraceResult mop = accessor.getMOP();
final Optional<IPart> maybePart = this.accessor.getMaybePart( te, mop );
if( maybePart.isPresent() )
{
final IPart part = maybePart.get();
ItemStack wailaStack = null;
for( final IPartWailaDataProvider provider : this.providers )
{
wailaStack = provider.getWailaStack( part, config, wailaStack );
}
return wailaStack;
}
return null;
}
@Override
public List<String> getWailaHead( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
{
final TileEntity te = accessor.getTileEntity();
final RayTraceResult mop = accessor.getMOP();
final Optional<IPart> maybePart = this.accessor.getMaybePart( te, mop );
if( maybePart.isPresent() )
{
final IPart part = maybePart.get();
for( final IPartWailaDataProvider provider : this.providers )
{
provider.getWailaHead( part, currentToolTip, accessor, config );
}
}
return currentToolTip;
}
@Override
public List<String> getWailaBody( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
{
final TileEntity te = accessor.getTileEntity();
final RayTraceResult mop = accessor.getMOP();
final Optional<IPart> maybePart = this.accessor.getMaybePart( te, mop );
if( maybePart.isPresent() )
{
final IPart part = maybePart.get();
for( final IPartWailaDataProvider provider : this.providers )
{
provider.getWailaBody( part, currentToolTip, accessor, config );
}
}
return currentToolTip;
}
@Override
public List<String> getWailaTail( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
{
final TileEntity te = accessor.getTileEntity();
final RayTraceResult mop = accessor.getMOP();
final Optional<IPart> maybePart = this.accessor.getMaybePart( te, mop );
if( maybePart.isPresent() )
{
final IPart part = maybePart.get();
for( final IPartWailaDataProvider provider : this.providers )
{
provider.getWailaTail( part, currentToolTip, accessor, config );
}
}
return currentToolTip;
}
@Override
public NBTTagCompound getNBTData( final EntityPlayerMP player, final TileEntity te, final NBTTagCompound tag, final World world, BlockPos pos )
{
final RayTraceResult mop = this.tracer.retraceBlock( world, player, pos );
if( mop != null )
{
final Optional<IPart> maybePart = this.accessor.getMaybePart( te, mop );
if( maybePart.isPresent() )
{
final IPart part = maybePart.get();
for( final IPartWailaDataProvider provider : this.providers )
{
provider.getNBTData( player, part, te, tag, world, pos );
}
}
}
return tag;
}
}

View file

@ -0,0 +1,119 @@
/*
* 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 com.google.common.collect.Lists;
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.math.BlockPos;
import net.minecraft.world.World;
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( final IWailaDataAccessor accessor, final IWailaConfigHandler config )
{
return null;
}
@Override
public List<String> getWailaHead( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
{
for( final IWailaDataProvider provider : this.providers )
{
provider.getWailaHead( itemStack, currentToolTip, accessor, config );
}
return currentToolTip;
}
@Override
public List<String> getWailaBody( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
{
for( final IWailaDataProvider provider : this.providers )
{
provider.getWailaBody( itemStack, currentToolTip, accessor, config );
}
return currentToolTip;
}
@Override
public List<String> getWailaTail( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
{
for( final IWailaDataProvider provider : this.providers )
{
provider.getWailaTail( itemStack, currentToolTip, accessor, config );
}
return currentToolTip;
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos)
{
for( final IWailaDataProvider provider : this.providers )
{
provider.getNBTData( player, te, tag, world, pos );
}
return tag;
}
}

View file

@ -0,0 +1,75 @@
/*
* 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.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
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 ItemStack getWailaStack( final IPart part, final IWailaConfigHandler config, final ItemStack partStack )
{
return null;
}
@Override
public List<String> getWailaHead( final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
{
return currentToolTip;
}
@Override
public List<String> getWailaBody( final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
{
return currentToolTip;
}
@Override
public List<String> getWailaTail( final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
{
return currentToolTip;
}
@Override
public NBTTagCompound getNBTData( EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos )
{
return tag;
}
}

View file

@ -0,0 +1,159 @@
/*
* 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.util.math.BlockPos;
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.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( final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final 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 );
final String formattedToolTip = String.format( WailaText.Channels.getLocal(), usedChannels, maxChannels );
currentToolTip.add( formattedToolTip );
}
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( final IPart part, final NBTTagCompound tag, final 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 pos pos of the part
*
* @return tag send to the client
*/
@Override
public NBTTagCompound getNBTData( EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos )
{
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;
}
}

View file

@ -0,0 +1,56 @@
/*
* 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.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
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
{
ItemStack getWailaStack( IPart part, IWailaConfigHandler config, ItemStack partStack );
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, BlockPos pos );
}

View file

@ -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.waila.part;
import java.util.Optional;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
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 IPartHost} with {@link BlockPos}.
* <p/>
* You can derive the looked at {@link IPart} by doing that. If a facade is being looked at, it is
* defined as being absent.
*
* @param te being looked at {@link TileEntity}
* @param mop type of ray-trace
*
* @return maybe the looked at {@link IPart}
*/
public Optional<IPart> getMaybePart( final TileEntity te, final RayTraceResult mop )
{
if( te instanceof IPartHost )
{
BlockPos pos = mop.getBlockPos();
final Vec3d position = mop.hitVec.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();
}
}

View file

@ -0,0 +1,47 @@
/*
* 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.waila.part;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.api.IWailaConfigHandler;
import appeng.api.parts.IPart;
import appeng.api.parts.PartItemStack;
/**
* Part ItemStack provider for WAILA
*
* @author TheJulianJES
* @version rv2
* @since rv2
*/
public class PartStackWailaDataProvider extends BasePartWailaDataProvider
{
@Override
public ItemStack getWailaStack( final IPart part, final IWailaConfigHandler config, ItemStack partStack )
{
partStack = part.getItemStack( PartItemStack.PICK );
return partStack;
}
}

View file

@ -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( final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final 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( final boolean isActive, final 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;
}
}

View file

@ -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( final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final 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 )
{
final IAEItemStack ais = (IAEItemStack) displayed;
currentToolTip.add( WailaText.Showing.getLocal() + ": " + ais.getItemStack().getDisplayName() );
}
else if( displayed instanceof IAEFluidStack )
{
final 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;
}
}

View file

@ -0,0 +1,100 @@
/*
* 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.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
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 pos pos of block
*
* @return trace movement. Can be null
*/
public RayTraceResult retraceBlock( final World world, final EntityPlayerMP player, BlockPos pos )
{
IBlockState blockState = world.getBlockState( pos );
final Vec3d headVec = this.getCorrectedHeadVec( player );
final Vec3d lookVec = player.getLook( 1.0F );
final double reach = this.getBlockReachDistance_server( player );
final Vec3d endVec = headVec.addVector( lookVec.xCoord * reach, lookVec.yCoord * reach, lookVec.zCoord * reach );
return blockState.collisionRayTrace( world, pos, headVec, endVec );
}
/**
* Gets the view point of a player
*
* @param player player with head
*
* @return view point of player
*/
private Vec3d getCorrectedHeadVec( final EntityPlayer player )
{
double x = player.posX;
double y = player.posY;
double z = player.posZ;
if( player.worldObj.isRemote )
{
// compatibility with eye height changing mods
y += player.getEyeHeight() - player.getDefaultEyeHeight();
}
else
{
y += player.getEyeHeight();
if( player instanceof EntityPlayerMP && player.isSneaking() )
{
y -= 0.08;
}
}
return new Vec3d( x, y, z );
}
/**
* @param player multi-player player
*
* @return block reach distance of player
*/
private double getBlockReachDistance_server( final EntityPlayerMP player )
{
return player.interactionManager.getBlockReachDistance();
}
}

View file

@ -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( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final 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;
}
}

View file

@ -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( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final 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;
}
}

View file

@ -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( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final 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;
}
}

View file

@ -0,0 +1,170 @@
/*
* 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.util.math.BlockPos;
import net.minecraft.world.World;
import gnu.trove.map.TObjectLongMap;
import gnu.trove.map.hash.TObjectLongHashMap;
import mcp.mobius.waila.api.ITaggedList;
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 ( &gt; 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( final ItemStack itemStack, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
{
// Removes RF tooltip on WAILA 1.5.9+
( (ITaggedList<String, String>) currentToolTip ).removeEntries( "RFEnergyStorage" );
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.getLocal() + ": " + 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 pos pos of the power storage
*
* @return tag send to the client
*/
@Override
public NBTTagCompound getNBTData( EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos )
{
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( final NBTTagCompound tag, final 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;
}
}