Compare commits

...

1 Commits

Author SHA1 Message Date
yueh 3cf48b2291 Remove channels per side from non smart cable states. (#3192)
These are unnecessary for these cable types and their rendering, but are
actually causing the cache to add duplicate models.
2017-11-04 13:24:57 +01:00
@@ -1087,7 +1087,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
this.getFacadeContainer().readFromNBT( data ); this.getFacadeContainer().readFromNBT( data );
} }
public List getDrops( final List drops ) public List<ItemStack> getDrops( final List<ItemStack> drops )
{ {
for( final AEPartLocation s : AEPartLocation.values() ) for( final AEPartLocation s : AEPartLocation.values() )
{ {
@@ -1111,7 +1111,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
return drops; return drops;
} }
public List getNoDrops( final List drops ) public List<ItemStack> getNoDrops( final List<ItemStack> drops )
{ {
for( final AEPartLocation s : AEPartLocation.values() ) for( final AEPartLocation s : AEPartLocation.values() )
{ {
@@ -1150,12 +1150,15 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
@Override @Override
public CableBusRenderState getRenderState() public CableBusRenderState getRenderState()
{ {
PartCable cable = (PartCable) this.getCenter(); final PartCable cable = (PartCable) this.getCenter();
CableBusRenderState renderState = new CableBusRenderState(); final CableBusRenderState renderState = new CableBusRenderState();
if( cable != null ) if( cable != null )
{ {
final boolean isSmart = cable.getCableConnectionType() == AECableType.SMART || cable.getCableConnectionType() == AECableType.DENSE_SMART;
final boolean isDense = cable.getCableConnectionType() == AECableType.DENSE_COVERED || cable.getCableConnectionType() == AECableType.DENSE_SMART;
renderState.setCableColor( cable.getCableColor() ); renderState.setCableColor( cable.getCableColor() );
renderState.setCableType( cable.getCableConnectionType() ); renderState.setCableType( cable.getCableConnectionType() );
renderState.setCoreType( CableCoreType.fromCableType( cable.getCableConnectionType() ) ); renderState.setCoreType( CableCoreType.fromCableType( cable.getCableConnectionType() ) );
@@ -1175,12 +1178,12 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
// Only use the incoming cable-type of the adjacent block, if it's not a cable bus itself // Only use the incoming cable-type of the adjacent block, if it's not a cable bus itself
// Dense cables however also respect the adjacent cable-type since their outgoing connection // Dense cables however also respect the adjacent cable-type since their outgoing connection
// point would look too big for other cable types // point would look too big for other cable types
BlockPos adjacentPos = this.getTile().getPos().offset( facing ); final BlockPos adjacentPos = this.getTile().getPos().offset( facing );
TileEntity adjacentTe = this.getTile().getWorld().getTileEntity( adjacentPos ); final TileEntity adjacentTe = this.getTile().getWorld().getTileEntity( adjacentPos );
if( adjacentTe instanceof IGridHost ) if( adjacentTe instanceof IGridHost )
{ {
if( !( adjacentTe instanceof IPartHost ) || cable.getCableConnectionType() == AECableType.DENSE_SMART || cable if( !( adjacentTe instanceof IPartHost ) || isDense )
.getCableConnectionType() == AECableType.DENSE_COVERED )
{ {
IGridHost gridHost = (IGridHost) adjacentTe; IGridHost gridHost = (IGridHost) adjacentTe;
connectionType = gridHost.getCableConnectionType( AEPartLocation.fromFacing( facing.getOpposite() ) ); connectionType = gridHost.getCableConnectionType( AEPartLocation.fromFacing( facing.getOpposite() ) );
@@ -1201,7 +1204,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
// adjacent tile requires it // adjacent tile requires it
for( EnumFacing facing : EnumFacing.values() ) for( EnumFacing facing : EnumFacing.values() )
{ {
int channels = cable.getChannelsOnSide( facing ); int channels = isSmart ? cable.getChannelsOnSide( facing ) : 0;
renderState.getChannelsOnSide().put( facing, channels ); renderState.getChannelsOnSide().put( facing, channels );
} }
} }
@@ -1209,14 +1212,14 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
// Determine attachments and facades // Determine attachments and facades
for( EnumFacing facing : EnumFacing.values() ) for( EnumFacing facing : EnumFacing.values() )
{ {
final FacadeRenderState facadeState = this.getFacadeRenderState( facing );
FacadeRenderState facadeState = this.getFacadeRenderState( facing );
if( facadeState != null ) if( facadeState != null )
{ {
renderState.getFacades().put( facing, facadeState ); renderState.getFacades().put( facing, facadeState );
} }
IPart part = this.getPart( facing ); final IPart part = this.getPart( facing );
if( part == null ) if( part == null )
{ {
@@ -1224,15 +1227,17 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
} }
// This will add the part's bounding boxes to the render state, which is required for facades // This will add the part's bounding boxes to the render state, which is required for facades
AEPartLocation loc = AEPartLocation.fromFacing( facing ); final AEPartLocation loc = AEPartLocation.fromFacing( facing );
IPartCollisionHelper bch = new BusCollisionHelper( renderState.getBoundingBoxes(), loc, null, true ); final IPartCollisionHelper bch = new BusCollisionHelper( renderState.getBoundingBoxes(), loc, null, true );
part.getBoxes( bch ); part.getBoxes( bch );
if( part instanceof IGridHost ) if( part instanceof IGridHost )
{ {
// Some attachments want a thicker cable than glass, account for that // Some attachments want a thicker cable than glass, account for that
IGridHost gridHost = (IGridHost) part; final IGridHost gridHost = (IGridHost) part;
AECableType desiredType = gridHost.getCableConnectionType( AEPartLocation.INTERNAL ); final AECableType desiredType = gridHost.getCableConnectionType( AEPartLocation.INTERNAL );
if( renderState.getCoreType() == CableCoreType.GLASS && ( desiredType == AECableType.SMART || desiredType == AECableType.COVERED ) ) if( renderState.getCoreType() == CableCoreType.GLASS && ( desiredType == AECableType.SMART || desiredType == AECableType.COVERED ) )
{ {
renderState.setCoreType( CableCoreType.COVERED ); renderState.setCoreType( CableCoreType.COVERED );
@@ -1254,14 +1259,16 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
private FacadeRenderState getFacadeRenderState( EnumFacing side ) private FacadeRenderState getFacadeRenderState( EnumFacing side )
{ {
// Store the "masqueraded" itemstack for the given side, if there is a facade // Store the "masqueraded" itemstack for the given side, if there is a facade
IFacadePart facade = this.getFacade( side.ordinal() ); final IFacadePart facade = this.getFacade( side.ordinal() );
if( facade != null ) if( facade != null )
{ {
ItemStack textureItem = facade.getTextureItem(); final ItemStack textureItem = facade.getTextureItem();
IBlockState blockState = facade.getBlockState(); final IBlockState blockState = facade.getBlockState();
if( blockState != null && textureItem != null ) if( blockState != null && textureItem != null )
{ {
EnumSet<EnumFacing> openFaces = this.calculateFaceOpenFaces( side ); final EnumSet<EnumFacing> openFaces = this.calculateFaceOpenFaces( side );
return new FacadeRenderState( blockState, openFaces, textureItem ); return new FacadeRenderState( blockState, openFaces, textureItem );
} }
} }
@@ -1273,9 +1280,9 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
{ {
final EnumSet<EnumFacing> out = EnumSet.of( side, side.getOpposite() ); final EnumSet<EnumFacing> out = EnumSet.of( side, side.getOpposite() );
final IFacadePart facade = this.getFacade( side.ordinal() ); final IFacadePart facade = this.getFacade( side.ordinal() );
final IBlockAccess blockAccess = this.getTile().getWorld();
final BlockPos pos = this.getTile().getPos();
IBlockAccess blockAccess = this.getTile().getWorld();
BlockPos pos = this.getTile().getPos();
for( final EnumFacing it : EnumFacing.values() ) for( final EnumFacing it : EnumFacing.values() )
{ {
if( !out.contains( it ) && this.hasAlphaDiff( blockAccess.getTileEntity( pos.offset( it ) ), side, facade ) ) if( !out.contains( it ) && this.hasAlphaDiff( blockAccess.getTileEntity( pos.offset( it ) ), side, facade ) )