AE2 First Commit, the dawn of 1.7 hast arrived.
This commit is contained in:
@@ -0,0 +1,240 @@
|
||||
package appeng.parts;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
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.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.networking.IGridHost;
|
||||
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;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.IGridProxyable;
|
||||
import appeng.parts.networking.PartCable;
|
||||
|
||||
public class AEBasePart implements IPart, IGridProxyable, IGridHost
|
||||
{
|
||||
|
||||
protected AENetworkProxy proxy = new AENetworkProxy( this, "part", this instanceof PartCable );
|
||||
protected TileEntity tile = null;
|
||||
protected IPartHost host = null;
|
||||
protected ForgeDirection side = null;
|
||||
|
||||
protected final ItemStack is;
|
||||
|
||||
public AEBasePart(Class c, ItemStack is) {
|
||||
this.is = is;
|
||||
proxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.setBounds( 1, 1, 1, 15, 15, 15 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setBounds( 1, 1, 1, 15, 15, 15 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.setBounds( 1, 1, 1, 15, 15, 15 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderDynamic(double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack(boolean wrenched)
|
||||
{
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSolid()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound extra)
|
||||
{
|
||||
proxy.readFromNBT( extra );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound extra)
|
||||
{
|
||||
proxy.writeToNBT( extra );
|
||||
}
|
||||
|
||||
@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 proxy.getNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(Entity entity)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFromWorld()
|
||||
{
|
||||
proxy.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToWorld()
|
||||
{
|
||||
proxy.onReady();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPartHostInfo(ForgeDirection side, IPartHost host, TileEntity tile)
|
||||
{
|
||||
this.side = side;
|
||||
this.tile = tile;
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public IPartHost getHost()
|
||||
{
|
||||
return host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getExternalFacingNode()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir)
|
||||
{
|
||||
return proxy.getNode();
|
||||
}
|
||||
|
||||
protected AEColor getColor()
|
||||
{
|
||||
if ( getHost() == null )
|
||||
return AEColor.Transparent;
|
||||
return getHost().getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
{
|
||||
return new DimensionalCoord( tile );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollsionHelper bch)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random r)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightLevel()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivate(EntityPlayer player, Vec3 pos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
{
|
||||
return AECableType.GLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(List<ItemStack> drops, boolean wrenched)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gridChanged()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package appeng.parts;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.parts.IPartCollsionHelper;
|
||||
|
||||
public class BusCollisionHelper implements IPartCollsionHelper
|
||||
{
|
||||
|
||||
final List<AxisAlignedBB> boxes;
|
||||
|
||||
final private ForgeDirection x;
|
||||
final private ForgeDirection y;
|
||||
final private ForgeDirection z;
|
||||
|
||||
public BusCollisionHelper(List<AxisAlignedBB> boxes, ForgeDirection x, ForgeDirection y, ForgeDirection z) {
|
||||
this.boxes = boxes;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public BusCollisionHelper(List<AxisAlignedBB> boxes, ForgeDirection s) {
|
||||
this.boxes = boxes;
|
||||
|
||||
switch (s)
|
||||
{
|
||||
case DOWN:
|
||||
x = ForgeDirection.EAST;
|
||||
y = ForgeDirection.NORTH;
|
||||
z = ForgeDirection.DOWN;
|
||||
break;
|
||||
case UP:
|
||||
x = ForgeDirection.EAST;
|
||||
y = ForgeDirection.SOUTH;
|
||||
z = ForgeDirection.UP;
|
||||
break;
|
||||
case EAST:
|
||||
x = ForgeDirection.SOUTH;
|
||||
y = ForgeDirection.UP;
|
||||
z = ForgeDirection.EAST;
|
||||
break;
|
||||
case WEST:
|
||||
x = ForgeDirection.NORTH;
|
||||
y = ForgeDirection.UP;
|
||||
z = ForgeDirection.WEST;
|
||||
break;
|
||||
case NORTH:
|
||||
x = ForgeDirection.WEST;
|
||||
y = ForgeDirection.UP;
|
||||
z = ForgeDirection.NORTH;
|
||||
break;
|
||||
case SOUTH:
|
||||
x = ForgeDirection.EAST;
|
||||
y = ForgeDirection.UP;
|
||||
z = ForgeDirection.SOUTH;
|
||||
break;
|
||||
case UNKNOWN:
|
||||
default:
|
||||
x = ForgeDirection.EAST;
|
||||
y = ForgeDirection.UP;
|
||||
z = ForgeDirection.SOUTH;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
|
||||
{
|
||||
minX /= 16.0;
|
||||
minY /= 16.0;
|
||||
minZ /= 16.0;
|
||||
maxX /= 16.0;
|
||||
maxY /= 16.0;
|
||||
maxZ /= 16.0;
|
||||
|
||||
double aX = minX * x.offsetX + minY * y.offsetX + minZ * z.offsetX;
|
||||
double aY = minX * x.offsetY + minY * y.offsetY + minZ * z.offsetY;
|
||||
double aZ = minX * x.offsetZ + minY * y.offsetZ + minZ * z.offsetZ;
|
||||
|
||||
double bX = maxX * x.offsetX + maxY * y.offsetX + maxZ * z.offsetX;
|
||||
double bY = maxX * x.offsetY + maxY * y.offsetY + maxZ * z.offsetY;
|
||||
double bZ = maxX * x.offsetZ + maxY * y.offsetZ + maxZ * z.offsetZ;
|
||||
|
||||
if ( x.offsetX + y.offsetX + z.offsetX < 0 )
|
||||
{
|
||||
aX += 1;
|
||||
bX += 1;
|
||||
}
|
||||
|
||||
if ( x.offsetY + y.offsetY + z.offsetY < 0 )
|
||||
{
|
||||
aY += 1;
|
||||
bY += 1;
|
||||
}
|
||||
|
||||
if ( x.offsetZ + y.offsetZ + z.offsetZ < 0 )
|
||||
{
|
||||
aZ += 1;
|
||||
bZ += 1;
|
||||
}
|
||||
|
||||
minX = Math.min( aX, bX );
|
||||
minY = Math.min( aY, bY );
|
||||
minZ = Math.min( aZ, bZ );
|
||||
maxX = Math.max( aX, bX );
|
||||
maxY = Math.max( aY, bY );
|
||||
maxZ = Math.max( aZ, bZ );
|
||||
|
||||
boxes.add( AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getWorldX()
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getWorldY()
|
||||
{
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getWorldZ()
|
||||
{
|
||||
return z;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,896 @@
|
||||
package appeng.parts;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.implementations.IPartCable;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.parts.IFacadeContainer;
|
||||
import appeng.api.parts.IFacadePart;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartCollsionHelper;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.client.render.BusRenderHelper;
|
||||
import appeng.client.render.BusRenderer;
|
||||
import appeng.client.render.RenderBlocksWorkaround;
|
||||
import appeng.facade.FacadeContainer;
|
||||
import appeng.helpers.AEMultiTile;
|
||||
import appeng.me.GridConnection;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class CableBusContainer implements AEMultiTile
|
||||
{
|
||||
|
||||
private IPartCable center;
|
||||
private IPart sides[] = new IPart[6];
|
||||
private FacadeContainer fc = new FacadeContainer();
|
||||
|
||||
public boolean hasRedstone = false;
|
||||
public IPartHost tcb;
|
||||
|
||||
boolean inWorld = false;
|
||||
|
||||
public void setHost(IPartHost host)
|
||||
{
|
||||
tcb.clearContainer();
|
||||
tcb = host;
|
||||
}
|
||||
|
||||
public CableBusContainer(IPartHost host) {
|
||||
tcb = host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPart getPart(ForgeDirection side)
|
||||
{
|
||||
if ( side == ForgeDirection.UNKNOWN )
|
||||
return center;
|
||||
return sides[side.ordinal()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePart(ForgeDirection side)
|
||||
{
|
||||
if ( side == ForgeDirection.UNKNOWN )
|
||||
{
|
||||
if ( center != null )
|
||||
center.removeFromWorld();
|
||||
center = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( sides[side.ordinal()] != null )
|
||||
sides[side.ordinal()].removeFromWorld();
|
||||
sides[side.ordinal()] = null;
|
||||
}
|
||||
|
||||
updateConnections();
|
||||
markForUpdate();
|
||||
PartChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* use for FMP
|
||||
*/
|
||||
public void updateConnections()
|
||||
{
|
||||
if ( center != null )
|
||||
{
|
||||
EnumSet<ForgeDirection> sides = EnumSet.allOf( ForgeDirection.class );
|
||||
|
||||
for (ForgeDirection s : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if ( getPart( s ) != null || isBlocked( s ) )
|
||||
sides.remove( s );
|
||||
}
|
||||
|
||||
center.setValidSides( sides );
|
||||
IGridNode n = center.getGridNode();
|
||||
if ( n != null )
|
||||
n.updateState();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAddPart(ItemStack is, ForgeDirection side)
|
||||
{
|
||||
if ( is.getItem() instanceof IPartItem )
|
||||
{
|
||||
IPartItem bi = (IPartItem) is.getItem();
|
||||
|
||||
is = is.copy();
|
||||
is.stackSize = 1;
|
||||
|
||||
IPart bp = bi.createPartFromItemStack( is );
|
||||
if ( bp instanceof IPartCable )
|
||||
{
|
||||
return getPart( ForgeDirection.UNKNOWN ) == null;
|
||||
}
|
||||
else if ( !(bp instanceof IPartCable) && side != ForgeDirection.UNKNOWN )
|
||||
{
|
||||
return getPart( side ) == null;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection addPart(ItemStack is, ForgeDirection side)
|
||||
{
|
||||
if ( canAddPart( is, side ) )
|
||||
{
|
||||
if ( is.getItem() instanceof IPartItem )
|
||||
{
|
||||
IPartItem bi = (IPartItem) is.getItem();
|
||||
|
||||
is = is.copy();
|
||||
is.stackSize = 1;
|
||||
|
||||
IPart bp = bi.createPartFromItemStack( is );
|
||||
if ( bp instanceof IPartCable )
|
||||
{
|
||||
if ( getPart( ForgeDirection.UNKNOWN ) != null )
|
||||
return null;
|
||||
|
||||
center = (IPartCable) bp;
|
||||
bp.setPartHostInfo( ForgeDirection.UNKNOWN, this, tcb.getTile() );
|
||||
|
||||
if ( inWorld )
|
||||
bp.addToWorld();
|
||||
|
||||
IGridNode cn = center.getGridNode();
|
||||
if ( cn != null )
|
||||
{
|
||||
for (ForgeDirection ins : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
IPart sbp = getPart( ins );
|
||||
if ( sbp != null )
|
||||
{
|
||||
IGridNode sn = sbp.getGridNode();
|
||||
if ( sn != null && cn != null )
|
||||
new GridConnection( (IGridNode) cn, (IGridNode) sn, ForgeDirection.UNKNOWN );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateConnections();
|
||||
markForUpdate();
|
||||
PartChanged();
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
else if ( !(bp instanceof IPartCable) && side != ForgeDirection.UNKNOWN )
|
||||
{
|
||||
sides[side.ordinal()] = bp;
|
||||
bp.setPartHostInfo( side, this, this.getTile() );
|
||||
|
||||
if ( inWorld )
|
||||
bp.addToWorld();
|
||||
|
||||
if ( center != null )
|
||||
{
|
||||
IGridNode cn = center.getGridNode();
|
||||
IGridNode sn = bp.getGridNode();
|
||||
|
||||
if ( cn != null && sn != null )
|
||||
{
|
||||
new GridConnection( (IGridNode) cn, (IGridNode) sn, ForgeDirection.UNKNOWN );
|
||||
}
|
||||
}
|
||||
|
||||
updateConnections();
|
||||
markForUpdate();
|
||||
PartChanged();
|
||||
return side;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addToWorld()
|
||||
{
|
||||
inWorld = true;
|
||||
|
||||
TileEntity te = getTile();
|
||||
hasRedstone = te.worldObj.isBlockIndirectlyGettingPowered( te.xCoord, te.yCoord, te.zCoord );
|
||||
|
||||
// start with the center, then install the side parts into the grid.
|
||||
for (int x = 6; x >= 0; x--)
|
||||
{
|
||||
ForgeDirection s = ForgeDirection.getOrientation( x );
|
||||
IPart part = getPart( s );
|
||||
|
||||
if ( part != null )
|
||||
{
|
||||
part.setPartHostInfo( s, this, te );
|
||||
part.addToWorld();
|
||||
|
||||
if ( s != ForgeDirection.UNKNOWN )
|
||||
{
|
||||
IGridNode sn = part.getGridNode();
|
||||
if ( sn != null )
|
||||
{
|
||||
// this is a really stupid if statement, why was this here?
|
||||
// if ( !sn.getConnections().iterator().hasNext() )
|
||||
|
||||
IPart center = getPart( ForgeDirection.UNKNOWN );
|
||||
if ( center != null )
|
||||
{
|
||||
IGridNode cn = center.getGridNode();
|
||||
if ( cn != null )
|
||||
{
|
||||
AEApi.instance().createGridConnection( cn, sn );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeFromWorld()
|
||||
{
|
||||
inWorld = false;
|
||||
|
||||
for (ForgeDirection s : ForgeDirection.values())
|
||||
{
|
||||
IPart part = getPart( s );
|
||||
if ( part != null )
|
||||
part.removeFromWorld();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canConnectRedstone(ForgeDirection side)
|
||||
{
|
||||
IPart part = getPart( side );
|
||||
return part != null && part.canConnectRedstone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection side)
|
||||
{
|
||||
IPart part = getPart( side );
|
||||
if ( part != null )
|
||||
{
|
||||
IGridNode n = part.getExternalFacingNode();
|
||||
if ( n != null )
|
||||
return n;
|
||||
}
|
||||
|
||||
if ( center != null )
|
||||
return center.getGridNode();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(boolean ignoreCableConnections)
|
||||
{
|
||||
List<AxisAlignedBB> boxes = new LinkedList<AxisAlignedBB>();
|
||||
|
||||
for (ForgeDirection s : ForgeDirection.values())
|
||||
{
|
||||
IPartCollsionHelper bch = new BusCollisionHelper( boxes, s );
|
||||
|
||||
IPart part = getPart( s );
|
||||
if ( part != null )
|
||||
{
|
||||
if ( ignoreCableConnections && part instanceof IPartCable )
|
||||
bch.addBox( 6.0, 6.0, 6.0, 10.0, 10.0, 10.0 );
|
||||
else
|
||||
part.getBoxes( bch );
|
||||
|
||||
}
|
||||
|
||||
if ( !ignoreCableConnections && s != null && s != ForgeDirection.UNKNOWN )
|
||||
{
|
||||
IFacadePart fp = fc.getFacade( s );
|
||||
if ( fp != null )
|
||||
fp.getBoxes( bch );
|
||||
}
|
||||
}
|
||||
|
||||
return boxes;
|
||||
}
|
||||
|
||||
public void onEntityCollision(Entity entity)
|
||||
{
|
||||
for (ForgeDirection s : ForgeDirection.values())
|
||||
{
|
||||
IPart part = getPart( s );
|
||||
if ( part != null )
|
||||
part.onEntityCollision( entity );
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
for (ForgeDirection s : ForgeDirection.values())
|
||||
{
|
||||
IPart part = getPart( s );
|
||||
if ( part != null )
|
||||
return false;
|
||||
|
||||
if ( s != ForgeDirection.UNKNOWN )
|
||||
{
|
||||
IFacadePart fp = fc.getFacade( s );
|
||||
if ( fp != null )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
TileEntity te = getTile();
|
||||
hasRedstone = te.worldObj.isBlockIndirectlyGettingPowered( te.xCoord, te.yCoord, te.zCoord );
|
||||
|
||||
for (ForgeDirection s : ForgeDirection.values())
|
||||
{
|
||||
IPart part = getPart( s );
|
||||
if ( part != null )
|
||||
part.onNeighborChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSolidOnSide(ForgeDirection side)
|
||||
{
|
||||
if ( side == null || side == ForgeDirection.UNKNOWN )
|
||||
return false;
|
||||
|
||||
// facades are solid..
|
||||
IFacadePart fp = fc.getFacade( side );
|
||||
if ( fp != null )
|
||||
return true;
|
||||
|
||||
// buses can be too.
|
||||
IPart part = getPart( side );
|
||||
return part != null && part.isSolid();
|
||||
}
|
||||
|
||||
public int isProvidingWeakPower(ForgeDirection side)
|
||||
{
|
||||
IPart part = getPart( side );
|
||||
return part != null ? part.isProvidingWeakPower() : 0;
|
||||
}
|
||||
|
||||
public int isProvidingStrongPower(ForgeDirection side)
|
||||
{
|
||||
IPart part = getPart( side );
|
||||
return part != null ? part.isProvidingStrongPower() : 0;
|
||||
}
|
||||
|
||||
public void setSide(ForgeDirection s)
|
||||
{
|
||||
switch (s)
|
||||
{
|
||||
case DOWN:
|
||||
BusRenderHelper.instance.ax = ForgeDirection.EAST;
|
||||
BusRenderHelper.instance.ay = ForgeDirection.NORTH;
|
||||
BusRenderHelper.instance.az = ForgeDirection.DOWN;
|
||||
break;
|
||||
case UP:
|
||||
BusRenderHelper.instance.ax = ForgeDirection.EAST;
|
||||
BusRenderHelper.instance.ay = ForgeDirection.SOUTH;
|
||||
BusRenderHelper.instance.az = ForgeDirection.UP;
|
||||
break;
|
||||
case EAST:
|
||||
BusRenderHelper.instance.ax = ForgeDirection.SOUTH;
|
||||
BusRenderHelper.instance.ay = ForgeDirection.UP;
|
||||
BusRenderHelper.instance.az = ForgeDirection.EAST;
|
||||
break;
|
||||
case WEST:
|
||||
BusRenderHelper.instance.ax = ForgeDirection.NORTH;
|
||||
BusRenderHelper.instance.ay = ForgeDirection.UP;
|
||||
BusRenderHelper.instance.az = ForgeDirection.WEST;
|
||||
break;
|
||||
case NORTH:
|
||||
BusRenderHelper.instance.ax = ForgeDirection.WEST;
|
||||
BusRenderHelper.instance.ay = ForgeDirection.UP;
|
||||
BusRenderHelper.instance.az = ForgeDirection.NORTH;
|
||||
break;
|
||||
case SOUTH:
|
||||
BusRenderHelper.instance.ax = ForgeDirection.EAST;
|
||||
BusRenderHelper.instance.ay = ForgeDirection.UP;
|
||||
BusRenderHelper.instance.az = ForgeDirection.SOUTH;
|
||||
break;
|
||||
case UNKNOWN:
|
||||
default:
|
||||
BusRenderHelper.instance.ax = ForgeDirection.EAST;
|
||||
BusRenderHelper.instance.ay = ForgeDirection.UP;
|
||||
BusRenderHelper.instance.az = ForgeDirection.SOUTH;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void renderStatic(double x, double y, double z)
|
||||
{
|
||||
TileEntity te = getTile();
|
||||
RenderBlocksWorkaround renderer = BusRenderer.instance.renderer;
|
||||
|
||||
if ( renderer.blockAccess == null )
|
||||
renderer.blockAccess = Minecraft.getMinecraft().theWorld;
|
||||
|
||||
for (ForgeDirection s : ForgeDirection.values())
|
||||
{
|
||||
setSide( s );
|
||||
|
||||
IPart part = getPart( s );
|
||||
if ( part != null )
|
||||
{
|
||||
renderer.renderAllFaces = true;
|
||||
part.renderStatic( te.xCoord, te.yCoord, te.zCoord, BusRenderHelper.instance, renderer );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !fc.isEmpty() )
|
||||
{
|
||||
/**
|
||||
* snag list of boxes...
|
||||
*/
|
||||
List<AxisAlignedBB> boxes = new ArrayList();
|
||||
for (ForgeDirection s : ForgeDirection.values())
|
||||
{
|
||||
IPart part = getPart( s );
|
||||
if ( part != null )
|
||||
{
|
||||
setSide( s );
|
||||
BusCollisionHelper bch = new BusCollisionHelper( boxes, BusRenderHelper.instance.ax, BusRenderHelper.instance.ay,
|
||||
BusRenderHelper.instance.az );
|
||||
part.getBoxes( bch );
|
||||
}
|
||||
}
|
||||
|
||||
for (ForgeDirection s : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
IFacadePart fPart = fc.getFacade( s );
|
||||
if ( fPart != null )
|
||||
{
|
||||
AxisAlignedBB b = null;
|
||||
AxisAlignedBB pb = fPart.getPrimaryBox();
|
||||
for (AxisAlignedBB bb : boxes)
|
||||
{
|
||||
if ( bb.intersectsWith( pb ) )
|
||||
{
|
||||
if ( b == null )
|
||||
b = bb;
|
||||
else
|
||||
{
|
||||
b.maxX = Math.max( b.maxX, bb.maxX );
|
||||
b.maxY = Math.max( b.maxY, bb.maxY );
|
||||
b.maxZ = Math.max( b.maxZ, bb.maxZ );
|
||||
b.minX = Math.min( b.minX, bb.minX );
|
||||
b.minY = Math.min( b.minY, bb.minY );
|
||||
b.minZ = Math.min( b.minZ, bb.minZ );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setSide( s );
|
||||
fPart.renderStatic( te.xCoord, te.yCoord, te.zCoord, BusRenderHelper.instance, renderer, fc, b, getPart( s ) == null );
|
||||
}
|
||||
}
|
||||
|
||||
renderer.isFacade = false;
|
||||
renderer.enableAO = false;
|
||||
renderer.setTexture( null );
|
||||
renderer.calculations = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void renderDynamic(double x, double y, double z)
|
||||
{
|
||||
for (ForgeDirection s : ForgeDirection.values())
|
||||
{
|
||||
IPart part = getPart( s );
|
||||
if ( part != null )
|
||||
{
|
||||
switch (s)
|
||||
{
|
||||
case DOWN:
|
||||
BusRenderHelper.instance.ax = ForgeDirection.EAST;
|
||||
BusRenderHelper.instance.ay = ForgeDirection.NORTH;
|
||||
BusRenderHelper.instance.az = ForgeDirection.DOWN;
|
||||
break;
|
||||
case UP:
|
||||
BusRenderHelper.instance.ax = ForgeDirection.EAST;
|
||||
BusRenderHelper.instance.ay = ForgeDirection.SOUTH;
|
||||
BusRenderHelper.instance.az = ForgeDirection.UP;
|
||||
break;
|
||||
case EAST:
|
||||
BusRenderHelper.instance.ax = ForgeDirection.SOUTH;
|
||||
BusRenderHelper.instance.ay = ForgeDirection.UP;
|
||||
BusRenderHelper.instance.az = ForgeDirection.EAST;
|
||||
break;
|
||||
case WEST:
|
||||
BusRenderHelper.instance.ax = ForgeDirection.NORTH;
|
||||
BusRenderHelper.instance.ay = ForgeDirection.UP;
|
||||
BusRenderHelper.instance.az = ForgeDirection.WEST;
|
||||
break;
|
||||
case NORTH:
|
||||
BusRenderHelper.instance.ax = ForgeDirection.WEST;
|
||||
BusRenderHelper.instance.ay = ForgeDirection.UP;
|
||||
BusRenderHelper.instance.az = ForgeDirection.NORTH;
|
||||
break;
|
||||
case SOUTH:
|
||||
BusRenderHelper.instance.ax = ForgeDirection.EAST;
|
||||
BusRenderHelper.instance.ay = ForgeDirection.UP;
|
||||
BusRenderHelper.instance.az = ForgeDirection.SOUTH;
|
||||
break;
|
||||
case UNKNOWN:
|
||||
default:
|
||||
BusRenderHelper.instance.ax = ForgeDirection.EAST;
|
||||
BusRenderHelper.instance.ay = ForgeDirection.UP;
|
||||
BusRenderHelper.instance.az = ForgeDirection.SOUTH;
|
||||
break;
|
||||
|
||||
}
|
||||
part.renderDynamic( x, y, z, BusRenderHelper.instance, BusRenderer.instance.renderer );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToStream(DataOutputStream data) throws IOException
|
||||
{
|
||||
int sides = 0;
|
||||
for (int x = 0; x < 7; x++)
|
||||
{
|
||||
IPart p = getPart( ForgeDirection.getOrientation( x ) );
|
||||
if ( p != null )
|
||||
{
|
||||
sides = sides | (1 << x);
|
||||
}
|
||||
}
|
||||
|
||||
data.writeByte( (byte) sides );
|
||||
|
||||
for (int x = 0; x < 7; x++)
|
||||
{
|
||||
ItemStack is = null;
|
||||
IPart p = getPart( ForgeDirection.getOrientation( x ) );
|
||||
if ( p != null )
|
||||
{
|
||||
is = p.getItemStack( false );
|
||||
is.setTagCompound( null );
|
||||
|
||||
data.writeShort( is.getItem().itemID );
|
||||
data.writeShort( is.getItemDamage() );
|
||||
|
||||
if ( p != null )
|
||||
p.writeToStream( data );
|
||||
}
|
||||
}
|
||||
|
||||
fc.writeToStream( data );
|
||||
}
|
||||
|
||||
public boolean readFromStream(DataInputStream data) throws IOException
|
||||
{
|
||||
byte sides = data.readByte();
|
||||
|
||||
for (int x = 0; x < 7; x++)
|
||||
{
|
||||
ForgeDirection side = ForgeDirection.getOrientation( x );
|
||||
if ( ((sides & (1 << x)) == (1 << x)) )
|
||||
{
|
||||
IPart p = getPart( side );
|
||||
|
||||
short itemID = data.readShort();
|
||||
short dmgValue = data.readShort();
|
||||
|
||||
ItemStack current = p != null ? p.getItemStack( false ) : null;
|
||||
if ( current != null && current.getItem().itemID == itemID && current.getItemDamage() == dmgValue )
|
||||
p.readFromStream( data );
|
||||
else
|
||||
{
|
||||
removePart( side );
|
||||
side = addPart( new ItemStack( Item.itemsList[itemID], 1, dmgValue ), side );
|
||||
if ( side != null )
|
||||
{
|
||||
p = getPart( side );
|
||||
p.readFromStream( data );
|
||||
}
|
||||
else
|
||||
throw new RuntimeException( "Invalid Stream For CableBus Container." );
|
||||
}
|
||||
}
|
||||
else
|
||||
removePart( side );
|
||||
}
|
||||
|
||||
return fc.readFromStream( data );
|
||||
}
|
||||
|
||||
ForgeDirection getSide(IPart part)
|
||||
{
|
||||
if ( center == part )
|
||||
return ForgeDirection.UNKNOWN;
|
||||
else
|
||||
{
|
||||
for (int x = 0; x < 6; x++)
|
||||
if ( sides[x] == part )
|
||||
{
|
||||
return ForgeDirection.getOrientation( x );
|
||||
}
|
||||
}
|
||||
throw new RuntimeException( "Uhh Bad Part on Side." );
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
for (ForgeDirection s : ForgeDirection.values())
|
||||
{
|
||||
fc.writeToNBT( data );
|
||||
|
||||
IPart part = getPart( s );
|
||||
if ( part != null )
|
||||
{
|
||||
NBTTagCompound def = new NBTTagCompound();
|
||||
part.getItemStack( false ).writeToNBT( def );
|
||||
|
||||
NBTTagCompound extra = new NBTTagCompound();
|
||||
part.writeToNBT( extra );
|
||||
|
||||
data.setCompoundTag( "def:" + getSide( part ).ordinal(), def );
|
||||
data.setCompoundTag( "extra:" + getSide( part ).ordinal(), extra );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
fc.readFromNBT( data );
|
||||
|
||||
for (int x = 0; x < 7; x++)
|
||||
{
|
||||
ForgeDirection side = ForgeDirection.getOrientation( x );
|
||||
|
||||
NBTTagCompound def = data.getCompoundTag( "def:" + side.ordinal() );
|
||||
NBTTagCompound extra = data.getCompoundTag( "extra:" + side.ordinal() );
|
||||
if ( def != null && extra != null )
|
||||
{
|
||||
IPart p = getPart( side );
|
||||
ItemStack iss = ItemStack.loadItemStackFromNBT( def );
|
||||
if ( iss == null )
|
||||
continue;
|
||||
|
||||
ItemStack current = p == null ? null : p.getItemStack( false );
|
||||
|
||||
if ( Platform.isSameItemType( iss, current ) )
|
||||
p.readFromNBT( extra );
|
||||
else
|
||||
{
|
||||
removePart( side );
|
||||
side = addPart( iss, side );
|
||||
if ( side != null )
|
||||
{
|
||||
p = getPart( side );
|
||||
p.readFromNBT( extra );
|
||||
}
|
||||
else
|
||||
throw new RuntimeException( "Invalid NBT For CableBus Container." );
|
||||
}
|
||||
}
|
||||
else
|
||||
removePart( side );
|
||||
}
|
||||
}
|
||||
|
||||
public List getDrops(List drops)
|
||||
{
|
||||
for (ForgeDirection s : ForgeDirection.values())
|
||||
{
|
||||
IPart part = getPart( s );
|
||||
if ( part != null )
|
||||
{
|
||||
drops.add( part.getItemStack( false ) );
|
||||
part.getDrops( drops, false );
|
||||
}
|
||||
|
||||
if ( s != ForgeDirection.UNKNOWN )
|
||||
{
|
||||
IFacadePart fp = getFacadeContainer().getFacade( s );
|
||||
if ( fp != null )
|
||||
drops.add( fp.getItemStack() );
|
||||
}
|
||||
}
|
||||
|
||||
return drops;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForUpdate()
|
||||
{
|
||||
tcb.markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
{
|
||||
return tcb.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTile()
|
||||
{
|
||||
return tcb.getTile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
{
|
||||
if ( center != null )
|
||||
{
|
||||
IPartCable c = center;
|
||||
return c.getCableConnectionType();
|
||||
}
|
||||
return AECableType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColor getColor()
|
||||
{
|
||||
if ( center != null )
|
||||
{
|
||||
IPartCable c = center;
|
||||
return c.getCableColor();
|
||||
}
|
||||
return AEColor.Transparent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFacadeContainer getFacadeContainer()
|
||||
{
|
||||
return fc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearContainer()
|
||||
{
|
||||
throw new RuntimeException( "Now thats silly!" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlocked(ForgeDirection side)
|
||||
{
|
||||
return tcb.isBlocked( side );
|
||||
}
|
||||
|
||||
public int getLightValue()
|
||||
{
|
||||
int light = 0;
|
||||
for (ForgeDirection d : ForgeDirection.values())
|
||||
{
|
||||
IPart p = getPart( d );
|
||||
if ( p != null )
|
||||
light = Math.max( p.getLightLevel(), light );
|
||||
}
|
||||
return light;
|
||||
}
|
||||
|
||||
public boolean recolourBlock(ForgeDirection side, int colour)
|
||||
{
|
||||
IPart cable = getPart( ForgeDirection.UNKNOWN );
|
||||
if ( cable != null )
|
||||
{
|
||||
IPartCable pc = (IPartCable) cable;
|
||||
|
||||
AEColor colors[] = AEColor.values();
|
||||
if ( colors.length > colour )
|
||||
return pc.changeColor( colors[colour] );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean activate(EntityPlayer player, Vec3 pos)
|
||||
{
|
||||
SelectedPart p = selectPart( pos );
|
||||
if ( p != null && p.part != null )
|
||||
{
|
||||
return p.part.onActivate( player, pos );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SelectedPart selectPart(Vec3 pos)
|
||||
{
|
||||
for (ForgeDirection side : ForgeDirection.values())
|
||||
{
|
||||
IPart p = getPart( side );
|
||||
if ( p != null )
|
||||
{
|
||||
List<AxisAlignedBB> boxes = new LinkedList<AxisAlignedBB>();
|
||||
|
||||
IPartCollsionHelper bch = new BusCollisionHelper( boxes, side );
|
||||
p.getBoxes( bch );
|
||||
for (AxisAlignedBB bb : boxes)
|
||||
{
|
||||
bb = bb.expand( 0.002, 0.002, 0.002 );
|
||||
if ( bb.isVecInside( pos ) )
|
||||
{
|
||||
return new SelectedPart( p, side );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
IFacadePart p = fc.getFacade( side );
|
||||
if ( p != null )
|
||||
{
|
||||
List<AxisAlignedBB> boxes = new LinkedList<AxisAlignedBB>();
|
||||
|
||||
IPartCollsionHelper bch = new BusCollisionHelper( boxes, side );
|
||||
p.getBoxes( bch );
|
||||
for (AxisAlignedBB bb : boxes)
|
||||
{
|
||||
bb = bb.expand( 0.01, 0.01, 0.01 );
|
||||
if ( bb.isVecInside( pos ) )
|
||||
{
|
||||
return new SelectedPart( p, side );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new SelectedPart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PartChanged()
|
||||
{
|
||||
tcb.PartChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForSave()
|
||||
{
|
||||
tcb.markForSave();
|
||||
}
|
||||
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random r)
|
||||
{
|
||||
for (ForgeDirection side : ForgeDirection.values())
|
||||
{
|
||||
IPart p = getPart( side );
|
||||
if ( p != null )
|
||||
{
|
||||
p.randomDisplayTick( world, x, y, z, r );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRedstone(ForgeDirection side)
|
||||
{
|
||||
return hasRedstone;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package appeng.parts;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.me.GridAccessException;
|
||||
|
||||
public class PartBasicState extends AEBasePart
|
||||
{
|
||||
|
||||
protected final int POWERED_FLAG = 1;
|
||||
protected final int CHANNEL_FLAG = 2;
|
||||
|
||||
protected int clientFlags = 0; // sent as byte.
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void chanRender(MENetworkChannelsChanged c)
|
||||
{
|
||||
getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender(MENetworkPowerStatusChange c)
|
||||
{
|
||||
getHost().markForUpdate();
|
||||
}
|
||||
|
||||
public void setColors(boolean hasChan, boolean hasPower)
|
||||
{
|
||||
if ( hasChan )
|
||||
{
|
||||
int l = 14;
|
||||
Tessellator.instance.setBrightness( l << 20 | l << 4 );
|
||||
Tessellator.instance.setColorOpaque_I( getColor().blackVariant );
|
||||
}
|
||||
else if ( hasPower )
|
||||
{
|
||||
int l = 9;
|
||||
Tessellator.instance.setBrightness( l << 20 | l << 4 );
|
||||
Tessellator.instance.setColorOpaque_I( getColor().whiteVariant );
|
||||
}
|
||||
else
|
||||
{
|
||||
Tessellator.instance.setBrightness( 0 );
|
||||
Tessellator.instance.setColorOpaque_I( 0x000000 );
|
||||
}
|
||||
}
|
||||
|
||||
public void renderLights(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
setColors( (clientFlags & (POWERED_FLAG | CHANNEL_FLAG)) == (POWERED_FLAG | CHANNEL_FLAG), (clientFlags & POWERED_FLAG) == POWERED_FLAG );
|
||||
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.EAST, renderer );
|
||||
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.WEST, renderer );
|
||||
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.UP, renderer );
|
||||
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.DOWN, renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(DataOutputStream data) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
|
||||
clientFlags = 0;
|
||||
|
||||
try
|
||||
{
|
||||
if ( proxy.getEnergy().isNetworkPowered() )
|
||||
clientFlags |= POWERED_FLAG;
|
||||
|
||||
if ( proxy.getNode().meetsChannelRequirements() )
|
||||
clientFlags |= CHANNEL_FLAG;
|
||||
|
||||
clientFlags = populateFlags( clientFlags );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// meh
|
||||
}
|
||||
|
||||
data.writeByte( (byte) clientFlags );
|
||||
}
|
||||
|
||||
protected int populateFlags(int cf)
|
||||
{
|
||||
return cf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(DataInputStream data) throws IOException
|
||||
{
|
||||
boolean eh = super.readFromStream( data );
|
||||
|
||||
int old = clientFlags;
|
||||
clientFlags = data.readByte();
|
||||
|
||||
return eh || old != clientFlags;
|
||||
}
|
||||
|
||||
public PartBasicState(Class c, ItemStack is) {
|
||||
super( c, is );
|
||||
proxy.setFlags( GridFlags.REQURE_CHANNEL );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package appeng.parts.automation;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartCollsionHelper;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.parts.PartBasicState;
|
||||
|
||||
public class PartAnnihilationPlane extends PartBasicState
|
||||
{
|
||||
|
||||
public PartAnnihilationPlane(ItemStack is) {
|
||||
super( PartAnnihilationPlane.class, is );
|
||||
}
|
||||
|
||||
@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( 1, 1, 15, 15, 15, 16 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setBounds( 5, 5, 14, 11, 11, 15 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
int minX = 1;
|
||||
int minY = 1;
|
||||
int maxX = 15;
|
||||
int maxY = 15;
|
||||
|
||||
ForgeDirection e = rh.getWorldX();
|
||||
ForgeDirection u = rh.getWorldY();
|
||||
|
||||
TileEntity te = getHost().getTile();
|
||||
|
||||
if ( isTransitionPlane( te.worldObj.getBlockTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), side ) )
|
||||
minX = 0;
|
||||
|
||||
if ( isTransitionPlane( te.worldObj.getBlockTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), side ) )
|
||||
maxX = 16;
|
||||
|
||||
if ( isTransitionPlane( te.worldObj.getBlockTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), side ) )
|
||||
minY = 0;
|
||||
|
||||
if ( isTransitionPlane( te.worldObj.getBlockTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), side ) )
|
||||
maxY = 16;
|
||||
|
||||
boolean isActive = (clientFlags & (POWERED_FLAG | CHANNEL_FLAG)) == (POWERED_FLAG | CHANNEL_FLAG);
|
||||
|
||||
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(),
|
||||
CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockAnnihilationPlaneOn.getIcon() : is.getIconIndex(),
|
||||
CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
|
||||
rh.setBounds( minX, minY, 15, maxX, maxY, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockAnnihilationPlaneOn.getIcon() : is.getIconIndex(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
|
||||
rh.setBounds( 5, 5, 14, 11, 11, 15 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
renderLights( x, y, z, rh, renderer );
|
||||
}
|
||||
|
||||
private boolean isTransitionPlane(TileEntity blockTileEntity, ForgeDirection side)
|
||||
{
|
||||
if ( blockTileEntity instanceof IPartHost )
|
||||
{
|
||||
IPart p = ((IPartHost) blockTileEntity).getPart( side );
|
||||
return p instanceof PartAnnihilationPlane;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollsionHelper bch)
|
||||
{
|
||||
int minX = 1;
|
||||
int minY = 1;
|
||||
int maxX = 15;
|
||||
int maxY = 15;
|
||||
|
||||
TileEntity te = getHost().getTile();
|
||||
|
||||
int x = te.xCoord;
|
||||
int y = te.yCoord;
|
||||
int z = te.zCoord;
|
||||
|
||||
ForgeDirection e = bch.getWorldX();
|
||||
ForgeDirection u = bch.getWorldY();
|
||||
|
||||
if ( isTransitionPlane( te.worldObj.getBlockTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), side ) )
|
||||
minX = 0;
|
||||
|
||||
if ( isTransitionPlane( te.worldObj.getBlockTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), side ) )
|
||||
maxX = 16;
|
||||
|
||||
if ( isTransitionPlane( te.worldObj.getBlockTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), side ) )
|
||||
minY = 0;
|
||||
|
||||
if ( isTransitionPlane( te.worldObj.getBlockTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), side ) )
|
||||
maxY = 16;
|
||||
|
||||
bch.addBox( 5, 5, 14, 11, 11, 15 );
|
||||
bch.addBox( minX, minY, 15, maxX, maxY, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package appeng.parts.automation;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.parts.IPartCollsionHelper;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.parts.PartBasicState;
|
||||
|
||||
public class PartExportBus extends PartBasicState
|
||||
{
|
||||
|
||||
public PartExportBus(ItemStack is) {
|
||||
super( PartExportBus.class, is );
|
||||
}
|
||||
|
||||
@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( 4, 4, 12, 12, 12, 14 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setBounds( 5, 5, 14, 11, 11, 15 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setBounds( 6, 6, 15, 10, 10, 16 );
|
||||
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( 4, 4, 12, 12, 12, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setBounds( 5, 5, 14, 11, 11, 15 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setBounds( 6, 6, 15, 10, 10, 16 );
|
||||
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, 11, 10, 10, 12 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
renderLights( x, y, z, rh, renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollsionHelper bch)
|
||||
{
|
||||
bch.addBox( 4, 4, 12, 12, 12, 14 );
|
||||
bch.addBox( 5, 5, 14, 11, 11, 15 );
|
||||
bch.addBox( 6, 6, 15, 10, 10, 16 );
|
||||
bch.addBox( 6, 6, 11, 10, 10, 12 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package appeng.parts.automation;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartCollsionHelper;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.parts.PartBasicState;
|
||||
|
||||
public class PartFormationPlane extends PartBasicState
|
||||
{
|
||||
|
||||
public PartFormationPlane(ItemStack is) {
|
||||
super( PartFormationPlane.class, is );
|
||||
}
|
||||
|
||||
@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( 1, 1, 15, 15, 15, 16 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setBounds( 5, 5, 14, 11, 11, 15 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
int minX = 1;
|
||||
int minY = 1;
|
||||
int maxX = 15;
|
||||
int maxY = 15;
|
||||
|
||||
ForgeDirection e = rh.getWorldX();
|
||||
ForgeDirection u = rh.getWorldY();
|
||||
|
||||
TileEntity te = getHost().getTile();
|
||||
|
||||
if ( isTransitionPlane( te.worldObj.getBlockTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), side ) )
|
||||
minX = 0;
|
||||
|
||||
if ( isTransitionPlane( te.worldObj.getBlockTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), side ) )
|
||||
maxX = 16;
|
||||
|
||||
if ( isTransitionPlane( te.worldObj.getBlockTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), side ) )
|
||||
minY = 0;
|
||||
|
||||
if ( isTransitionPlane( te.worldObj.getBlockTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), side ) )
|
||||
maxY = 16;
|
||||
|
||||
boolean isActive = (clientFlags & (POWERED_FLAG | CHANNEL_FLAG)) == (POWERED_FLAG | CHANNEL_FLAG);
|
||||
|
||||
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(),
|
||||
CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockFormPlaneOn.getIcon() : is.getIconIndex(),
|
||||
CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
|
||||
rh.setBounds( minX, minY, 15, maxX, maxY, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockFormPlaneOn.getIcon() : is.getIconIndex(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
|
||||
rh.setBounds( 5, 5, 14, 11, 11, 15 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
renderLights( x, y, z, rh, renderer );
|
||||
}
|
||||
|
||||
private boolean isTransitionPlane(TileEntity blockTileEntity, ForgeDirection side)
|
||||
{
|
||||
if ( blockTileEntity instanceof IPartHost )
|
||||
{
|
||||
IPart p = ((IPartHost) blockTileEntity).getPart( side );
|
||||
return p instanceof PartFormationPlane;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollsionHelper bch)
|
||||
{
|
||||
int minX = 1;
|
||||
int minY = 1;
|
||||
int maxX = 15;
|
||||
int maxY = 15;
|
||||
|
||||
TileEntity te = getHost().getTile();
|
||||
|
||||
int x = te.xCoord;
|
||||
int y = te.yCoord;
|
||||
int z = te.zCoord;
|
||||
|
||||
ForgeDirection e = bch.getWorldX();
|
||||
ForgeDirection u = bch.getWorldY();
|
||||
|
||||
if ( isTransitionPlane( te.worldObj.getBlockTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), side ) )
|
||||
minX = 0;
|
||||
|
||||
if ( isTransitionPlane( te.worldObj.getBlockTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), side ) )
|
||||
maxX = 16;
|
||||
|
||||
if ( isTransitionPlane( te.worldObj.getBlockTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), side ) )
|
||||
minY = 0;
|
||||
|
||||
if ( isTransitionPlane( te.worldObj.getBlockTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), side ) )
|
||||
maxY = 16;
|
||||
|
||||
bch.addBox( 5, 5, 14, 11, 11, 15 );
|
||||
bch.addBox( minX, minY, 15, maxX, maxY, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package appeng.parts.automation;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.parts.IPartCollsionHelper;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.parts.PartBasicState;
|
||||
|
||||
public class PartImportBus extends PartBasicState
|
||||
{
|
||||
|
||||
public PartImportBus(ItemStack is) {
|
||||
super( PartImportBus.class, is );
|
||||
}
|
||||
|
||||
@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( 4, 4, 14, 12, 12, 15 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setBounds( 5, 5, 13, 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( 4, 4, 14, 12, 12, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setBounds( 5, 5, 13, 11, 11, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setBounds( 6, 6, 12, 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, 11, 10, 10, 12 );
|
||||
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, 12 );
|
||||
bch.addBox( 6, 6, 12, 10, 10, 13 );
|
||||
bch.addBox( 5, 5, 13, 11, 11, 14 );
|
||||
bch.addBox( 4, 4, 14, 12, 12, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
package appeng.parts.automation;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.parts.IPartCollsionHelper;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.parts.PartBasicState;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PartLevelEmitter extends PartBasicState
|
||||
{
|
||||
|
||||
final int FLAG_ON = 4;
|
||||
|
||||
@Override
|
||||
protected int populateFlags(int cf)
|
||||
{
|
||||
return cf | (isLevelEmitterOn() ? FLAG_ON : 0);
|
||||
}
|
||||
|
||||
public PartLevelEmitter(ItemStack is) {
|
||||
super( PartLevelEmitter.class, is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.setTexture( is.getIconIndex() );
|
||||
Tessellator.instance.startDrawingQuads();
|
||||
renderTorchAtAngle( 0, -0.5, 0 );
|
||||
Tessellator.instance.draw();
|
||||
// rh.setBounds( 7, 7, 10, 9, 9, 15 );
|
||||
// rh.renderInventoryBox( renderer );
|
||||
}
|
||||
|
||||
double cenx;
|
||||
double ceny;
|
||||
double cenz;
|
||||
|
||||
public void addVertexWithUV(double x, double y, double z, double u, double v)
|
||||
{
|
||||
Tessellator var12 = Tessellator.instance;
|
||||
|
||||
x -= cenx;
|
||||
y -= ceny;
|
||||
z -= cenz;
|
||||
|
||||
if ( side == ForgeDirection.DOWN )
|
||||
{
|
||||
y = -y;
|
||||
z = -z;
|
||||
}
|
||||
|
||||
if ( side == ForgeDirection.EAST )
|
||||
{
|
||||
double m = x;
|
||||
x = y;
|
||||
y = m;
|
||||
y = -y;
|
||||
}
|
||||
|
||||
if ( side == ForgeDirection.WEST )
|
||||
{
|
||||
double m = x;
|
||||
x = -y;
|
||||
y = m;
|
||||
}
|
||||
|
||||
if ( side == ForgeDirection.SOUTH )
|
||||
{
|
||||
double m = z;
|
||||
z = y;
|
||||
y = m;
|
||||
y = -y;
|
||||
}
|
||||
|
||||
if ( side == ForgeDirection.NORTH )
|
||||
{
|
||||
double m = z;
|
||||
z = -y;
|
||||
y = m;
|
||||
}
|
||||
|
||||
x += cenx;// + orientation.offsetX * 0.4;
|
||||
y += ceny;// + orientation.offsetY * 0.4;
|
||||
z += cenz;// + orientation.offsetZ * 0.4;
|
||||
|
||||
var12.addVertexWithUV( x, y, z, u, v );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random r)
|
||||
{
|
||||
if ( isLevelEmitterOn() )
|
||||
{
|
||||
ForgeDirection d = side;
|
||||
|
||||
double d0 = (double) ((float) d.offsetX * 0.45F) + (double) (r.nextFloat() - 0.5F) * 0.2D;
|
||||
double d1 = (double) ((float) d.offsetY * 0.45F) + (double) (r.nextFloat() - 0.5F) * 0.2D;
|
||||
double d2 = (double) ((float) d.offsetZ * 0.45F) + (double) (r.nextFloat() - 0.5F) * 0.2D;
|
||||
|
||||
world.spawnParticle( "reddust", 0.5 + x + d0, 0.5 + y + d1, 0.5 + z + d2, 0.0D, 0.0D, 0.0D );
|
||||
}
|
||||
}
|
||||
|
||||
public void renderTorchAtAngle(double baseX, double baseY, double baseZ)
|
||||
{
|
||||
boolean isOn = isLevelEmitterOn();
|
||||
Icon icon = (isOn ? CableBusTextures.LevelEmitterTorchOn.getIcon() : is.getIconIndex());
|
||||
//
|
||||
cenx = baseX + 0.5;
|
||||
ceny = baseY + 0.5;
|
||||
cenz = baseZ + 0.5;
|
||||
|
||||
baseY += 7.0 / 16.0;
|
||||
;
|
||||
double par10 = 0;
|
||||
// double par11 = 0;
|
||||
double Zero = 0;
|
||||
|
||||
/*
|
||||
* double d5 = (double)icon.func_94209_e(); double d6 = (double)icon.func_94206_g(); double d7 =
|
||||
* (double)icon.func_94212_f(); double d8 = (double)icon.func_94210_h(); double d9 =
|
||||
* (double)icon.func_94214_a(7.0D); double d10 = (double)icon.func_94207_b(6.0D); double d11 =
|
||||
* (double)icon.func_94214_a(9.0D); double d12 = (double)icon.func_94207_b(8.0D); double d13 =
|
||||
* (double)icon.func_94214_a(7.0D); double d14 = (double)icon.func_94207_b(13.0D); double d15 =
|
||||
* (double)icon.func_94214_a(9.0D); double d16 = (double)icon.func_94207_b(15.0D);
|
||||
*/
|
||||
|
||||
float var16 = icon.getMinU();
|
||||
float var17 = icon.getMaxU();
|
||||
float var18 = icon.getMinV();
|
||||
float var19 = icon.getMaxV();
|
||||
/*
|
||||
* float var16 = (float)var14 / 256.0F; float var17 = ((float)var14 + 15.99F) / 256.0F; float var18 =
|
||||
* (float)var15 / 256.0F; float var19 = ((float)var15 + 15.99F) / 256.0F;
|
||||
*/
|
||||
double var20 = (double) icon.getInterpolatedU( 7.0D );
|
||||
double var24 = (double) icon.getInterpolatedU( 9.0D );
|
||||
double var22 = (double) icon.getInterpolatedV( 6.0D + (isOn ? 0 : 1.0D) );
|
||||
double var26 = (double) icon.getInterpolatedV( 8.0D + (isOn ? 0 : 1.0D) );
|
||||
double var28 = (double) icon.getInterpolatedU( 7.0D );
|
||||
double var30 = (double) icon.getInterpolatedV( 13.0D );
|
||||
double var32 = (double) icon.getInterpolatedU( 9.0D );
|
||||
double var34 = (double) icon.getInterpolatedV( 15.0D );
|
||||
|
||||
double var22b = (double) icon.getInterpolatedV( 9.0D );
|
||||
double var26b = (double) icon.getInterpolatedV( 11.0D );
|
||||
|
||||
baseX += 0.5D;
|
||||
baseZ += 0.5D;
|
||||
double var36 = baseX - 0.5D;
|
||||
double var38 = baseX + 0.5D;
|
||||
double var40 = baseZ - 0.5D;
|
||||
double var42 = baseZ + 0.5D;
|
||||
double var44 = 0.0625D;
|
||||
double var422 = 0.1915D;
|
||||
double TorchLen = 0.625D;
|
||||
|
||||
double toff = 0.0d;
|
||||
|
||||
if ( !isOn )
|
||||
{
|
||||
toff = 1.0d / 16.0d;
|
||||
}
|
||||
|
||||
Tessellator var12 = Tessellator.instance;
|
||||
if ( isOn )
|
||||
{
|
||||
var12.setColorOpaque_F( 1.0F, 1.0F, 1.0F );
|
||||
var12.setBrightness( 11 << 20 | 11 << 4 );
|
||||
}
|
||||
|
||||
this.addVertexWithUV( baseX + Zero * (1.0D - TorchLen) - var44, baseY + TorchLen - toff, baseZ + par10 * (1.0D - TorchLen) - var44, var20, var22 );
|
||||
this.addVertexWithUV( baseX + Zero * (1.0D - TorchLen) - var44, baseY + TorchLen - toff, baseZ + par10 * (1.0D - TorchLen) + var44, var20, var26 );
|
||||
this.addVertexWithUV( baseX + Zero * (1.0D - TorchLen) + var44, baseY + TorchLen - toff, baseZ + par10 * (1.0D - TorchLen) + var44, var24, var26 );
|
||||
this.addVertexWithUV( baseX + Zero * (1.0D - TorchLen) + var44, baseY + TorchLen - toff, baseZ + par10 * (1.0D - TorchLen) - var44, var24, var22 );
|
||||
|
||||
this.addVertexWithUV( baseX + Zero * (1.0D - TorchLen) + var44, baseY + var422, baseZ + par10 * (1.0D - TorchLen) - var44, var24, var22b );
|
||||
this.addVertexWithUV( baseX + Zero * (1.0D - TorchLen) + var44, baseY + var422, baseZ + par10 * (1.0D - TorchLen) + var44, var24, var26b );
|
||||
this.addVertexWithUV( baseX + Zero * (1.0D - TorchLen) - var44, baseY + var422, baseZ + par10 * (1.0D - TorchLen) + var44, var20, var26b );
|
||||
this.addVertexWithUV( baseX + Zero * (1.0D - TorchLen) - var44, baseY + var422, baseZ + par10 * (1.0D - TorchLen) - var44, var20, var22b );
|
||||
|
||||
this.addVertexWithUV( baseX + var44 + Zero, baseY, baseZ - var44 + par10, var32, var30 );
|
||||
this.addVertexWithUV( baseX + var44 + Zero, baseY, baseZ + var44 + par10, var32, var34 );
|
||||
this.addVertexWithUV( baseX - var44 + Zero, baseY, baseZ + var44 + par10, var28, var34 );
|
||||
this.addVertexWithUV( baseX - var44 + Zero, baseY, baseZ - var44 + par10, var28, var30 );
|
||||
|
||||
this.addVertexWithUV( baseX - var44, baseY + 1.0D, var40, (double) var16, (double) var18 );
|
||||
this.addVertexWithUV( baseX - var44 + Zero, baseY + 0.0D, var40 + par10, (double) var16, (double) var19 );
|
||||
this.addVertexWithUV( baseX - var44 + Zero, baseY + 0.0D, var42 + par10, (double) var17, (double) var19 );
|
||||
this.addVertexWithUV( baseX - var44, baseY + 1.0D, var42, (double) var17, (double) var18 );
|
||||
|
||||
this.addVertexWithUV( baseX + var44, baseY + 1.0D, var42, (double) var16, (double) var18 );
|
||||
this.addVertexWithUV( baseX + Zero + var44, baseY + 0.0D, var42 + par10, (double) var16, (double) var19 );
|
||||
this.addVertexWithUV( baseX + Zero + var44, baseY + 0.0D, var40 + par10, (double) var17, (double) var19 );
|
||||
this.addVertexWithUV( baseX + var44, baseY + 1.0D, var40, (double) var17, (double) var18 );
|
||||
|
||||
this.addVertexWithUV( var36, baseY + 1.0D, baseZ + var44, (double) var16, (double) var18 );
|
||||
this.addVertexWithUV( var36 + Zero, baseY + 0.0D, baseZ + var44 + par10, (double) var16, (double) var19 );
|
||||
this.addVertexWithUV( var38 + Zero, baseY + 0.0D, baseZ + var44 + par10, (double) var17, (double) var19 );
|
||||
this.addVertexWithUV( var38, baseY + 1.0D, baseZ + var44, (double) var17, (double) var18 );
|
||||
|
||||
this.addVertexWithUV( var38, baseY + 1.0D, baseZ - var44, (double) var16, (double) var18 );
|
||||
this.addVertexWithUV( var38 + Zero, baseY + 0.0D, baseZ - var44 + par10, (double) var16, (double) var19 );
|
||||
this.addVertexWithUV( var36 + Zero, baseY + 0.0D, baseZ - var44 + par10, (double) var17, (double) var19 );
|
||||
this.addVertexWithUV( var36, baseY + 1.0D, baseZ - var44, (double) var17, (double) var18 );
|
||||
}
|
||||
|
||||
boolean status = false;;
|
||||
|
||||
private boolean isLevelEmitterOn()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return (clientFlags & FLAG_ON) == FLAG_ON;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.setTexture( is.getIconIndex() );
|
||||
// rh.setTexture( CableBusTextures.ItemPartLevelEmitterOn.getIcon() );
|
||||
|
||||
// rh.setBounds( 2, 2, 14, 14, 14, 16 );
|
||||
// rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
// rh.setBounds( 7, 7, 10, 9, 9, 15 );
|
||||
// rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
renderer.renderAllFaces = true;
|
||||
|
||||
Tessellator tess = Tessellator.instance;
|
||||
tess.setBrightness( rh.getBlock().getMixedBrightnessForBlock( this.getHost().getTile().worldObj, x, y, z ) );
|
||||
tess.setColorOpaque_F( 1.0F, 1.0F, 1.0F );
|
||||
|
||||
renderTorchAtAngle( x, y, z );
|
||||
|
||||
renderer.renderAllFaces = false;
|
||||
|
||||
rh.setBounds( 7, 7, 11, 9, 9, 12 );
|
||||
renderLights( x, y, z, rh, renderer );
|
||||
|
||||
// super.renderWorldBlock( world, x, y, z, block, modelId, renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollsionHelper bch)
|
||||
{
|
||||
bch.addBox( 7, 7, 10, 9, 9, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
{
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,823 @@
|
||||
package appeng.parts.networking;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.implementations.IPartCable;
|
||||
import appeng.api.networking.IGridConnection;
|
||||
import appeng.api.networking.IGridHost;
|
||||
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;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.IReadOnlyCollection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.client.texture.FlipableIcon;
|
||||
import appeng.client.texture.TaughtIcon;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.parts.AEBasePart;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PartCable extends AEBasePart implements IPartCable
|
||||
{
|
||||
|
||||
int channelsOnSide[] = new int[] { 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
EnumSet<ForgeDirection> connections = EnumSet.noneOf( ForgeDirection.class );
|
||||
boolean powered = false;
|
||||
|
||||
public PartCable(Class c, ItemStack is) {
|
||||
super( c, is );
|
||||
proxy.setIdlePowerUsage( 1.0 / 16.0 );
|
||||
proxy.myColor = AEColor.fromCable( is );
|
||||
}
|
||||
|
||||
public Icon getGlassTexture(AEColor c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case Black:
|
||||
return CableBusTextures.MECable_Black.getIcon();
|
||||
case Blue:
|
||||
return CableBusTextures.MECable_Blue.getIcon();
|
||||
case Brown:
|
||||
return CableBusTextures.MECable_Brown.getIcon();
|
||||
case Cyan:
|
||||
return CableBusTextures.MECable_Cyan.getIcon();
|
||||
case Gray:
|
||||
return CableBusTextures.MECable_Grey.getIcon();
|
||||
case Green:
|
||||
return CableBusTextures.MECable_Green.getIcon();
|
||||
case LightBlue:
|
||||
return CableBusTextures.MECable_LightBlue.getIcon();
|
||||
case LightGray:
|
||||
return CableBusTextures.MECable_LightGrey.getIcon();
|
||||
case Lime:
|
||||
return CableBusTextures.MECable_Lime.getIcon();
|
||||
case Magenta:
|
||||
return CableBusTextures.MECable_Magenta.getIcon();
|
||||
case Orange:
|
||||
return CableBusTextures.MECable_Orange.getIcon();
|
||||
case Pink:
|
||||
return CableBusTextures.MECable_Pink.getIcon();
|
||||
case Purple:
|
||||
return CableBusTextures.MECable_Purple.getIcon();
|
||||
case Red:
|
||||
return CableBusTextures.MECable_Red.getIcon();
|
||||
case White:
|
||||
return CableBusTextures.MECable_White.getIcon();
|
||||
case Yellow:
|
||||
return CableBusTextures.MECable_Yellow.getIcon();
|
||||
default:
|
||||
}
|
||||
return is.getIconIndex();
|
||||
}
|
||||
|
||||
public Icon getTexture(AEColor c)
|
||||
{
|
||||
return getGlassTexture( c );
|
||||
}
|
||||
|
||||
public Icon getCoveredTexture(AEColor c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case Black:
|
||||
return CableBusTextures.MECovered_Black.getIcon();
|
||||
case Blue:
|
||||
return CableBusTextures.MECovered_Blue.getIcon();
|
||||
case Brown:
|
||||
return CableBusTextures.MECovered_Brown.getIcon();
|
||||
case Cyan:
|
||||
return CableBusTextures.MECovered_Cyan.getIcon();
|
||||
case Gray:
|
||||
return CableBusTextures.MECovered_Gray.getIcon();
|
||||
case Green:
|
||||
return CableBusTextures.MECovered_Green.getIcon();
|
||||
case LightBlue:
|
||||
return CableBusTextures.MECovered_LightBlue.getIcon();
|
||||
case LightGray:
|
||||
return CableBusTextures.MECovered_LightGrey.getIcon();
|
||||
case Lime:
|
||||
return CableBusTextures.MECovered_Lime.getIcon();
|
||||
case Magenta:
|
||||
return CableBusTextures.MECovered_Magenta.getIcon();
|
||||
case Orange:
|
||||
return CableBusTextures.MECovered_Orange.getIcon();
|
||||
case Pink:
|
||||
return CableBusTextures.MECovered_Pink.getIcon();
|
||||
case Purple:
|
||||
return CableBusTextures.MECovered_Purple.getIcon();
|
||||
case Red:
|
||||
return CableBusTextures.MECovered_Red.getIcon();
|
||||
case White:
|
||||
return CableBusTextures.MECovered_White.getIcon();
|
||||
case Yellow:
|
||||
return CableBusTextures.MECovered_Yellow.getIcon();
|
||||
default:
|
||||
}
|
||||
return AEApi.instance().parts().partCableCovered.item().getIconIndex( AEApi.instance().parts().partCableCovered.stack( 1 ) );
|
||||
}
|
||||
|
||||
public Icon getSmartTexture(AEColor c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case Black:
|
||||
return CableBusTextures.MESmart_Black.getIcon();
|
||||
case Blue:
|
||||
return CableBusTextures.MESmart_Blue.getIcon();
|
||||
case Brown:
|
||||
return CableBusTextures.MESmart_Brown.getIcon();
|
||||
case Cyan:
|
||||
return CableBusTextures.MESmart_Cyan.getIcon();
|
||||
case Gray:
|
||||
return CableBusTextures.MESmart_Gray.getIcon();
|
||||
case Green:
|
||||
return CableBusTextures.MESmart_Green.getIcon();
|
||||
case LightBlue:
|
||||
return CableBusTextures.MESmart_LightBlue.getIcon();
|
||||
case LightGray:
|
||||
return CableBusTextures.MESmart_LightGrey.getIcon();
|
||||
case Lime:
|
||||
return CableBusTextures.MESmart_Lime.getIcon();
|
||||
case Magenta:
|
||||
return CableBusTextures.MESmart_Magenta.getIcon();
|
||||
case Orange:
|
||||
return CableBusTextures.MESmart_Orange.getIcon();
|
||||
case Pink:
|
||||
return CableBusTextures.MESmart_Pink.getIcon();
|
||||
case Purple:
|
||||
return CableBusTextures.MESmart_Purple.getIcon();
|
||||
case Red:
|
||||
return CableBusTextures.MESmart_Red.getIcon();
|
||||
case White:
|
||||
return CableBusTextures.MESmart_White.getIcon();
|
||||
case Yellow:
|
||||
return CableBusTextures.MESmart_Yellow.getIcon();
|
||||
default:
|
||||
}
|
||||
|
||||
return is.getIconIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColor getCableColor()
|
||||
{
|
||||
return proxy.myColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType()
|
||||
{
|
||||
return AECableType.GLASS;
|
||||
}
|
||||
|
||||
public AENetworkProxy getProxy()
|
||||
{
|
||||
return proxy;
|
||||
}
|
||||
|
||||
public void markForUpdate()
|
||||
{
|
||||
getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(DataOutputStream data) throws IOException
|
||||
{
|
||||
int cs = 0;
|
||||
int sideOut = 0;
|
||||
|
||||
IGridNode n = getGridNode();
|
||||
if ( n != null )
|
||||
{
|
||||
for (ForgeDirection thisSide : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
IPart part = getHost().getPart( thisSide );
|
||||
if ( part != null )
|
||||
{
|
||||
if ( part.getGridNode() != null )
|
||||
{
|
||||
IReadOnlyCollection<IGridConnection> set = part.getGridNode().getConnections();
|
||||
for (IGridConnection gc : set)
|
||||
{
|
||||
sideOut |= gc.getUsedChannels() << (4 * thisSide.ordinal());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (IGridConnection gc : n.getConnections())
|
||||
{
|
||||
ForgeDirection side = gc.getDirection( n );
|
||||
if ( side != ForgeDirection.UNKNOWN )
|
||||
{
|
||||
sideOut |= gc.getUsedChannels() << (4 * side.ordinal());
|
||||
cs |= (1 << side.ordinal());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if ( proxy.getEnergy().isNetworkPowered() )
|
||||
cs |= (1 << ForgeDirection.UNKNOWN.ordinal());
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// aww...
|
||||
}
|
||||
|
||||
data.writeByte( (byte) cs );
|
||||
data.writeInt( sideOut );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(DataInputStream data) throws IOException
|
||||
{
|
||||
int cs = data.readByte();
|
||||
int sideOut = data.readInt();
|
||||
|
||||
EnumSet<ForgeDirection> myC = connections;
|
||||
boolean wasPowered = powered;
|
||||
powered = false;
|
||||
boolean chchanged = false;
|
||||
|
||||
for (ForgeDirection d : ForgeDirection.values())
|
||||
{
|
||||
if ( d != ForgeDirection.UNKNOWN )
|
||||
{
|
||||
int ch = (sideOut >> (d.ordinal() * 4)) & 0xF;
|
||||
if ( ch != channelsOnSide[d.ordinal()] )
|
||||
{
|
||||
chchanged = true;
|
||||
channelsOnSide[d.ordinal()] = ch;
|
||||
}
|
||||
}
|
||||
|
||||
if ( d == ForgeDirection.UNKNOWN )
|
||||
{
|
||||
int id = 1 << d.ordinal();
|
||||
if ( id == (cs & id) )
|
||||
powered = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int id = 1 << d.ordinal();
|
||||
if ( id == (cs & id) )
|
||||
connections.add( d );
|
||||
else
|
||||
connections.remove( d );
|
||||
}
|
||||
}
|
||||
|
||||
return !myC.equals( connections ) || wasPowered != powered || chchanged;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollsionHelper bch)
|
||||
{
|
||||
bch.addBox( 6.0, 6.0, 6.0, 10.0, 10.0, 10.0 );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
IGridNode n = getGridNode();
|
||||
if ( n != null )
|
||||
connections = n.getConnectedSides();
|
||||
else
|
||||
connections.clear();
|
||||
}
|
||||
|
||||
for (ForgeDirection of : connections)
|
||||
{
|
||||
switch (of)
|
||||
{
|
||||
case DOWN:
|
||||
bch.addBox( 6.0, 0.0, 6.0, 10.0, 6.0, 10.0 );
|
||||
break;
|
||||
case EAST:
|
||||
bch.addBox( 10.0, 6.0, 6.0, 16.0, 10.0, 10.0 );
|
||||
break;
|
||||
case NORTH:
|
||||
bch.addBox( 6.0, 6.0, 0.0, 10.0, 10.0, 6.0 );
|
||||
break;
|
||||
case SOUTH:
|
||||
bch.addBox( 6.0, 6.0, 10.0, 10.0, 10.0, 16.0 );
|
||||
break;
|
||||
case UP:
|
||||
bch.addBox( 6.0, 10.0, 6.0, 10.0, 16.0, 10.0 );
|
||||
break;
|
||||
case WEST:
|
||||
bch.addBox( 0.0, 6.0, 6.0, 6.0, 10.0, 10.0 );
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
GL11.glTranslated( -0.2, -0.3, 0.0 );
|
||||
|
||||
rh.setTexture( getTexture( getCableColor() ) );
|
||||
rh.setBounds( 6.0f, 6.0f, 2.0f, 10.0f, 10.0f, 14.0f );
|
||||
rh.renderInventoryBox( renderer );
|
||||
rh.setTexture( null );
|
||||
}
|
||||
|
||||
public void rendereGlassConection(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer, ForgeDirection of)
|
||||
{
|
||||
TileEntity te = this.tile.worldObj.getBlockTileEntity( x + of.offsetX, y + of.offsetY, z + of.offsetZ );
|
||||
IPartHost ccph = te instanceof IPartHost ? (IPartHost) te : null;
|
||||
IGridHost gh = te instanceof IGridHost ? (IGridHost) te : null;
|
||||
|
||||
if ( gh != null && ccph != null && gh.getCableConnectionType( of ) == AECableType.GLASS && ccph.getColor() != AEColor.Transparent
|
||||
&& ccph.getPart( of.getOpposite() ) == null )
|
||||
rh.setTexture( getTexture( ccph.getColor() ) );
|
||||
else if ( ccph == null && gh != null && gh.getCableConnectionType( of ) != AECableType.GLASS )
|
||||
{
|
||||
rh.setTexture( getCoveredTexture( getCableColor() ) );
|
||||
switch (of)
|
||||
{
|
||||
case DOWN:
|
||||
rh.setBounds( 5, 0, 5, 11, 4, 11 );
|
||||
break;
|
||||
case EAST:
|
||||
rh.setBounds( 12, 5, 5, 16, 11, 11 );
|
||||
break;
|
||||
case NORTH:
|
||||
rh.setBounds( 5, 5, 0, 11, 11, 4 );
|
||||
break;
|
||||
case SOUTH:
|
||||
rh.setBounds( 5, 5, 12, 11, 11, 16 );
|
||||
break;
|
||||
case UP:
|
||||
rh.setBounds( 5, 12, 5, 11, 16, 11 );
|
||||
break;
|
||||
case WEST:
|
||||
rh.setBounds( 0, 5, 5, 4, 11, 11 );
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setTexture( getTexture( getCableColor() ) );
|
||||
}
|
||||
else
|
||||
rh.setTexture( getTexture( getCableColor() ) );
|
||||
|
||||
switch (of)
|
||||
{
|
||||
case DOWN:
|
||||
rh.setBounds( 6, 0, 6, 10, 6, 10 );
|
||||
break;
|
||||
case EAST:
|
||||
rh.setBounds( 10, 6, 6, 16, 10, 10 );
|
||||
break;
|
||||
case NORTH:
|
||||
rh.setBounds( 6, 6, 0, 10, 10, 6 );
|
||||
break;
|
||||
case SOUTH:
|
||||
rh.setBounds( 6, 6, 10, 10, 10, 16 );
|
||||
break;
|
||||
case UP:
|
||||
rh.setBounds( 6, 10, 6, 10, 16, 10 );
|
||||
break;
|
||||
case WEST:
|
||||
rh.setBounds( 0, 6, 6, 6, 10, 10 );
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
}
|
||||
|
||||
protected CableBusTextures getChannelTex(int i, boolean b)
|
||||
{
|
||||
if ( !powered )
|
||||
i = 0;
|
||||
|
||||
if ( b )
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
default:
|
||||
return CableBusTextures.Channels10;
|
||||
case 5:
|
||||
return CableBusTextures.Channels11;
|
||||
case 6:
|
||||
return CableBusTextures.Channels12;
|
||||
case 7:
|
||||
return CableBusTextures.Channels13;
|
||||
case 8:
|
||||
return CableBusTextures.Channels14;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
return CableBusTextures.Channels00;
|
||||
case 1:
|
||||
return CableBusTextures.Channels01;
|
||||
case 2:
|
||||
return CableBusTextures.Channels02;
|
||||
case 3:
|
||||
return CableBusTextures.Channels03;
|
||||
default:
|
||||
return CableBusTextures.Channels04;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void renderCoveredConection(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer, int channels, ForgeDirection of)
|
||||
{
|
||||
TileEntity te = this.tile.worldObj.getBlockTileEntity( x + of.offsetX, y + of.offsetY, z + of.offsetZ );
|
||||
IPartHost ccph = te instanceof IPartHost ? (IPartHost) te : null;
|
||||
IGridHost ghh = te instanceof IGridHost ? (IGridHost) te : null;
|
||||
boolean isSmart = false;
|
||||
|
||||
if ( ghh != null && ccph != null && ghh.getCableConnectionType( of ) == AECableType.GLASS && ccph.getPart( of.getOpposite() ) == null )
|
||||
rh.setTexture( getGlassTexture( ccph.getColor() ) );
|
||||
else if ( ccph == null && ghh != null && ghh.getCableConnectionType( of ) != AECableType.GLASS )
|
||||
{
|
||||
rh.setTexture( getCoveredTexture( getCableColor() ) );
|
||||
switch (of)
|
||||
{
|
||||
case DOWN:
|
||||
rh.setBounds( 5, 0, 5, 11, 4, 11 );
|
||||
break;
|
||||
case EAST:
|
||||
rh.setBounds( 12, 5, 5, 16, 11, 11 );
|
||||
break;
|
||||
case NORTH:
|
||||
rh.setBounds( 5, 5, 0, 11, 11, 4 );
|
||||
break;
|
||||
case SOUTH:
|
||||
rh.setBounds( 5, 5, 12, 11, 11, 16 );
|
||||
break;
|
||||
case UP:
|
||||
rh.setBounds( 5, 12, 5, 11, 16, 11 );
|
||||
break;
|
||||
case WEST:
|
||||
rh.setBounds( 0, 5, 5, 4, 11, 11 );
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setTexture( getTexture( getCableColor() ) );
|
||||
}
|
||||
else if ( ghh != null && ccph != null && ghh.getCableConnectionType( of ) == AECableType.COVERED && ccph.getColor() != AEColor.Transparent )
|
||||
rh.setTexture( getCoveredTexture( ccph.getColor() ) );
|
||||
else if ( ghh != null && ccph != null && ghh.getCableConnectionType( of ) == AECableType.SMART )
|
||||
{
|
||||
isSmart = true;
|
||||
rh.setTexture( getSmartTexture( getCableColor() ) );
|
||||
}
|
||||
else
|
||||
rh.setTexture( getCoveredTexture( getCableColor() ) );
|
||||
|
||||
switch (of)
|
||||
{
|
||||
case DOWN:
|
||||
rh.setBounds( 6, 0, 6, 10, 5, 10 );
|
||||
break;
|
||||
case EAST:
|
||||
rh.setBounds( 11, 6, 6, 16, 10, 10 );
|
||||
break;
|
||||
case NORTH:
|
||||
rh.setBounds( 6, 6, 0, 10, 10, 5 );
|
||||
break;
|
||||
case SOUTH:
|
||||
rh.setBounds( 6, 6, 11, 10, 10, 16 );
|
||||
break;
|
||||
case UP:
|
||||
rh.setBounds( 6, 11, 6, 10, 16, 10 );
|
||||
break;
|
||||
case WEST:
|
||||
rh.setBounds( 0, 6, 6, 5, 10, 10 );
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
if ( isSmart )
|
||||
{
|
||||
setSmartConnectionRotations( of, renderer );
|
||||
Icon defa = new TaughtIcon( getChannelTex( channels, false ).getIcon(), -0.2f );
|
||||
Icon defb = new TaughtIcon( getChannelTex( channels, true ).getIcon(), -0.2f );
|
||||
|
||||
if ( of == ForgeDirection.EAST || of == ForgeDirection.WEST )
|
||||
{
|
||||
AEBaseBlock blk = (AEBaseBlock) rh.getBlock();
|
||||
FlipableIcon ico = blk.getRendererInstance().getTexture( ForgeDirection.EAST );
|
||||
ico.setFlip( false, true );
|
||||
}
|
||||
|
||||
Tessellator.instance.setBrightness( 15 << 20 | 15 << 5 );
|
||||
Tessellator.instance.setColorOpaque_I( getCableColor().mediumVariant );
|
||||
rh.setTexture( defa, defa, defa, defa, defa, defa );
|
||||
renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, renderer );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( getCableColor().whiteVariant );
|
||||
rh.setTexture( defb, defb, defb, defb, defb, defb );
|
||||
renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, renderer );
|
||||
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void renderSmartConection(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer, int channels, ForgeDirection of)
|
||||
{
|
||||
TileEntity te = this.tile.worldObj.getBlockTileEntity( x + of.offsetX, y + of.offsetY, z + of.offsetZ );
|
||||
IPartHost ccph = te instanceof IPartHost ? (IPartHost) te : null;
|
||||
IGridHost ghh = te instanceof IGridHost ? (IGridHost) te : null;
|
||||
boolean isGlass = false;
|
||||
AEColor myColor = getCableColor();
|
||||
|
||||
if ( ghh != null && ccph != null && ghh.getCableConnectionType( of ) == AECableType.GLASS && ccph.getPart( of.getOpposite() ) == null )
|
||||
{
|
||||
isGlass = true;
|
||||
rh.setTexture( getGlassTexture( myColor = ccph.getColor() ) );
|
||||
}
|
||||
else if ( ccph == null && ghh != null && ghh.getCableConnectionType( of ) != AECableType.GLASS )
|
||||
{
|
||||
rh.setTexture( getSmartTexture( myColor ) );
|
||||
switch (of)
|
||||
{
|
||||
case DOWN:
|
||||
rh.setBounds( 5, 0, 5, 11, 4, 11 );
|
||||
break;
|
||||
case EAST:
|
||||
rh.setBounds( 12, 5, 5, 16, 11, 11 );
|
||||
break;
|
||||
case NORTH:
|
||||
rh.setBounds( 5, 5, 0, 11, 11, 4 );
|
||||
break;
|
||||
case SOUTH:
|
||||
rh.setBounds( 5, 5, 12, 11, 11, 16 );
|
||||
break;
|
||||
case UP:
|
||||
rh.setBounds( 5, 12, 5, 11, 16, 11 );
|
||||
break;
|
||||
case WEST:
|
||||
rh.setBounds( 0, 5, 5, 4, 11, 11 );
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
if ( true )
|
||||
{
|
||||
setSmartConnectionRotations( of, renderer );
|
||||
Icon defa = new TaughtIcon( getChannelTex( channels, false ).getIcon(), -0.2f );
|
||||
Icon defb = new TaughtIcon( getChannelTex( channels, true ).getIcon(), -0.2f );
|
||||
|
||||
if ( of == ForgeDirection.EAST || of == ForgeDirection.WEST )
|
||||
{
|
||||
AEBaseBlock blk = (AEBaseBlock) rh.getBlock();
|
||||
FlipableIcon ico = blk.getRendererInstance().getTexture( ForgeDirection.EAST );
|
||||
ico.setFlip( false, true );
|
||||
}
|
||||
|
||||
Tessellator.instance.setBrightness( 15 << 20 | 15 << 5 );
|
||||
Tessellator.instance.setColorOpaque_I( myColor.mediumVariant );
|
||||
rh.setTexture( defa, defa, defa, defa, defa, defa );
|
||||
renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, renderer );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( myColor.whiteVariant );
|
||||
rh.setTexture( defb, defb, defb, defb, defb, defb );
|
||||
renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, renderer );
|
||||
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
||||
}
|
||||
|
||||
rh.setTexture( getTexture( getCableColor() ) );
|
||||
}
|
||||
|
||||
else if ( ghh != null && ccph != null && ghh.getCableConnectionType( of ) != AECableType.GLASS && ccph.getColor() != AEColor.Transparent )
|
||||
rh.setTexture( getSmartTexture( myColor = ccph.getColor() ) );
|
||||
else
|
||||
rh.setTexture( getSmartTexture( getCableColor() ) );
|
||||
|
||||
switch (of)
|
||||
{
|
||||
case DOWN:
|
||||
rh.setBounds( 6, 0, 6, 10, 5, 10 );
|
||||
break;
|
||||
case EAST:
|
||||
rh.setBounds( 11, 6, 6, 16, 10, 10 );
|
||||
break;
|
||||
case NORTH:
|
||||
rh.setBounds( 6, 6, 0, 10, 10, 5 );
|
||||
break;
|
||||
case SOUTH:
|
||||
rh.setBounds( 6, 6, 11, 10, 10, 16 );
|
||||
break;
|
||||
case UP:
|
||||
rh.setBounds( 6, 11, 6, 10, 16, 10 );
|
||||
break;
|
||||
case WEST:
|
||||
rh.setBounds( 0, 6, 6, 5, 10, 10 );
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
if ( !isGlass )
|
||||
{
|
||||
setSmartConnectionRotations( of, renderer );
|
||||
|
||||
Icon defa = new TaughtIcon( getChannelTex( channels, false ).getIcon(), -0.2f );
|
||||
Icon defb = new TaughtIcon( getChannelTex( channels, true ).getIcon(), -0.2f );
|
||||
|
||||
Tessellator.instance.setBrightness( 15 << 20 | 15 << 5 );
|
||||
Tessellator.instance.setColorOpaque_I( myColor.mediumVariant );
|
||||
rh.setTexture( defa, defa, defa, defa, defa, defa );
|
||||
renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, renderer );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( myColor.whiteVariant );
|
||||
rh.setTexture( defb, defb, defb, defb, defb, defb );
|
||||
renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, renderer );
|
||||
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected void setSmartConnectionRotations(ForgeDirection of, RenderBlocks renderer)
|
||||
{
|
||||
switch (of)
|
||||
{
|
||||
case UP:
|
||||
case DOWN:
|
||||
renderer.uvRotateTop = 0;
|
||||
renderer.uvRotateBottom = 0;
|
||||
renderer.uvRotateSouth = 3;
|
||||
renderer.uvRotateEast = 3;
|
||||
break;
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
renderer.uvRotateTop = 3;
|
||||
renderer.uvRotateBottom = 3;
|
||||
renderer.uvRotateNorth = 1;
|
||||
renderer.uvRotateSouth = 2;
|
||||
renderer.uvRotateWest = 1;
|
||||
break;
|
||||
case EAST:
|
||||
case WEST:
|
||||
renderer.uvRotateEast = 2;
|
||||
renderer.uvRotateWest = 1;
|
||||
renderer.uvRotateBottom = 2;
|
||||
renderer.uvRotateTop = 1;
|
||||
renderer.uvRotateSouth = 3;
|
||||
renderer.uvRotateNorth = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderAllFaces(AEBaseBlock blk, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
renderer.renderFaceXNeg( blk, x, y, z, blk.getRendererInstance().getTexture( ForgeDirection.WEST ) );
|
||||
renderer.renderFaceXPos( blk, x, y, z, blk.getRendererInstance().getTexture( ForgeDirection.EAST ) );
|
||||
renderer.renderFaceZNeg( blk, x, y, z, blk.getRendererInstance().getTexture( ForgeDirection.NORTH ) );
|
||||
renderer.renderFaceZPos( blk, x, y, z, blk.getRendererInstance().getTexture( ForgeDirection.SOUTH ) );
|
||||
renderer.renderFaceYNeg( blk, x, y, z, blk.getRendererInstance().getTexture( ForgeDirection.DOWN ) );
|
||||
renderer.renderFaceYPos( blk, x, y, z, blk.getRendererInstance().getTexture( ForgeDirection.UP ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
boolean useCovered = false;
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
IPart p = getHost().getPart( dir );
|
||||
if ( p != null && p instanceof IGridHost )
|
||||
{
|
||||
IGridHost igh = (IGridHost) p;
|
||||
AECableType type = igh.getCableConnectionType( dir.getOpposite() );
|
||||
if ( type == AECableType.COVERED || type == AECableType.SMART )
|
||||
{
|
||||
useCovered = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( useCovered )
|
||||
{
|
||||
rh.setTexture( getCoveredTexture( getCableColor() ) );
|
||||
rh.setBounds( 5, 5, 5, 11, 11, 11 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
}
|
||||
else
|
||||
{
|
||||
rh.setTexture( getTexture( getCableColor() ) );
|
||||
rh.setBounds( 6, 6, 6, 10, 10, 10 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
}
|
||||
|
||||
IPartHost ph = getHost();
|
||||
for (ForgeDirection of : EnumSet.complementOf( connections ))
|
||||
{
|
||||
IPart bp = ph.getPart( of );
|
||||
if ( bp instanceof IGridHost )
|
||||
{
|
||||
int len = bp.cableConnectionRenderTo();
|
||||
if ( len < 8 )
|
||||
{
|
||||
switch (of)
|
||||
{
|
||||
case DOWN:
|
||||
rh.setBounds( 6, len, 6, 10, 6, 10 );
|
||||
break;
|
||||
case EAST:
|
||||
rh.setBounds( 10, 6, 6, 16 - len, 10, 10 );
|
||||
break;
|
||||
case NORTH:
|
||||
rh.setBounds( 6, 6, len, 10, 10, 6 );
|
||||
break;
|
||||
case SOUTH:
|
||||
rh.setBounds( 6, 6, 10, 10, 10, 16 - len );
|
||||
break;
|
||||
case UP:
|
||||
rh.setBounds( 6, 10, 6, 10, 16 - len, 10 );
|
||||
break;
|
||||
case WEST:
|
||||
rh.setBounds( len, 6, 6, 6, 10, 10 );
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ForgeDirection of : connections)
|
||||
{
|
||||
rendereGlassConection( x, y, z, rh, renderer, of );
|
||||
}
|
||||
|
||||
rh.setTexture( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean changeColor(AEColor newColor)
|
||||
{
|
||||
if ( getCableColor() != newColor )
|
||||
{
|
||||
is.setItemDamage( newColor.ordinal() );
|
||||
markForUpdate();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValidSides(EnumSet<ForgeDirection> sides)
|
||||
{
|
||||
proxy.setValidSides( sides );
|
||||
}
|
||||
|
||||
protected boolean nonLinear(EnumSet<ForgeDirection> sides)
|
||||
{
|
||||
return (sides.contains( ForgeDirection.EAST ) && sides.contains( ForgeDirection.WEST ))
|
||||
|| (sides.contains( ForgeDirection.NORTH ) && sides.contains( ForgeDirection.SOUTH ))
|
||||
|| (sides.contains( ForgeDirection.UP ) && sides.contains( ForgeDirection.DOWN ));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
package appeng.parts.networking;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartCollsionHelper;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.client.texture.OffsetIcon;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PartCableCovered extends PartCable
|
||||
{
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void channelUpdated(MENetworkChannelsChanged c)
|
||||
{
|
||||
getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender(MENetworkPowerStatusChange c)
|
||||
{
|
||||
getHost().markForUpdate();
|
||||
}
|
||||
|
||||
public PartCableCovered(ItemStack is) {
|
||||
super( PartCableCovered.class, is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getTexture(AEColor c)
|
||||
{
|
||||
return getCoveredTexture( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType()
|
||||
{
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollsionHelper bch)
|
||||
{
|
||||
bch.addBox( 5.0, 5.0, 5.0, 11.0, 11.0, 11.0 );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
IGridNode n = getGridNode();
|
||||
if ( n != null )
|
||||
connections = n.getConnectedSides();
|
||||
else
|
||||
connections.clear();
|
||||
}
|
||||
|
||||
for (ForgeDirection of : connections)
|
||||
{
|
||||
switch (of)
|
||||
{
|
||||
case DOWN:
|
||||
bch.addBox( 5.0, 0.0, 5.0, 11.0, 5.0, 11.0 );
|
||||
break;
|
||||
case EAST:
|
||||
bch.addBox( 11.0, 5.0, 5.0, 16.0, 11.0, 11.0 );
|
||||
break;
|
||||
case NORTH:
|
||||
bch.addBox( 5.0, 5.0, 0.0, 11.0, 11.0, 5.0 );
|
||||
break;
|
||||
case SOUTH:
|
||||
bch.addBox( 5.0, 5.0, 11.0, 11.0, 11.0, 16.0 );
|
||||
break;
|
||||
case UP:
|
||||
bch.addBox( 5.0, 11.0, 5.0, 11.0, 16.0, 11.0 );
|
||||
break;
|
||||
case WEST:
|
||||
bch.addBox( 0.0, 5.0, 5.0, 5.0, 11.0, 11.0 );
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
GL11.glTranslated( -0.2, -0.3, 0.0 );
|
||||
|
||||
rh.setTexture( getTexture( getCableColor() ) );
|
||||
rh.setBounds( 5.0f, 5.0f, 2.0f, 11.0f, 11.0f, 14.0f );
|
||||
rh.renderInventoryBox( renderer );
|
||||
rh.setTexture( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.setTexture( getTexture( getCableColor() ) );
|
||||
|
||||
EnumSet<ForgeDirection> sides = connections.clone();
|
||||
|
||||
boolean hasBuses = false;
|
||||
IPartHost ph = getHost();
|
||||
for (ForgeDirection of : EnumSet.complementOf( connections ))
|
||||
{
|
||||
IPart bp = ph.getPart( of );
|
||||
if ( bp instanceof IGridHost )
|
||||
{
|
||||
if ( of != ForgeDirection.UNKNOWN )
|
||||
{
|
||||
sides.add( of );
|
||||
hasBuses = true;
|
||||
}
|
||||
|
||||
int len = bp.cableConnectionRenderTo();
|
||||
if ( len < 8 )
|
||||
{
|
||||
switch (of)
|
||||
{
|
||||
case DOWN:
|
||||
rh.setBounds( 6, len, 6, 10, 5, 10 );
|
||||
break;
|
||||
case EAST:
|
||||
rh.setBounds( 11, 6, 6, 16 - len, 10, 10 );
|
||||
break;
|
||||
case NORTH:
|
||||
rh.setBounds( 6, 6, len, 10, 10, 5 );
|
||||
break;
|
||||
case SOUTH:
|
||||
rh.setBounds( 6, 6, 11, 10, 10, 16 - len );
|
||||
break;
|
||||
case UP:
|
||||
rh.setBounds( 6, 11, 6, 10, 16 - len, 10 );
|
||||
break;
|
||||
case WEST:
|
||||
rh.setBounds( len, 6, 6, 5, 10, 10 );
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( sides.size() != 2 || !nonLinear( sides ) || hasBuses )
|
||||
{
|
||||
for (ForgeDirection of : connections)
|
||||
{
|
||||
renderCoveredConection( x, y, z, rh, renderer, channelsOnSide[of.ordinal()], of );
|
||||
}
|
||||
|
||||
rh.setTexture( getTexture( getCableColor() ) );
|
||||
rh.setBounds( 5, 5, 5, 11, 11, 11 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
}
|
||||
else
|
||||
{
|
||||
Icon def = getTexture( getCableColor() );
|
||||
Icon off = new OffsetIcon( def, 0, -12 );
|
||||
for (ForgeDirection of : connections)
|
||||
{
|
||||
switch (of)
|
||||
{
|
||||
case DOWN:
|
||||
case UP:
|
||||
rh.setTexture( def, def, off, off, off, off );
|
||||
renderer.setRenderBounds( 5 / 16.0, 0, 5 / 16.0, 11 / 16.0, 16 / 16.0, 11 / 16.0 );
|
||||
break;
|
||||
case EAST:
|
||||
case WEST:
|
||||
rh.setTexture( off, off, off, off, def, def );
|
||||
renderer.uvRotateEast = renderer.uvRotateWest = 1;
|
||||
renderer.uvRotateBottom = renderer.uvRotateTop = 1;
|
||||
renderer.setRenderBounds( 0, 5 / 16.0, 5 / 16.0, 16 / 16.0, 11 / 16.0, 11 / 16.0 );
|
||||
break;
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
rh.setTexture( off, off, def, def, off, off );
|
||||
renderer.uvRotateNorth = renderer.uvRotateSouth = 1;
|
||||
renderer.setRenderBounds( 5 / 16.0, 5 / 16.0, 0, 11 / 16.0, 11 / 16.0, 16 / 16.0 );
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
renderer.renderStandardBlock( rh.getBlock(), x, y, z );
|
||||
}
|
||||
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
||||
rh.setTexture( null );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package appeng.parts.networking;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class PartCableGlass extends PartCable
|
||||
{
|
||||
|
||||
public PartCableGlass(ItemStack is) {
|
||||
super( PartCableGlass.class, is );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
package appeng.parts.networking;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartCollsionHelper;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.texture.FlipableIcon;
|
||||
import appeng.client.texture.OffsetIcon;
|
||||
import appeng.client.texture.TaughtIcon;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PartCableSmart extends PartCable
|
||||
{
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void channelUpdated(MENetworkChannelsChanged c)
|
||||
{
|
||||
getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender(MENetworkPowerStatusChange c)
|
||||
{
|
||||
getHost().markForUpdate();
|
||||
}
|
||||
|
||||
public PartCableSmart(ItemStack is) {
|
||||
super( PartCableSmart.class, is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType()
|
||||
{
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getTexture(AEColor c)
|
||||
{
|
||||
return getSmartTexture( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
GL11.glTranslated( -0.2, -0.3, 0.0 );
|
||||
|
||||
rh.setTexture( getTexture( getCableColor() ) );
|
||||
rh.setBounds( 5.0f, 5.0f, 2.0f, 11.0f, 11.0f, 14.0f );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setTexture( getChannelTex( 4, false ).getIcon() );
|
||||
rh.setBounds( 5.0f, 5.0f, 2.0f, 11.0f, 11.0f, 14.0f );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setTexture( getChannelTex( 4, true ).getIcon() );
|
||||
rh.setBounds( 5.0f, 5.0f, 2.0f, 11.0f, 11.0f, 14.0f );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setTexture( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollsionHelper bch)
|
||||
{
|
||||
bch.addBox( 5.0, 5.0, 5.0, 11.0, 11.0, 11.0 );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
IGridNode n = getGridNode();
|
||||
if ( n != null )
|
||||
connections = n.getConnectedSides();
|
||||
else
|
||||
connections.clear();
|
||||
}
|
||||
|
||||
for (ForgeDirection of : connections)
|
||||
{
|
||||
switch (of)
|
||||
{
|
||||
case DOWN:
|
||||
bch.addBox( 5.0, 0.0, 5.0, 11.0, 5.0, 11.0 );
|
||||
break;
|
||||
case EAST:
|
||||
bch.addBox( 11.0, 5.0, 5.0, 16.0, 11.0, 11.0 );
|
||||
break;
|
||||
case NORTH:
|
||||
bch.addBox( 5.0, 5.0, 0.0, 11.0, 11.0, 5.0 );
|
||||
break;
|
||||
case SOUTH:
|
||||
bch.addBox( 5.0, 5.0, 11.0, 11.0, 11.0, 16.0 );
|
||||
break;
|
||||
case UP:
|
||||
bch.addBox( 5.0, 11.0, 5.0, 11.0, 16.0, 11.0 );
|
||||
break;
|
||||
case WEST:
|
||||
bch.addBox( 0.0, 5.0, 5.0, 5.0, 11.0, 11.0 );
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.setTexture( getTexture( getCableColor() ) );
|
||||
|
||||
EnumSet<ForgeDirection> sides = connections.clone();
|
||||
|
||||
boolean hasBuses = false;
|
||||
IPartHost ph = getHost();
|
||||
for (ForgeDirection of : EnumSet.complementOf( connections ))
|
||||
{
|
||||
IPart bp = ph.getPart( of );
|
||||
if ( bp instanceof IGridHost )
|
||||
{
|
||||
if ( of != ForgeDirection.UNKNOWN )
|
||||
{
|
||||
sides.add( of );
|
||||
hasBuses = true;
|
||||
}
|
||||
|
||||
int len = bp.cableConnectionRenderTo();
|
||||
if ( len < 8 )
|
||||
{
|
||||
switch (of)
|
||||
{
|
||||
case DOWN:
|
||||
rh.setBounds( 6, len, 6, 10, 5, 10 );
|
||||
break;
|
||||
case EAST:
|
||||
rh.setBounds( 11, 6, 6, 16 - len, 10, 10 );
|
||||
break;
|
||||
case NORTH:
|
||||
rh.setBounds( 6, 6, len, 10, 10, 5 );
|
||||
break;
|
||||
case SOUTH:
|
||||
rh.setBounds( 6, 6, 11, 10, 10, 16 - len );
|
||||
break;
|
||||
case UP:
|
||||
rh.setBounds( 6, 11, 6, 10, 16 - len, 10 );
|
||||
break;
|
||||
case WEST:
|
||||
rh.setBounds( len, 6, 6, 5, 10, 10 );
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
setSmartConnectionRotations( of, renderer );
|
||||
Icon defa = new TaughtIcon( getChannelTex( channelsOnSide[of.ordinal()], false ).getIcon(), -0.2f );
|
||||
Icon defb = new TaughtIcon( getChannelTex( channelsOnSide[of.ordinal()], true ).getIcon(), -0.2f );
|
||||
|
||||
if ( of == ForgeDirection.EAST || of == ForgeDirection.WEST )
|
||||
{
|
||||
AEBaseBlock blk = (AEBaseBlock) rh.getBlock();
|
||||
FlipableIcon ico = blk.getRendererInstance().getTexture( ForgeDirection.EAST );
|
||||
ico.setFlip( false, true );
|
||||
}
|
||||
|
||||
Tessellator.instance.setBrightness( 15 << 20 | 15 << 5 );
|
||||
Tessellator.instance.setColorOpaque_I( getCableColor().mediumVariant );
|
||||
rh.setTexture( defa, defa, defa, defa, defa, defa );
|
||||
renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, renderer );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( getCableColor().whiteVariant );
|
||||
rh.setTexture( defb, defb, defb, defb, defb, defb );
|
||||
renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, renderer );
|
||||
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
||||
|
||||
rh.setTexture( getTexture( getCableColor() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( sides.size() != 2 || !nonLinear( sides ) || hasBuses )
|
||||
{
|
||||
for (ForgeDirection of : connections)
|
||||
{
|
||||
renderSmartConection( x, y, z, rh, renderer, channelsOnSide[of.ordinal()], of );
|
||||
}
|
||||
|
||||
rh.setTexture( getCoveredTexture( getCableColor() ) );
|
||||
rh.setBounds( 5, 5, 5, 11, 11, 11 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
}
|
||||
else
|
||||
{
|
||||
ForgeDirection selectedSide = ForgeDirection.UNKNOWN;
|
||||
|
||||
for (ForgeDirection of : connections)
|
||||
{
|
||||
selectedSide = of;
|
||||
break;
|
||||
}
|
||||
|
||||
int channels = channelsOnSide[selectedSide.ordinal()];
|
||||
Icon def = getTexture( getCableColor() );
|
||||
Icon off = new OffsetIcon( def, 0, -12 );
|
||||
|
||||
Icon defa = new TaughtIcon( getChannelTex( channels, false ).getIcon(), -0.2f );
|
||||
Icon offa = new OffsetIcon( defa, 0, -12 );
|
||||
|
||||
Icon defb = new TaughtIcon( getChannelTex( channels, true ).getIcon(), -0.2f );
|
||||
Icon offb = new OffsetIcon( defb, 0, -12 );
|
||||
|
||||
switch (selectedSide)
|
||||
{
|
||||
case DOWN:
|
||||
case UP:
|
||||
renderer.setRenderBounds( 5 / 16.0, 0, 5 / 16.0, 11 / 16.0, 16 / 16.0, 11 / 16.0 );
|
||||
rh.setTexture( def, def, off, off, off, off );
|
||||
renderer.renderStandardBlock( rh.getBlock(), x, y, z );
|
||||
renderer.uvRotateTop = 0;
|
||||
renderer.uvRotateBottom = 0;
|
||||
renderer.uvRotateSouth = 3;
|
||||
renderer.uvRotateEast = 3;
|
||||
|
||||
Tessellator.instance.setBrightness( 15 << 20 | 15 << 5 );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( getCableColor().mediumVariant );
|
||||
rh.setTexture( defa, defa, offa, offa, offa, offa );
|
||||
renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, renderer );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( getCableColor().whiteVariant );
|
||||
rh.setTexture( defb, defb, offb, offb, offb, offb );
|
||||
renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, renderer );
|
||||
break;
|
||||
case EAST:
|
||||
case WEST:
|
||||
rh.setTexture( off, off, off, off, def, def );
|
||||
renderer.uvRotateEast = 2;
|
||||
renderer.uvRotateWest = 1;
|
||||
renderer.uvRotateBottom = 2;
|
||||
renderer.uvRotateTop = 1;
|
||||
renderer.uvRotateSouth = 3;
|
||||
renderer.uvRotateNorth = 0;
|
||||
|
||||
AEBaseBlock blk = (AEBaseBlock) rh.getBlock();
|
||||
FlipableIcon ico = blk.getRendererInstance().getTexture( ForgeDirection.EAST );
|
||||
ico.setFlip( false, true );
|
||||
|
||||
renderer.setRenderBounds( 0, 5 / 16.0, 5 / 16.0, 16 / 16.0, 11 / 16.0, 11 / 16.0 );
|
||||
renderer.renderStandardBlock( rh.getBlock(), x, y, z );
|
||||
|
||||
Tessellator.instance.setBrightness( 15 << 20 | 15 << 5 );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( getCableColor().mediumVariant );
|
||||
rh.setTexture( offa, offa, offa, offa, defa, defa );
|
||||
renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, renderer );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( getCableColor().whiteVariant );
|
||||
rh.setTexture( offb, offb, offb, offb, defb, defb );
|
||||
renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, renderer );
|
||||
break;
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
rh.setTexture( off, off, def, def, off, off );
|
||||
renderer.uvRotateTop = 3;
|
||||
renderer.uvRotateBottom = 3;
|
||||
renderer.uvRotateNorth = 1;
|
||||
renderer.uvRotateSouth = 2;
|
||||
renderer.uvRotateWest = 1;
|
||||
renderer.setRenderBounds( 5 / 16.0, 5 / 16.0, 0, 11 / 16.0, 11 / 16.0, 16 / 16.0 );
|
||||
renderer.renderStandardBlock( rh.getBlock(), x, y, z );
|
||||
|
||||
Tessellator.instance.setBrightness( 15 << 20 | 15 << 5 );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( getCableColor().mediumVariant );
|
||||
rh.setTexture( offa, offa, defa, defa, offa, offa );
|
||||
renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, renderer );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( getCableColor().whiteVariant );
|
||||
rh.setTexture( offb, offb, defb, defb, offb, offb );
|
||||
renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, renderer );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
||||
rh.setTexture( null );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package appeng.parts.networking;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.energy.IEnergyGridProvider;
|
||||
import appeng.api.parts.IPartCollsionHelper;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.parts.AEBasePart;
|
||||
|
||||
public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider
|
||||
{
|
||||
|
||||
AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", true );
|
||||
|
||||
public PartQuartzFiber(ItemStack is) {
|
||||
super( PartQuartzFiber.class, is );
|
||||
proxy.setFlags( GridFlags.CANNOT_CARRY );
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
@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 renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
Icon myIcon = is.getIconIndex();
|
||||
rh.setTexture( myIcon );
|
||||
rh.setBounds( 6, 6, 10, 10, 10, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
rh.setTexture( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollsionHelper bch)
|
||||
{
|
||||
bch.addBox( 6, 6, 10, 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.0f, 6.0f, 5.0f, 10.0f, 10.0f, 11.0f );
|
||||
rh.renderInventoryBox( renderer );
|
||||
rh.setTexture( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower(double amt, Actionable mode, Set<IEnergyGrid> seen)
|
||||
{
|
||||
double aquiredPower = 0;
|
||||
|
||||
try
|
||||
{
|
||||
IEnergyGrid eg = proxy.getEnergy();
|
||||
aquiredPower += eg.extractAEPower( amt - aquiredPower, mode, seen );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
IEnergyGrid eg = outerProxy.getEnergy();
|
||||
aquiredPower += eg.extractAEPower( amt - aquiredPower, mode, seen );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
return aquiredPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package appeng.parts.reporting;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
|
||||
public class PartConversionMonitor extends PartStorageMonitor
|
||||
{
|
||||
|
||||
public PartConversionMonitor(ItemStack is) {
|
||||
super( PartConversionMonitor.class, is );
|
||||
frontBright = CableBusTextures.PartConvMonitor_Bright;
|
||||
frontColored = CableBusTextures.PartConvMonitor_Colored;
|
||||
frontDark = CableBusTextures.PartConvMonitor_Dark;
|
||||
frontSolid = CableBusTextures.PartConvMonitor_Solid;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package appeng.parts.reporting;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
|
||||
public class PartCraftingMonitor extends PartMonitor
|
||||
{
|
||||
|
||||
public PartCraftingMonitor(ItemStack is) {
|
||||
super( PartCraftingMonitor.class, is );
|
||||
frontBright = CableBusTextures.PartCraftingMonitor_Bright;
|
||||
frontColored = CableBusTextures.PartCraftingMonitor_Colored;
|
||||
frontDark = CableBusTextures.PartCraftingMonitor_Dark;
|
||||
frontSolid = CableBusTextures.PartCraftingMonitor_Solid;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package appeng.parts.reporting;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
|
||||
public class PartCraftingTerminal extends PartMonitor
|
||||
{
|
||||
|
||||
public PartCraftingTerminal(ItemStack is) {
|
||||
super( PartCraftingTerminal.class, is );
|
||||
frontBright = CableBusTextures.PartCraftingTerm_Bright;
|
||||
frontColored = CableBusTextures.PartCraftingTerm_Colored;
|
||||
frontDark = CableBusTextures.PartCraftingTerm_Dark;
|
||||
frontSolid = CableBusTextures.PartCraftingTerm_Solid;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package appeng.parts.reporting;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
|
||||
public class PartDarkMonitor extends PartMonitor
|
||||
{
|
||||
|
||||
public PartDarkMonitor(ItemStack is) {
|
||||
super( PartDarkMonitor.class, is );
|
||||
|
||||
notLightSource = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.setBounds( 2, 2, 14, 14, 14, 16 );
|
||||
|
||||
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
|
||||
frontSolid.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setInvColor( getColor().mediumVariant );
|
||||
rh.renderInventoryFace( frontBright.getIcon(), ForgeDirection.SOUTH, renderer );
|
||||
|
||||
rh.setBounds( 4, 4, 13, 12, 12, 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(),
|
||||
frontSolid.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
|
||||
rh.setBounds( 2, 2, 14, 14, 14, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
if ( getLightLevel() > 0 )
|
||||
{
|
||||
int l = 13;
|
||||
Tessellator.instance.setBrightness( l << 20 | l << 4 );
|
||||
}
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( getColor().mediumVariant );
|
||||
rh.renderFace( x, y, z, frontBright.getIcon(), ForgeDirection.SOUTH, renderer );
|
||||
|
||||
rh.setBounds( 4, 4, 13, 12, 12, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
package appeng.parts.reporting;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.implementations.IPartMonitor;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.events.MENetworkBootingStatusChange;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.parts.IPartCollsionHelper;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.AEBasePart;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PartMonitor extends AEBasePart implements IPartMonitor
|
||||
{
|
||||
|
||||
CableBusTextures frontSolid = CableBusTextures.PartMonitor_Solid;
|
||||
CableBusTextures frontDark = CableBusTextures.PartMonitor_Colored;
|
||||
CableBusTextures frontBright = CableBusTextures.PartMonitor_Bright;
|
||||
CableBusTextures frontColored = CableBusTextures.PartMonitor_Colored;
|
||||
|
||||
boolean notLightSource = !this.getClass().equals( PartMonitor.class );
|
||||
|
||||
final int POWERED_FLAG = 1;
|
||||
final int BOOTING_FLAG = 2;
|
||||
final int CHANNEL_FLAG = 4;
|
||||
|
||||
int clientFlags = 0; // sent as byte.
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void bootingRender(MENetworkBootingStatusChange c)
|
||||
{
|
||||
if ( notLightSource )
|
||||
getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender(MENetworkPowerStatusChange c)
|
||||
{
|
||||
getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(DataOutputStream data) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
clientFlags = 0;
|
||||
|
||||
try
|
||||
{
|
||||
if ( proxy.getEnergy().isNetworkPowered() )
|
||||
clientFlags = clientFlags | POWERED_FLAG;
|
||||
|
||||
if ( proxy.getPath().isNetworkBooting() )
|
||||
clientFlags = clientFlags | BOOTING_FLAG;
|
||||
|
||||
if ( proxy.getNode().meetsChannelRequirements() )
|
||||
clientFlags = clientFlags | CHANNEL_FLAG;
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// um.. nothing.
|
||||
}
|
||||
|
||||
data.writeByte( (byte) clientFlags );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(DataInputStream data) throws IOException
|
||||
{
|
||||
super.readFromStream( data );
|
||||
int oldFlags = clientFlags;
|
||||
clientFlags = data.readByte();
|
||||
if ( clientFlags == oldFlags )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightLevel()
|
||||
{
|
||||
return isPowered() ? (notLightSource ? 9 : 15) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowered()
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
return proxy.getEnergy().isNetworkPowered();
|
||||
else
|
||||
return ((clientFlags & POWERED_FLAG) == POWERED_FLAG);
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public PartMonitor(ItemStack is) {
|
||||
super( PartMonitor.class, is );
|
||||
}
|
||||
|
||||
protected PartMonitor(Class c, ItemStack is) {
|
||||
super( c, is );
|
||||
if ( notLightSource )
|
||||
proxy.setFlags( GridFlags.REQURE_CHANNEL );
|
||||
else
|
||||
proxy.setIdlePowerUsage( 1.0 / 16.0 ); // lights drain a little bit.
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.setBounds( 2, 2, 14, 14, 14, 16 );
|
||||
|
||||
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
|
||||
frontSolid.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setInvColor( getColor().whiteVariant );
|
||||
rh.renderInventoryFace( frontBright.getIcon(), ForgeDirection.SOUTH, renderer );
|
||||
|
||||
rh.setInvColor( getColor().mediumVariant );
|
||||
rh.renderInventoryFace( frontDark.getIcon(), ForgeDirection.SOUTH, renderer );
|
||||
|
||||
rh.setInvColor( getColor().blackVariant );
|
||||
rh.renderInventoryFace( frontColored.getIcon(), ForgeDirection.SOUTH, renderer );
|
||||
|
||||
rh.setBounds( 4, 4, 13, 12, 12, 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(),
|
||||
frontSolid.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
|
||||
rh.setBounds( 2, 2, 14, 14, 14, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
if ( getLightLevel() > 0 )
|
||||
{
|
||||
int l = 13;
|
||||
Tessellator.instance.setBrightness( l << 20 | l << 4 );
|
||||
}
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( getColor().whiteVariant );
|
||||
rh.renderFace( x, y, z, frontBright.getIcon(), ForgeDirection.SOUTH, renderer );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( getColor().mediumVariant );
|
||||
rh.renderFace( x, y, z, frontDark.getIcon(), ForgeDirection.SOUTH, renderer );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( getColor().blackVariant );
|
||||
rh.renderFace( x, y, z, frontColored.getIcon(), ForgeDirection.SOUTH, renderer );
|
||||
|
||||
if ( notLightSource )
|
||||
{
|
||||
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorBack.getIcon(), frontSolid.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
}
|
||||
|
||||
rh.setBounds( 4, 4, 13, 12, 12, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
if ( notLightSource )
|
||||
{
|
||||
boolean hasChan = (clientFlags & (POWERED_FLAG | CHANNEL_FLAG)) == (POWERED_FLAG | CHANNEL_FLAG);
|
||||
boolean hasPower = (clientFlags & POWERED_FLAG) == POWERED_FLAG;
|
||||
|
||||
if ( hasChan )
|
||||
{
|
||||
int l = 14;
|
||||
Tessellator.instance.setBrightness( l << 20 | l << 4 );
|
||||
Tessellator.instance.setColorOpaque_I( getColor().blackVariant );
|
||||
}
|
||||
else if ( hasPower )
|
||||
{
|
||||
int l = 9;
|
||||
Tessellator.instance.setBrightness( l << 20 | l << 4 );
|
||||
Tessellator.instance.setColorOpaque_I( getColor().whiteVariant );
|
||||
}
|
||||
else
|
||||
{
|
||||
Tessellator.instance.setBrightness( 0 );
|
||||
Tessellator.instance.setColorOpaque_I( 0x000000 );
|
||||
}
|
||||
|
||||
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.EAST, renderer );
|
||||
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.WEST, renderer );
|
||||
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.UP, renderer );
|
||||
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.DOWN, renderer );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollsionHelper bch)
|
||||
{
|
||||
bch.addBox( 2, 2, 14, 14, 14, 16 );
|
||||
bch.addBox( 4, 4, 13, 12, 12, 14 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivate(EntityPlayer player, Vec3 pos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package appeng.parts.reporting;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
|
||||
public class PartPatternTerminal extends PartMonitor
|
||||
{
|
||||
|
||||
public PartPatternTerminal(ItemStack is) {
|
||||
super( PartPatternTerminal.class, is );
|
||||
frontBright = CableBusTextures.PartPatternTerm_Bright;
|
||||
frontColored = CableBusTextures.PartPatternTerm_Colored;
|
||||
frontDark = CableBusTextures.PartPatternTerm_Dark;
|
||||
frontSolid = CableBusTextures.PartPatternTerm_Solid;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package appeng.parts.reporting;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
|
||||
public class PartSemiDarkMonitor extends PartMonitor
|
||||
{
|
||||
|
||||
public PartSemiDarkMonitor(ItemStack is) {
|
||||
super( PartSemiDarkMonitor.class, is );
|
||||
|
||||
notLightSource = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.setBounds( 2, 2, 14, 14, 14, 16 );
|
||||
|
||||
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
|
||||
frontSolid.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
int light = getColor().whiteVariant;
|
||||
int dark = getColor().mediumVariant;
|
||||
rh.setInvColor( (((((light >> 16) & 0xff) + ((dark >> 16) & 0xff)) / 2) << 16) | (((((light >> 8) & 0xff) + ((dark >> 8) & 0xff)) / 2) << 8)
|
||||
| ((((light) & 0xff) + ((dark) & 0xff)) / 2) );
|
||||
rh.renderInventoryFace( frontBright.getIcon(), ForgeDirection.SOUTH, renderer );
|
||||
|
||||
rh.setBounds( 4, 4, 13, 12, 12, 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(),
|
||||
frontSolid.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
|
||||
rh.setBounds( 2, 2, 14, 14, 14, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
if ( getLightLevel() > 0 )
|
||||
{
|
||||
int l = 13;
|
||||
Tessellator.instance.setBrightness( l << 20 | l << 4 );
|
||||
}
|
||||
|
||||
int light = getColor().whiteVariant;
|
||||
int dark = getColor().mediumVariant;
|
||||
Tessellator.instance.setColorOpaque( (((light >> 16) & 0xff) + ((dark >> 16) & 0xff)) / 2, (((light >> 8) & 0xff) + ((dark >> 8) & 0xff)) / 2,
|
||||
(((light) & 0xff) + ((dark) & 0xff)) / 2 );
|
||||
rh.renderFace( x, y, z, frontBright.getIcon(), ForgeDirection.SOUTH, renderer );
|
||||
|
||||
rh.setBounds( 4, 4, 13, 12, 12, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package appeng.parts.reporting;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.implementations.IPartStorageMonitor;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
|
||||
public class PartStorageMonitor extends PartMonitor implements IPartStorageMonitor
|
||||
{
|
||||
|
||||
protected PartStorageMonitor(Class myClass, ItemStack is) {
|
||||
super( myClass, is );
|
||||
}
|
||||
|
||||
public PartStorageMonitor(ItemStack is) {
|
||||
super( PartStorageMonitor.class, is );
|
||||
frontBright = CableBusTextures.PartStorageMonitor_Bright;
|
||||
frontColored = CableBusTextures.PartStorageMonitor_Colored;
|
||||
frontDark = CableBusTextures.PartStorageMonitor_Dark;
|
||||
frontSolid = CableBusTextures.PartStorageMonitor_Solid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEStack getDisplayed()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocked()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package appeng.parts.reporting;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Vec3;
|
||||
import appeng.api.implementations.IStorageMonitorable;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PartTerminal extends PartMonitor implements IStorageMonitorable
|
||||
{
|
||||
|
||||
public PartTerminal(ItemStack is) {
|
||||
super( PartTerminal.class, is );
|
||||
frontBright = CableBusTextures.PartTerminal_Bright;
|
||||
frontColored = CableBusTextures.PartTerminal_Colored;
|
||||
frontDark = CableBusTextures.PartTerminal_Dark;
|
||||
frontSolid = CableBusTextures.PartTerminal_Solid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivate(EntityPlayer player, Vec3 pos)
|
||||
{
|
||||
if ( !player.isSneaking() )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
Platform.openGUI( player, getHost().getTile(), side, GuiBridge.GUI_ME );
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user