2013-12-27 23:59:59 +01:00
|
|
|
package appeng.items.tools.powered;
|
|
|
|
|
|
|
|
import java.util.EnumSet;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.util.StatCollector;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import appeng.api.AEApi;
|
2014-02-17 01:50:25 +01:00
|
|
|
import appeng.api.config.Settings;
|
|
|
|
import appeng.api.config.SortDir;
|
|
|
|
import appeng.api.config.SortOrder;
|
|
|
|
import appeng.api.config.ViewItems;
|
2014-02-02 08:32:10 +01:00
|
|
|
import appeng.api.features.IWirelessTermHandler;
|
2014-02-17 01:50:25 +01:00
|
|
|
import appeng.api.util.IConfigManager;
|
2014-02-09 06:08:27 +01:00
|
|
|
import appeng.core.AEConfig;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.core.features.AEFeature;
|
2014-01-30 19:54:32 +01:00
|
|
|
import appeng.core.localization.GuiText;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
2014-02-17 01:50:25 +01:00
|
|
|
import appeng.util.ConfigManager;
|
|
|
|
import appeng.util.IConfigManagerHost;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.util.Platform;
|
|
|
|
|
2014-02-02 08:32:10 +01:00
|
|
|
public class ToolWirelessTerminal extends AEBasePoweredItem implements IWirelessTermHandler
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
public ToolWirelessTerminal() {
|
|
|
|
super( ToolWirelessTerminal.class, null );
|
|
|
|
setfeature( EnumSet.of( AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools ) );
|
2014-02-09 06:08:27 +01:00
|
|
|
maxStoredPower = AEConfig.instance.wireless_battery;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack onItemRightClick(ItemStack item, World w, EntityPlayer player)
|
|
|
|
{
|
|
|
|
AEApi.instance().registries().wireless().OpenWirelessTermainlGui( item, w, player );
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void addInformation(ItemStack i, EntityPlayer p, List l, boolean b)
|
|
|
|
{
|
2014-02-02 08:32:10 +01:00
|
|
|
super.addInformation( i, p, l, b );
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
if ( i.hasTagCompound() )
|
|
|
|
{
|
|
|
|
NBTTagCompound tag = Platform.openNbtData( i );
|
|
|
|
if ( tag != null )
|
|
|
|
{
|
2014-02-02 08:32:10 +01:00
|
|
|
String encKey = tag.getString( "encryptionKey" );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
if ( encKey == null || encKey == "" )
|
2014-01-30 19:54:32 +01:00
|
|
|
l.add( GuiText.Unlinked.getLocal() );
|
2013-12-27 23:59:59 +01:00
|
|
|
else
|
2014-01-30 19:54:32 +01:00
|
|
|
l.add( GuiText.Linked.getLocal() );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
l.add( StatCollector.translateToLocal( "AppEng.GuiITooltip.Unlinked" ) );
|
|
|
|
}
|
|
|
|
|
2014-02-02 08:32:10 +01:00
|
|
|
@Override
|
|
|
|
public boolean canHandle(ItemStack is)
|
|
|
|
{
|
2014-05-10 07:00:02 +02:00
|
|
|
return AEApi.instance().items().itemWirelessTerminal.sameAsStack( is );
|
2014-02-02 08:32:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-03 05:33:50 +01:00
|
|
|
public boolean usePower(EntityPlayer player, double amount, ItemStack is)
|
2014-02-02 08:32:10 +01:00
|
|
|
{
|
|
|
|
return this.extractAEPower( is, amount ) >= amount - 0.5;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-03 05:33:50 +01:00
|
|
|
public boolean hasPower(EntityPlayer player, double amt, ItemStack is)
|
2014-02-02 08:32:10 +01:00
|
|
|
{
|
2014-02-03 05:33:50 +01:00
|
|
|
return getAECurrentPower( is ) >= amt;
|
2014-02-02 08:32:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getEncryptionKey(ItemStack item)
|
|
|
|
{
|
|
|
|
NBTTagCompound tag = Platform.openNbtData( item );
|
|
|
|
return tag.getString( "encryptionKey" );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setEncryptionKey(ItemStack item, String encKey, String name)
|
|
|
|
{
|
|
|
|
NBTTagCompound tag = Platform.openNbtData( item );
|
|
|
|
tag.setString( "encryptionKey", encKey );
|
|
|
|
tag.setString( "name", name );
|
|
|
|
}
|
|
|
|
|
2014-02-17 01:50:25 +01:00
|
|
|
@Override
|
|
|
|
public IConfigManager getConfigManager(final ItemStack target)
|
|
|
|
{
|
|
|
|
final ConfigManager out = new ConfigManager( new IConfigManagerHost() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
|
|
|
{
|
|
|
|
NBTTagCompound data = Platform.openNbtData( target );
|
|
|
|
manager.writeToNBT( data );
|
|
|
|
}
|
|
|
|
|
|
|
|
} );
|
|
|
|
|
2014-02-17 01:51:19 +01:00
|
|
|
out.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
2014-02-17 01:50:25 +01:00
|
|
|
out.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
|
|
|
out.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
|
|
|
|
|
|
|
out.readFromNBT( (NBTTagCompound) Platform.openNbtData( target ).copy() );
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|