Basic reformat, hit once, hope never again
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.fmp;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
@@ -76,6 +77,7 @@ import appeng.parts.PartPlacement;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
/**
|
||||
* Implementing these might help improve visuals for hollow covers
|
||||
*
|
||||
@@ -84,6 +86,7 @@ import appeng.util.Platform;
|
||||
public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IRedstonePart, AEMultiTile
|
||||
{
|
||||
|
||||
public static final ThreadLocal<Boolean> DISABLE_FACADE_OCCLUSION = new ThreadLocal<Boolean>();
|
||||
private final static Cuboid6[] SIDE_TESTS = 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),
|
||||
@@ -98,99 +101,23 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds
|
||||
|
||||
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),
|
||||
};
|
||||
|
||||
public static final ThreadLocal<Boolean> DISABLE_FACADE_OCCLUSION = new ThreadLocal<Boolean>();
|
||||
public CableBusContainer cb = new CableBusContainer( this );
|
||||
boolean canUpdate = false;
|
||||
|
||||
@Override
|
||||
public boolean isInWorld()
|
||||
{
|
||||
return this.cb.isInWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesTick()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
{
|
||||
return this.cb.getCableConnectionType( dir );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock(ForgeDirection side, AEColor colour, EntityPlayer who)
|
||||
public boolean recolourBlock( ForgeDirection side, AEColor colour, EntityPlayer who )
|
||||
{
|
||||
return this.cb.recolourBlock( side, colour, who );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColor getColor()
|
||||
{
|
||||
return this.cb.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(NBTTagCompound tag)
|
||||
{
|
||||
this.cb.writeToNBT( tag );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(NBTTagCompound tag)
|
||||
{
|
||||
this.cb.readFromNBT( tag );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDesc(MCDataOutput packet)
|
||||
{
|
||||
ByteBuf stream = Unpooled.buffer();
|
||||
|
||||
try
|
||||
{
|
||||
this.cb.writeToStream( stream );
|
||||
packet.writeInt( stream.readableBytes() );
|
||||
stream.capacity( stream.readableBytes() );
|
||||
packet.writeByteArray( stream.array() );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readDesc(MCDataInput packet)
|
||||
{
|
||||
int len = packet.readInt();
|
||||
byte[] data = packet.readByteArray( len );
|
||||
|
||||
try
|
||||
{
|
||||
if ( len > 0 )
|
||||
{
|
||||
ByteBuf byteBuffer = Unpooled.wrappedBuffer( data );
|
||||
this.cb.readFromStream( byteBuffer );
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cuboid6 getBounds()
|
||||
{
|
||||
AxisAlignedBB b = null;
|
||||
|
||||
for (AxisAlignedBB bx : this.cb.getSelectedBoundingBoxesFromPool( false, true, null, true ))
|
||||
for( AxisAlignedBB bx : this.cb.getSelectedBoundingBoxesFromPool( false, true, null, true ) )
|
||||
{
|
||||
if ( b == null )
|
||||
if( b == null )
|
||||
b = bx;
|
||||
else
|
||||
{
|
||||
@@ -204,7 +131,7 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds
|
||||
}
|
||||
}
|
||||
|
||||
if ( b == null )
|
||||
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 );
|
||||
@@ -217,36 +144,9 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPartChanged(TMultiPart part)
|
||||
public int getLightValue()
|
||||
{
|
||||
this.cb.updateConnections();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack pickItem(MovingObjectPosition hit)
|
||||
{
|
||||
Vec3 v3 = hit.hitVec.addVector( -hit.blockX, -hit.blockY, -hit.blockZ );
|
||||
SelectedPart sp = this.cb.selectPart( v3 );
|
||||
if ( sp != null )
|
||||
{
|
||||
if ( sp.part != null )
|
||||
return sp.part.getItemStack( PartItemStack.Break );
|
||||
if ( sp.facade != null )
|
||||
return sp.facade.getItemStack();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<ItemStack> getDrops()
|
||||
{
|
||||
return this.cb.getDrops( new ArrayList() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(Entity entity)
|
||||
{
|
||||
this.cb.onEntityCollision( entity );
|
||||
return this.cb.getLightValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -258,56 +158,15 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWorldSeparate()
|
||||
public boolean occlusionTest( TMultiPart part )
|
||||
{
|
||||
this.canUpdate = false;
|
||||
this.cb.removeFromWorld();
|
||||
return NormalOcclusionTest.apply( this, part );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone(int side)
|
||||
public boolean renderStatic( Vector3 pos, int pass )
|
||||
{
|
||||
return this.cb.canConnectRedstone( EnumSet.of( ForgeDirection.getOrientation( side ) ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int strongPowerLevel(int side)
|
||||
{
|
||||
return this.cb.isProvidingStrongPower( ForgeDirection.getOrientation( side ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int weakPowerLevel(int side)
|
||||
{
|
||||
return this.cb.isProvidingWeakPower( ForgeDirection.getOrientation( side ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
this.cb.onNeighborChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activate(EntityPlayer player, MovingObjectPosition hit, ItemStack item)
|
||||
{
|
||||
return this.cb.activate( player, hit.hitVec.addVector( -hit.blockX, -hit.blockY, -hit.blockZ ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderDynamic(Vector3 pos, float frame, int pass)
|
||||
{
|
||||
if ( pass == 0 || (pass == 1 && AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass )) )
|
||||
{
|
||||
BusRenderHelper.INSTANCE.setPass( pass );
|
||||
this.cb.renderDynamic( pos.x, pos.y, pos.z );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderStatic(Vector3 pos, int pass)
|
||||
{
|
||||
if ( pass == 0 || (pass == 1 && AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass )) )
|
||||
if( pass == 0 || ( pass == 1 && AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) ) )
|
||||
{
|
||||
BusRenderHelper.INSTANCE.setPass( pass );
|
||||
BusRenderer.INSTANCE.renderer.renderAllFaces = true;
|
||||
@@ -320,93 +179,101 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue()
|
||||
public void renderDynamic( Vector3 pos, float frame, int pass )
|
||||
{
|
||||
return this.cb.getLightValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAddPart(ItemStack is, ForgeDirection side)
|
||||
{
|
||||
IFacadePart fp = PartPlacement.isFacade( is, side );
|
||||
if ( fp != null )
|
||||
if( pass == 0 || ( pass == 1 && AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) ) )
|
||||
{
|
||||
if ( !(side == null || side == ForgeDirection.UNKNOWN || this.tile() == null) )
|
||||
{
|
||||
List<AxisAlignedBB> boxes = new ArrayList<AxisAlignedBB>();
|
||||
IPartCollisionHelper bch = new BusCollisionHelper( boxes, side, null, true );
|
||||
fp.getBoxes( bch, null );
|
||||
for (AxisAlignedBB bb : boxes)
|
||||
{
|
||||
DISABLE_FACADE_OCCLUSION.set( true );
|
||||
boolean canAdd = this.tile().canAddPart( new NormallyOccludedPart( new Cuboid6( bb ) ) );
|
||||
DISABLE_FACADE_OCCLUSION.remove();
|
||||
if ( !canAdd )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
BusRenderHelper.INSTANCE.setPass( pass );
|
||||
this.cb.renderDynamic( pos.x, pos.y, pos.z );
|
||||
}
|
||||
}
|
||||
|
||||
if ( is.getItem() instanceof IPartItem )
|
||||
@Override
|
||||
public void onPartChanged( TMultiPart part )
|
||||
{
|
||||
this.cb.updateConnections();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision( Entity entity )
|
||||
{
|
||||
this.cb.onEntityCollision( entity );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activate( EntityPlayer player, MovingObjectPosition hit, ItemStack item )
|
||||
{
|
||||
return this.cb.activate( player, hit.hitVec.addVector( -hit.blockX, -hit.blockY, -hit.blockZ ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load( NBTTagCompound tag )
|
||||
{
|
||||
this.cb.readFromNBT( tag );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWorldSeparate()
|
||||
{
|
||||
this.canUpdate = false;
|
||||
this.cb.removeFromWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save( NBTTagCompound tag )
|
||||
{
|
||||
this.cb.writeToNBT( tag );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDesc( MCDataOutput packet )
|
||||
{
|
||||
ByteBuf stream = Unpooled.buffer();
|
||||
|
||||
try
|
||||
{
|
||||
IPartItem bi = (IPartItem) is.getItem();
|
||||
|
||||
is = is.copy();
|
||||
is.stackSize = 1;
|
||||
|
||||
IPart bp = bi.createPartFromItemStack( is );
|
||||
if ( !(side == null || side == ForgeDirection.UNKNOWN || this.tile() == null) )
|
||||
{
|
||||
List<AxisAlignedBB> boxes = new ArrayList<AxisAlignedBB>();
|
||||
IPartCollisionHelper bch = new BusCollisionHelper( boxes, side, null, true );
|
||||
bp.getBoxes( bch );
|
||||
for (AxisAlignedBB bb : boxes)
|
||||
{
|
||||
if ( !this.tile().canAddPart( new NormallyOccludedPart( new Cuboid6( bb ) ) ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.cb.writeToStream( stream );
|
||||
packet.writeInt( stream.readableBytes() );
|
||||
stream.capacity( stream.readableBytes() );
|
||||
packet.writeByteArray( stream.array() );
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
|
||||
return this.cb.canAddPart( is, side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection addPart(ItemStack is, ForgeDirection side, EntityPlayer owner)
|
||||
public ItemStack pickItem( MovingObjectPosition hit )
|
||||
{
|
||||
return this.cb.addPart( is, side, owner );
|
||||
Vec3 v3 = hit.hitVec.addVector( -hit.blockX, -hit.blockY, -hit.blockZ );
|
||||
SelectedPart sp = this.cb.selectPart( v3 );
|
||||
if( sp != null )
|
||||
{
|
||||
if( sp.part != null )
|
||||
return sp.part.getItemStack( PartItemStack.Break );
|
||||
if( sp.facade != null )
|
||||
return sp.facade.getItemStack();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPart getPart(ForgeDirection side)
|
||||
public Iterable<ItemStack> getDrops()
|
||||
{
|
||||
return this.cb.getPart( side );
|
||||
return this.cb.getDrops( new ArrayList() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePart(ForgeDirection side, boolean suppressUpdate)
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
this.cb.removePart( side, suppressUpdate );
|
||||
}
|
||||
|
||||
boolean canUpdate = false;
|
||||
|
||||
@Override
|
||||
public void markForUpdate()
|
||||
{
|
||||
if ( Platform.isServer() && this.canUpdate )
|
||||
this.sendDescUpdate();
|
||||
this.cb.onNeighborChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
public boolean doesTick()
|
||||
{
|
||||
return new DimensionalCoord( this.tile() );
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -415,46 +282,55 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds
|
||||
this.cb.setHost( this );
|
||||
}
|
||||
|
||||
public void convertFromTile(TileEntity blockTileEntity)
|
||||
@Override
|
||||
public void readDesc( MCDataInput packet )
|
||||
{
|
||||
int len = packet.readInt();
|
||||
byte[] data = packet.readByteArray( len );
|
||||
|
||||
try
|
||||
{
|
||||
if( len > 0 )
|
||||
{
|
||||
ByteBuf byteBuffer = Unpooled.wrappedBuffer( data );
|
||||
this.cb.readFromStream( byteBuffer );
|
||||
}
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone( int side )
|
||||
{
|
||||
return this.cb.canConnectRedstone( EnumSet.of( ForgeDirection.getOrientation( side ) ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int weakPowerLevel( int side )
|
||||
{
|
||||
return this.cb.isProvidingWeakPower( ForgeDirection.getOrientation( side ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int strongPowerLevel( int side )
|
||||
{
|
||||
return this.cb.isProvidingStrongPower( ForgeDirection.getOrientation( side ) );
|
||||
}
|
||||
|
||||
public void convertFromTile( TileEntity blockTileEntity )
|
||||
{
|
||||
TileCableBus tcb = (TileCableBus) blockTileEntity;
|
||||
this.cb = tcb.cb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean occlusionTest(TMultiPart part)
|
||||
{
|
||||
return NormalOcclusionTest.apply( this, part );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Cuboid6> getCollisionBoxes()
|
||||
{
|
||||
LinkedList<Cuboid6> l = new LinkedList<Cuboid6>();
|
||||
for (AxisAlignedBB b : this.cb.getSelectedBoundingBoxesFromPool( false, true, null, true ))
|
||||
{
|
||||
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<IndexedCuboid6>();
|
||||
for (Cuboid6 c : this.getCollisionBoxes())
|
||||
{
|
||||
l.add( new IndexedCuboid6( 0, c ) );
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Cuboid6> getOcclusionBoxes()
|
||||
{
|
||||
LinkedList<Cuboid6> l = new LinkedList<Cuboid6>();
|
||||
for (AxisAlignedBB b : this.cb.getSelectedBoundingBoxesFromPool( true, DISABLE_FACADE_OCCLUSION.get() == null, null, true ))
|
||||
for( AxisAlignedBB b : this.cb.getSelectedBoundingBoxesFromPool( true, DISABLE_FACADE_OCCLUSION.get() == null, null, true ) )
|
||||
{
|
||||
l.add( new Cuboid6( b.minX, b.minY, b.minZ, b.maxX, b.maxY, b.maxZ ) );
|
||||
}
|
||||
@@ -462,68 +338,15 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir)
|
||||
public IGridNode getGridNode( ForgeDirection dir )
|
||||
{
|
||||
return this.cb.getGridNode( dir );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFacadeContainer getFacadeContainer()
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return this.cb.getFacadeContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearContainer()
|
||||
{
|
||||
this.cb = new CableBusContainer( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlocked(ForgeDirection side)
|
||||
{
|
||||
if ( side == null || side == ForgeDirection.UNKNOWN || this.tile() == null )
|
||||
return false;
|
||||
|
||||
DISABLE_FACADE_OCCLUSION.set( true );
|
||||
boolean blocked = !this.tile().canAddPart( new NormallyOccludedPart( SIDE_TESTS[side.ordinal()] ) );
|
||||
DISABLE_FACADE_OCCLUSION.remove();
|
||||
|
||||
return blocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SelectedPart selectPart(Vec3 pos)
|
||||
{
|
||||
return this.cb.selectPart( pos );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void partChanged()
|
||||
{
|
||||
if ( this.isInWorld() )
|
||||
this.notifyNeighbors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<LayerFlags> getLayerFlags()
|
||||
{
|
||||
return this.cb.getLayerFlags();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForSave()
|
||||
{
|
||||
// mark the chunk for save...
|
||||
TileEntity te = this.tile();
|
||||
if ( te != null && te.getWorldObj() != null )
|
||||
te.getWorldObj().getChunkFromBlockCoords( this.x(), this.z() ).isModified = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRedstone(ForgeDirection side)
|
||||
{
|
||||
return this.cb.hasRedstone( side );
|
||||
return this.cb.getCableConnectionType( dir );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -532,56 +355,34 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds
|
||||
this.cb.securityBreak();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return this.cb.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup()
|
||||
{
|
||||
this.tile().remPart( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyNeighbors()
|
||||
{
|
||||
if ( this.tile() instanceof TIInventoryTile )
|
||||
((TIInventoryTile) this.tile()).rebuildSlotMap();
|
||||
|
||||
if ( this.world() != null && this.world().blockExists( this.x(), this.y(), this.z() ) && !CableBusContainer.isLoading() )
|
||||
Platform.notifyBlocksOfNeighbors(this.world(), this.x(), this.y(), this.z() );
|
||||
}
|
||||
|
||||
// @Override
|
||||
public int getHollowSize(int side)
|
||||
public int getHollowSize( int side )
|
||||
{
|
||||
IPartCable cable = (IPartCable) this.getPart( ForgeDirection.UNKNOWN );
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation( side );
|
||||
if ( cable != null && cable.isConnected( dir ) )
|
||||
if( cable != null && cable.isConnected( dir ) )
|
||||
{
|
||||
List<AxisAlignedBB> boxes = new ArrayList<AxisAlignedBB>();
|
||||
|
||||
BusCollisionHelper bch = new BusCollisionHelper( boxes, ForgeDirection.EAST, ForgeDirection.UP, ForgeDirection.SOUTH, null, true );
|
||||
|
||||
for (ForgeDirection whichSide : ForgeDirection.values())
|
||||
for( ForgeDirection whichSide : ForgeDirection.values() )
|
||||
{
|
||||
IPart fPart = this.getPart( whichSide );
|
||||
|
||||
if ( fPart != null )
|
||||
if( fPart != null )
|
||||
fPart.getBoxes( bch );
|
||||
}
|
||||
|
||||
AxisAlignedBB b = null;
|
||||
AxisAlignedBB pb = Platform.getPrimaryBox( dir, 2 );
|
||||
|
||||
for (AxisAlignedBB bb : boxes)
|
||||
for( AxisAlignedBB bb : boxes )
|
||||
{
|
||||
if ( bb.intersectsWith( pb ) )
|
||||
if( bb.intersectsWith( pb ) )
|
||||
{
|
||||
if ( b == null )
|
||||
if( b == null )
|
||||
b = bb;
|
||||
else
|
||||
{
|
||||
@@ -595,33 +396,33 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds
|
||||
}
|
||||
}
|
||||
|
||||
if ( b == null )
|
||||
if( b == null )
|
||||
return 0;
|
||||
|
||||
switch (dir)
|
||||
switch( dir )
|
||||
{
|
||||
case WEST:
|
||||
case EAST:
|
||||
return this.getSize( b.minZ, b.maxZ, b.minY, b.maxY );
|
||||
case DOWN:
|
||||
case NORTH:
|
||||
return this.getSize( b.minX, b.maxX, b.minZ, b.maxZ );
|
||||
case SOUTH:
|
||||
case UP:
|
||||
return this.getSize( b.minX, b.maxX, b.minY, b.maxY );
|
||||
default:
|
||||
case WEST:
|
||||
case EAST:
|
||||
return this.getSize( b.minZ, b.maxZ, b.minY, b.maxY );
|
||||
case DOWN:
|
||||
case NORTH:
|
||||
return this.getSize( b.minX, b.maxX, b.minZ, b.maxZ );
|
||||
case SOUTH:
|
||||
case UP:
|
||||
return this.getSize( b.minX, b.maxX, b.minY, b.maxY );
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
return 12;
|
||||
}
|
||||
|
||||
int getSize(double a, double b, double c, double d)
|
||||
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 ));
|
||||
return ( 8 * (int) Math.max( Math.abs( d - 0.5 ), r ) );
|
||||
}
|
||||
|
||||
// @Override
|
||||
@@ -629,15 +430,211 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds
|
||||
{
|
||||
int mask = 0;
|
||||
|
||||
for (ForgeDirection side : ForgeDirection.values())
|
||||
for( ForgeDirection side : ForgeDirection.values() )
|
||||
{
|
||||
if ( this.getPart( side ) != null )
|
||||
if( this.getPart( side ) != null )
|
||||
mask |= 1 << side.ordinal();
|
||||
else if ( side != ForgeDirection.UNKNOWN && this.getFacadeContainer().getFacade( side ) != null )
|
||||
else if( side != ForgeDirection.UNKNOWN && this.getFacadeContainer().getFacade( side ) != null )
|
||||
mask |= 1 << side.ordinal();
|
||||
}
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFacadeContainer getFacadeContainer()
|
||||
{
|
||||
return this.cb.getFacadeContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAddPart( ItemStack is, ForgeDirection side )
|
||||
{
|
||||
IFacadePart fp = PartPlacement.isFacade( is, side );
|
||||
if( fp != null )
|
||||
{
|
||||
if( !( side == null || side == ForgeDirection.UNKNOWN || this.tile() == null ) )
|
||||
{
|
||||
List<AxisAlignedBB> boxes = new ArrayList<AxisAlignedBB>();
|
||||
IPartCollisionHelper bch = new BusCollisionHelper( boxes, side, null, true );
|
||||
fp.getBoxes( bch, null );
|
||||
for( AxisAlignedBB bb : boxes )
|
||||
{
|
||||
DISABLE_FACADE_OCCLUSION.set( true );
|
||||
boolean canAdd = this.tile().canAddPart( new NormallyOccludedPart( new Cuboid6( bb ) ) );
|
||||
DISABLE_FACADE_OCCLUSION.remove();
|
||||
if( !canAdd )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
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 || this.tile() == null ) )
|
||||
{
|
||||
List<AxisAlignedBB> boxes = new ArrayList<AxisAlignedBB>();
|
||||
IPartCollisionHelper bch = new BusCollisionHelper( boxes, side, null, true );
|
||||
bp.getBoxes( bch );
|
||||
for( AxisAlignedBB bb : boxes )
|
||||
{
|
||||
if( !this.tile().canAddPart( new NormallyOccludedPart( new Cuboid6( bb ) ) ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.cb.canAddPart( is, side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection addPart( ItemStack is, ForgeDirection side, EntityPlayer owner )
|
||||
{
|
||||
return this.cb.addPart( is, side, owner );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPart getPart( ForgeDirection side )
|
||||
{
|
||||
return this.cb.getPart( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePart( ForgeDirection side, boolean suppressUpdate )
|
||||
{
|
||||
this.cb.removePart( side, suppressUpdate );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForUpdate()
|
||||
{
|
||||
if( Platform.isServer() && this.canUpdate )
|
||||
this.sendDescUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
{
|
||||
return new DimensionalCoord( this.tile() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColor getColor()
|
||||
{
|
||||
return this.cb.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearContainer()
|
||||
{
|
||||
this.cb = new CableBusContainer( this );
|
||||
} @Override
|
||||
public Iterable<Cuboid6> getCollisionBoxes()
|
||||
{
|
||||
LinkedList<Cuboid6> l = new LinkedList<Cuboid6>();
|
||||
for( AxisAlignedBB b : this.cb.getSelectedBoundingBoxesFromPool( false, true, null, true ) )
|
||||
{
|
||||
l.add( new Cuboid6( b.minX, b.minY, b.minZ, b.maxX, b.maxY, b.maxZ ) );
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlocked( ForgeDirection side )
|
||||
{
|
||||
if( side == null || side == ForgeDirection.UNKNOWN || this.tile() == null )
|
||||
return false;
|
||||
|
||||
DISABLE_FACADE_OCCLUSION.set( true );
|
||||
boolean blocked = !this.tile().canAddPart( new NormallyOccludedPart( SIDE_TESTS[side.ordinal()] ) );
|
||||
DISABLE_FACADE_OCCLUSION.remove();
|
||||
|
||||
return blocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SelectedPart selectPart( Vec3 pos )
|
||||
{
|
||||
return this.cb.selectPart( pos );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForSave()
|
||||
{
|
||||
// mark the chunk for save...
|
||||
TileEntity te = this.tile();
|
||||
if( te != null && te.getWorldObj() != null )
|
||||
te.getWorldObj().getChunkFromBlockCoords( this.x(), this.z() ).isModified = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void partChanged()
|
||||
{
|
||||
if( this.isInWorld() )
|
||||
this.notifyNeighbors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRedstone( ForgeDirection side )
|
||||
{
|
||||
return this.cb.hasRedstone( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return this.cb.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<LayerFlags> getLayerFlags()
|
||||
{
|
||||
return this.cb.getLayerFlags();
|
||||
} @Override
|
||||
public Iterable<IndexedCuboid6> getSubParts()
|
||||
{
|
||||
LinkedList<IndexedCuboid6> l = new LinkedList<IndexedCuboid6>();
|
||||
for( Cuboid6 c : this.getCollisionBoxes() )
|
||||
{
|
||||
l.add( new IndexedCuboid6( 0, c ) );
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup()
|
||||
{
|
||||
this.tile().remPart( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyNeighbors()
|
||||
{
|
||||
if( this.tile() instanceof TIInventoryTile )
|
||||
( (TIInventoryTile) this.tile() ).rebuildSlotMap();
|
||||
|
||||
if( this.world() != null && this.world().blockExists( this.x(), this.y(), this.z() ) && !CableBusContainer.isLoading() )
|
||||
Platform.notifyBlocksOfNeighbors( this.world(), this.x(), this.y(), this.z() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInWorld()
|
||||
{
|
||||
return this.cb.isInWorld();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.fmp;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFence;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -44,6 +45,7 @@ import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketMultiPart;
|
||||
import appeng.integration.modules.helpers.FMPPacketEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Basically a total rip of of the FMP version for vanilla, seemed to work well enough...
|
||||
*/
|
||||
@@ -53,29 +55,15 @@ public class FMPEvent
|
||||
private final ThreadLocal<Object> placing = new ThreadLocal<Object>();
|
||||
|
||||
@SubscribeEvent
|
||||
public void ServerFMPEvent(FMPPacketEvent event)
|
||||
public void ServerFMPEvent( FMPPacketEvent event )
|
||||
{
|
||||
FMPEvent.place( event.sender, event.sender.worldObj );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void playerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if ( event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote )
|
||||
{
|
||||
if ( this.placing.get() != null )
|
||||
return;
|
||||
this.placing.set( event );
|
||||
if ( place( event.entityPlayer, event.entityPlayer.worldObj ) )
|
||||
event.setCanceled( true );
|
||||
this.placing.set( null );
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean place(EntityPlayer player, World world)
|
||||
public static boolean place( EntityPlayer player, World world )
|
||||
{
|
||||
MovingObjectPosition hit = RayTracer.reTrace( world, player );
|
||||
if ( hit == null )
|
||||
if( hit == null )
|
||||
return false;
|
||||
|
||||
BlockCoord pos = new BlockCoord( hit.blockX, hit.blockY, hit.blockZ ).offset( hit.sideHit );
|
||||
@@ -84,47 +72,44 @@ public class FMPEvent
|
||||
|
||||
Block blk = null;
|
||||
|
||||
if ( held == null )
|
||||
if( held == null )
|
||||
return false;
|
||||
|
||||
if ( held.getItem() instanceof AEBaseItemBlock )
|
||||
if( held.getItem() instanceof AEBaseItemBlock )
|
||||
{
|
||||
AEBaseItemBlock ib = (AEBaseItemBlock) held.getItem();
|
||||
blk = Block.getBlockFromItem( ib );
|
||||
part = PartRegistry.getPartByBlock( blk, hit.sideHit );
|
||||
}
|
||||
|
||||
if ( part == null )
|
||||
if( part == null )
|
||||
return false;
|
||||
|
||||
if ( world.isRemote && !player.isSneaking() )// attempt to use block activated like normal and tell the server
|
||||
// the right stuff
|
||||
if( world.isRemote && !player.isSneaking() )// attempt to use block activated like normal and tell the server
|
||||
// the right stuff
|
||||
{
|
||||
Vector3 f = new Vector3( hit.hitVec ).add( -hit.blockX, -hit.blockY, -hit.blockZ );
|
||||
Block block = world.getBlock( hit.blockX, hit.blockY, hit.blockZ );
|
||||
if ( block != null && !ignoreActivate( block )
|
||||
&& block.onBlockActivated( world, hit.blockX, hit.blockY, hit.blockZ, player, hit.sideHit, (float) f.x, (float) f.y, (float) f.z ) )
|
||||
if( block != null && !ignoreActivate( block ) && block.onBlockActivated( world, hit.blockX, hit.blockY, hit.blockZ, player, hit.sideHit, (float) f.x, (float) f.y, (float) f.z ) )
|
||||
{
|
||||
player.swingItem();
|
||||
PacketCustom.sendToServer( new C08PacketPlayerBlockPlacement( hit.blockX, hit.blockY, hit.blockZ, hit.sideHit, player.inventory
|
||||
.getCurrentItem(), (float) f.x, (float) f.y, (float) f.z ) );
|
||||
PacketCustom.sendToServer( new C08PacketPlayerBlockPlacement( hit.blockX, hit.blockY, hit.blockZ, hit.sideHit, player.inventory.getCurrentItem(), (float) f.x, (float) f.y, (float) f.z ) );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
TileMultipart tile = TileMultipart.getOrConvertTile( world, pos );
|
||||
if ( tile == null || !tile.canAddPart( part ) )
|
||||
if( tile == null || !tile.canAddPart( part ) )
|
||||
return false;
|
||||
|
||||
if ( !world.isRemote )
|
||||
if( !world.isRemote )
|
||||
{
|
||||
TileMultipart.addPart( world, pos, part );
|
||||
world.playSoundEffect( pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, blk.stepSound.func_150496_b(), (blk.stepSound.getVolume() + 1.0F) / 2.0F,
|
||||
blk.stepSound.getPitch() * 0.8F );
|
||||
if ( !player.capabilities.isCreativeMode )
|
||||
world.playSoundEffect( pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, blk.stepSound.func_150496_b(), ( blk.stepSound.getVolume() + 1.0F ) / 2.0F, blk.stepSound.getPitch() * 0.8F );
|
||||
if( !player.capabilities.isCreativeMode )
|
||||
{
|
||||
held.stackSize--;
|
||||
if ( held.stackSize == 0 )
|
||||
if( held.stackSize == 0 )
|
||||
{
|
||||
player.inventory.mainInventory[player.inventory.currentItem] = null;
|
||||
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( player, held ) );
|
||||
@@ -142,10 +127,24 @@ public class FMPEvent
|
||||
/**
|
||||
* Because vanilla is weird.
|
||||
*/
|
||||
private static boolean ignoreActivate(Block block)
|
||||
private static boolean ignoreActivate( Block block )
|
||||
{
|
||||
if ( block instanceof BlockFence )
|
||||
if( block instanceof BlockFence )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void playerInteract( PlayerInteractEvent event )
|
||||
{
|
||||
if( event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote )
|
||||
{
|
||||
if( this.placing.get() != null )
|
||||
return;
|
||||
this.placing.set( event );
|
||||
if( place( event.entityPlayer, event.entityPlayer.worldObj ) )
|
||||
event.setCanceled( true );
|
||||
this.placing.set( null );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.fmp;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -43,89 +44,30 @@ import appeng.facade.FacadeContainer;
|
||||
import appeng.parts.CableBusStorage;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class FMPPlacementHelper implements IPartHost
|
||||
{
|
||||
|
||||
static class NullStorage extends CableBusStorage
|
||||
{
|
||||
|
||||
@Override
|
||||
public IFacadePart getFacade(int x)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacade(int x, IFacadePart facade)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
final private static CableBusStorage NULL_STORAGE = new NullStorage();
|
||||
|
||||
private boolean hasPart = false;
|
||||
private TileMultipart myMP;
|
||||
private CableBusPart myPart;
|
||||
|
||||
private CableBusPart getPart()
|
||||
public FMPPlacementHelper( TileMultipart mp )
|
||||
{
|
||||
scala.collection.Iterator<TMultiPart> i = this.myMP.partList().iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
TMultiPart p = i.next();
|
||||
if ( p instanceof CableBusPart )
|
||||
this.myPart = (CableBusPart) p;
|
||||
}
|
||||
|
||||
if ( this.myPart == null )
|
||||
this.myPart = (CableBusPart) PartRegistry.CableBusPart.construct( 0 );
|
||||
|
||||
BlockCoord loc = new BlockCoord( this.myMP.xCoord, this.myMP.yCoord, this.myMP.zCoord );
|
||||
|
||||
if ( this.myMP.canAddPart( this.myPart ) && Platform.isServer() )
|
||||
{
|
||||
this.myMP = TileMultipart.addPart( this.myMP.getWorldObj(), loc, this.myPart );
|
||||
this.hasPart = true;
|
||||
}
|
||||
|
||||
return this.myPart;
|
||||
}
|
||||
|
||||
public void removePart()
|
||||
{
|
||||
if ( this.myPart.isEmpty() )
|
||||
{
|
||||
scala.collection.Iterator<TMultiPart> i = this.myMP.partList().iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
TMultiPart p = i.next();
|
||||
if ( p == this.myPart )
|
||||
{
|
||||
this.myMP = this.myMP.remPart( this.myPart );
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.hasPart = false;
|
||||
this.myPart = null;
|
||||
}
|
||||
}
|
||||
|
||||
public FMPPlacementHelper(TileMultipart mp) {
|
||||
this.myMP = mp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFacadeContainer getFacadeContainer()
|
||||
{
|
||||
if ( this.myPart == null )
|
||||
if( this.myPart == null )
|
||||
return new FacadeContainer( NULL_STORAGE );
|
||||
return this.myPart.getFacadeContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAddPart(ItemStack part, ForgeDirection side)
|
||||
public boolean canAddPart( ItemStack part, ForgeDirection side )
|
||||
{
|
||||
CableBusPart myPart = this.getPart();
|
||||
|
||||
@@ -136,8 +78,51 @@ public class FMPPlacementHelper implements IPartHost
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
private CableBusPart getPart()
|
||||
{
|
||||
scala.collection.Iterator<TMultiPart> i = this.myMP.partList().iterator();
|
||||
while( i.hasNext() )
|
||||
{
|
||||
TMultiPart p = i.next();
|
||||
if( p instanceof CableBusPart )
|
||||
this.myPart = (CableBusPart) p;
|
||||
}
|
||||
|
||||
if( this.myPart == null )
|
||||
this.myPart = (CableBusPart) PartRegistry.CableBusPart.construct( 0 );
|
||||
|
||||
BlockCoord loc = new BlockCoord( this.myMP.xCoord, this.myMP.yCoord, this.myMP.zCoord );
|
||||
|
||||
if( this.myMP.canAddPart( this.myPart ) && Platform.isServer() )
|
||||
{
|
||||
this.myMP = TileMultipart.addPart( this.myMP.getWorldObj(), loc, this.myPart );
|
||||
this.hasPart = true;
|
||||
}
|
||||
|
||||
return this.myPart;
|
||||
}
|
||||
|
||||
public void removePart()
|
||||
{
|
||||
if( this.myPart.isEmpty() )
|
||||
{
|
||||
scala.collection.Iterator<TMultiPart> i = this.myMP.partList().iterator();
|
||||
while( i.hasNext() )
|
||||
{
|
||||
TMultiPart p = i.next();
|
||||
if( p == this.myPart )
|
||||
{
|
||||
this.myMP = this.myMP.remPart( this.myPart );
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.hasPart = false;
|
||||
this.myPart = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection addPart(ItemStack is, ForgeDirection side, EntityPlayer owner)
|
||||
public ForgeDirection addPart( ItemStack is, ForgeDirection side, EntityPlayer owner )
|
||||
{
|
||||
CableBusPart myPart = this.getPart();
|
||||
|
||||
@@ -149,17 +134,17 @@ public class FMPPlacementHelper implements IPartHost
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPart getPart(ForgeDirection side)
|
||||
public IPart getPart( ForgeDirection side )
|
||||
{
|
||||
if ( this.myPart == null )
|
||||
if( this.myPart == null )
|
||||
return null;
|
||||
return this.myPart.getPart( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePart(ForgeDirection side, boolean suppressUpdate)
|
||||
public void removePart( ForgeDirection side, boolean suppressUpdate )
|
||||
{
|
||||
if ( this.myPart == null )
|
||||
if( this.myPart == null )
|
||||
return;
|
||||
this.myPart.removePart( side, suppressUpdate );
|
||||
}
|
||||
@@ -167,7 +152,7 @@ public class FMPPlacementHelper implements IPartHost
|
||||
@Override
|
||||
public void markForUpdate()
|
||||
{
|
||||
if ( this.myPart == null )
|
||||
if( this.myPart == null )
|
||||
return;
|
||||
this.myPart.markForUpdate();
|
||||
}
|
||||
@@ -175,7 +160,7 @@ public class FMPPlacementHelper implements IPartHost
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
{
|
||||
if ( this.myPart == null )
|
||||
if( this.myPart == null )
|
||||
return new DimensionalCoord( this.myMP );
|
||||
return this.myPart.getLocation();
|
||||
}
|
||||
@@ -189,7 +174,7 @@ public class FMPPlacementHelper implements IPartHost
|
||||
@Override
|
||||
public AEColor getColor()
|
||||
{
|
||||
if ( this.myPart == null )
|
||||
if( this.myPart == null )
|
||||
return AEColor.Transparent;
|
||||
return this.myPart.getColor();
|
||||
}
|
||||
@@ -197,13 +182,13 @@ public class FMPPlacementHelper implements IPartHost
|
||||
@Override
|
||||
public void clearContainer()
|
||||
{
|
||||
if ( this.myPart == null )
|
||||
if( this.myPart == null )
|
||||
return;
|
||||
this.myPart.clearContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlocked(ForgeDirection side)
|
||||
public boolean isBlocked( ForgeDirection side )
|
||||
{
|
||||
this.getPart();
|
||||
|
||||
@@ -215,9 +200,9 @@ public class FMPPlacementHelper implements IPartHost
|
||||
}
|
||||
|
||||
@Override
|
||||
public SelectedPart selectPart(Vec3 pos)
|
||||
public SelectedPart selectPart( Vec3 pos )
|
||||
{
|
||||
if ( this.myPart == null )
|
||||
if( this.myPart == null )
|
||||
return new SelectedPart();
|
||||
return this.myPart.selectPart( pos );
|
||||
}
|
||||
@@ -225,7 +210,7 @@ public class FMPPlacementHelper implements IPartHost
|
||||
@Override
|
||||
public void markForSave()
|
||||
{
|
||||
if ( this.myPart == null )
|
||||
if( this.myPart == null )
|
||||
return;
|
||||
this.myPart.markForSave();
|
||||
}
|
||||
@@ -233,15 +218,15 @@ public class FMPPlacementHelper implements IPartHost
|
||||
@Override
|
||||
public void partChanged()
|
||||
{
|
||||
if ( this.myPart == null )
|
||||
if( this.myPart == null )
|
||||
return;
|
||||
this.myPart.partChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRedstone(ForgeDirection side)
|
||||
public boolean hasRedstone( ForgeDirection side )
|
||||
{
|
||||
if ( this.myPart == null )
|
||||
if( this.myPart == null )
|
||||
return false;
|
||||
return this.myPart.hasRedstone( side );
|
||||
}
|
||||
@@ -249,7 +234,7 @@ public class FMPPlacementHelper implements IPartHost
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
if ( this.myPart == null )
|
||||
if( this.myPart == null )
|
||||
return true;
|
||||
return this.myPart.isEmpty();
|
||||
}
|
||||
@@ -257,7 +242,7 @@ public class FMPPlacementHelper implements IPartHost
|
||||
@Override
|
||||
public Set<LayerFlags> getLayerFlags()
|
||||
{
|
||||
if ( this.myPart == null )
|
||||
if( this.myPart == null )
|
||||
return EnumSet.noneOf( LayerFlags.class );
|
||||
return this.myPart.getLayerFlags();
|
||||
}
|
||||
@@ -265,7 +250,7 @@ public class FMPPlacementHelper implements IPartHost
|
||||
@Override
|
||||
public void cleanup()
|
||||
{
|
||||
if ( this.myPart == null )
|
||||
if( this.myPart == null )
|
||||
return;
|
||||
this.myPart.cleanup();
|
||||
}
|
||||
@@ -273,7 +258,7 @@ public class FMPPlacementHelper implements IPartHost
|
||||
@Override
|
||||
public void notifyNeighbors()
|
||||
{
|
||||
if ( this.myPart == null )
|
||||
if( this.myPart == null )
|
||||
return;
|
||||
this.myPart.notifyNeighbors();
|
||||
}
|
||||
@@ -281,9 +266,24 @@ public class FMPPlacementHelper implements IPartHost
|
||||
@Override
|
||||
public boolean isInWorld()
|
||||
{
|
||||
if ( this.myPart == null )
|
||||
if( this.myPart == null )
|
||||
return this.myMP.getWorldObj() != null;
|
||||
return this.myPart.isInWorld();
|
||||
}
|
||||
|
||||
static class NullStorage extends CableBusStorage
|
||||
{
|
||||
|
||||
@Override
|
||||
public IFacadePart getFacade( int x )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacade( int x, IFacadePart facade )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.fmp;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import codechicken.multipart.TMultiPart;
|
||||
@@ -27,46 +28,28 @@ import appeng.block.misc.BlockQuartzTorch;
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import appeng.core.Api;
|
||||
|
||||
|
||||
public enum PartRegistry
|
||||
{
|
||||
QuartzTorchPart("ae2_torch", BlockQuartzTorch.class, QuartzTorchPart.class), CableBusPart("ae2_cablebus", BlockCableBus.class, CableBusPart.class);
|
||||
QuartzTorchPart( "ae2_torch", BlockQuartzTorch.class, QuartzTorchPart.class ), CableBusPart( "ae2_cablebus", BlockCableBus.class, CableBusPart.class );
|
||||
|
||||
final private String name;
|
||||
final private Class<? extends AEBaseBlock> blk;
|
||||
final private Class<? extends TMultiPart> part;
|
||||
|
||||
public String getName()
|
||||
PartRegistry( String name, Class<? extends AEBaseBlock> blk, Class<? extends TMultiPart> part )
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
PartRegistry( String name, Class<? extends AEBaseBlock> blk, Class<? extends TMultiPart> part ) {
|
||||
this.name = name;
|
||||
this.blk = blk;
|
||||
this.part = part;
|
||||
}
|
||||
|
||||
public TMultiPart construct(int meta)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( this == CableBusPart )
|
||||
return (TMultiPart) Api.INSTANCE.getPartHelper().getCombinedInstance( this.part.getName() ).newInstance();
|
||||
else
|
||||
return this.part.getConstructor( int.class ).newInstance( meta );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPartName(TMultiPart part)
|
||||
public static String getPartName( TMultiPart part )
|
||||
{
|
||||
Class c = part.getClass();
|
||||
for (PartRegistry pr : values())
|
||||
for( PartRegistry pr : values() )
|
||||
{
|
||||
if ( pr.equals( c ) )
|
||||
if( pr.equals( c ) )
|
||||
{
|
||||
return pr.name;
|
||||
}
|
||||
@@ -74,11 +57,11 @@ public enum PartRegistry
|
||||
throw new RuntimeException( "Invalid PartName" );
|
||||
}
|
||||
|
||||
public static TMultiPart getPartByBlock(Block block, int meta)
|
||||
public static TMultiPart getPartByBlock( Block block, int meta )
|
||||
{
|
||||
for (PartRegistry pr : values())
|
||||
for( PartRegistry pr : values() )
|
||||
{
|
||||
if ( pr.blk.isInstance( block ) )
|
||||
if( pr.blk.isInstance( block ) )
|
||||
{
|
||||
return pr.construct( meta );
|
||||
}
|
||||
@@ -86,15 +69,35 @@ public enum PartRegistry
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isPart(Block block)
|
||||
public TMultiPart construct( int meta )
|
||||
{
|
||||
for (PartRegistry pr : values())
|
||||
try
|
||||
{
|
||||
if ( pr.blk.isInstance( block ) )
|
||||
if( this == CableBusPart )
|
||||
return (TMultiPart) Api.INSTANCE.getPartHelper().getCombinedInstance( this.part.getName() ).newInstance();
|
||||
else
|
||||
return this.part.getConstructor( int.class ).newInstance( meta );
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isPart( Block block )
|
||||
{
|
||||
for( PartRegistry pr : values() )
|
||||
{
|
||||
if( pr.blk.isInstance( block ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.fmp;
|
||||
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -37,31 +38,33 @@ import appeng.api.exceptions.MissingDefinition;
|
||||
public class QuartzTorchPart extends McSidedMetaPart implements IRandomDisplayTick
|
||||
{
|
||||
|
||||
public QuartzTorchPart() {
|
||||
public QuartzTorchPart()
|
||||
{
|
||||
this( ForgeDirection.DOWN.ordinal() );
|
||||
}
|
||||
|
||||
public QuartzTorchPart(int meta) {
|
||||
public QuartzTorchPart( int meta )
|
||||
{
|
||||
super( meta );
|
||||
}
|
||||
|
||||
public static McBlockPart placement( World world, BlockCoord pos, int side )
|
||||
{
|
||||
pos = pos.copy().offset( side );
|
||||
if( !world.isSideSolid( pos.x, pos.y, pos.z, ForgeDirection.getOrientation( side ) ) )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new QuartzTorchPart( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesTick()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock()
|
||||
{
|
||||
for ( Block torchBlock : AEApi.instance().definitions().blocks().quartzTorch().maybeBlock().asSet() )
|
||||
{
|
||||
return torchBlock;
|
||||
}
|
||||
|
||||
throw new MissingDefinition( "Tried to retrieve a quartz torch, even though it is disabled." );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
@@ -74,7 +77,7 @@ public class QuartzTorchPart extends McSidedMetaPart implements IRandomDisplayTi
|
||||
return this.getBounds( this.meta );
|
||||
}
|
||||
|
||||
public Cuboid6 getBounds(int meta)
|
||||
public Cuboid6 getBounds( int meta )
|
||||
{
|
||||
ForgeDirection up = ForgeDirection.getOrientation( meta );
|
||||
double xOff = -0.3 * up.offsetX;
|
||||
@@ -84,25 +87,25 @@ public class QuartzTorchPart extends McSidedMetaPart implements IRandomDisplayTi
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sideForMeta(int meta)
|
||||
public int sideForMeta( int meta )
|
||||
{
|
||||
return ForgeDirection.getOrientation( meta ).getOpposite().ordinal();
|
||||
}
|
||||
|
||||
public static McBlockPart placement(World world, BlockCoord pos, int side)
|
||||
{
|
||||
pos = pos.copy().offset( side );
|
||||
if ( !world.isSideSolid( pos.x, pos.y, pos.z, ForgeDirection.getOrientation( side ) ) )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new QuartzTorchPart( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(Random r)
|
||||
public void randomDisplayTick( Random r )
|
||||
{
|
||||
this.getBlock().randomDisplayTick( this.world(), this.x(), this.y(), this.z(), r );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock()
|
||||
{
|
||||
for( Block torchBlock : AEApi.instance().definitions().blocks().quartzTorch().maybeBlock().asSet() )
|
||||
{
|
||||
return torchBlock;
|
||||
}
|
||||
|
||||
throw new MissingDefinition( "Tried to retrieve a quartz torch, even though it is disabled." );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user