AE2 First Commit, the dawn of 1.7 hast arrived.
This commit is contained in:
@@ -0,0 +1,191 @@
|
||||
package appeng.parts.misc;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartCollsionHelper;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
|
||||
public class PartCableAnchor implements IPart
|
||||
{
|
||||
|
||||
ItemStack is = null;
|
||||
|
||||
public PartCableAnchor(ItemStack is) {
|
||||
this.is = is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
Icon myIcon = is.getIconIndex();
|
||||
rh.setTexture( myIcon );
|
||||
rh.setBounds( 7, 7, 10, 9, 9, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
rh.setTexture( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random r)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(IPartRenderHelper instance, RenderBlocks renderer)
|
||||
{
|
||||
instance.setTexture( is.getIconIndex() );
|
||||
instance.setBounds( 7, 7, 4, 9, 9, 14 );
|
||||
instance.renderInventoryBox( renderer );
|
||||
instance.setTexture( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollsionHelper bch)
|
||||
{
|
||||
bch.addBox( 7, 7, 10, 9, 9, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack(boolean wrenched)
|
||||
{
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderDynamic(double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSolid()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightLevel()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(DataOutputStream data) throws IOException
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(DataInputStream data) throws IOException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(Entity entity)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFromWorld()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToWorld()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getExternalFacingNode()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPartHostInfo(ForgeDirection side, IPartHost host, TileEntity tile)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivate(EntityPlayer player, Vec3 pos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(List<ItemStack> drops, boolean wrenched)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package appeng.parts.misc;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class PartInvertedToggleBus extends PartToggleBus
|
||||
{
|
||||
|
||||
public PartInvertedToggleBus(ItemStack is) {
|
||||
super( PartInvertedToggleBus.class, is );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean getIntention()
|
||||
{
|
||||
return !super.getIntention();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package appeng.parts.misc;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.parts.IPartCollsionHelper;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.parts.PartBasicState;
|
||||
|
||||
public class PartP2PTunnel extends PartBasicState
|
||||
{
|
||||
|
||||
public boolean output;
|
||||
public long freq;
|
||||
|
||||
public PartP2PTunnel(ItemStack is) {
|
||||
super( PartP2PTunnel.class, is );
|
||||
}
|
||||
|
||||
public void onChange()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.setTexture( AEApi.instance().blocks().blockQuartz.block().getIcon( 0, 0 ) );
|
||||
|
||||
rh.setBounds( 2, 2, 14, 14, 14, 16 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.BlockP2PTunnel2.getIcon(),
|
||||
is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
|
||||
rh.setBounds( 2, 2, 14, 14, 14, 16 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.setTexture( AEApi.instance().blocks().blockQuartz.block().getIcon( 0, 0 ) );
|
||||
|
||||
rh.setBounds( 2, 2, 14, 14, 14, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.BlockP2PTunnel2.getIcon(),
|
||||
is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
|
||||
rh.setBounds( 2, 2, 14, 14, 14, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setBounds( 3, 3, 13, 13, 13, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setTexture( CableBusTextures.BlockP2PTunnel3.getIcon() );
|
||||
|
||||
rh.setBounds( 6, 5, 12, 10, 11, 13 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setBounds( 5, 6, 12, 11, 10, 13 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
renderLights( x, y, z, rh, renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColors(boolean hasChan, boolean hasPower)
|
||||
{
|
||||
super.setColors( hasChan, hasPower );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollsionHelper bch)
|
||||
{
|
||||
bch.addBox( 2, 2, 14, 14, 14, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
package appeng.parts.misc;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.events.MENetworkCellArrayUpdate;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.ITickManager;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.parts.IPartCollsionHelper;
|
||||
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;
|
||||
import appeng.api.storage.IMEMontorHandlerReciever;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.me.storage.MEMonitorIInventory;
|
||||
import appeng.parts.PartBasicState;
|
||||
|
||||
public class PartStorageBus extends PartBasicState implements IGridTickable, ICellContainer, IMEMontorHandlerReciever<IAEItemStack>
|
||||
{
|
||||
|
||||
int priority = 0;
|
||||
|
||||
public PartStorageBus(ItemStack is) {
|
||||
super( PartStorageBus.class, is );
|
||||
}
|
||||
|
||||
boolean cached = false;
|
||||
MEMonitorIInventory monitor = null;
|
||||
MEInventoryHandler handler = null;
|
||||
|
||||
int handlerHash = 0;
|
||||
|
||||
@Override
|
||||
public boolean isValid(Object verificationToken)
|
||||
{
|
||||
return handler == verificationToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
cached = false;
|
||||
try
|
||||
{
|
||||
proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// :3
|
||||
}
|
||||
}
|
||||
|
||||
private MEInventoryHandler getHandler()
|
||||
{
|
||||
if ( cached )
|
||||
return handler;
|
||||
|
||||
boolean wasSleeping = monitor == null;
|
||||
|
||||
cached = true;
|
||||
TileEntity self = getHost().getTile();
|
||||
TileEntity target = self.worldObj.getBlockTileEntity( self.xCoord + side.offsetX, self.yCoord + side.offsetY, self.zCoord + side.offsetZ );
|
||||
|
||||
int newHandlerHash = generateTileHash( target );
|
||||
|
||||
if ( handlerHash == newHandlerHash )
|
||||
return handler;
|
||||
|
||||
handlerHash = newHandlerHash;
|
||||
handler = null;
|
||||
monitor = null;
|
||||
if ( target != null )
|
||||
{
|
||||
IExternalStorageHandler esh = AEApi.instance().registries().externalStorage().getHandler( target, side.getOpposite(), StorageChannel.ITEMS );
|
||||
if ( esh != null )
|
||||
{
|
||||
IMEInventory inv = esh.getInventory( target, side.getOpposite(), StorageChannel.ITEMS );
|
||||
|
||||
if ( inv instanceof MEMonitorIInventory )
|
||||
monitor = (MEMonitorIInventory) inv;
|
||||
|
||||
if ( inv != null )
|
||||
{
|
||||
handler = new MEInventoryHandler( inv );
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* generates a hash for a tile to detect if the tile has changed, or changed settings, if it does it will re-gen the
|
||||
* handler.
|
||||
*/
|
||||
private int generateTileHash(TileEntity target)
|
||||
{
|
||||
if ( target == null )
|
||||
return 0;
|
||||
|
||||
int hash = target.hashCode();
|
||||
|
||||
if ( target instanceof IInventory )
|
||||
hash ^= ((IInventory) target).getSizeInventory();
|
||||
|
||||
if ( target instanceof ISidedInventory )
|
||||
{
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
int offset = 0;
|
||||
for (Integer Side : ((ISidedInventory) target).getAccessibleSlotsFromSide( dir.ordinal() ))
|
||||
{
|
||||
hash ^= Side << (offset++ % 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
|
||||
is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.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
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
|
||||
is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.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.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
|
||||
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(), 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
|
||||
public void getBoxes(IPartCollsionHelper bch)
|
||||
{
|
||||
bch.addBox( 3, 3, 15, 13, 13, 16 );
|
||||
bch.addBox( 2, 2, 14, 14, 14, 15 );
|
||||
bch.addBox( 5, 5, 12, 11, 11, 13 );
|
||||
bch.addBox( 5, 5, 13, 11, 11, 14 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(IGridNode node)
|
||||
{
|
||||
return new TickingRequest( 5, 20 * 3, monitor == null, false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
|
||||
{
|
||||
if ( monitor != null )
|
||||
return monitor.onTick();
|
||||
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound extra)
|
||||
{
|
||||
super.writeToNBT( extra );
|
||||
extra.setInteger( "priority", priority );
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound extra)
|
||||
{
|
||||
super.readFromNBT( extra );
|
||||
priority = extra.getInteger( "priority" );
|
||||
};
|
||||
|
||||
@Override
|
||||
public List<IMEInventoryHandler> getCellArray(StorageChannel channel)
|
||||
{
|
||||
IMEInventoryHandler out = getHandler();
|
||||
if ( out == null )
|
||||
return Arrays.asList( new IMEInventoryHandler[] {} );
|
||||
return Arrays.asList( new IMEInventoryHandler[] { out } );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority()
|
||||
{
|
||||
return priority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blinkCell(int slot)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange(IAEItemStack change)
|
||||
{
|
||||
try
|
||||
{
|
||||
proxy.getStorage().postAlterationOfStoredItems( StorageChannel.ITEMS, change );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// :(
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
package appeng.parts.misc;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.IGridConnection;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.parts.IPartCollsionHelper;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.parts.PartBasicState;
|
||||
|
||||
public class PartToggleBus extends PartBasicState
|
||||
{
|
||||
|
||||
AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", true );
|
||||
IGridConnection connection;
|
||||
|
||||
protected final int REDSTONE_FLAG = 4;
|
||||
|
||||
boolean hasRedstone = false;
|
||||
|
||||
@Override
|
||||
protected int populateFlags(int cf)
|
||||
{
|
||||
return cf | (getIntention() ? REDSTONE_FLAG : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
boolean oldHasRedstone = hasRedstone;
|
||||
hasRedstone = getHost().hasRedstone( side );
|
||||
|
||||
if ( hasRedstone != oldHasRedstone )
|
||||
{
|
||||
updateInternalState();
|
||||
getHost().markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public PartToggleBus(ItemStack is) {
|
||||
this( PartToggleBus.class, is );
|
||||
}
|
||||
|
||||
public PartToggleBus(Class cls, ItemStack is) {
|
||||
super( cls, is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPartHostInfo(ForgeDirection side, IPartHost host, TileEntity tile)
|
||||
{
|
||||
super.setPartHostInfo( side, host, tile );
|
||||
outerProxy.setValidSides( EnumSet.of( side ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound extra)
|
||||
{
|
||||
super.readFromNBT( extra );
|
||||
outerProxy.readFromNBT( extra );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound extra)
|
||||
{
|
||||
super.writeToNBT( extra );
|
||||
outerProxy.writeToNBT( extra );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToWorld()
|
||||
{
|
||||
super.addToWorld();
|
||||
outerProxy.onReady();
|
||||
updateInternalState();
|
||||
}
|
||||
|
||||
private void updateInternalState()
|
||||
{
|
||||
boolean intention = getIntention();
|
||||
if ( intention != (connection != null) )
|
||||
{
|
||||
if ( proxy.getNode() != null && outerProxy.getNode() != null )
|
||||
{
|
||||
if ( intention )
|
||||
{
|
||||
connection = AEApi.instance().createGridConnection( proxy.getNode(), outerProxy.getNode() );
|
||||
}
|
||||
else
|
||||
{
|
||||
connection.destroy();
|
||||
connection = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean getIntention()
|
||||
{
|
||||
return getHost().hasRedstone( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFromWorld()
|
||||
{
|
||||
super.removeFromWorld();
|
||||
outerProxy.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getExternalFacingNode()
|
||||
{
|
||||
return outerProxy.getNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
{
|
||||
return AECableType.GLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColors(boolean hasChan, boolean hasPower)
|
||||
{
|
||||
hasRedstone = (clientFlags & REDSTONE_FLAG) == REDSTONE_FLAG;
|
||||
super.setColors( hasChan && hasRedstone, hasPower && hasRedstone );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.setTexture( 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(), is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
|
||||
rh.setBounds( 6, 6, 13, 10, 10, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
renderLights( x, y, z, rh, renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollsionHelper bch)
|
||||
{
|
||||
bch.addBox( 6, 6, 11, 10, 10, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
GL11.glTranslated( -0.2, -0.3, 0.0 );
|
||||
|
||||
rh.setTexture( is.getIconIndex() );
|
||||
rh.setBounds( 6, 6, 14 - 4, 10, 10, 16 - 4 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setBounds( 6, 6, 11 - 4, 10, 10, 13 - 4 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setBounds( 6, 6, 13 - 4, 10, 10, 14 - 4 );
|
||||
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setTexture( CableBusTextures.PartMonitorSidesStatusLights.getIcon() );
|
||||
rh.setInvColor( 0x000000 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
rh.setInvColor( 0xffffff );
|
||||
|
||||
rh.setTexture( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user