Covered dense cables (#3030)

* Renamed all dense smart cable related things to include smart
* Added dense covered cables
* Added abstract PartDenseCable to reduce redundant code
* Added dense covered recipes

* Ensures ItemPart ordering to be consitent.

Now takes the metadata into account to preserve the ordering for colored
items instead of just the part type name and depend on the insertion
order of a hashmap.
This commit is contained in:
yueh
2017-08-17 18:41:39 +02:00
committed by GitHub
parent 4f9fd1b369
commit b61219ef88
77 changed files with 818 additions and 61 deletions
@@ -101,6 +101,9 @@ class CableBuilder
case SMART:
textureFolder = "parts/cable/smart/";
break;
case DENSE_COVERED:
textureFolder = "parts/cable/dense_covered/";
break;
case DENSE_SMART:
textureFolder = "parts/cable/dense_smart/";
break;
@@ -127,6 +130,7 @@ class CableBuilder
case SMART:
this.addCableCore( CableCoreType.COVERED, color, quadsOut );
break;
case DENSE_COVERED:
case DENSE_SMART:
this.addCableCore( CableCoreType.DENSE_SMART, color, quadsOut );
break;
@@ -448,7 +452,31 @@ class CableBuilder
addCoveredCableSizedCube( facing, distanceFromEdge, cubeBuilder );
}
public void addDenseConnection( EnumFacing facing, AEColor cableColor, AECableType connectionType, boolean cableBusAdjacent, int channels, List<BakedQuad> quadsOut )
public void addDenseCoveredConnection( EnumFacing facing, AEColor cableColor, AECableType connectionType, boolean cableBusAdjacent, List<BakedQuad> quadsOut )
{
// Dense cables only render their connections as dense if the adjacent blocks actually wants that
if( connectionType == AECableType.COVERED || connectionType == AECableType.SMART || connectionType == AECableType.GLASS )
{
this.addCoveredConnection( facing, cableColor, connectionType, cableBusAdjacent, quadsOut );
return;
}
CubeBuilder cubeBuilder = new CubeBuilder( this.format, quadsOut );
// We render all faces except the one on the connection side
cubeBuilder.setDrawFaces( EnumSet.complementOf( EnumSet.of( facing ) ) );
TextureAtlasSprite texture = this.connectionTextures.get( AECableType.DENSE_COVERED ).get( cableColor );
cubeBuilder.setTexture( texture );
addDenseCableSizedCube( facing, cubeBuilder );
// Reset back to normal rendering for the rest
cubeBuilder.setRenderFullBright( false );
cubeBuilder.setTexture( texture );
}
public void addDenseSmartConnection( EnumFacing facing, AEColor cableColor, AECableType connectionType, boolean cableBusAdjacent, int channels, List<BakedQuad> quadsOut )
{
// Dense cables only render their connections as dense if the adjacent blocks actually wants that
if( connectionType == AECableType.SMART )
@@ -456,7 +484,7 @@ class CableBuilder
this.addSmartConnection( facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut );
return;
}
else if( connectionType != AECableType.DENSE_SMART )
else if( connectionType == AECableType.COVERED || connectionType == AECableType.GLASS )
{
this.addCoveredConnection( facing, cableColor, connectionType, cableBusAdjacent, quadsOut );
return;
@@ -495,7 +523,19 @@ class CableBuilder
}
public void addStraightDenseConnection( EnumFacing facing, AEColor cableColor, int channels, List<BakedQuad> quadsOut )
public void addStraightDenseCoveredConnection( EnumFacing facing, AEColor cableColor, List<BakedQuad> quadsOut )
{
CubeBuilder cubeBuilder = new CubeBuilder( this.format, quadsOut );
TextureAtlasSprite texture = this.connectionTextures.get( AECableType.DENSE_COVERED ).get( cableColor );
cubeBuilder.setTexture( texture );
setStraightCableUVs( cubeBuilder, facing, 5, 11 );
addStraightDenseCableSizedCube( facing, cubeBuilder );
}
public void addStraightDenseSmartConnection( EnumFacing facing, AEColor cableColor, int channels, List<BakedQuad> quadsOut )
{
CubeBuilder cubeBuilder = new CubeBuilder( this.format, quadsOut );
@@ -164,6 +164,8 @@ public class CableBusBakedModel implements IBakedModel
{
case GLASS:
return firstType == AECableType.GLASS && secondType == AECableType.GLASS;
case DENSE_COVERED:
return firstType == AECableType.DENSE_COVERED && secondType == AECableType.DENSE_COVERED;
case DENSE_SMART:
return firstType == AECableType.DENSE_SMART && secondType == AECableType.DENSE_SMART;
}
@@ -200,8 +202,11 @@ public class CableBusBakedModel implements IBakedModel
case SMART:
this.cableBuilder.addStraightSmartConnection( facing, cableColor, renderState.getChannelsOnSide().get( facing ), quadsOut );
break;
case DENSE_COVERED:
this.cableBuilder.addStraightDenseCoveredConnection( facing, cableColor, quadsOut );
break;
case DENSE_SMART:
this.cableBuilder.addStraightDenseConnection( facing, cableColor, renderState.getChannelsOnSide().get( facing ), quadsOut );
this.cableBuilder.addStraightDenseSmartConnection( facing, cableColor, renderState.getChannelsOnSide().get( facing ), quadsOut );
break;
}
@@ -228,6 +233,7 @@ public class CableBusBakedModel implements IBakedModel
case SMART:
this.cableBuilder.addConstrainedSmartConnection( facing, cableColor, distance, channels, quadsOut );
break;
case DENSE_COVERED:
case DENSE_SMART:
// Dense cables do not render connections to parts since none can be attached
break;
@@ -253,8 +259,11 @@ public class CableBusBakedModel implements IBakedModel
case SMART:
this.cableBuilder.addSmartConnection( facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut );
break;
case DENSE_COVERED:
this.cableBuilder.addDenseCoveredConnection( facing, cableColor, connectionType, cableBusAdjacent, quadsOut );
break;
case DENSE_SMART:
this.cableBuilder.addDenseConnection( facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut );
this.cableBuilder.addDenseSmartConnection( facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut );
break;
}
}
@@ -55,6 +55,7 @@ public enum CableCoreType
result.put( AECableType.GLASS, CableCoreType.GLASS );
result.put( AECableType.COVERED, CableCoreType.COVERED );
result.put( AECableType.SMART, CableCoreType.COVERED );
result.put( AECableType.DENSE_COVERED, CableCoreType.DENSE_SMART );
result.put( AECableType.DENSE_SMART, CableCoreType.DENSE_SMART );
return ImmutableMap.copyOf( result );
@@ -42,7 +42,8 @@ public final class ApiParts implements IParts
private final AEColoredItemDefinition cableSmart;
private final AEColoredItemDefinition cableCovered;
private final AEColoredItemDefinition cableGlass;
private final AEColoredItemDefinition cableDense;
private final AEColoredItemDefinition cableDenseCovered;
private final AEColoredItemDefinition cableDenseSmart;
// private final AEColoredItemDefinition lumenCableSmart;
// private final AEColoredItemDefinition lumenCableCovered;
// private final AEColoredItemDefinition lumenCableGlass;
@@ -94,7 +95,8 @@ public final class ApiParts implements IParts
this.cableSmart = constructColoredDefinition( itemPart, PartType.CABLE_SMART );
this.cableCovered = constructColoredDefinition( itemPart, PartType.CABLE_COVERED );
this.cableGlass = constructColoredDefinition( itemPart, PartType.CABLE_GLASS );
this.cableDense = constructColoredDefinition( itemPart, PartType.CABLE_DENSE_SMART );
this.cableDenseCovered = constructColoredDefinition( itemPart, PartType.CABLE_DENSE_COVERED );
this.cableDenseSmart = constructColoredDefinition( itemPart, PartType.CABLE_DENSE_SMART );
// this.lumenCableSmart = Optional.absent(); // has yet to be implemented, no PartType defined for it yet
// this.lumenCableCovered = Optional.absent(); // has yet to be implemented, no PartType defined for it yet
// this.lumenCableGlass = Optional.absent(); // has yet to be implemented, no PartType defined for it yet
@@ -166,9 +168,15 @@ public final class ApiParts implements IParts
}
@Override
public AEColoredItemDefinition cableDense()
public AEColoredItemDefinition cableDenseCovered()
{
return this.cableDense;
return this.cableDenseCovered;
}
@Override
public AEColoredItemDefinition cableDenseSmart()
{
return this.cableDenseSmart;
}
@Override
@@ -193,7 +201,7 @@ public final class ApiParts implements IParts
}
@Override
public AEColoredItemDefinition lumenCableDense()
public AEColoredItemDefinition lumenDenseCableSmart()
{
throw new MissingDefinition( "Lumen Dense Cable has yet to be implemented." );
// return this.lumenCableDense;
@@ -167,7 +167,7 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
this.addNewAttunement( parts.cableGlass().stack( c, 1 ), TunnelType.ME );
this.addNewAttunement( parts.cableCovered().stack( c, 1 ), TunnelType.ME );
this.addNewAttunement( parts.cableSmart().stack( c, 1 ), TunnelType.ME );
this.addNewAttunement( parts.cableDense().stack( c, 1 ), TunnelType.ME );
this.addNewAttunement( parts.cableDenseSmart().stack( c, 1 ), TunnelType.ME );
}
/**
@@ -80,7 +80,7 @@ public enum Achievements
Networking2( 4, 0, AEApi.instance().definitions().parts().cableSmart(), AchievementType.Custom ),
// done
Networking3( 4, 2, AEApi.instance().definitions().parts().cableDense(), AchievementType.Custom ),
Networking3( 4, 2, AEApi.instance().definitions().parts().cableDenseSmart(), AchievementType.Custom ),
// done
P2P( 2, -2, AEApi.instance().definitions().parts().p2PTunnelME(), AchievementType.Craft ),
@@ -31,7 +31,7 @@ import mcjty.theoneprobe.api.ProbeMode;
import appeng.api.parts.IPart;
import appeng.integration.modules.theoneprobe.TheOneProbeText;
import appeng.parts.networking.PartCableSmart;
import appeng.parts.networking.PartDenseCable;
import appeng.parts.networking.PartDenseCableSmart;
public class ChannelInfoProvider implements IPartProbInfoProvider
@@ -40,10 +40,10 @@ public class ChannelInfoProvider implements IPartProbInfoProvider
@Override
public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
{
if( part instanceof PartDenseCable || part instanceof PartCableSmart )
if( part instanceof PartDenseCableSmart || part instanceof PartCableSmart )
{
final int usedChannels;
final int maxChannels = ( part instanceof PartDenseCable ) ? 32 : 8;
final int maxChannels = ( part instanceof PartDenseCableSmart ) ? 32 : 8;
if( part.getGridNode().isActive() )
{
@@ -35,7 +35,7 @@ import mcp.mobius.waila.api.IWailaDataAccessor;
import appeng.api.parts.IPart;
import appeng.core.localization.WailaText;
import appeng.parts.networking.PartCableSmart;
import appeng.parts.networking.PartDenseCable;
import appeng.parts.networking.PartDenseCableSmart;
/**
@@ -75,7 +75,7 @@ public final class ChannelWailaDataProvider extends BasePartWailaDataProvider
@Override
public List<String> getWailaBody( final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
{
if( part instanceof PartCableSmart || part instanceof PartDenseCable )
if( part instanceof PartCableSmart || part instanceof PartDenseCableSmart )
{
final NBTTagCompound tag = accessor.getNBTData();
@@ -83,7 +83,7 @@ public final class ChannelWailaDataProvider extends BasePartWailaDataProvider
if( usedChannels >= 0 )
{
final byte maxChannels = (byte) ( ( part instanceof PartDenseCable ) ? 32 : 8 );
final byte maxChannels = (byte) ( ( part instanceof PartDenseCableSmart ) ? 32 : 8 );
final String formattedToolTip = String.format( WailaText.Channels.getLocal(), usedChannels, maxChannels );
currentToolTip.add( formattedToolTip );
@@ -144,7 +144,7 @@ public final class ChannelWailaDataProvider extends BasePartWailaDataProvider
@Override
public NBTTagCompound getNBTData( EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos )
{
if( part instanceof PartCableSmart || part instanceof PartDenseCable )
if( part instanceof PartCableSmart || part instanceof PartDenseCableSmart )
{
final NBTTagCompound tempTag = new NBTTagCompound();
+10 -1
View File
@@ -343,7 +343,16 @@ public final class ItemPart extends AEBaseItem implements IPartItem, IItemGroup
@Override
public int compare( final Entry<Integer, PartTypeWithVariant> o1, final Entry<Integer, PartTypeWithVariant> o2 )
{
return o1.getValue().part.name().compareTo( o2.getValue().part.name() );
final String string1 = o1.getValue().part.name();
final String string2 = o2.getValue().part.name();
final int comparedString = string1.compareTo( string2 );
if( comparedString == 0 )
{
return Integer.compare( o1.getKey(), o2.getKey() );
}
return comparedString;
}
}
+22 -2
View File
@@ -57,7 +57,8 @@ import appeng.parts.misc.PartToggleBus;
import appeng.parts.networking.PartCableCovered;
import appeng.parts.networking.PartCableGlass;
import appeng.parts.networking.PartCableSmart;
import appeng.parts.networking.PartDenseCable;
import appeng.parts.networking.PartDenseCableCovered;
import appeng.parts.networking.PartDenseCableSmart;
import appeng.parts.networking.PartQuartzFiber;
import appeng.parts.p2p.PartP2PFEPower;
import appeng.parts.p2p.PartP2PFluids;
@@ -138,7 +139,26 @@ public enum PartType
},
CABLE_DENSE_SMART( 60, "cable_dense_smart", EnumSet.of( AEFeature.CHANNELS, AEFeature.DENSE_CABLES ), EnumSet
.noneOf( IntegrationType.class ), PartDenseCable.class )
.noneOf( IntegrationType.class ), PartDenseCableSmart.class )
{
@Override
public boolean isCable()
{
return true;
}
@Override
@SideOnly( Side.CLIENT )
protected List<ModelResourceLocation> createItemModels( String baseName )
{
return Arrays.stream( AEColor.values() )
.map( color -> modelFromBaseName( baseName + "_" + color.name().toLowerCase() ) )
.collect( Collectors.toList() );
}
},
CABLE_DENSE_COVERED( 500, "cable_dense_covered", EnumSet.of( AEFeature.CHANNELS, AEFeature.DENSE_CABLES ), EnumSet
.noneOf( IntegrationType.class ), PartDenseCableCovered.class )
{
@Override
public boolean isCable()
@@ -1179,7 +1179,8 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
TileEntity adjacentTe = this.getTile().getWorld().getTileEntity( adjacentPos );
if( adjacentTe instanceof IGridHost )
{
if( !( adjacentTe instanceof IPartHost ) || cable.getCableConnectionType() == AECableType.DENSE_SMART )
if( !( adjacentTe instanceof IPartHost ) || cable.getCableConnectionType() == AECableType.DENSE_SMART || cable
.getCableConnectionType() == AECableType.DENSE_COVERED )
{
IGridHost gridHost = (IGridHost) adjacentTe;
connectionType = gridHost.getCableConnectionType( AEPartLocation.fromFacing( facing.getOpposite() ) );
@@ -128,9 +128,13 @@ public class PartCable extends AEBasePart implements IPartCable
{
newPart = parts.cableSmart().stack( newColor, 1 );
}
else if( this.getCableConnectionType() == AECableType.DENSE_COVERED )
{
newPart = parts.cableDenseCovered().stack( newColor, 1 );
}
else if( this.getCableConnectionType() == AECableType.DENSE_SMART )
{
newPart = parts.cableDense().stack( newColor, 1 );
newPart = parts.cableDenseSmart().stack( newColor, 1 );
}
boolean hasPermission = true;
@@ -36,7 +36,7 @@ import appeng.helpers.Reflected;
import appeng.util.Platform;
public class PartDenseCable extends PartCable
public abstract class PartDenseCable extends PartCable
{
@Reflected
public PartDenseCable( final ItemStack is )
@@ -52,12 +52,6 @@ public class PartDenseCable extends PartCable
return BusSupport.DENSE_CABLE;
}
@Override
public AECableType getCableConnectionType()
{
return AECableType.DENSE_SMART;
}
@Override
public void getBoxes( final IPartCollisionHelper bch )
{
@@ -135,25 +129,16 @@ public class PartDenseCable extends PartCable
}
}
private boolean isSmart( final AEPartLocation of )
{
final TileEntity te = this.getTile().getWorld().getTileEntity( this.getTile().getPos().offset( of.getFacing() ) );
if( te instanceof IGridHost )
{
final AECableType t = ( (IGridHost) te ).getCableConnectionType( of.getOpposite() );
return t == AECableType.SMART;
}
return false;
}
private boolean isDense( final AEPartLocation of )
{
final TileEntity te = this.getTile().getWorld().getTileEntity( this.getTile().getPos().offset( of.getFacing() ) );
if( te instanceof IGridHost )
{
final AECableType t = ( (IGridHost) te ).getCableConnectionType( of.getOpposite() );
return t == AECableType.DENSE_SMART;
return t == AECableType.DENSE_COVERED || t == AECableType.DENSE_SMART;
}
return false;
}
@@ -0,0 +1,41 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.parts.networking;
import net.minecraft.item.ItemStack;
import appeng.api.util.AECableType;
public class PartDenseCableCovered extends PartDenseCable
{
public PartDenseCableCovered( ItemStack is )
{
super( is );
}
@Override
public AECableType getCableConnectionType()
{
return AECableType.DENSE_COVERED;
}
}
@@ -0,0 +1,40 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.parts.networking;
import net.minecraft.item.ItemStack;
import appeng.api.util.AECableType;
public class PartDenseCableSmart extends PartDenseCable
{
public PartDenseCableSmart( ItemStack is )
{
super( is );
}
@Override
public AECableType getCableConnectionType()
{
return AECableType.DENSE_SMART;
}
}
@@ -91,14 +91,24 @@ public class AEItemResolver implements ISubItemResolver
return this.cableItem( parts.cableSmart(), itemName.substring( itemName.indexOf( '.' ) + 1 ) );
}
if( itemName.equals( "cable_dense_covered" ) )
{
return new ResolverResultSet( "cable_dense_covered", parts.cableDenseCovered().allStacks( 1 ) );
}
if( itemName.startsWith( "cable_dense_covered." ) )
{
return this.cableItem( parts.cableDenseCovered(), itemName.substring( itemName.indexOf( '.' ) + 1 ) );
}
if( itemName.equals( "cable_dense_smart" ) )
{
return new ResolverResultSet( "cable_dense", parts.cableDense().allStacks( 1 ) );
return new ResolverResultSet( "cable_dense_smart", parts.cableDenseSmart().allStacks( 1 ) );
}
if( itemName.startsWith( "cable_dense_smart." ) )
{
return this.cableItem( parts.cableDense(), itemName.substring( itemName.indexOf( '.' ) + 1 ) );
return this.cableItem( parts.cableDenseSmart(), itemName.substring( itemName.indexOf( '.' ) + 1 ) );
}
if( itemName.startsWith( "crystal_seed." ) )
+1 -1
View File
@@ -1626,7 +1626,7 @@ public class Platform
return Collections.singletonList( stack );
}
if( parts.cableDense().sameAs( AEColor.TRANSPARENT, stack ) )
if( parts.cableDenseSmart().sameAs( AEColor.TRANSPARENT, stack ) )
{
return Collections.singletonList( stack );
}