2013-12-27 23:59:59 +01:00
|
|
|
package appeng.parts.reporting;
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2014-03-04 08:52:07 +01:00
|
|
|
import net.minecraft.inventory.IInventory;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2014-02-17 01:50:25 +01:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.util.Vec3;
|
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-03-04 08:52:07 +01:00
|
|
|
import appeng.api.implementations.tiles.IViewCellStorage;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.storage.IMEMonitor;
|
2014-02-17 01:50:25 +01:00
|
|
|
import appeng.api.storage.ITerminalHost;
|
|
|
|
import appeng.api.util.IConfigManager;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.client.texture.CableBusTextures;
|
|
|
|
import appeng.core.sync.GuiBridge;
|
|
|
|
import appeng.me.GridAccessException;
|
2014-03-04 08:52:07 +01:00
|
|
|
import appeng.tile.inventory.AppEngInternalInventory;
|
|
|
|
import appeng.tile.inventory.IAEAppEngInventory;
|
|
|
|
import appeng.tile.inventory.InvOperation;
|
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-03-04 08:52:07 +01:00
|
|
|
public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigManagerHost, IViewCellStorage, IAEAppEngInventory
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
|
2014-02-17 01:50:25 +01:00
|
|
|
IConfigManager cm = new ConfigManager( this );
|
2014-03-05 04:12:23 +01:00
|
|
|
AppEngInternalInventory viewCell = new AppEngInternalInventory( this, 5 );
|
2014-02-17 01:50:25 +01:00
|
|
|
|
2014-02-05 03:44:54 +01:00
|
|
|
public PartTerminal(Class clz, ItemStack is) {
|
2014-04-09 21:22:36 +02:00
|
|
|
super( clz, is,true );
|
2014-02-17 01:50:25 +01:00
|
|
|
|
|
|
|
cm.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
|
|
|
cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
|
|
|
cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void readFromNBT(NBTTagCompound data)
|
|
|
|
{
|
|
|
|
super.readFromNBT( data );
|
|
|
|
cm.readFromNBT( data );
|
2014-03-04 08:52:07 +01:00
|
|
|
viewCell.readFromNBT( data, "viewCell" );
|
2014-02-17 01:50:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeToNBT(NBTTagCompound data)
|
|
|
|
{
|
|
|
|
super.writeToNBT( data );
|
|
|
|
cm.writeToNBT( data );
|
2014-03-04 08:52:07 +01:00
|
|
|
viewCell.writeToNBT( data, "viewCell" );
|
2014-02-05 03:44:54 +01:00
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
public PartTerminal(ItemStack is) {
|
2014-04-09 21:22:36 +02:00
|
|
|
super( PartTerminal.class, is,true );
|
2013-12-27 23:59:59 +01:00
|
|
|
frontBright = CableBusTextures.PartTerminal_Bright;
|
|
|
|
frontColored = CableBusTextures.PartTerminal_Colored;
|
|
|
|
frontDark = CableBusTextures.PartTerminal_Dark;
|
2014-02-22 23:14:43 +01:00
|
|
|
// frontSolid = CableBusTextures.PartTerminal_Solid;
|
2014-02-17 01:50:25 +01:00
|
|
|
|
|
|
|
cm.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
|
|
|
cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
|
|
|
cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2014-02-05 03:44:54 +01:00
|
|
|
public GuiBridge getGui()
|
|
|
|
{
|
|
|
|
return GuiBridge.GUI_ME;
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@Override
|
2014-02-20 06:18:49 +01:00
|
|
|
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
if ( !player.isSneaking() )
|
|
|
|
{
|
|
|
|
if ( Platform.isClient() )
|
|
|
|
return true;
|
|
|
|
|
2014-03-28 05:31:06 +01:00
|
|
|
Platform.openGUI( player, getHost().getTile(), side, getGui() );
|
2014-02-03 03:30:52 +01:00
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IMEMonitor getFluidInventory()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return proxy.getStorage().getFluidInventory();
|
|
|
|
}
|
|
|
|
catch (GridAccessException e)
|
|
|
|
{
|
|
|
|
// err nope?
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IMEMonitor getItemInventory()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return proxy.getStorage().getItemInventory();
|
|
|
|
}
|
|
|
|
catch (GridAccessException e)
|
|
|
|
{
|
|
|
|
// err nope?
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2014-02-17 01:50:25 +01:00
|
|
|
@Override
|
|
|
|
public IConfigManager getConfigManager()
|
|
|
|
{
|
|
|
|
return cm;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-03-04 08:52:07 +01:00
|
|
|
@Override
|
|
|
|
public IInventory getViewCellStorage()
|
|
|
|
{
|
|
|
|
return viewCell;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
|
|
|
{
|
|
|
|
host.markForSave();
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|