Cables & parts and Baking pipeline
- Added cables & parts rendering. - Facades got a completely new way of rendering. Anvil facades are totally a thing. - Added baking pipeline for simplified, highly configurable quad baking. NOTE: Yes, there are a lot of improvements to do, bugs to fix, stuff to add. I'm just pushing it prior to code structure change, so it does not get lost in stashes. But it actually works!
This commit is contained in:
@@ -24,11 +24,17 @@ import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -40,6 +46,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
@@ -47,6 +54,7 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.client.BakingPipeline;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
@@ -64,8 +72,11 @@ import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.client.render.model.ModelsCache;
|
||||
import appeng.helpers.ICustomNameObject;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.items.parts.ItemMultiPart;
|
||||
import appeng.items.parts.PartType;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.IGridProxyable;
|
||||
import appeng.parts.networking.PartCable;
|
||||
@@ -77,6 +88,35 @@ import appeng.util.SettingsFrom;
|
||||
public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradeableHost, ICustomNameObject
|
||||
{
|
||||
|
||||
private static final Pattern PROPERTY_PATTERN = Pattern.compile( "\\$\\{([\\p{Alnum}_\\-\\.]+)\\}" );
|
||||
|
||||
public static final ResourceLocation replaceProperties( ResourceLocation location, ImmutableMap<String, String> properties )
|
||||
{
|
||||
Matcher m = PROPERTY_PATTERN.matcher( location.getResourcePath() );
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
while( m.find() )
|
||||
{
|
||||
m.appendReplacement( buffer, properties.get( m.group( 1 ) ) );
|
||||
}
|
||||
m.appendTail( buffer );
|
||||
return new ResourceLocation( location.getResourceDomain(), buffer.toString() );
|
||||
}
|
||||
|
||||
protected static final Function<ResourceLocation, TextureAtlasSprite> propertyTextureGetter( ImmutableMap<String, String> properties )
|
||||
{
|
||||
return location -> ModelsCache.DEFAULTTEXTUREGETTER.apply( replaceProperties( location, properties ) );
|
||||
}
|
||||
|
||||
protected static final Function<ResourceLocation, TextureAtlasSprite> propertyTextureGetter( ImmutableMap.Builder<String, String> properties )
|
||||
{
|
||||
return propertyTextureGetter( properties.build() );
|
||||
}
|
||||
|
||||
protected static final ResourceLocation withProperties( ResourceLocation location, ImmutableMap.Builder<String, String> properties )
|
||||
{
|
||||
return new ResourceLocation( location.getResourceDomain(), location.getResourcePath() + properties.build().toString() );
|
||||
}
|
||||
|
||||
private final AENetworkProxy proxy;
|
||||
private final ItemStack is;
|
||||
private TileEntity tile = null;
|
||||
@@ -97,6 +137,16 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
return this.host;
|
||||
}
|
||||
|
||||
public PartType getType()
|
||||
{
|
||||
return ItemMultiPart.instance.getTypeByStack( is );
|
||||
}
|
||||
|
||||
public ResourceLocation getDefaultModelLocation()
|
||||
{
|
||||
return getType().getModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode( final AEPartLocation dir )
|
||||
{
|
||||
@@ -319,7 +369,7 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
public int getCableConnectionLength()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
@@ -515,6 +565,18 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public List<BakedQuad> getOrBakeQuads( BakingPipeline<BakedQuad, BakedQuad> rotatingPipeline, IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
return rotatingPipeline.pipe( ModelsCache.INSTANCE.getOrLoadModel( withProperties( getDefaultModelLocation(), propertiesForModel( getSide().getFacing() ) ), getDefaultModelLocation(), propertyTextureGetter( propertiesForModel( getSide().getFacing() ) ) ).getQuads( state, side, rand ), null, state, getSide().getFacing(), rand );
|
||||
}
|
||||
|
||||
protected ImmutableMap.Builder<String, String> propertiesForModel( EnumFacing facing )
|
||||
{
|
||||
return ImmutableMap.<String, String>builder().put( "color", getColor().name() );
|
||||
}
|
||||
|
||||
public AEPartLocation getSide()
|
||||
{
|
||||
return this.side;
|
||||
|
||||
@@ -80,6 +80,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
|
||||
private final EnumSet<LayerFlags> myLayerFlags = EnumSet.noneOf( LayerFlags.class );
|
||||
private YesNo hasRedstone = YesNo.UNDECIDED;
|
||||
private IPartHost tcb;
|
||||
//TODO 1.10.2-R - does somebody seriously want to make parts TESR??? Hope not.
|
||||
private boolean requiresDynamicRender = false;
|
||||
private boolean inWorld = false;
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
@@ -75,18 +76,18 @@ public class PartPlacement
|
||||
private final ThreadLocal<Object> placing = new ThreadLocal<Object>();
|
||||
private boolean wasCanceled = false;
|
||||
|
||||
public static boolean place( final ItemStack held, final BlockPos pos, EnumFacing side, final EntityPlayer player, final EnumHand hand, final World world, PlaceType pass, final int depth )
|
||||
public static EnumActionResult place( final ItemStack held, final BlockPos pos, EnumFacing side, final EntityPlayer player, final EnumHand hand, final World world, PlaceType pass, final int depth )
|
||||
{
|
||||
if( depth > 3 )
|
||||
{
|
||||
return false;
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
if( held != null && Platform.isWrench( player, held, pos ) && player.isSneaking() )
|
||||
{
|
||||
if( !Platform.hasPermissions( new DimensionalCoord( world, pos ), player ) )
|
||||
{
|
||||
return false;
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
final Block block = world.getBlockState( pos ).getBlock();
|
||||
@@ -140,10 +141,10 @@ public class PartPlacement
|
||||
player.swingArm( hand );
|
||||
NetworkHandler.instance.sendToServer( new PacketPartPlacement( pos, side, getEyeOffset( player ), hand ) );
|
||||
}
|
||||
return true;
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
return false;
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
@@ -165,7 +166,7 @@ public class PartPlacement
|
||||
{
|
||||
if( host.getPart( AEPartLocation.INTERNAL ) == null )
|
||||
{
|
||||
return false;
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
if( host.canAddPart( held, AEPartLocation.fromFacing( side ) ) )
|
||||
@@ -182,7 +183,7 @@ public class PartPlacement
|
||||
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( player, held, hand ) );
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -190,10 +191,10 @@ public class PartPlacement
|
||||
{
|
||||
player.swingArm( hand );
|
||||
NetworkHandler.instance.sendToServer( new PacketPartPlacement( pos, side, getEyeOffset( player ), hand ) );
|
||||
return true;
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,7 +234,7 @@ public class PartPlacement
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketPartPlacement( pos, side, getEyeOffset( player ), hand ) );
|
||||
}
|
||||
return true;
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -242,7 +243,7 @@ public class PartPlacement
|
||||
|
||||
if( held == null || !( held.getItem() instanceof IPartItem ) )
|
||||
{
|
||||
return false;
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
BlockPos te_pos = pos;
|
||||
@@ -312,18 +313,18 @@ public class PartPlacement
|
||||
{
|
||||
player.swingArm( hand );
|
||||
NetworkHandler.instance.sendToServer( new PacketPartPlacement( pos, side, getEyeOffset( player ), hand ) );
|
||||
return true;
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
else if( host != null && !host.canAddPart( held, AEPartLocation.fromFacing( side ) ) )
|
||||
{
|
||||
return false;
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
if( host == null )
|
||||
{
|
||||
return false;
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
if( !host.canAddPart( held, AEPartLocation.fromFacing( side ) ) )
|
||||
@@ -341,13 +342,13 @@ public class PartPlacement
|
||||
}
|
||||
|
||||
if( ( blkID == null || blkID.isReplaceable( world, te_pos ) || host != null ) ) // /&& side !=
|
||||
// AEPartLocation.INTERNAL
|
||||
// )
|
||||
// AEPartLocation.INTERNAL
|
||||
// )
|
||||
{
|
||||
return place( held, te_pos, side.getOpposite(), player, hand, world, pass == PlaceType.INTERACT_FIRST_PASS ? PlaceType.INTERACT_SECOND_PASS : PlaceType.PLACE_ITEM, depth + 1 );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
if( !world.isRemote )
|
||||
@@ -364,7 +365,7 @@ public class PartPlacement
|
||||
{
|
||||
if( !player.isSneaking() && sp.part.onActivate( player, hand, mop.hitVec ) )
|
||||
{
|
||||
return false;
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -372,7 +373,7 @@ public class PartPlacement
|
||||
final DimensionalCoord dc = host.getLocation();
|
||||
if( !Platform.hasPermissions( dc, player ) )
|
||||
{
|
||||
return false;
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
final AEPartLocation mySide = host.addPart( held, AEPartLocation.fromFacing( side ), player, hand );
|
||||
@@ -401,7 +402,7 @@ public class PartPlacement
|
||||
player.swingArm( hand );
|
||||
NetworkHandler.instance.sendToServer( new PacketPartPlacement( pos, side, getEyeOffset( player ), hand ) );
|
||||
}
|
||||
return true;
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
private static float getEyeOffset( final EntityPlayer p )
|
||||
@@ -494,7 +495,7 @@ public class PartPlacement
|
||||
this.placing.set( event );
|
||||
|
||||
final ItemStack held = event.getEntityPlayer().getHeldItem( event.getHand() );
|
||||
if( place( held, event.getPos(), event.getFace(), event.getEntityPlayer(), event.getHand(), event.getEntityPlayer().worldObj, PlaceType.INTERACT_FIRST_PASS, 0 ) )
|
||||
if( place( held, event.getPos(), event.getFace(), event.getEntityPlayer(), event.getHand(), event.getEntityPlayer().worldObj, PlaceType.INTERACT_FIRST_PASS, 0 ) == EnumActionResult.SUCCESS )
|
||||
{
|
||||
event.setCanceled( true );
|
||||
this.wasCanceled = true;
|
||||
|
||||
@@ -208,7 +208,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
public int getCableConnectionLength()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
public int getCableConnectionLength()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
public int getCableConnectionLength()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
public int getCableConnectionLength()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
@@ -425,7 +425,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
public int getCableConnectionLength()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
@@ -25,17 +25,23 @@ import java.util.Random;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
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.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.client.BakingPipeline;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.parts.BusSupport;
|
||||
import appeng.api.parts.IPart;
|
||||
@@ -204,7 +210,7 @@ public class PartCableAnchor implements IPart
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
public int getCableConnectionLength()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -226,4 +232,12 @@ public class PartCableAnchor implements IPart
|
||||
{
|
||||
return what == BusSupport.CABLE || what == BusSupport.DENSE_CABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public List<BakedQuad> getOrBakeQuads( BakingPipeline<BakedQuad, BakedQuad> rotatingPipeline, IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
public int getCableConnectionLength()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
public int getCableConnectionLength()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ public class PartToggleBus extends PartBasicState
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
public int getCableConnectionLength()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
@@ -20,16 +20,29 @@ package appeng.parts.networking;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.lwjgl.util.vector.Matrix4f;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.client.BakingPipeline;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.api.implementations.parts.IPartCable;
|
||||
@@ -45,6 +58,10 @@ import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.IReadOnlyCollection;
|
||||
import appeng.client.render.model.ModelsCache;
|
||||
import appeng.client.render.model.pipeline.FacingQuadRotator;
|
||||
import appeng.client.render.model.pipeline.MatVecApplicator;
|
||||
import appeng.client.render.model.pipeline.TypeTransformer;
|
||||
import appeng.items.parts.ItemMultiPart;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.AEBasePart;
|
||||
@@ -54,6 +71,8 @@ import appeng.util.Platform;
|
||||
public class PartCable extends AEBasePart implements IPartCable
|
||||
{
|
||||
|
||||
private static final ImmutableSet<AEPartLocation> STRAIGHT_PART_LOCATIONS = ImmutableSet.of( AEPartLocation.DOWN, AEPartLocation.NORTH, AEPartLocation.EAST );
|
||||
|
||||
private final int[] channelsOnSide = { 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
private EnumSet<AEPartLocation> connections = EnumSet.noneOf( AEPartLocation.class );
|
||||
@@ -180,7 +199,7 @@ public class PartCable extends AEBasePart implements IPartCable
|
||||
final IPart p = ph.getPart( dir );
|
||||
if( p instanceof IGridHost )
|
||||
{
|
||||
final double dist = p.cableConnectionRenderTo();
|
||||
final double dist = p.getCableConnectionLength();
|
||||
|
||||
if( dist > 8 )
|
||||
{
|
||||
@@ -281,14 +300,7 @@ public class PartCable extends AEBasePart implements IPartCable
|
||||
final IReadOnlyCollection<IGridConnection> set = part.getGridNode().getConnections();
|
||||
for( final IGridConnection gc : set )
|
||||
{
|
||||
if( this.getProxy().getNode().hasFlag( GridFlags.DENSE_CAPACITY ) && gc.getOtherSide( this.getProxy().getNode() ).hasFlag( GridFlags.DENSE_CAPACITY ) )
|
||||
{
|
||||
sideOut |= ( gc.getUsedChannels() / 4 ) << ( 4 * thisSide.ordinal() );
|
||||
}
|
||||
else
|
||||
{
|
||||
sideOut |= ( gc.getUsedChannels() ) << ( 4 * thisSide.ordinal() );
|
||||
}
|
||||
sideOut |= ( gc.getUsedChannels() ) << ( 5 * thisSide.ordinal() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -299,17 +311,7 @@ public class PartCable extends AEBasePart implements IPartCable
|
||||
final AEPartLocation side = gc.getDirection( n );
|
||||
if( side != AEPartLocation.INTERNAL )
|
||||
{
|
||||
final boolean isTier2a = this.getProxy().getNode().hasFlag( GridFlags.DENSE_CAPACITY );
|
||||
final boolean isTier2b = gc.getOtherSide( this.getProxy().getNode() ).hasFlag( GridFlags.DENSE_CAPACITY );
|
||||
|
||||
if( isTier2a && isTier2b )
|
||||
{
|
||||
sideOut |= ( gc.getUsedChannels() / 4 ) << ( 4 * side.ordinal() );
|
||||
}
|
||||
else
|
||||
{
|
||||
sideOut |= gc.getUsedChannels() << ( 4 * side.ordinal() );
|
||||
}
|
||||
sideOut |= gc.getUsedChannels() << ( 5 * side.ordinal() );
|
||||
cs |= ( 1 << side.ordinal() );
|
||||
}
|
||||
}
|
||||
@@ -346,7 +348,7 @@ public class PartCable extends AEBasePart implements IPartCable
|
||||
{
|
||||
if( d != AEPartLocation.INTERNAL )
|
||||
{
|
||||
final int ch = ( sideOut >> ( d.ordinal() * 4 ) ) & 0xF;
|
||||
final int ch = ( sideOut >> ( d.ordinal() * 5 ) ) & 0x1F;
|
||||
if( ch != this.getChannelsOnSide( d.ordinal() ) )
|
||||
{
|
||||
channelsChanged = true;
|
||||
@@ -379,9 +381,53 @@ public class PartCable extends AEBasePart implements IPartCable
|
||||
return !myC.equals( this.getConnections() ) || wasPowered != this.powered || channelsChanged;
|
||||
}
|
||||
|
||||
protected boolean nonLinear( final EnumSet<AEPartLocation> sides )
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public List<BakedQuad> getOrBakeQuads( BakingPipeline rotatingPipeline, IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
return ( sides.contains( AEPartLocation.EAST ) && sides.contains( AEPartLocation.WEST ) ) || ( sides.contains( AEPartLocation.NORTH ) && sides.contains( AEPartLocation.SOUTH ) ) || ( sides.contains( AEPartLocation.UP ) && sides.contains( AEPartLocation.DOWN ) );
|
||||
List<BakedQuad> elements = new ArrayList<>();
|
||||
if( isStraight( getHost(), connections ) )
|
||||
{
|
||||
EnumFacing facing = getConnections().contains( AEPartLocation.DOWN ) ? EnumFacing.DOWN : getConnections().contains( AEPartLocation.NORTH ) ? EnumFacing.NORTH : getConnections().contains( AEPartLocation.EAST ) ? EnumFacing.EAST : EnumFacing.NORTH;
|
||||
elements.addAll( rotatingPipeline.pipe( ModelsCache.INSTANCE.getOrLoadModel( withProperties( getCableConnectionType().getStraightModel(), propertiesForModel( facing ) ), getCableConnectionType().getStraightModel(), propertyTextureGetter( propertiesForModel( facing ) ) ).getQuads( state, side, rand ), null, state, connections.contains( AEPartLocation.DOWN ) ? EnumFacing.DOWN : connections.contains( AEPartLocation.NORTH ) ? EnumFacing.NORTH : connections.contains( AEPartLocation.EAST ) ? EnumFacing.EAST : EnumFacing.NORTH, rand ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
elements.addAll( ModelsCache.INSTANCE.getOrLoadModel( withProperties( getCableConnectionType().getModel(), propertiesForModel( null ) ), getCableConnectionType().getModel(), propertyTextureGetter( propertiesForModel( null ) ) ).getQuads( state, side, rand ) );
|
||||
for( EnumFacing facing : EnumFacing.values() )
|
||||
{
|
||||
if( isConnected( facing ) )
|
||||
{
|
||||
elements.addAll( rotatingPipeline.pipe( ModelsCache.INSTANCE.getOrLoadModel( withProperties( getCableConnectionType().getConnectionModel(), propertiesForModel( facing ) ), getCableConnectionType().getConnectionModel(), propertyTextureGetter( propertiesForModel( facing ) ) ).getQuads( state, side, rand ), null, state, facing, rand ) );
|
||||
}
|
||||
else if( getHost().getPart( facing ) != null )
|
||||
{
|
||||
IPart part = getHost().getPart( facing );
|
||||
if( part.getCableConnectionLength() != -1 )
|
||||
{
|
||||
elements.addAll( new BakingPipeline( TypeTransformer.quads2vecs, new MatVecApplicator( TRSRTransformation.toVecmath( new Matrix4f().scale( new Vector3f( 1, 1, part.getCableConnectionLength() / 4f ) ) ) ), new FacingQuadRotator( facing ), TypeTransformer.vecs2quads ).pipe( ModelsCache.INSTANCE.getOrLoadModel( withProperties( getCableConnectionType().getConnectionModel(), propertiesForModel( facing ) ), getCableConnectionType().getConnectionModel(), propertyTextureGetter( propertiesForModel( facing ) ) ).getQuads( state, side, rand ), null, state, facing, rand ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
protected boolean isStraight( IPartHost host, final EnumSet<AEPartLocation> sides )
|
||||
{
|
||||
boolean b = false;
|
||||
for( EnumFacing facing : EnumFacing.values() )
|
||||
{
|
||||
b |= host.getPart( facing ) != null;
|
||||
}
|
||||
if( !b && sides.size() == 2 )
|
||||
{
|
||||
return ( sides.contains( AEPartLocation.EAST ) && sides.contains( AEPartLocation.WEST ) ) || ( sides.contains( AEPartLocation.NORTH ) && sides.contains( AEPartLocation.SOUTH ) ) || ( sides.contains( AEPartLocation.UP ) && sides.contains( AEPartLocation.DOWN ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int getChannelsOnSide( final int i )
|
||||
|
||||
@@ -19,7 +19,10 @@
|
||||
package appeng.parts.networking;
|
||||
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
@@ -102,4 +105,11 @@ public class PartCableSmart extends PartCable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImmutableMap.Builder<String, String> propertiesForModel( EnumFacing facing )
|
||||
{
|
||||
return facing != null ? super.propertiesForModel( facing ).put( "channels", String.valueOf( getChannelsOnSide( facing.ordinal() ) ) ) : super.propertiesForModel( facing );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,11 @@
|
||||
package appeng.parts.networking;
|
||||
|
||||
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.IGridHost;
|
||||
@@ -168,4 +171,11 @@ public class PartDenseCable extends PartCable
|
||||
{
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Builder<String, String> propertiesForModel( EnumFacing facing )
|
||||
{
|
||||
return facing != null ? super.propertiesForModel( facing ).put( "channels", String.valueOf( getChannelsOnSide( facing.ordinal() ) ) ) : super.propertiesForModel( facing );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
public int getCableConnectionLength()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
public int getCableConnectionLength()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user