2013-12-27 23:59:59 +01:00
|
|
|
package appeng.fmp;
|
|
|
|
|
2014-04-10 21:52:17 +02:00
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
import io.netty.buffer.Unpooled;
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.ArrayList;
|
2014-01-28 18:29:17 +01:00
|
|
|
import java.util.EnumSet;
|
2013-12-27 23:59:59 +01:00
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
2014-02-23 23:50:53 +01:00
|
|
|
import java.util.Set;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
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.AxisAlignedBB;
|
|
|
|
import net.minecraft.util.MovingObjectPosition;
|
|
|
|
import net.minecraft.util.Vec3;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2014-08-08 08:40:49 +02:00
|
|
|
import appeng.api.implementations.parts.IPartCable;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.networking.IGridNode;
|
|
|
|
import appeng.api.parts.IFacadeContainer;
|
2014-04-20 06:35:48 +02:00
|
|
|
import appeng.api.parts.IFacadePart;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.parts.IPart;
|
|
|
|
import appeng.api.parts.IPartCollsionHelper;
|
|
|
|
import appeng.api.parts.IPartHost;
|
|
|
|
import appeng.api.parts.IPartItem;
|
2014-02-23 23:50:53 +01:00
|
|
|
import appeng.api.parts.LayerFlags;
|
2014-01-28 18:29:17 +01:00
|
|
|
import appeng.api.parts.PartItemStack;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.parts.SelectedPart;
|
|
|
|
import appeng.api.util.AECableType;
|
|
|
|
import appeng.api.util.AEColor;
|
|
|
|
import appeng.api.util.DimensionalCoord;
|
2014-05-05 02:51:05 +02:00
|
|
|
import appeng.client.render.BusRenderHelper;
|
2014-05-16 04:18:30 +02:00
|
|
|
import appeng.client.render.BusRenderer;
|
2014-05-05 02:51:05 +02:00
|
|
|
import appeng.core.AEConfig;
|
2014-02-07 21:37:22 +01:00
|
|
|
import appeng.core.AELog;
|
2014-05-05 02:51:05 +02:00
|
|
|
import appeng.core.features.AEFeature;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.helpers.AEMultiTile;
|
|
|
|
import appeng.parts.BusCollisionHelper;
|
|
|
|
import appeng.parts.CableBusContainer;
|
2014-05-04 21:54:07 +02:00
|
|
|
import appeng.parts.PartPlacement;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.tile.networking.TileCableBus;
|
|
|
|
import appeng.util.Platform;
|
|
|
|
import codechicken.lib.data.MCDataInput;
|
|
|
|
import codechicken.lib.data.MCDataOutput;
|
|
|
|
import codechicken.lib.raytracer.IndexedCuboid6;
|
|
|
|
import codechicken.lib.vec.Cuboid6;
|
|
|
|
import codechicken.lib.vec.Vector3;
|
|
|
|
import codechicken.multipart.IRedstonePart;
|
|
|
|
import codechicken.multipart.JCuboidPart;
|
|
|
|
import codechicken.multipart.JNormalOcclusion;
|
|
|
|
import codechicken.multipart.NormalOcclusionTest;
|
|
|
|
import codechicken.multipart.NormallyOccludedPart;
|
|
|
|
import codechicken.multipart.TMultiPart;
|
2014-04-11 04:50:27 +02:00
|
|
|
import codechicken.multipart.scalatraits.TIInventoryTile;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-08-08 08:40:49 +02:00
|
|
|
/**
|
|
|
|
* Implementing these might help improve visuals for hollow covers
|
|
|
|
*
|
|
|
|
* TSlottedPart,ISidedHollowConnect
|
|
|
|
*/
|
2013-12-27 23:59:59 +01:00
|
|
|
public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IRedstonePart, IPartHost, AEMultiTile
|
|
|
|
{
|
|
|
|
|
|
|
|
final static Cuboid6 sideTests[] = new Cuboid6[] {
|
|
|
|
|
|
|
|
new Cuboid6( 6.0 / 16.0, 0, 6.0 / 16.0, 10.0 / 16.0, 6.0 / 16.0, 10.0 / 16.0 ), // DOWN(0, -1, 0),
|
|
|
|
|
|
|
|
new Cuboid6( 6.0 / 16.0, 10.0 / 16.0, 6.0 / 16.0, 10.0 / 16.0, 1.0, 10.0 / 16.0 ), // UP(0, 1, 0),
|
|
|
|
|
|
|
|
new Cuboid6( 6.0 / 16.0, 6.0 / 16.0, 0.0, 10.0 / 16.0, 10.0 / 16.0, 6.0 / 16.0 ),// NORTH(0, 0, -1),
|
|
|
|
|
|
|
|
new Cuboid6( 6.0 / 16.0, 6.0 / 16.0, 10.0 / 16.0, 10.0 / 16.0, 10.0 / 16.0, 1.0 ),// SOUTH(0, 0, 1),
|
|
|
|
|
|
|
|
new Cuboid6( 0.0, 6.0 / 16.0, 6.0 / 16.0, 6.0 / 16.0, 10.0 / 16.0, 10.0 / 16.0 ),// WEST(-1, 0, 0),
|
|
|
|
|
|
|
|
new Cuboid6( 10.0 / 16.0, 6.0 / 16.0, 6.0 / 16.0, 1.0, 10.0 / 16.0, 10.0 / 16.0 ),// EAST(1, 0, 0),
|
|
|
|
};
|
|
|
|
|
2014-04-29 08:44:13 +02:00
|
|
|
public static ThreadLocal<Boolean> disableFacadeOcclusion = new ThreadLocal<Boolean>();
|
2013-12-27 23:59:59 +01:00
|
|
|
public CableBusContainer cb = new CableBusContainer( this );
|
|
|
|
|
2014-06-09 01:10:19 +02:00
|
|
|
@Override
|
|
|
|
public boolean isInWorld()
|
|
|
|
{
|
|
|
|
return cb.isInWorld();
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@Override
|
|
|
|
public boolean doesTick()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public AECableType getCableConnectionType(ForgeDirection dir)
|
|
|
|
{
|
|
|
|
return cb.getCableConnectionType( dir );
|
|
|
|
}
|
|
|
|
|
2014-07-21 05:45:08 +02:00
|
|
|
@Override
|
|
|
|
public boolean recolourBlock(ForgeDirection side, AEColor colour, EntityPlayer who)
|
|
|
|
{
|
|
|
|
return cb.recolourBlock( side, colour, who );
|
|
|
|
}
|
2014-08-03 06:53:34 +02:00
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@Override
|
|
|
|
public AEColor getColor()
|
|
|
|
{
|
|
|
|
return cb.getColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void save(NBTTagCompound tag)
|
|
|
|
{
|
|
|
|
cb.writeToNBT( tag );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void load(NBTTagCompound tag)
|
|
|
|
{
|
|
|
|
cb.readFromNBT( tag );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeDesc(MCDataOutput packet)
|
|
|
|
{
|
2014-04-10 21:52:17 +02:00
|
|
|
ByteBuf stream = Unpooled.buffer();
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
cb.writeToStream( stream );
|
2014-04-10 21:52:17 +02:00
|
|
|
packet.writeInt( stream.readableBytes() );
|
|
|
|
stream.capacity( stream.readableBytes() );
|
|
|
|
packet.writeByteArray( stream.array() );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
catch (IOException e)
|
|
|
|
{
|
2014-02-07 21:37:22 +01:00
|
|
|
AELog.error( e );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void readDesc(MCDataInput packet)
|
|
|
|
{
|
|
|
|
int len = packet.readInt();
|
|
|
|
byte data[] = packet.readByteArray( len );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2014-04-10 21:52:17 +02:00
|
|
|
if ( len > 0 )
|
|
|
|
{
|
2014-04-11 04:50:27 +02:00
|
|
|
ByteBuf bybuff = Unpooled.wrappedBuffer( data );
|
2014-04-10 21:52:17 +02:00
|
|
|
cb.readFromStream( bybuff );
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
catch (IOException e)
|
|
|
|
{
|
2014-02-07 21:37:22 +01:00
|
|
|
AELog.error( e );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Cuboid6 getBounds()
|
|
|
|
{
|
|
|
|
AxisAlignedBB b = null;
|
|
|
|
|
2014-04-29 08:44:13 +02:00
|
|
|
for (AxisAlignedBB bx : cb.getSelectedBoundingBoxsFromPool( false, true, null, true ))
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
if ( b == null )
|
|
|
|
b = bx;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
double minX = Math.min( b.minX, bx.minX );
|
|
|
|
double minY = Math.min( b.minY, bx.minY );
|
|
|
|
double minZ = Math.min( b.minZ, bx.minZ );
|
|
|
|
double maxX = Math.max( b.maxX, bx.maxX );
|
|
|
|
double maxY = Math.max( b.maxY, bx.maxY );
|
|
|
|
double maxZ = Math.max( b.maxZ, bx.maxZ );
|
|
|
|
b.setBounds( minX, minY, minZ, maxX, maxY, maxZ );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( b == null )
|
|
|
|
return new Cuboid6( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 );
|
|
|
|
|
|
|
|
return new Cuboid6( b.minX, b.minY, b.minZ, b.maxX, b.maxY, b.maxZ );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getType()
|
|
|
|
{
|
|
|
|
return PartRegistry.CableBusPart.getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPartChanged(TMultiPart part)
|
|
|
|
{
|
|
|
|
cb.updateConnections();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack pickItem(MovingObjectPosition hit)
|
|
|
|
{
|
|
|
|
Vec3 v3 = hit.hitVec.addVector( -hit.blockX, -hit.blockY, -hit.blockZ );
|
|
|
|
SelectedPart sp = cb.selectPart( v3 );
|
|
|
|
if ( sp != null )
|
|
|
|
{
|
|
|
|
if ( sp.part != null )
|
2014-01-28 18:29:17 +01:00
|
|
|
return sp.part.getItemStack( PartItemStack.Break );
|
2013-12-27 23:59:59 +01:00
|
|
|
if ( sp.facade != null )
|
|
|
|
return sp.facade.getItemStack();
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Iterable<ItemStack> getDrops()
|
|
|
|
{
|
|
|
|
return cb.getDrops( new ArrayList() );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onEntityCollision(Entity entity)
|
|
|
|
{
|
|
|
|
cb.onEntityCollision( entity );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onWorldJoin()
|
|
|
|
{
|
|
|
|
canUpdate = true;
|
|
|
|
cb.updateConnections();
|
|
|
|
cb.addToWorld();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onWorldSeparate()
|
|
|
|
{
|
|
|
|
canUpdate = false;
|
|
|
|
cb.removeFromWorld();
|
|
|
|
};
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canConnectRedstone(int side)
|
|
|
|
{
|
2014-01-28 18:29:17 +01:00
|
|
|
return cb.canConnectRedstone( EnumSet.of( ForgeDirection.getOrientation( side ) ) );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int strongPowerLevel(int side)
|
|
|
|
{
|
|
|
|
return cb.isProvidingStrongPower( ForgeDirection.getOrientation( side ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int weakPowerLevel(int side)
|
|
|
|
{
|
|
|
|
return cb.isProvidingWeakPower( ForgeDirection.getOrientation( side ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onNeighborChanged()
|
|
|
|
{
|
|
|
|
cb.onNeighborChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean activate(EntityPlayer player, MovingObjectPosition hit, ItemStack item)
|
|
|
|
{
|
|
|
|
return cb.activate( player, hit.hitVec.addVector( -hit.blockX, -hit.blockY, -hit.blockZ ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void renderDynamic(Vector3 pos, float frame, int pass)
|
|
|
|
{
|
2014-05-05 02:51:05 +02:00
|
|
|
if ( pass == 0 || (pass == 1 && AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass )) )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-05-05 02:51:05 +02:00
|
|
|
BusRenderHelper.instance.setPass( pass );
|
2013-12-27 23:59:59 +01:00
|
|
|
cb.renderDynamic( pos.x, pos.y, pos.z );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-04-10 21:52:17 +02:00
|
|
|
public boolean renderStatic(Vector3 pos, int pass)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-05-05 02:51:05 +02:00
|
|
|
if ( pass == 0 || (pass == 1 && AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass )) )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-05-05 02:51:05 +02:00
|
|
|
BusRenderHelper.instance.setPass( pass );
|
2014-05-16 04:18:30 +02:00
|
|
|
BusRenderer.instance.renderer.renderAllFaces = true;
|
|
|
|
BusRenderer.instance.renderer.blockAccess = world();
|
|
|
|
BusRenderer.instance.renderer.overrideBlockTexture = null;
|
2013-12-27 23:59:59 +01:00
|
|
|
cb.renderStatic( pos.x, pos.y, pos.z );
|
2014-05-05 02:51:05 +02:00
|
|
|
return BusRenderHelper.instance.getItemsRendered() > 0;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
2014-04-10 21:52:17 +02:00
|
|
|
return false;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getLightValue()
|
|
|
|
{
|
|
|
|
return cb.getLightValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canAddPart(ItemStack is, ForgeDirection side)
|
|
|
|
{
|
2014-05-04 21:54:07 +02:00
|
|
|
IFacadePart fp = PartPlacement.isFacade( is, side );
|
|
|
|
if ( fp != null )
|
2014-04-20 06:35:48 +02:00
|
|
|
{
|
|
|
|
if ( !(side == null || side == ForgeDirection.UNKNOWN || tile() == null) )
|
|
|
|
{
|
|
|
|
List<AxisAlignedBB> boxes = new ArrayList();
|
|
|
|
IPartCollsionHelper bch = new BusCollisionHelper( boxes, side, null, true );
|
2014-08-03 06:53:34 +02:00
|
|
|
fp.getBoxes( bch, null );
|
2014-04-20 06:35:48 +02:00
|
|
|
for (AxisAlignedBB bb : boxes)
|
|
|
|
{
|
2014-04-29 08:44:13 +02:00
|
|
|
disableFacadeOcclusion.set( true );
|
|
|
|
boolean canAdd = tile().canAddPart( new NormallyOccludedPart( new Cuboid6( bb ) ) );
|
|
|
|
disableFacadeOcclusion.remove();
|
|
|
|
if ( !canAdd )
|
2014-04-20 06:35:48 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
if ( is.getItem() instanceof IPartItem )
|
|
|
|
{
|
|
|
|
IPartItem bi = (IPartItem) is.getItem();
|
|
|
|
|
|
|
|
is = is.copy();
|
|
|
|
is.stackSize = 1;
|
|
|
|
|
|
|
|
IPart bp = bi.createPartFromItemStack( is );
|
|
|
|
if ( !(side == null || side == ForgeDirection.UNKNOWN || tile() == null) )
|
|
|
|
{
|
|
|
|
List<AxisAlignedBB> boxes = new ArrayList();
|
2014-01-31 18:54:34 +01:00
|
|
|
IPartCollsionHelper bch = new BusCollisionHelper( boxes, side, null, true );
|
2013-12-27 23:59:59 +01:00
|
|
|
bp.getBoxes( bch );
|
|
|
|
for (AxisAlignedBB bb : boxes)
|
|
|
|
{
|
|
|
|
if ( !tile().canAddPart( new NormallyOccludedPart( new Cuboid6( bb ) ) ) )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return cb.canAddPart( is, side );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-01-28 18:29:17 +01:00
|
|
|
public ForgeDirection addPart(ItemStack is, ForgeDirection side, EntityPlayer owner)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-01-28 18:29:17 +01:00
|
|
|
return cb.addPart( is, side, owner );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IPart getPart(ForgeDirection side)
|
|
|
|
{
|
|
|
|
return cb.getPart( side );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-01-28 18:29:17 +01:00
|
|
|
public void removePart(ForgeDirection side, boolean supressUpdate)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-01-28 18:29:17 +01:00
|
|
|
cb.removePart( side, supressUpdate );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
boolean canUpdate = false;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void markForUpdate()
|
|
|
|
{
|
|
|
|
if ( Platform.isServer() && canUpdate )
|
|
|
|
sendDescUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public DimensionalCoord getLocation()
|
|
|
|
{
|
|
|
|
return new DimensionalCoord( getTile() );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void invalidateConvertedTile()
|
|
|
|
{
|
|
|
|
cb.setHost( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
public void convertFromTile(TileEntity blockTileEntity)
|
|
|
|
{
|
|
|
|
TileCableBus tcb = (TileCableBus) blockTileEntity;
|
|
|
|
cb = tcb.cb;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean occlusionTest(TMultiPart npart)
|
|
|
|
{
|
|
|
|
return NormalOcclusionTest.apply( this, npart );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Iterable<Cuboid6> getCollisionBoxes()
|
|
|
|
{
|
|
|
|
LinkedList l = new LinkedList();
|
2014-04-29 08:44:13 +02:00
|
|
|
for (AxisAlignedBB b : cb.getSelectedBoundingBoxsFromPool( false, true, null, false ))
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
l.add( new Cuboid6( b.minX, b.minY, b.minZ, b.maxX, b.maxY, b.maxZ ) );
|
|
|
|
}
|
|
|
|
return l;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Iterable<IndexedCuboid6> getSubParts()
|
|
|
|
{
|
|
|
|
LinkedList<IndexedCuboid6> l = new LinkedList();
|
|
|
|
for (Cuboid6 c : getCollisionBoxes())
|
|
|
|
{
|
|
|
|
l.add( new IndexedCuboid6( 0, c ) );
|
|
|
|
}
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Iterable<Cuboid6> getOcclusionBoxes()
|
|
|
|
{
|
|
|
|
LinkedList l = new LinkedList();
|
2014-04-29 08:44:13 +02:00
|
|
|
for (AxisAlignedBB b : cb.getSelectedBoundingBoxsFromPool( true, disableFacadeOcclusion.get() == null, null, true ))
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
l.add( new Cuboid6( b.minX, b.minY, b.minZ, b.maxX, b.maxY, b.maxZ ) );
|
|
|
|
}
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IGridNode getGridNode(ForgeDirection dir)
|
|
|
|
{
|
|
|
|
return cb.getGridNode( dir );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IFacadeContainer getFacadeContainer()
|
|
|
|
{
|
|
|
|
return cb.getFacadeContainer();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void clearContainer()
|
|
|
|
{
|
|
|
|
cb = new CableBusContainer( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isBlocked(ForgeDirection side)
|
|
|
|
{
|
|
|
|
if ( side == null || side == ForgeDirection.UNKNOWN || tile() == null )
|
|
|
|
return false;
|
2014-04-29 08:44:13 +02:00
|
|
|
|
|
|
|
disableFacadeOcclusion.set( true );
|
|
|
|
boolean blocked = !tile().canAddPart( new NormallyOccludedPart( sideTests[side.ordinal()] ) );
|
|
|
|
disableFacadeOcclusion.remove();
|
|
|
|
|
|
|
|
return blocked;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public SelectedPart selectPart(Vec3 pos)
|
|
|
|
{
|
|
|
|
return cb.selectPart( pos );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-26 16:17:39 +01:00
|
|
|
public void partChanged()
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-08-12 02:44:48 +02:00
|
|
|
if ( isInWorld() )
|
|
|
|
notifyNeighbors();
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2014-02-23 23:50:53 +01:00
|
|
|
@Override
|
|
|
|
public Set<LayerFlags> getLayerFlags()
|
|
|
|
{
|
|
|
|
return cb.getLayerFlags();
|
|
|
|
}
|
2014-04-11 04:50:27 +02:00
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@Override
|
|
|
|
public void markForSave()
|
|
|
|
{
|
2014-04-10 21:52:17 +02:00
|
|
|
// mark the chunk for save...
|
2014-05-05 02:51:05 +02:00
|
|
|
TileEntity te = getTile();
|
|
|
|
if ( te != null && te.getWorldObj() != null )
|
|
|
|
te.getWorldObj().getChunkFromBlockCoords( x(), z() ).isModified = true;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean hasRedstone(ForgeDirection side)
|
|
|
|
{
|
|
|
|
return cb.hasRedstone( side );
|
|
|
|
}
|
|
|
|
|
2014-01-28 18:29:17 +01:00
|
|
|
@Override
|
|
|
|
public void securityBreak()
|
|
|
|
{
|
|
|
|
cb.securityBreak();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isEmpty()
|
|
|
|
{
|
|
|
|
return cb.isEmpty();
|
|
|
|
}
|
|
|
|
|
2014-04-10 22:01:04 +02:00
|
|
|
@Override
|
2014-04-11 04:50:27 +02:00
|
|
|
public void cleanup()
|
|
|
|
{
|
2014-04-10 22:01:04 +02:00
|
|
|
tile().remPart( this );
|
|
|
|
}
|
|
|
|
|
2014-06-09 01:10:19 +02:00
|
|
|
@Override
|
|
|
|
public void notifyNeighbors()
|
|
|
|
{
|
|
|
|
if ( tile() instanceof TIInventoryTile )
|
|
|
|
((TIInventoryTile) tile()).rebuildSlotMap();
|
|
|
|
|
2014-06-26 04:19:20 +02:00
|
|
|
if ( world() != null && world().blockExists( x(), y(), z() ) && !CableBusContainer.isLoading() )
|
2014-09-08 20:55:28 +02:00
|
|
|
Platform.notifyBlocksOfNeighbors(world(), x(), y(), z() );
|
2014-06-09 01:10:19 +02:00
|
|
|
}
|
|
|
|
|
2014-08-08 08:40:49 +02:00
|
|
|
// @Override
|
|
|
|
public int getHollowSize(int side)
|
|
|
|
{
|
|
|
|
IPartCable cable = (IPartCable) getPart( ForgeDirection.UNKNOWN );
|
|
|
|
|
|
|
|
ForgeDirection dir = ForgeDirection.getOrientation( side );
|
|
|
|
if ( cable != null && cable.isConnected( dir ) )
|
|
|
|
{
|
|
|
|
List<AxisAlignedBB> boxes = new ArrayList();
|
|
|
|
|
|
|
|
BusCollisionHelper bch = new BusCollisionHelper( boxes, ForgeDirection.EAST, ForgeDirection.UP, ForgeDirection.SOUTH, null, true );
|
|
|
|
|
|
|
|
for (ForgeDirection whichSide : ForgeDirection.values())
|
|
|
|
{
|
|
|
|
IPart fPart = getPart( whichSide );
|
|
|
|
|
|
|
|
if ( fPart != null )
|
|
|
|
fPart.getBoxes( bch );
|
|
|
|
}
|
|
|
|
|
|
|
|
AxisAlignedBB b = null;
|
|
|
|
AxisAlignedBB pb = Platform.getPrimaryBox( dir, 2 );
|
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( b == null )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
switch (dir)
|
|
|
|
{
|
|
|
|
case WEST:
|
|
|
|
case EAST:
|
|
|
|
return getSize( b.minZ, b.maxZ, b.minY, b.maxY );
|
|
|
|
case DOWN:
|
|
|
|
case NORTH:
|
|
|
|
return getSize( b.minX, b.maxX, b.minZ, b.maxZ );
|
|
|
|
case SOUTH:
|
|
|
|
case UP:
|
|
|
|
return getSize( b.minX, b.maxX, b.minY, b.maxY );
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 12;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getSize(double a, double b, double c, double d)
|
|
|
|
{
|
|
|
|
double r = Math.abs( a - 0.5 );
|
|
|
|
r = Math.max( Math.abs( b - 0.5 ), r );
|
|
|
|
r = Math.max( Math.abs( c - 0.5 ), r );
|
|
|
|
return (8 * (int) Math.max( Math.abs( d - 0.5 ), r ));
|
|
|
|
}
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
public int getSlotMask()
|
|
|
|
{
|
|
|
|
int mask = 0;
|
|
|
|
|
|
|
|
for (ForgeDirection side : ForgeDirection.values())
|
|
|
|
{
|
|
|
|
if ( getPart( side ) != null )
|
|
|
|
mask |= 1 << side.ordinal();
|
|
|
|
else if ( side != ForgeDirection.UNKNOWN && getFacadeContainer().getFacade( side ) != null )
|
|
|
|
mask |= 1 << side.ordinal();
|
|
|
|
}
|
|
|
|
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|