Fixes #675 No disabled feature should log spam or crash anymore.
Deprecates the old usage of the AEItemDefinitions via the direct method access of * blocks() * parts() * items() * materials() and thus use the new re-direct via definitions(). All definitions are now initialized, no matter what. But SubItems, Items and Blocks are not registered, if by chance are disabled.
This commit is contained in:
@@ -18,11 +18,10 @@
|
||||
|
||||
package appeng.parts.misc;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -38,6 +37,8 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
||||
@@ -64,73 +65,43 @@ import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.DualityInterface;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.parts.PartBasicState;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.IInventoryDestination;
|
||||
|
||||
public class PartInterface extends PartBasicState implements IGridTickable, IStorageMonitorable, IInventoryDestination, IInterfaceHost,
|
||||
ISidedInventory, IAEAppEngInventory, ITileStorageMonitorable, IPriorityHost
|
||||
|
||||
public class PartInterface extends PartBasicState
|
||||
implements IGridTickable, IStorageMonitorable, IInventoryDestination, IInterfaceHost, ISidedInventory, IAEAppEngInventory, ITileStorageMonitorable, IPriorityHost
|
||||
{
|
||||
|
||||
final DualityInterface duality = new DualityInterface( this.proxy, this );
|
||||
|
||||
public PartInterface(ItemStack is) {
|
||||
super( PartInterface.class, is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToWorld()
|
||||
@Reflected
|
||||
public PartInterface( ItemStack is )
|
||||
{
|
||||
super.addToWorld();
|
||||
this.duality.initialize();
|
||||
super( is );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange(MENetworkChannelsChanged c)
|
||||
public void stateChange( MENetworkChannelsChanged c )
|
||||
{
|
||||
this.duality.notifyNeighbors();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange(MENetworkPowerStatusChange c)
|
||||
public void stateChange( MENetworkPowerStatusChange c )
|
||||
{
|
||||
this.duality.notifyNeighbors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gridChanged()
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
this.duality.gridChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.duality.writeToNBT( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.duality.readFromNBT( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(List<ItemStack> drops, boolean wrenched)
|
||||
{
|
||||
this.duality.addDrops( drops );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
|
||||
this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
|
||||
rh.setBounds( 3, 3, 15, 13, 13, 16 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
@@ -143,25 +114,21 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );
|
||||
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
|
||||
this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
|
||||
rh.setBounds( 2, 2, 14, 14, 14, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
|
||||
this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
|
||||
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(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
|
||||
rh.setBounds( 5, 5, 13, 11, 11, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
@@ -170,18 +137,39 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getBreakingTexture()
|
||||
public void readFromNBT( NBTTagCompound data )
|
||||
{
|
||||
return this.is.getIconIndex();
|
||||
super.readFromNBT( data );
|
||||
this.duality.readFromNBT( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollisionHelper bch)
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.duality.writeToNBT( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToWorld()
|
||||
{
|
||||
super.addToWorld();
|
||||
this.duality.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 2, 2, 14, 14, 14, 16 );
|
||||
bch.addBox( 5, 5, 12, 11, 11, 14 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops( List<ItemStack> drops, boolean wrenched )
|
||||
{
|
||||
this.duality.addDrops( drops );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
@@ -189,13 +177,49 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity()
|
||||
public void gridChanged()
|
||||
{
|
||||
return super.getHost().getTile();
|
||||
this.duality.gridChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsert(ItemStack stack)
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
return this.duality.getConfigManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
return this.duality.getInventoryByName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades( Upgrades u )
|
||||
{
|
||||
return this.duality.getInstalledUpgrades( u );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate( EntityPlayer p, Vec3 pos )
|
||||
{
|
||||
if ( p.isSneaking() )
|
||||
return false;
|
||||
|
||||
if ( Platform.isServer() )
|
||||
Platform.openGUI( p, this.getTileEntity(), this.side, GuiBridge.GUI_INTERFACE );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getBreakingTexture()
|
||||
{
|
||||
return this.is.getIconIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsert( ItemStack stack )
|
||||
{
|
||||
return this.duality.canInsert( stack );
|
||||
}
|
||||
@@ -213,13 +237,13 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(IGridNode node)
|
||||
public TickingRequest getTickingRequest( IGridNode node )
|
||||
{
|
||||
return this.duality.getTickingRequest( node );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
|
||||
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
|
||||
{
|
||||
return this.duality.tickingRequest( node, TicksSinceLastCall );
|
||||
}
|
||||
@@ -231,25 +255,25 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i)
|
||||
public ItemStack getStackInSlot( int i )
|
||||
{
|
||||
return this.duality.getStorage().getStackInSlot( i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j)
|
||||
public ItemStack decrStackSize( int i, int j )
|
||||
{
|
||||
return this.duality.getStorage().decrStackSize( i, j );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i)
|
||||
public ItemStack getStackInSlotOnClosing( int i )
|
||||
{
|
||||
return this.duality.getStorage().getStackInSlotOnClosing( i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack)
|
||||
public void setInventorySlotContents( int i, ItemStack itemstack )
|
||||
{
|
||||
this.duality.getStorage().setInventorySlotContents( i, itemstack );
|
||||
}
|
||||
@@ -272,18 +296,6 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
return this.duality.getStorage().getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
return this.duality.getConfigManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name)
|
||||
{
|
||||
return this.duality.getInventoryByName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
@@ -291,7 +303,7 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
||||
public boolean isUseableByPlayer( EntityPlayer entityplayer )
|
||||
{
|
||||
return this.duality.getStorage().isUseableByPlayer( entityplayer );
|
||||
}
|
||||
@@ -309,31 +321,31 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
return this.duality.getStorage().isItemValidForSlot( i, itemstack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int s)
|
||||
public int[] getAccessibleSlotsFromSide( int s )
|
||||
{
|
||||
return this.duality.getAccessibleSlotsFromSide( s );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int i, ItemStack itemstack, int j)
|
||||
public boolean canInsertItem( int i, ItemStack itemstack, int j )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int i, ItemStack itemstack, int j)
|
||||
public boolean canExtractItem( int i, ItemStack itemstack, int j )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
this.duality.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
||||
}
|
||||
@@ -345,41 +357,29 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(EntityPlayer p, Vec3 pos)
|
||||
public EnumSet<ForgeDirection> getTargets()
|
||||
{
|
||||
if ( p.isSneaking() )
|
||||
return false;
|
||||
|
||||
if ( Platform.isServer() )
|
||||
Platform.openGUI( p, this.getTileEntity(), this.side, GuiBridge.GUI_INTERFACE );
|
||||
|
||||
return true;
|
||||
return EnumSet.of( this.side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src)
|
||||
public TileEntity getTileEntity()
|
||||
{
|
||||
return super.getHost().getTile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageMonitorable getMonitorable( ForgeDirection side, BaseActionSource src )
|
||||
{
|
||||
return this.duality.getMonitorable( side, src, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table)
|
||||
public boolean pushPattern( ICraftingPatternDetails patternDetails, InventoryCrafting table )
|
||||
{
|
||||
return this.duality.pushPattern( patternDetails, table );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void provideCrafting(ICraftingProviderHelper craftingTracker)
|
||||
{
|
||||
this.duality.provideCrafting( craftingTracker );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<ForgeDirection> getTargets()
|
||||
{
|
||||
return EnumSet.of( this.side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBusy()
|
||||
{
|
||||
@@ -387,9 +387,9 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades(Upgrades u)
|
||||
public void provideCrafting( ICraftingProviderHelper craftingTracker )
|
||||
{
|
||||
return this.duality.getInstalledUpgrades( u );
|
||||
this.duality.provideCrafting( craftingTracker );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -399,13 +399,13 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode)
|
||||
public IAEItemStack injectCraftedItems( ICraftingLink link, IAEItemStack items, Actionable mode )
|
||||
{
|
||||
return this.duality.injectCraftedItems( link, items, mode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jobStateChange(ICraftingLink link)
|
||||
public void jobStateChange( ICraftingLink link )
|
||||
{
|
||||
this.duality.jobStateChange( link );
|
||||
}
|
||||
@@ -417,9 +417,8 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority(int newValue)
|
||||
public void setPriority( int newValue )
|
||||
{
|
||||
this.duality.setPriority( newValue );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,13 +18,18 @@
|
||||
|
||||
package appeng.parts.misc;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.helpers.Reflected;
|
||||
|
||||
|
||||
public class PartInvertedToggleBus extends PartToggleBus
|
||||
{
|
||||
|
||||
public PartInvertedToggleBus(ItemStack is) {
|
||||
super( PartInvertedToggleBus.class, is );
|
||||
@Reflected
|
||||
public PartInvertedToggleBus( ItemStack is )
|
||||
{
|
||||
super( is );
|
||||
this.proxy.setIdlePowerUsage( 0.0 );
|
||||
this.outerProxy.setIdlePowerUsage( 0.0 );
|
||||
this.proxy.setFlags();
|
||||
@@ -36,5 +41,4 @@ public class PartInvertedToggleBus extends PartToggleBus
|
||||
{
|
||||
return !super.getIntention();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ import appeng.core.stats.Achievements;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.me.storage.MEMonitorIInventory;
|
||||
@@ -90,31 +91,29 @@ import appeng.util.prioitylist.PrecisePriorityList;
|
||||
|
||||
|
||||
@Interface( iname = "BC", iface = "buildcraft.api.transport.IPipeConnection" )
|
||||
public class PartStorageBus
|
||||
extends PartUpgradeable
|
||||
public class PartStorageBus extends PartUpgradeable
|
||||
implements IGridTickable, ICellContainer, IMEMonitorHandlerReceiver<IAEItemStack>, IPipeConnection, IPriorityHost
|
||||
{
|
||||
int priority = 0;
|
||||
final BaseActionSource mySrc;
|
||||
|
||||
final AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 );
|
||||
int priority = 0;
|
||||
boolean cached = false;
|
||||
MEMonitorIInventory monitor = null;
|
||||
MEInventoryHandler handler = null;
|
||||
int handlerHash = 0;
|
||||
boolean wasActive = false;
|
||||
private byte resetCacheLogic = 0;
|
||||
|
||||
@Reflected
|
||||
public PartStorageBus( ItemStack is )
|
||||
{
|
||||
super( PartStorageBus.class, is );
|
||||
super( is );
|
||||
this.getConfigManager().registerSetting( Settings.ACCESS, AccessRestriction.READ_WRITE );
|
||||
this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
this.getConfigManager().registerSetting( Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY );
|
||||
this.mySrc = new MachineSource( this );
|
||||
}
|
||||
|
||||
boolean cached = false;
|
||||
MEMonitorIInventory monitor = null;
|
||||
MEInventoryHandler handler = null;
|
||||
|
||||
int handlerHash = 0;
|
||||
boolean wasActive = false;
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender( MENetworkPowerStatusChange c )
|
||||
@@ -122,12 +121,6 @@ public class PartStorageBus
|
||||
this.updateStatus();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void updateChannels( MENetworkChannelsChanged changedChannels )
|
||||
{
|
||||
this.updateStatus();
|
||||
}
|
||||
|
||||
private void updateStatus()
|
||||
{
|
||||
boolean currentActive = this.proxy.isActive();
|
||||
@@ -146,19 +139,10 @@ public class PartStorageBus
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
|
||||
@MENetworkEventSubscribe
|
||||
public void updateChannels( MENetworkChannelsChanged changedChannels )
|
||||
{
|
||||
if ( !player.isSneaking() )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_STORAGEBUS );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
this.updateStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -168,9 +152,19 @@ public class PartStorageBus
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid( Object verificationToken )
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
{
|
||||
return this.handler == verificationToken;
|
||||
super.writeToNBT( data );
|
||||
this.Config.writeToNBT( data, "config" );
|
||||
data.setInteger( "priority", this.priority );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.Config.readFromNBT( data, "config" );
|
||||
this.priority = data.getInteger( "priority" );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -182,7 +176,102 @@ public class PartStorageBus
|
||||
return super.getInventoryByName( name );
|
||||
}
|
||||
|
||||
private byte resetCacheLogic = 0;
|
||||
@Override
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
this.resetCache( true );
|
||||
this.host.markForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradesChanged()
|
||||
{
|
||||
super.upgradesChanged();
|
||||
this.resetCache( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
||||
|
||||
if ( inv == this.Config )
|
||||
this.resetCache( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid( Object verificationToken )
|
||||
{
|
||||
return this.handler == verificationToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange( IBaseMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change, BaseActionSource source )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( this.proxy.isActive() )
|
||||
this.proxy.getStorage().postAlterationOfStoredItems( StorageChannel.ITEMS, change, this.mySrc );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
{
|
||||
// :(
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListUpdate()
|
||||
{
|
||||
// not used here.
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
rh.setTexture( CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon() );
|
||||
|
||||
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
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );
|
||||
rh.setTexture( CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon() );
|
||||
|
||||
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 );
|
||||
|
||||
rh.setTexture( CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon() );
|
||||
|
||||
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(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
|
||||
rh.setBounds( 5, 5, 13, 11, 11, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
this.renderLights( x, y, z, rh, renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
this.resetCache( false );
|
||||
}
|
||||
|
||||
private void resetCache( boolean fullReset )
|
||||
{
|
||||
@@ -204,6 +293,53 @@ public class PartStorageBus
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 3, 3, 15, 13, 13, 16 );
|
||||
bch.addBox( 2, 2, 14, 14, 14, 15 );
|
||||
bch.addBox( 5, 5, 12, 11, 11, 14 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
|
||||
{
|
||||
if ( !player.isSneaking() )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_STORAGEBUS );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest( IGridNode node )
|
||||
{
|
||||
return new TickingRequest( TickRates.StorageBus.min, TickRates.StorageBus.max, this.monitor == null, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
|
||||
{
|
||||
if ( this.resetCacheLogic != 0 )
|
||||
this.resetCache();
|
||||
|
||||
if ( this.monitor != null )
|
||||
return this.monitor.onTick();
|
||||
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
private void resetCache()
|
||||
{
|
||||
boolean fullReset = this.resetCacheLogic == 2;
|
||||
@@ -230,43 +366,6 @@ public class PartStorageBus
|
||||
Platform.postListChanges( before, after, this, this.mySrc );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
this.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 == this.Config )
|
||||
this.resetCache( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradesChanged()
|
||||
{
|
||||
super.upgradesChanged();
|
||||
this.resetCache( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
this.resetCache( true );
|
||||
this.host.markForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority( int newValue )
|
||||
{
|
||||
this.priority = newValue;
|
||||
this.host.markForSave();
|
||||
this.resetCache( true );
|
||||
}
|
||||
|
||||
public MEInventoryHandler getInternalHandler()
|
||||
{
|
||||
if ( this.cached )
|
||||
@@ -305,13 +404,13 @@ public class PartStorageBus
|
||||
|
||||
if ( inv instanceof MEMonitorIInventory )
|
||||
{
|
||||
MEMonitorIInventory h = ( MEMonitorIInventory ) inv;
|
||||
h.mode = ( StorageFilter ) this.getConfigManager().getSetting( Settings.STORAGE_FILTER );
|
||||
MEMonitorIInventory h = (MEMonitorIInventory) inv;
|
||||
h.mode = (StorageFilter) this.getConfigManager().getSetting( Settings.STORAGE_FILTER );
|
||||
h.mySource = new MachineSource( this );
|
||||
}
|
||||
|
||||
if ( inv instanceof MEMonitorIInventory )
|
||||
this.monitor = ( MEMonitorIInventory ) inv;
|
||||
this.monitor = (MEMonitorIInventory) inv;
|
||||
|
||||
if ( inv != null )
|
||||
{
|
||||
@@ -334,12 +433,12 @@ public class PartStorageBus
|
||||
}
|
||||
|
||||
if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
this.handler.setPartitionList( new FuzzyPriorityList( priorityList, ( FuzzyMode ) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) );
|
||||
this.handler.setPartitionList( new FuzzyPriorityList( priorityList, (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) );
|
||||
else
|
||||
this.handler.setPartitionList ( new PrecisePriorityList( priorityList ));
|
||||
this.handler.setPartitionList( new PrecisePriorityList( priorityList ) );
|
||||
|
||||
if ( inv instanceof IMEMonitor )
|
||||
( ( IMEMonitor ) inv ).addListener( this, this.handler );
|
||||
( (IMEMonitor) inv ).addListener( this, this.handler );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -369,13 +468,13 @@ public class PartStorageBus
|
||||
IInterfaceHost achievement = null;
|
||||
|
||||
if ( target instanceof IInterfaceHost )
|
||||
achievement = ( IInterfaceHost ) target;
|
||||
achievement = (IInterfaceHost) target;
|
||||
|
||||
if ( target instanceof IPartHost )
|
||||
{
|
||||
Object part = ( ( IPartHost ) target ).getPart( side );
|
||||
Object part = ( (IPartHost) target ).getPart( side );
|
||||
if ( part instanceof IInterfaceHost )
|
||||
achievement = ( IInterfaceHost ) part;
|
||||
achievement = (IInterfaceHost) part;
|
||||
}
|
||||
|
||||
if ( achievement != null && achievement.getActionableNode() != null )
|
||||
@@ -385,100 +484,6 @@ public class PartStorageBus
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
rh.setTexture( CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageBack.getIcon(),
|
||||
this.is.getIconIndex(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon() );
|
||||
|
||||
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
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );
|
||||
rh.setTexture( CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon() );
|
||||
|
||||
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 );
|
||||
|
||||
rh.setTexture( CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageBack.getIcon(),
|
||||
this.is.getIconIndex(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon() );
|
||||
|
||||
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(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
|
||||
rh.setBounds( 5, 5, 13, 11, 11, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
this.renderLights( x, y, z, rh, renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 3, 3, 15, 13, 13, 16 );
|
||||
bch.addBox( 2, 2, 14, 14, 14, 15 );
|
||||
bch.addBox( 5, 5, 12, 11, 11, 14 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest( IGridNode node )
|
||||
{
|
||||
return new TickingRequest( TickRates.StorageBus.min, TickRates.StorageBus.max, this.monitor == null, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
|
||||
{
|
||||
if ( this.resetCacheLogic != 0 )
|
||||
this.resetCache();
|
||||
|
||||
if ( this.monitor != null )
|
||||
return this.monitor.onTick();
|
||||
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.Config.writeToNBT( data, "config" );
|
||||
data.setInteger( "priority", this.priority );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.Config.readFromNBT( data, "config" );
|
||||
this.priority = data.getInteger( "priority" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IMEInventoryHandler> getCellArray( StorageChannel channel )
|
||||
{
|
||||
@@ -488,7 +493,7 @@ public class PartStorageBus
|
||||
if ( out != null )
|
||||
return Collections.singletonList( out );
|
||||
}
|
||||
return Arrays.asList( new IMEInventoryHandler[] {} );
|
||||
return Arrays.asList( new IMEInventoryHandler[] { } );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -498,21 +503,16 @@ public class PartStorageBus
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blinkCell( int slot )
|
||||
{}
|
||||
public void setPriority( int newValue )
|
||||
{
|
||||
this.priority = newValue;
|
||||
this.host.markForSave();
|
||||
this.resetCache( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange( IBaseMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change, BaseActionSource source )
|
||||
public void blinkCell( int slot )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( this.proxy.isActive() )
|
||||
this.proxy.getStorage().postAlterationOfStoredItems( StorageChannel.ITEMS, change, this.mySrc );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
{
|
||||
// :(
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -522,12 +522,6 @@ public class PartStorageBus
|
||||
return type == PipeType.ITEM && with == this.side ? ConnectOverride.CONNECT : ConnectOverride.DISCONNECT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListUpdate()
|
||||
{
|
||||
// not used here.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges( IMEInventory cellInventory )
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.parts.misc;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
@@ -44,113 +45,41 @@ import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.parts.PartBasicState;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class PartToggleBus extends PartBasicState
|
||||
{
|
||||
|
||||
protected final int REDSTONE_FLAG = 4;
|
||||
final AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", null, true );
|
||||
IGridConnection connection;
|
||||
|
||||
protected final int REDSTONE_FLAG = 4;
|
||||
|
||||
boolean hasRedstone = false;
|
||||
|
||||
@Override
|
||||
public void onPlacement(EntityPlayer player, ItemStack held, ForgeDirection side)
|
||||
@Reflected
|
||||
public PartToggleBus( ItemStack is )
|
||||
{
|
||||
super.onPlacement( player, held, side );
|
||||
this.outerProxy.setOwner( player );
|
||||
}
|
||||
super( is );
|
||||
|
||||
@Override
|
||||
protected int populateFlags(int cf)
|
||||
{
|
||||
return cf | (this.getIntention() ? this.REDSTONE_FLAG : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
boolean oldHasRedstone = this.hasRedstone;
|
||||
this.hasRedstone = this.getHost().hasRedstone( this.side );
|
||||
|
||||
if ( this.hasRedstone != oldHasRedstone )
|
||||
{
|
||||
this.updateInternalState();
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public PartToggleBus(ItemStack is) {
|
||||
this( PartToggleBus.class, is );
|
||||
this.proxy.setIdlePowerUsage( 0.0 );
|
||||
this.outerProxy.setIdlePowerUsage( 0.0 );
|
||||
this.proxy.setFlags();
|
||||
this.outerProxy.setFlags();
|
||||
}
|
||||
|
||||
public PartToggleBus(Class cls, ItemStack is) {
|
||||
super( cls, is );
|
||||
@Override
|
||||
public void setColors( boolean hasChan, boolean hasPower )
|
||||
{
|
||||
this.hasRedstone = ( this.clientFlags & this.REDSTONE_FLAG ) == this.REDSTONE_FLAG;
|
||||
super.setColors( hasChan && this.hasRedstone, hasPower && this.hasRedstone );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPartHostInfo(ForgeDirection side, IPartHost host, TileEntity tile)
|
||||
protected int populateFlags( int cf )
|
||||
{
|
||||
super.setPartHostInfo( side, host, tile );
|
||||
this.outerProxy.setValidSides( EnumSet.of( side ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound extra)
|
||||
{
|
||||
super.readFromNBT( extra );
|
||||
this.outerProxy.readFromNBT( extra );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound extra)
|
||||
{
|
||||
super.writeToNBT( extra );
|
||||
this.outerProxy.writeToNBT( extra );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToWorld()
|
||||
{
|
||||
super.addToWorld();
|
||||
this.outerProxy.onReady();
|
||||
this.hasRedstone = this.getHost().hasRedstone( this.side );
|
||||
this.updateInternalState();
|
||||
}
|
||||
|
||||
private void updateInternalState()
|
||||
{
|
||||
boolean intention = this.getIntention();
|
||||
if ( intention == ( this.connection == null ) )
|
||||
{
|
||||
if ( this.proxy.getNode() != null && this.outerProxy.getNode() != null )
|
||||
{
|
||||
if ( intention )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.connection = AEApi.instance().createGridConnection( this.proxy.getNode(), this.outerProxy.getNode() );
|
||||
}
|
||||
catch (FailedConnection e)
|
||||
{
|
||||
// :(
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.connection.destroy();
|
||||
this.connection = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cf | ( this.getIntention() ? this.REDSTONE_FLAG : 0 );
|
||||
}
|
||||
|
||||
protected boolean getIntention()
|
||||
@@ -158,55 +87,6 @@ public class PartToggleBus extends PartBasicState
|
||||
return this.getHost().hasRedstone( this.side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFromWorld()
|
||||
{
|
||||
super.removeFromWorld();
|
||||
this.outerProxy.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getExternalFacingNode()
|
||||
{
|
||||
return this.outerProxy.getNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
{
|
||||
return AECableType.GLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColors(boolean hasChan, boolean hasPower)
|
||||
{
|
||||
this.hasRedstone = (this.clientFlags & this.REDSTONE_FLAG) == this.REDSTONE_FLAG;
|
||||
super.setColors( hasChan && this.hasRedstone, hasPower && this.hasRedstone );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );
|
||||
rh.setTexture( this.is.getIconIndex() );
|
||||
|
||||
rh.setBounds( 6, 6, 14, 10, 10, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setBounds( 6, 6, 11, 10, 10, 13 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
|
||||
rh.setBounds( 6, 6, 13, 10, 10, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
this.renderLights( x, y, z, rh, renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getBreakingTexture()
|
||||
{
|
||||
@@ -214,14 +94,8 @@ public class PartToggleBus extends PartBasicState
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollisionHelper bch)
|
||||
{
|
||||
bch.addBox( 6, 6, 11, 10, 10, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
GL11.glTranslated( -0.2, -0.3, 0.0 );
|
||||
|
||||
@@ -244,12 +118,108 @@ public class PartToggleBus extends PartBasicState
|
||||
rh.setTexture( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
|
||||
{
|
||||
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );
|
||||
rh.setTexture( this.is.getIconIndex() );
|
||||
|
||||
rh.setBounds( 6, 6, 14, 10, 10, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setBounds( 6, 6, 11, 10, 10, 13 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
|
||||
rh.setBounds( 6, 6, 13, 10, 10, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
this.renderLights( x, y, z, rh, renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
boolean oldHasRedstone = this.hasRedstone;
|
||||
this.hasRedstone = this.getHost().hasRedstone( this.side );
|
||||
|
||||
if ( this.hasRedstone != oldHasRedstone )
|
||||
{
|
||||
this.updateInternalState();
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound extra )
|
||||
{
|
||||
super.readFromNBT( extra );
|
||||
this.outerProxy.readFromNBT( extra );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound extra )
|
||||
{
|
||||
super.writeToNBT( extra );
|
||||
this.outerProxy.writeToNBT( extra );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFromWorld()
|
||||
{
|
||||
super.removeFromWorld();
|
||||
this.outerProxy.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToWorld()
|
||||
{
|
||||
super.addToWorld();
|
||||
this.outerProxy.onReady();
|
||||
this.hasRedstone = this.getHost().hasRedstone( this.side );
|
||||
this.updateInternalState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPartHostInfo( ForgeDirection side, IPartHost host, TileEntity tile )
|
||||
{
|
||||
super.setPartHostInfo( side, host, tile );
|
||||
this.outerProxy.setValidSides( EnumSet.of( side ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getExternalFacingNode()
|
||||
{
|
||||
return this.outerProxy.getNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 6, 6, 11, 10, 10, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.GLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlacement( EntityPlayer player, ItemStack held, ForgeDirection side )
|
||||
{
|
||||
super.onPlacement( player, held, side );
|
||||
this.outerProxy.setOwner( player );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void securityBreak()
|
||||
{
|
||||
@@ -262,4 +232,31 @@ public class PartToggleBus extends PartBasicState
|
||||
this.is.stackSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateInternalState()
|
||||
{
|
||||
boolean intention = this.getIntention();
|
||||
if ( intention == ( this.connection == null ) )
|
||||
{
|
||||
if ( this.proxy.getNode() != null && this.outerProxy.getNode() != null )
|
||||
{
|
||||
if ( intention )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.connection = AEApi.instance().createGridConnection( this.proxy.getNode(), this.outerProxy.getNode() );
|
||||
}
|
||||
catch ( FailedConnection e )
|
||||
{
|
||||
// :(
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.connection.destroy();
|
||||
this.connection = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user