2013-12-27 23:59:59 +01:00
|
|
|
package appeng.parts.misc;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
2014-01-24 17:35:58 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2014-01-27 05:00:36 +01:00
|
|
|
import net.minecraft.inventory.IInventory;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2014-01-24 17:35:58 +01:00
|
|
|
import net.minecraft.util.Vec3;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.AEApi;
|
2014-01-24 17:35:58 +01:00
|
|
|
import appeng.api.config.AccessRestriction;
|
|
|
|
import appeng.api.config.FuzzyMode;
|
2014-01-27 05:00:36 +01:00
|
|
|
import appeng.api.config.IncludeExclude;
|
2014-01-24 17:35:58 +01:00
|
|
|
import appeng.api.config.Settings;
|
2014-08-13 07:32:43 +02:00
|
|
|
import appeng.api.config.StorageFilter;
|
2014-01-27 05:00:36 +01:00
|
|
|
import appeng.api.config.Upgrades;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.networking.IGridNode;
|
|
|
|
import appeng.api.networking.events.MENetworkCellArrayUpdate;
|
2014-02-03 03:30:52 +01:00
|
|
|
import appeng.api.networking.events.MENetworkChannelsChanged;
|
|
|
|
import appeng.api.networking.events.MENetworkEventSubscribe;
|
2014-03-20 02:51:41 +01:00
|
|
|
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
2014-01-05 09:43:49 +01:00
|
|
|
import appeng.api.networking.security.BaseActionSource;
|
|
|
|
import appeng.api.networking.security.MachineSource;
|
2014-06-27 07:44:56 +02:00
|
|
|
import appeng.api.networking.storage.IBaseMonitor;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.networking.ticking.IGridTickable;
|
|
|
|
import appeng.api.networking.ticking.ITickManager;
|
|
|
|
import appeng.api.networking.ticking.TickRateModulation;
|
|
|
|
import appeng.api.networking.ticking.TickingRequest;
|
2014-09-20 22:20:53 +02:00
|
|
|
import appeng.api.parts.IPartCollisionHelper;
|
2014-09-14 07:02:02 +02:00
|
|
|
import appeng.api.parts.IPartHost;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.parts.IPartRenderHelper;
|
|
|
|
import appeng.api.storage.ICellContainer;
|
|
|
|
import appeng.api.storage.IExternalStorageHandler;
|
|
|
|
import appeng.api.storage.IMEInventory;
|
|
|
|
import appeng.api.storage.IMEInventoryHandler;
|
|
|
|
import appeng.api.storage.IMEMonitor;
|
2014-02-12 17:35:42 +01:00
|
|
|
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.storage.StorageChannel;
|
|
|
|
import appeng.api.storage.data.IAEItemStack;
|
2014-01-27 05:00:36 +01:00
|
|
|
import appeng.api.storage.data.IItemList;
|
2014-02-17 01:50:25 +01:00
|
|
|
import appeng.api.util.IConfigManager;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.client.texture.CableBusTextures;
|
2014-03-17 20:59:50 +01:00
|
|
|
import appeng.core.settings.TickRates;
|
2014-09-14 07:02:02 +02:00
|
|
|
import appeng.core.stats.Achievements;
|
2014-01-24 17:35:58 +01:00
|
|
|
import appeng.core.sync.GuiBridge;
|
2014-09-14 07:02:02 +02:00
|
|
|
import appeng.helpers.IInterfaceHost;
|
2014-01-27 05:00:36 +01:00
|
|
|
import appeng.helpers.IPriorityHost;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.me.GridAccessException;
|
|
|
|
import appeng.me.storage.MEInventoryHandler;
|
|
|
|
import appeng.me.storage.MEMonitorIInventory;
|
2014-01-24 17:35:58 +01:00
|
|
|
import appeng.parts.automation.PartUpgradeable;
|
2014-01-27 05:00:36 +01:00
|
|
|
import appeng.tile.inventory.AppEngInternalAEInventory;
|
|
|
|
import appeng.tile.inventory.InvOperation;
|
2014-04-06 08:55:24 +02:00
|
|
|
import appeng.transformer.annotations.integration.Interface;
|
|
|
|
import appeng.transformer.annotations.integration.Method;
|
2013-12-28 22:07:13 +01:00
|
|
|
import appeng.util.Platform;
|
2014-01-27 05:00:36 +01:00
|
|
|
import appeng.util.prioitylist.FuzzyPriorityList;
|
|
|
|
import appeng.util.prioitylist.PrecisePriorityList;
|
2013-12-28 22:07:13 +01:00
|
|
|
import buildcraft.api.transport.IPipeConnection;
|
|
|
|
import buildcraft.api.transport.IPipeTile.PipeType;
|
2014-02-07 06:51:19 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-04-06 08:55:24 +02:00
|
|
|
@Interface(iname = "BC", iface = "buildcraft.api.transport.IPipeConnection")
|
2014-02-12 17:35:42 +01:00
|
|
|
public class PartStorageBus extends PartUpgradeable implements IGridTickable, ICellContainer, IMEMonitorHandlerReceiver<IAEItemStack>, IPipeConnection,
|
2014-01-27 05:00:36 +01:00
|
|
|
IPriorityHost
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
int priority = 0;
|
2014-01-05 09:43:49 +01:00
|
|
|
BaseActionSource mySrc;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-01-27 05:00:36 +01:00
|
|
|
AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 );
|
|
|
|
|
2014-09-14 07:02:02 +02:00
|
|
|
public PartStorageBus(ItemStack is)
|
|
|
|
{
|
2013-12-27 23:59:59 +01:00
|
|
|
super( PartStorageBus.class, is );
|
2014-01-24 17:35:58 +01:00
|
|
|
getConfigManager().registerSetting( Settings.ACCESS, AccessRestriction.READ_WRITE );
|
|
|
|
getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
2014-08-13 07:32:43 +02:00
|
|
|
getConfigManager().registerSetting( Settings.STORAGE_FILTER, StorageFilter.EXTACTABLE_ONLY );
|
2014-01-05 09:43:49 +01:00
|
|
|
mySrc = new MachineSource( this );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
boolean cached = false;
|
|
|
|
MEMonitorIInventory monitor = null;
|
|
|
|
MEInventoryHandler handler = null;
|
|
|
|
|
|
|
|
int handlerHash = 0;
|
2014-02-03 03:30:52 +01:00
|
|
|
boolean wasActive = false;
|
|
|
|
|
2014-03-20 02:51:41 +01:00
|
|
|
@MENetworkEventSubscribe
|
|
|
|
public void powerRender(MENetworkPowerStatusChange c)
|
|
|
|
{
|
|
|
|
updateStatus();
|
|
|
|
}
|
|
|
|
|
2014-02-03 03:30:52 +01:00
|
|
|
@MENetworkEventSubscribe
|
|
|
|
public void updateChannels(MENetworkChannelsChanged chann)
|
2014-03-20 02:51:41 +01:00
|
|
|
{
|
|
|
|
updateStatus();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateStatus()
|
2014-02-03 03:30:52 +01:00
|
|
|
{
|
|
|
|
boolean currentActive = proxy.isActive();
|
|
|
|
if ( wasActive != currentActive )
|
|
|
|
{
|
|
|
|
wasActive = currentActive;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
2014-04-08 02:45:38 +02:00
|
|
|
host.markForUpdate();
|
2014-02-03 03:30:52 +01:00
|
|
|
}
|
|
|
|
catch (GridAccessException e)
|
|
|
|
{
|
|
|
|
// :P
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-01-24 17:35:58 +01:00
|
|
|
@Override
|
2014-02-20 06:18:49 +01:00
|
|
|
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
|
2014-01-24 17:35:58 +01:00
|
|
|
{
|
|
|
|
if ( !player.isSneaking() )
|
|
|
|
{
|
|
|
|
if ( Platform.isClient() )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
Platform.openGUI( player, getHost().getTile(), side, GuiBridge.GUI_STORAGEBUS );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected int getUpgradeSlots()
|
|
|
|
{
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@Override
|
|
|
|
public boolean isValid(Object verificationToken)
|
|
|
|
{
|
|
|
|
return handler == verificationToken;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-01-27 05:00:36 +01:00
|
|
|
public IInventory getInventoryByName(String name)
|
|
|
|
{
|
|
|
|
if ( name.equals( "config" ) )
|
|
|
|
return Config;
|
|
|
|
|
|
|
|
return super.getInventoryByName( name );
|
|
|
|
}
|
|
|
|
|
2014-08-01 07:44:44 +02:00
|
|
|
private byte resetCacheLogic = 0;
|
|
|
|
|
2014-01-27 05:00:36 +01:00
|
|
|
private void resetCache(boolean fullReset)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-07-29 04:53:43 +02:00
|
|
|
if ( host == null || host.getTile() == null || host.getTile().getWorldObj() == null || host.getTile().getWorldObj().isRemote )
|
2014-05-04 06:15:26 +02:00
|
|
|
return;
|
|
|
|
|
2014-08-01 07:44:44 +02:00
|
|
|
if ( fullReset )
|
|
|
|
resetCacheLogic = 2;
|
|
|
|
else
|
|
|
|
resetCacheLogic = 1;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
proxy.getTick().alertDevice( proxy.getNode() );
|
|
|
|
}
|
|
|
|
catch (GridAccessException e)
|
|
|
|
{
|
|
|
|
// :P
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void resetCache()
|
|
|
|
{
|
|
|
|
boolean fullReset = resetCacheLogic == 2;
|
|
|
|
resetCacheLogic = 0;
|
|
|
|
|
2014-05-22 04:09:13 +02:00
|
|
|
IMEInventory<IAEItemStack> in = getInternalHandler();
|
2014-05-04 02:20:54 +02:00
|
|
|
IItemList<IAEItemStack> before = AEApi.instance().storage().createItemList();
|
|
|
|
if ( in != null )
|
|
|
|
before = in.getAvailableItems( before );
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
cached = false;
|
2014-01-27 05:00:36 +01:00
|
|
|
if ( fullReset )
|
|
|
|
handlerHash = 0;
|
2014-05-04 02:20:54 +02:00
|
|
|
|
2014-05-22 04:09:13 +02:00
|
|
|
IMEInventory<IAEItemStack> out = getInternalHandler();
|
2014-07-24 06:20:16 +02:00
|
|
|
|
|
|
|
if ( monitor != null )
|
|
|
|
monitor.onTick();
|
|
|
|
|
2014-05-04 02:20:54 +02:00
|
|
|
IItemList<IAEItemStack> after = AEApi.instance().storage().createItemList();
|
|
|
|
if ( out != null )
|
|
|
|
after = out.getAvailableItems( after );
|
|
|
|
|
|
|
|
Platform.postListChanges( before, after, this, mySrc );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2014-01-27 05:00:36 +01:00
|
|
|
@Override
|
|
|
|
public void onNeighborChanged()
|
|
|
|
{
|
|
|
|
resetCache( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
|
|
|
{
|
|
|
|
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
|
|
|
|
|
|
|
if ( inv == Config )
|
|
|
|
resetCache( true );
|
|
|
|
}
|
|
|
|
|
2014-05-22 04:09:13 +02:00
|
|
|
@Override
|
|
|
|
public void upgradesChanged()
|
|
|
|
{
|
|
|
|
super.upgradesChanged();
|
|
|
|
resetCache( true );
|
|
|
|
}
|
|
|
|
|
2014-01-27 05:00:36 +01:00
|
|
|
@Override
|
2014-02-17 01:50:25 +01:00
|
|
|
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
2014-01-27 05:00:36 +01:00
|
|
|
{
|
|
|
|
resetCache( true );
|
|
|
|
host.markForSave();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setPriority(int newValue)
|
|
|
|
{
|
|
|
|
priority = newValue;
|
|
|
|
host.markForSave();
|
|
|
|
resetCache( true );
|
|
|
|
}
|
|
|
|
|
2014-05-22 04:09:13 +02:00
|
|
|
public MEInventoryHandler getInternalHandler()
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
if ( cached )
|
|
|
|
return handler;
|
|
|
|
|
|
|
|
boolean wasSleeping = monitor == null;
|
|
|
|
|
|
|
|
cached = true;
|
|
|
|
TileEntity self = getHost().getTile();
|
2014-02-09 02:34:52 +01:00
|
|
|
TileEntity target = self.getWorldObj().getTileEntity( self.xCoord + side.offsetX, self.yCoord + side.offsetY, self.zCoord + side.offsetZ );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2013-12-28 22:07:13 +01:00
|
|
|
int newHandlerHash = Platform.generateTileHash( target );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-01-03 19:28:52 +01:00
|
|
|
if ( handlerHash == newHandlerHash && handlerHash != 0 )
|
2013-12-27 23:59:59 +01:00
|
|
|
return handler;
|
|
|
|
|
2014-07-22 05:50:40 +02:00
|
|
|
try
|
|
|
|
{
|
|
|
|
// force grid to update handlers...
|
|
|
|
proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
|
|
|
}
|
|
|
|
catch (GridAccessException e)
|
|
|
|
{
|
|
|
|
// :3
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
handlerHash = newHandlerHash;
|
|
|
|
handler = null;
|
|
|
|
monitor = null;
|
|
|
|
if ( target != null )
|
|
|
|
{
|
2014-05-25 01:23:23 +02:00
|
|
|
IExternalStorageHandler esh = AEApi.instance().registries().externalStorage().getHandler( target, side.getOpposite(), StorageChannel.ITEMS, mySrc );
|
2013-12-27 23:59:59 +01:00
|
|
|
if ( esh != null )
|
|
|
|
{
|
2014-04-18 05:33:48 +02:00
|
|
|
IMEInventory inv = esh.getInventory( target, side.getOpposite(), StorageChannel.ITEMS, mySrc );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-01-05 09:43:49 +01:00
|
|
|
if ( inv instanceof MEMonitorIInventory )
|
2014-08-13 07:32:43 +02:00
|
|
|
{
|
|
|
|
MEMonitorIInventory h = (MEMonitorIInventory) inv;
|
|
|
|
h.mode = (StorageFilter) getConfigManager().getSetting( Settings.STORAGE_FILTER );
|
|
|
|
h.mySource = new MachineSource( this );
|
|
|
|
}
|
2014-01-05 09:43:49 +01:00
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
if ( inv instanceof MEMonitorIInventory )
|
|
|
|
monitor = (MEMonitorIInventory) inv;
|
|
|
|
|
|
|
|
if ( inv != null )
|
|
|
|
{
|
2014-09-14 07:02:02 +02:00
|
|
|
checkInterfaceVsStorageBus( target, side.getOpposite() );
|
|
|
|
|
2014-07-23 21:11:12 +02:00
|
|
|
handler = new MEInventoryHandler( inv, StorageChannel.ITEMS );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-01-27 05:00:36 +01:00
|
|
|
handler.myAccess = (AccessRestriction) this.getConfigManager().getSetting( Settings.ACCESS );
|
|
|
|
handler.myWhitelist = getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST;
|
|
|
|
handler.myPriority = priority;
|
|
|
|
|
2014-02-21 21:36:40 +01:00
|
|
|
IItemList<IAEItemStack> priorityList = AEApi.instance().storage().createItemList();
|
2014-01-27 05:00:36 +01:00
|
|
|
|
|
|
|
int slotsToUse = 18 + getInstalledUpgrades( Upgrades.CAPACITY ) * 9;
|
|
|
|
for (int x = 0; x < Config.getSizeInventory() && x < slotsToUse; x++)
|
|
|
|
{
|
|
|
|
IAEItemStack is = Config.getAEStackInSlot( x );
|
|
|
|
if ( is != null )
|
|
|
|
priorityList.add( is );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
|
|
|
handler.myPartitionList = new FuzzyPriorityList( priorityList, (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) );
|
|
|
|
else
|
|
|
|
handler.myPartitionList = new PrecisePriorityList( priorityList );
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
if ( inv instanceof IMEMonitor )
|
|
|
|
((IMEMonitor) inv).addListener( this, handler );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// update sleep state...
|
|
|
|
if ( wasSleeping != (monitor == null) )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
ITickManager tm = proxy.getTick();
|
|
|
|
if ( monitor == null )
|
|
|
|
tm.sleepDevice( proxy.getNode() );
|
|
|
|
else
|
|
|
|
tm.wakeDevice( proxy.getNode() );
|
|
|
|
}
|
|
|
|
catch (GridAccessException e)
|
|
|
|
{
|
|
|
|
// :(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return handler;
|
|
|
|
}
|
|
|
|
|
2014-09-14 07:02:02 +02:00
|
|
|
private void checkInterfaceVsStorageBus(TileEntity target, ForgeDirection side)
|
|
|
|
{
|
|
|
|
IInterfaceHost achiv = null;
|
|
|
|
|
|
|
|
if ( target instanceof IInterfaceHost )
|
|
|
|
achiv = (IInterfaceHost) target;
|
|
|
|
|
|
|
|
if ( target instanceof IPartHost )
|
|
|
|
{
|
|
|
|
Object part = ((IPartHost) target).getPart( side );
|
|
|
|
if ( part instanceof IInterfaceHost )
|
|
|
|
achiv = (IInterfaceHost) part;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( achiv != null )
|
|
|
|
{
|
|
|
|
Platform.addStat( achiv.getActionableNode().getPlayerID(), Achievements.Recursive.getAchivement() );
|
|
|
|
Platform.addStat( getActionableNode().getPlayerID(), Achievements.Recursive.getAchivement() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@Override
|
2014-02-07 06:51:19 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-12-27 23:59:59 +01:00
|
|
|
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
|
|
|
{
|
2014-04-04 06:31:10 +02:00
|
|
|
rh.setTexture( CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageBack.getIcon(),
|
|
|
|
is.getIconIndex(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon() );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
rh.setBounds( 3, 3, 15, 13, 13, 16 );
|
|
|
|
rh.renderInventoryBox( renderer );
|
|
|
|
|
|
|
|
rh.setBounds( 2, 2, 14, 14, 14, 15 );
|
|
|
|
rh.renderInventoryBox( renderer );
|
|
|
|
|
|
|
|
rh.setBounds( 5, 5, 12, 11, 11, 14 );
|
|
|
|
rh.renderInventoryBox( renderer );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-07 06:51:19 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-12-27 23:59:59 +01:00
|
|
|
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
|
|
|
{
|
2014-02-15 07:30:06 +01:00
|
|
|
renderCache = rh.useSimpliedRendering( x, y, z, this, renderCache );
|
2014-04-04 06:31:10 +02:00
|
|
|
rh.setTexture( CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageBack.getIcon(),
|
|
|
|
is.getIconIndex(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon() );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
rh.setBounds( 3, 3, 15, 13, 13, 16 );
|
|
|
|
rh.renderBlock( x, y, z, renderer );
|
|
|
|
|
|
|
|
rh.setBounds( 2, 2, 14, 14, 14, 15 );
|
|
|
|
rh.renderBlock( x, y, z, renderer );
|
|
|
|
|
2014-04-04 06:31:10 +02:00
|
|
|
rh.setTexture( CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageBack.getIcon(),
|
|
|
|
is.getIconIndex(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon() );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
rh.setBounds( 5, 5, 12, 11, 11, 13 );
|
|
|
|
rh.renderBlock( x, y, z, renderer );
|
|
|
|
|
|
|
|
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
|
|
|
CableBusTextures.PartMonitorBack.getIcon(), is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
|
|
|
CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
|
|
|
|
|
|
|
rh.setBounds( 5, 5, 13, 11, 11, 14 );
|
|
|
|
rh.renderBlock( x, y, z, renderer );
|
|
|
|
|
|
|
|
renderLights( x, y, z, rh, renderer );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-09-20 22:20:53 +02:00
|
|
|
public void getBoxes(IPartCollisionHelper bch)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
bch.addBox( 3, 3, 15, 13, 13, 16 );
|
|
|
|
bch.addBox( 2, 2, 14, 14, 14, 15 );
|
2014-04-11 05:54:28 +02:00
|
|
|
bch.addBox( 5, 5, 12, 11, 11, 14 );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int cableConnectionRenderTo()
|
|
|
|
{
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TickingRequest getTickingRequest(IGridNode node)
|
|
|
|
{
|
2014-08-01 07:44:44 +02:00
|
|
|
return new TickingRequest( TickRates.StorageBus.min, TickRates.StorageBus.max, monitor == null, true );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
|
|
|
|
{
|
2014-08-01 07:44:44 +02:00
|
|
|
if ( resetCacheLogic != 0 )
|
|
|
|
resetCache();
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
if ( monitor != null )
|
|
|
|
return monitor.onTick();
|
|
|
|
|
|
|
|
return TickRateModulation.SLEEP;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-01-27 05:00:36 +01:00
|
|
|
public void writeToNBT(NBTTagCompound data)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-01-27 05:00:36 +01:00
|
|
|
super.writeToNBT( data );
|
|
|
|
Config.writeToNBT( data, "config" );
|
|
|
|
data.setInteger( "priority", priority );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2014-01-27 05:00:36 +01:00
|
|
|
public void readFromNBT(NBTTagCompound data)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-01-27 05:00:36 +01:00
|
|
|
super.readFromNBT( data );
|
|
|
|
Config.readFromNBT( data, "config" );
|
|
|
|
priority = data.getInteger( "priority" );
|
2013-12-27 23:59:59 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<IMEInventoryHandler> getCellArray(StorageChannel channel)
|
|
|
|
{
|
2014-02-06 05:36:10 +01:00
|
|
|
if ( channel == StorageChannel.ITEMS )
|
|
|
|
{
|
2014-05-22 04:09:13 +02:00
|
|
|
IMEInventoryHandler out = proxy.isActive() ? getInternalHandler() : null;
|
2014-02-06 05:36:10 +01:00
|
|
|
if ( out != null )
|
|
|
|
return Arrays.asList( new IMEInventoryHandler[] { out } );
|
|
|
|
}
|
|
|
|
return Arrays.asList( new IMEInventoryHandler[] {} );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getPriority()
|
|
|
|
{
|
|
|
|
return priority;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void blinkCell(int slot)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-09-11 06:12:34 +02:00
|
|
|
public void postChange(IBaseMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change, BaseActionSource source)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2014-02-03 03:30:52 +01:00
|
|
|
if ( proxy.isActive() )
|
|
|
|
proxy.getStorage().postAlterationOfStoredItems( StorageChannel.ITEMS, change, mySrc );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
catch (GridAccessException e)
|
|
|
|
{
|
|
|
|
// :(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-28 22:07:13 +01:00
|
|
|
@Override
|
2014-04-06 08:55:24 +02:00
|
|
|
@Method(iname = "BC")
|
2013-12-28 22:07:13 +01:00
|
|
|
public ConnectOverride overridePipeConnection(PipeType type, ForgeDirection with)
|
|
|
|
{
|
|
|
|
return type == PipeType.ITEM && with == side ? ConnectOverride.CONNECT : ConnectOverride.DISCONNECT;
|
|
|
|
}
|
|
|
|
|
2014-03-28 05:31:06 +01:00
|
|
|
@Override
|
|
|
|
public void onListUpdate()
|
|
|
|
{
|
|
|
|
// not used here.
|
|
|
|
}
|
|
|
|
|
2014-07-28 07:11:34 +02:00
|
|
|
@Override
|
|
|
|
public void saveChanges(IMEInventory cellInventory)
|
|
|
|
{
|
|
|
|
// nope!
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|