Reimplemented cable and parts rendering.
This commit is contained in:
@@ -24,33 +24,28 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.MouseEvent;
|
||||
import net.minecraftforge.client.event.RenderLivingEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import appeng.api.parts.CableRenderMode;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.effects.AssemblerFX;
|
||||
@@ -59,12 +54,10 @@ import appeng.client.render.effects.EnergyFx;
|
||||
import appeng.client.render.effects.LightningArcFX;
|
||||
import appeng.client.render.effects.LightningFX;
|
||||
import appeng.client.render.effects.VibrantFX;
|
||||
import appeng.client.render.model.ModelsCache;
|
||||
import appeng.client.render.model.UVLModelLoader;
|
||||
import appeng.client.render.textures.ParticleTextures;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketAssemblerAnimation;
|
||||
@@ -76,8 +69,6 @@ import appeng.entity.RenderTinyTNTPrimed;
|
||||
import appeng.helpers.IMouseWheelItem;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.hooks.TickHandler.PlayerColor;
|
||||
import appeng.items.parts.PartType;
|
||||
import appeng.parts.AEBasePart;
|
||||
import appeng.server.ServerHelper;
|
||||
import appeng.transformer.MissingCoreMod;
|
||||
import appeng.util.Platform;
|
||||
@@ -91,7 +82,6 @@ public class ClientHelper extends ServerHelper
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register( this );
|
||||
ModelLoaderRegistry.registerLoader( UVLModelLoader.INSTANCE );
|
||||
( (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager() ).registerReloadListener( ModelsCache.INSTANCE );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -204,26 +194,26 @@ public class ClientHelper extends ServerHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRenderItem( final ItemStack itemstack, final World w )
|
||||
public void doRenderItem( final ItemStack itemstack )
|
||||
{
|
||||
if( itemstack != null )
|
||||
{
|
||||
final EntityItem entityitem = new EntityItem( w, 0.0D, 0.0D, 0.0D, itemstack );
|
||||
entityitem.getEntityItem().stackSize = 1;
|
||||
|
||||
// set all this stuff and then do shit? meh?
|
||||
entityitem.hoverStart = 0;
|
||||
entityitem.setNoDespawn();
|
||||
entityitem.rotationYaw = 0;
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef( 0, -0.04F, 0 );
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
// GL11.glDisable( GL11.GL_CULL_FACE );
|
||||
// The Z-scaling by 0.0001 causes the model to be visually "flattened"
|
||||
// This cannot replace a proper projection, but it's cheap and gives the desired
|
||||
// effect at least from head-on
|
||||
final float scale = 0.8f;
|
||||
GlStateManager.scale( scale / 32.0f, scale / 32.0f, 0.0001f );
|
||||
// Position the item icon at the top middle of the panel
|
||||
GlStateManager.translate( -8, -11, 0 );
|
||||
|
||||
// TODO RENDER ITEM FOR STORAGE MONITOR!
|
||||
RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
|
||||
renderItem.renderItemAndEffectIntoGUI(itemstack, 0, 0);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,47 +388,5 @@ public class ClientHelper extends ServerHelper
|
||||
public void onTextureStitch( final TextureStitchEvent.Pre event )
|
||||
{
|
||||
ParticleTextures.registerSprite( event );
|
||||
for( AECableType type : AECableType.VALIDCABLES )
|
||||
{
|
||||
for( IModel model : new IModel[] { ModelsCache.INSTANCE.getOrLoadModel( type.getModel() ), ModelsCache.INSTANCE.getOrLoadModel( type.getConnectionModel() ), ModelsCache.INSTANCE.getOrLoadModel( type.getStraightModel() ) } )
|
||||
{
|
||||
for( ResourceLocation location : model.getTextures() )
|
||||
{
|
||||
for( AEColor color : AEColor.values() )
|
||||
{
|
||||
if( type.displayedChannels() > 0 )
|
||||
{
|
||||
for( int i = 0; i <= type.displayedChannels(); i++ )
|
||||
{
|
||||
event.getMap().registerSprite( AEBasePart.replaceProperties( location, ImmutableMap.of( "color", color.name(), "channels", String.valueOf( i ) ) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
event.getMap().registerSprite( AEBasePart.replaceProperties( location, ImmutableMap.of( "color", color.name() ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for( PartType part : PartType.values() )
|
||||
{
|
||||
if( !part.isCable() )
|
||||
{
|
||||
IModel model = ModelsCache.INSTANCE.getOrLoadModel( part.getModel() );
|
||||
for( ResourceLocation location : model.getTextures() )
|
||||
{
|
||||
for( AEColor color : AEColor.values() )
|
||||
{
|
||||
event.getMap().registerSprite( AEBasePart.replaceProperties( location, ImmutableMap.of( "color", color.name() ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for( ResourceLocation location : ModelsCache.INSTANCE.getOrLoadModel( new ResourceLocation( AppEng.MOD_ID, "part/cable_facade" ) ).getTextures() )
|
||||
{
|
||||
event.getMap().registerSprite( location );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,15 +53,6 @@ public class ColorableTileBlockColor implements IBlockColor
|
||||
}
|
||||
}
|
||||
|
||||
switch( tintIndex )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return color.whiteVariant;
|
||||
case 1:
|
||||
return color.mediumVariant;
|
||||
case 2:
|
||||
return color.blackVariant;
|
||||
}
|
||||
return color.getVariantByTintIndex( tintIndex );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,16 +23,7 @@ public class StaticItemColor implements IItemColor
|
||||
@Override
|
||||
public int getColorFromItemstack( ItemStack stack, int tintIndex )
|
||||
{
|
||||
switch( tintIndex )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return color.whiteVariant;
|
||||
case 1:
|
||||
return color.mediumVariant;
|
||||
case 2:
|
||||
return color.blackVariant;
|
||||
}
|
||||
return color.getVariantByTintIndex( tintIndex );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,673 @@
|
||||
package appeng.client.render.cablebus;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
|
||||
|
||||
/**
|
||||
* A helper class that builds quads for cable connections.
|
||||
*/
|
||||
class CableBuilder
|
||||
{
|
||||
|
||||
private final VertexFormat format;
|
||||
|
||||
// Textures for the cable core types, one per type/color pair
|
||||
private final EnumMap<CableCoreType, EnumMap<AEColor, TextureAtlasSprite>> coreTextures;
|
||||
|
||||
// Textures for rendering the actual connection cubes, one per type/color pair
|
||||
private final EnumMap<AECableType, EnumMap<AEColor, TextureAtlasSprite>> connectionTextures;
|
||||
|
||||
private final SmartCableTextures smartCableTextures;
|
||||
|
||||
CableBuilder( VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
this.format = format;
|
||||
this.coreTextures = new EnumMap<>( CableCoreType.class );
|
||||
|
||||
for( CableCoreType type : CableCoreType.values() )
|
||||
{
|
||||
EnumMap<AEColor, TextureAtlasSprite> colorTextures = new EnumMap<>( AEColor.class );
|
||||
|
||||
for( AEColor color : AEColor.values() )
|
||||
{
|
||||
colorTextures.put( color, bakedTextureGetter.apply( type.getTexture( color ) ) );
|
||||
}
|
||||
|
||||
coreTextures.put( type, colorTextures );
|
||||
}
|
||||
|
||||
this.connectionTextures = new EnumMap<>( AECableType.class );
|
||||
|
||||
for( AECableType type : AECableType.VALIDCABLES )
|
||||
{
|
||||
EnumMap<AEColor, TextureAtlasSprite> colorTextures = new EnumMap<>( AEColor.class );
|
||||
|
||||
for( AEColor color : AEColor.values() )
|
||||
{
|
||||
colorTextures.put( color, bakedTextureGetter.apply( type.getConnectionTexture( color ) ) );
|
||||
}
|
||||
|
||||
connectionTextures.put( type, colorTextures );
|
||||
}
|
||||
|
||||
smartCableTextures = new SmartCableTextures( bakedTextureGetter );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the core of a cable to the given list of quads.
|
||||
*
|
||||
* The type of cable core is automatically deduced from the given cable type.
|
||||
*/
|
||||
public void addCableCore( AECableType cableType, AEColor color, List<BakedQuad> quadsOut )
|
||||
{
|
||||
switch( cableType )
|
||||
{
|
||||
case GLASS:
|
||||
addCableCore( CableCoreType.GLASS, color, quadsOut );
|
||||
break;
|
||||
case COVERED:
|
||||
case SMART:
|
||||
addCableCore( CableCoreType.COVERED, color, quadsOut );
|
||||
break;
|
||||
case DENSE:
|
||||
addCableCore( CableCoreType.DENSE, color, quadsOut );
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
public void addCableCore( CableCoreType coreType, AEColor color, List<BakedQuad> quadsOut )
|
||||
{
|
||||
CubeBuilder cubeBuilder = new CubeBuilder( format, quadsOut );
|
||||
|
||||
TextureAtlasSprite texture = coreTextures.get( coreType ).get( color );
|
||||
cubeBuilder.setTexture( texture );
|
||||
|
||||
switch( coreType )
|
||||
{
|
||||
case GLASS:
|
||||
cubeBuilder.addCube( 6, 6, 6, 10, 10, 10 );
|
||||
break;
|
||||
case COVERED:
|
||||
cubeBuilder.addCube( 5, 5, 5, 11, 11, 11 );
|
||||
break;
|
||||
case DENSE:
|
||||
cubeBuilder.addCube( 3, 3, 3, 13, 13, 13 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void addGlassConnection( EnumFacing facing, AEColor cableColor, AECableType connectionType, boolean cableBusAdjacent, List<BakedQuad> quadsOut )
|
||||
{
|
||||
CubeBuilder cubeBuilder = new CubeBuilder( format, quadsOut );
|
||||
|
||||
// We render all faces except the one on the connection side
|
||||
cubeBuilder.setDrawFaces( EnumSet.complementOf( EnumSet.of( facing ) ) );
|
||||
|
||||
// For to-machine connections, use a thicker end-cap for the connection
|
||||
if( connectionType != AECableType.GLASS && !cableBusAdjacent )
|
||||
{
|
||||
TextureAtlasSprite texture = connectionTextures.get( AECableType.COVERED ).get( cableColor );
|
||||
cubeBuilder.setTexture( texture );
|
||||
|
||||
addBigCoveredCableSizedCube( facing, cubeBuilder );
|
||||
}
|
||||
|
||||
TextureAtlasSprite texture = connectionTextures.get( AECableType.GLASS ).get( cableColor );
|
||||
cubeBuilder.setTexture( texture );
|
||||
|
||||
switch( facing )
|
||||
{
|
||||
case DOWN:
|
||||
cubeBuilder.addCube( 6, 0, 6, 10, 6, 10 );
|
||||
break;
|
||||
case EAST:
|
||||
cubeBuilder.addCube( 10, 6, 6, 16, 10, 10 );
|
||||
break;
|
||||
case NORTH:
|
||||
cubeBuilder.addCube( 6, 6, 0, 10, 10, 6 );
|
||||
break;
|
||||
case SOUTH:
|
||||
cubeBuilder.addCube( 6, 6, 10, 10, 10, 16 );
|
||||
break;
|
||||
case UP:
|
||||
cubeBuilder.addCube( 6, 10, 6, 10, 16, 10 );
|
||||
break;
|
||||
case WEST:
|
||||
cubeBuilder.addCube( 0, 6, 6, 6, 10, 10 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void addStraightGlassConnection( EnumFacing facing, AEColor cableColor, List<BakedQuad> quadsOut )
|
||||
{
|
||||
CubeBuilder cubeBuilder = new CubeBuilder( format, quadsOut );
|
||||
|
||||
// We render all faces except the connection caps. We can do this because the glass cable is the smallest one
|
||||
// and its ends will always be covered by something
|
||||
cubeBuilder.setDrawFaces( EnumSet.complementOf( EnumSet.of( facing, facing.getOpposite() ) ) );
|
||||
|
||||
TextureAtlasSprite texture = connectionTextures.get( AECableType.GLASS ).get( cableColor );
|
||||
cubeBuilder.setTexture( texture );
|
||||
|
||||
switch( facing )
|
||||
{
|
||||
case DOWN:
|
||||
case UP:
|
||||
cubeBuilder.addCube( 6, 0, 6, 10, 16, 10 );
|
||||
break;
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
cubeBuilder.addCube( 6, 6, 0, 10, 10, 16 );
|
||||
break;
|
||||
case EAST:
|
||||
case WEST:
|
||||
cubeBuilder.addCube( 0, 6, 6, 16, 10, 10 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void addConstrainedGlassConnection( EnumFacing facing, AEColor cableColor, int distanceFromEdge, List<BakedQuad> quadsOut )
|
||||
{
|
||||
|
||||
// Glass connections reach only 6 voxels from the edge
|
||||
if( distanceFromEdge >= 6 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CubeBuilder cubeBuilder = new CubeBuilder( format, quadsOut );
|
||||
|
||||
TextureAtlasSprite texture = connectionTextures.get( AECableType.GLASS ).get( cableColor );
|
||||
cubeBuilder.setTexture( texture );
|
||||
|
||||
switch( facing )
|
||||
{
|
||||
case DOWN:
|
||||
cubeBuilder.addCube( 6, distanceFromEdge, 6, 10, 6, 10 );
|
||||
break;
|
||||
case EAST:
|
||||
cubeBuilder.addCube( 10, 6, 6, 16 - distanceFromEdge, 10, 10 );
|
||||
break;
|
||||
case NORTH:
|
||||
cubeBuilder.addCube( 6, 6, distanceFromEdge, 10, 10, 6 );
|
||||
break;
|
||||
case SOUTH:
|
||||
cubeBuilder.addCube( 6, 6, 10, 10, 10, 16 - distanceFromEdge );
|
||||
break;
|
||||
case UP:
|
||||
cubeBuilder.addCube( 6, 10, 6, 10, 16 - distanceFromEdge, 10 );
|
||||
break;
|
||||
case WEST:
|
||||
cubeBuilder.addCube( distanceFromEdge, 6, 6, 6, 10, 10 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void addCoveredConnection( EnumFacing facing, AEColor cableColor, AECableType connectionType, boolean cableBusAdjacent, List<BakedQuad> quadsOut )
|
||||
{
|
||||
|
||||
CubeBuilder cubeBuilder = new CubeBuilder( format, quadsOut );
|
||||
|
||||
// We render all faces except the one on the connection side
|
||||
cubeBuilder.setDrawFaces( EnumSet.complementOf( EnumSet.of( facing ) ) );
|
||||
|
||||
TextureAtlasSprite texture = connectionTextures.get( AECableType.COVERED ).get( cableColor );
|
||||
cubeBuilder.setTexture( texture );
|
||||
|
||||
// Draw a covered connection, if anything but glass is requested
|
||||
if( connectionType != AECableType.GLASS && !cableBusAdjacent )
|
||||
{
|
||||
addBigCoveredCableSizedCube( facing, cubeBuilder );
|
||||
}
|
||||
|
||||
addCoveredCableSizedCube( facing, cubeBuilder );
|
||||
}
|
||||
|
||||
public void addStraightCoveredConnection( EnumFacing facing, AEColor cableColor, List<BakedQuad> quadsOut )
|
||||
{
|
||||
CubeBuilder cubeBuilder = new CubeBuilder( format, quadsOut );
|
||||
|
||||
TextureAtlasSprite texture = connectionTextures.get( AECableType.COVERED ).get( cableColor );
|
||||
cubeBuilder.setTexture( texture );
|
||||
|
||||
setStraightCableUVs( cubeBuilder, facing, 5, 11 );
|
||||
|
||||
addStraightCoveredCableSizedCube( facing, cubeBuilder );
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static void setStraightCableUVs( CubeBuilder cubeBuilder, EnumFacing facing, int x, int y )
|
||||
{
|
||||
switch( facing )
|
||||
{
|
||||
case DOWN:
|
||||
case UP:
|
||||
cubeBuilder.setCustomUv( EnumFacing.NORTH, x, 0, y, x );
|
||||
cubeBuilder.setCustomUv( EnumFacing.EAST, x, 0, y, x );
|
||||
cubeBuilder.setCustomUv( EnumFacing.SOUTH, x, 0, y, x );
|
||||
cubeBuilder.setCustomUv( EnumFacing.WEST, x, 0, y, x );
|
||||
break;
|
||||
case EAST:
|
||||
case WEST:
|
||||
cubeBuilder.setCustomUv( EnumFacing.UP, 0, x, x, y );
|
||||
cubeBuilder.setCustomUv( EnumFacing.DOWN, 0, x, x, y );
|
||||
cubeBuilder.setCustomUv( EnumFacing.NORTH, 0, x, x, y );
|
||||
cubeBuilder.setCustomUv( EnumFacing.SOUTH, 0, x, x, y );
|
||||
break;
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
cubeBuilder.setCustomUv( EnumFacing.UP, x, 0, y, x );
|
||||
cubeBuilder.setCustomUv( EnumFacing.DOWN, x, 0, y, x );
|
||||
cubeBuilder.setCustomUv( EnumFacing.EAST, 0, x, x, y );
|
||||
cubeBuilder.setCustomUv( EnumFacing.WEST, 0, x, x, y );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void addConstrainedCoveredConnection( EnumFacing facing, AEColor cableColor, int distanceFromEdge, List<BakedQuad> quadsOut )
|
||||
{
|
||||
|
||||
// The core of a covered cable reaches up to 5 voxels from the block edge, so
|
||||
// drawing a connection can only occur from there onwards
|
||||
if( distanceFromEdge >= 5 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CubeBuilder cubeBuilder = new CubeBuilder( format, quadsOut );
|
||||
|
||||
TextureAtlasSprite texture = connectionTextures.get( AECableType.COVERED ).get( cableColor );
|
||||
cubeBuilder.setTexture( texture );
|
||||
|
||||
addCoveredCableSizedCube( facing, distanceFromEdge, cubeBuilder );
|
||||
|
||||
}
|
||||
|
||||
public void addSmartConnection( EnumFacing facing, AEColor cableColor, AECableType connectionType, boolean cableBusAdjacent, int channels, List<BakedQuad> quadsOut )
|
||||
{
|
||||
|
||||
CubeBuilder cubeBuilder = new CubeBuilder( format, quadsOut );
|
||||
|
||||
// We render all faces except the one on the connection side
|
||||
cubeBuilder.setDrawFaces( EnumSet.complementOf( EnumSet.of( facing ) ) );
|
||||
|
||||
TextureAtlasSprite texture = connectionTextures.get( AECableType.SMART ).get( cableColor );
|
||||
cubeBuilder.setTexture( texture );
|
||||
|
||||
TextureAtlasSprite oddChannel = smartCableTextures.getOddTextureForChannels( channels );
|
||||
TextureAtlasSprite evenChannel = smartCableTextures.getEvenTextureForChannels( channels );
|
||||
|
||||
// For to-machine connections, use a thicker end-cap for the connection
|
||||
if( connectionType != AECableType.GLASS && !cableBusAdjacent )
|
||||
{
|
||||
addBigCoveredCableSizedCube( facing, cubeBuilder );
|
||||
|
||||
// Render the channel indicators brightly lit at night
|
||||
cubeBuilder.setRenderFullBright( true );
|
||||
|
||||
cubeBuilder.setTexture( oddChannel );
|
||||
cubeBuilder.setColorRGB( cableColor.blackVariant );
|
||||
addBigCoveredCableSizedCube( facing, cubeBuilder );
|
||||
|
||||
cubeBuilder.setTexture( evenChannel );
|
||||
cubeBuilder.setColorRGB( cableColor.whiteVariant );
|
||||
addBigCoveredCableSizedCube( facing, cubeBuilder );
|
||||
|
||||
// Reset back to normal rendering for the rest
|
||||
cubeBuilder.setRenderFullBright( false );
|
||||
cubeBuilder.setTexture( texture );
|
||||
}
|
||||
|
||||
addCoveredCableSizedCube( facing, cubeBuilder );
|
||||
|
||||
// Render the channel indicators brightly lit at night
|
||||
cubeBuilder.setRenderFullBright( true );
|
||||
|
||||
cubeBuilder.setTexture( oddChannel );
|
||||
cubeBuilder.setColorRGB( cableColor.blackVariant );
|
||||
addCoveredCableSizedCube( facing, cubeBuilder );
|
||||
|
||||
cubeBuilder.setTexture( evenChannel );
|
||||
cubeBuilder.setColorRGB( cableColor.whiteVariant );
|
||||
addCoveredCableSizedCube( facing, cubeBuilder );
|
||||
|
||||
/* TODO: this.setSmartConnectionRotations( of, renderer );
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;*/
|
||||
}
|
||||
|
||||
public void addStraightSmartConnection( EnumFacing facing, AEColor cableColor, int channels, List<BakedQuad> quadsOut )
|
||||
{
|
||||
CubeBuilder cubeBuilder = new CubeBuilder( format, quadsOut );
|
||||
|
||||
TextureAtlasSprite texture = connectionTextures.get( AECableType.SMART ).get( cableColor );
|
||||
cubeBuilder.setTexture( texture );
|
||||
|
||||
setStraightCableUVs( cubeBuilder, facing, 5, 11 );
|
||||
|
||||
addStraightCoveredCableSizedCube( facing, cubeBuilder );
|
||||
|
||||
TextureAtlasSprite oddChannel = smartCableTextures.getOddTextureForChannels( channels );
|
||||
TextureAtlasSprite evenChannel = smartCableTextures.getEvenTextureForChannels( channels );
|
||||
|
||||
// Render the channel indicators brightly lit at night
|
||||
cubeBuilder.setRenderFullBright( true );
|
||||
|
||||
cubeBuilder.setTexture( oddChannel );
|
||||
cubeBuilder.setColorRGB( cableColor.blackVariant );
|
||||
addStraightCoveredCableSizedCube( facing, cubeBuilder );
|
||||
|
||||
cubeBuilder.setTexture( evenChannel );
|
||||
cubeBuilder.setColorRGB( cableColor.whiteVariant );
|
||||
addStraightCoveredCableSizedCube( facing, cubeBuilder );
|
||||
}
|
||||
|
||||
public void addConstrainedSmartConnection( EnumFacing facing, AEColor cableColor, int distanceFromEdge, int channels, List<BakedQuad> quadsOut )
|
||||
{
|
||||
// Same as with covered cables, the smart cable's core extends up to 5 voxels away from the edge.
|
||||
// Drawing a connection to any point before that point is fruitless
|
||||
if( distanceFromEdge >= 5 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CubeBuilder cubeBuilder = new CubeBuilder( format, quadsOut );
|
||||
|
||||
TextureAtlasSprite texture = connectionTextures.get( AECableType.SMART ).get( cableColor );
|
||||
cubeBuilder.setTexture( texture );
|
||||
|
||||
addCoveredCableSizedCube( facing, distanceFromEdge, cubeBuilder );
|
||||
|
||||
TextureAtlasSprite oddChannel = smartCableTextures.getOddTextureForChannels( channels );
|
||||
TextureAtlasSprite evenChannel = smartCableTextures.getEvenTextureForChannels( channels );
|
||||
|
||||
// Render the channel indicators brightly lit at night
|
||||
cubeBuilder.setRenderFullBright( true );
|
||||
|
||||
cubeBuilder.setTexture( oddChannel );
|
||||
cubeBuilder.setColorRGB( cableColor.blackVariant );
|
||||
addCoveredCableSizedCube( facing, distanceFromEdge, cubeBuilder );
|
||||
|
||||
cubeBuilder.setTexture( evenChannel );
|
||||
cubeBuilder.setColorRGB( cableColor.whiteVariant );
|
||||
addCoveredCableSizedCube( facing, distanceFromEdge, cubeBuilder );
|
||||
}
|
||||
|
||||
public void addDenseConnection( 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 )
|
||||
{
|
||||
addSmartConnection( facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut );
|
||||
return;
|
||||
}
|
||||
else if( connectionType != AECableType.DENSE )
|
||||
{
|
||||
addCoveredConnection( facing, cableColor, connectionType, cableBusAdjacent, quadsOut );
|
||||
return;
|
||||
}
|
||||
|
||||
CubeBuilder cubeBuilder = new CubeBuilder( format, quadsOut );
|
||||
|
||||
// We render all faces except the one on the connection side
|
||||
cubeBuilder.setDrawFaces( EnumSet.complementOf( EnumSet.of( facing ) ) );
|
||||
|
||||
TextureAtlasSprite texture = connectionTextures.get( AECableType.DENSE ).get( cableColor );
|
||||
cubeBuilder.setTexture( texture );
|
||||
|
||||
addDenseCableSizedCube( facing, cubeBuilder );
|
||||
|
||||
// Dense cables show used channels in groups of 4, rounded up
|
||||
channels = (channels + 3) / 4;
|
||||
|
||||
TextureAtlasSprite oddChannel = smartCableTextures.getOddTextureForChannels( channels );
|
||||
TextureAtlasSprite evenChannel = smartCableTextures.getEvenTextureForChannels( channels );
|
||||
|
||||
// Render the channel indicators brightly lit at night
|
||||
cubeBuilder.setRenderFullBright( true );
|
||||
|
||||
cubeBuilder.setTexture( oddChannel );
|
||||
cubeBuilder.setColorRGB( cableColor.blackVariant );
|
||||
addDenseCableSizedCube( facing, cubeBuilder );
|
||||
|
||||
cubeBuilder.setTexture( evenChannel );
|
||||
cubeBuilder.setColorRGB( cableColor.whiteVariant );
|
||||
addDenseCableSizedCube( facing, cubeBuilder );
|
||||
|
||||
// Reset back to normal rendering for the rest
|
||||
cubeBuilder.setRenderFullBright( false );
|
||||
cubeBuilder.setTexture( texture );
|
||||
|
||||
}
|
||||
|
||||
public void addStraightDenseConnection( EnumFacing facing, AEColor cableColor, int channels, List<BakedQuad> quadsOut )
|
||||
{
|
||||
CubeBuilder cubeBuilder = new CubeBuilder( format, quadsOut );
|
||||
|
||||
TextureAtlasSprite texture = connectionTextures.get( AECableType.DENSE ).get( cableColor );
|
||||
cubeBuilder.setTexture( texture );
|
||||
|
||||
setStraightCableUVs( cubeBuilder, facing, 5, 11 );
|
||||
|
||||
addStraightDenseCableSizedCube( facing, cubeBuilder );
|
||||
|
||||
// Dense cables show used channels in groups of 4, rounded up
|
||||
channels = (channels + 3) / 4;
|
||||
|
||||
TextureAtlasSprite oddChannel = smartCableTextures.getOddTextureForChannels( channels );
|
||||
TextureAtlasSprite evenChannel = smartCableTextures.getEvenTextureForChannels( channels );
|
||||
|
||||
// Render the channel indicators brightly lit at night
|
||||
cubeBuilder.setRenderFullBright( true );
|
||||
|
||||
cubeBuilder.setTexture( oddChannel );
|
||||
cubeBuilder.setColorRGB( cableColor.blackVariant );
|
||||
addStraightDenseCableSizedCube( facing, cubeBuilder );
|
||||
|
||||
cubeBuilder.setTexture( evenChannel );
|
||||
cubeBuilder.setColorRGB( cableColor.whiteVariant );
|
||||
addStraightDenseCableSizedCube( facing, cubeBuilder );
|
||||
}
|
||||
|
||||
|
||||
private static void addDenseCableSizedCube( EnumFacing facing, CubeBuilder cubeBuilder )
|
||||
{
|
||||
switch( facing )
|
||||
{
|
||||
case DOWN:
|
||||
cubeBuilder.addCube( 4, 0, 4, 12, 5, 12 );
|
||||
break;
|
||||
case EAST:
|
||||
cubeBuilder.addCube( 11, 4, 4, 16, 12, 12 );
|
||||
break;
|
||||
case NORTH:
|
||||
cubeBuilder.addCube( 4, 4, 0, 12, 12, 5 );
|
||||
break;
|
||||
case SOUTH:
|
||||
cubeBuilder.addCube( 4, 4, 11, 12, 12, 16 );
|
||||
break;
|
||||
case UP:
|
||||
cubeBuilder.addCube( 4, 11, 4, 12, 16, 12 );
|
||||
break;
|
||||
case WEST:
|
||||
cubeBuilder.addCube( 0, 4, 4, 5, 12, 12 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Adds a cube to the given cube builder that has the size of a dense cable connection and spans the entire block for the given direction
|
||||
private static void addStraightDenseCableSizedCube( EnumFacing facing, CubeBuilder cubeBuilder )
|
||||
{
|
||||
switch( facing )
|
||||
{
|
||||
case DOWN:
|
||||
case UP:
|
||||
cubeBuilder.addCube( 3, 0, 3, 13, 16, 13 );
|
||||
break;
|
||||
case EAST:
|
||||
case WEST:
|
||||
/*renderer.uvRotateEast = renderer.uvRotateWest = 1;
|
||||
renderer.uvRotateBottom = renderer.uvRotateTop = 1;*/
|
||||
cubeBuilder.addCube( 0, 3, 3, 16, 13, 13 );
|
||||
break;
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
// TODO renderer.uvRotateNorth = renderer.uvRotateSouth = 1;
|
||||
cubeBuilder.addCube( 3, 3, 0, 13, 13, 16 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Adds a cube to the given cube builder that has the size of a covered cable connection from the core of the cable to the given face
|
||||
private static void addCoveredCableSizedCube( EnumFacing facing, CubeBuilder cubeBuilder )
|
||||
{
|
||||
switch( facing )
|
||||
{
|
||||
case DOWN:
|
||||
cubeBuilder.addCube( 6, 0, 6, 10, 5, 10 );
|
||||
break;
|
||||
case EAST:
|
||||
cubeBuilder.addCube( 11, 6, 6, 16, 10, 10 );
|
||||
break;
|
||||
case NORTH:
|
||||
cubeBuilder.addCube( 6, 6, 0, 10, 10, 5 );
|
||||
break;
|
||||
case SOUTH:
|
||||
cubeBuilder.addCube( 6, 6, 11, 10, 10, 16 );
|
||||
break;
|
||||
case UP:
|
||||
cubeBuilder.addCube( 6, 11, 6, 10, 16, 10 );
|
||||
break;
|
||||
case WEST:
|
||||
cubeBuilder.addCube( 0, 6, 6, 5, 10, 10 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Adds a cube to the given cube builder that has the size of a covered cable connection and spans the entire block for the given direction
|
||||
private static void addStraightCoveredCableSizedCube( EnumFacing facing, CubeBuilder cubeBuilder )
|
||||
{
|
||||
switch( facing )
|
||||
{
|
||||
case DOWN:
|
||||
case UP:
|
||||
cubeBuilder.addCube( 5, 0, 5, 11, 16, 11 );
|
||||
break;
|
||||
case EAST:
|
||||
case WEST:
|
||||
/*renderer.uvRotateEast = renderer.uvRotateWest = 1;
|
||||
renderer.uvRotateBottom = renderer.uvRotateTop = 1;*/
|
||||
cubeBuilder.addCube( 0, 5, 5, 16, 11, 11 );
|
||||
break;
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
// TODO renderer.uvRotateNorth = renderer.uvRotateSouth = 1;
|
||||
cubeBuilder.addCube( 5, 5, 0, 11, 11, 16 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void addCoveredCableSizedCube( EnumFacing facing, int distanceFromEdge, CubeBuilder cubeBuilder )
|
||||
{
|
||||
switch( facing )
|
||||
{
|
||||
case DOWN:
|
||||
cubeBuilder.addCube( 6, distanceFromEdge, 6, 10, 5, 10 );
|
||||
break;
|
||||
case EAST:
|
||||
cubeBuilder.addCube( 11, 6, 6, 16 - distanceFromEdge, 10, 10 );
|
||||
break;
|
||||
case NORTH:
|
||||
cubeBuilder.addCube( 6, 6, distanceFromEdge, 10, 10, 5 );
|
||||
break;
|
||||
case SOUTH:
|
||||
cubeBuilder.addCube( 6, 6, 11, 10, 10, 16 - distanceFromEdge );
|
||||
break;
|
||||
case UP:
|
||||
cubeBuilder.addCube( 6, 11, 6, 10, 16 - distanceFromEdge, 10 );
|
||||
break;
|
||||
case WEST:
|
||||
cubeBuilder.addCube( distanceFromEdge, 6, 6, 5, 10, 10 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This renders a slightly bigger covered cable connection to the specified side. This is used to connect cable cores with adjacent machines
|
||||
* that do not want to be connected to using a glass cable connection. This applies to most machines (interfaces, etc.)
|
||||
*/
|
||||
private void addBigCoveredCableSizedCube( EnumFacing facing, CubeBuilder cubeBuilder )
|
||||
{
|
||||
switch( facing )
|
||||
{
|
||||
case DOWN:
|
||||
cubeBuilder.addCube( 5, 0, 5, 11, 4, 11 );
|
||||
break;
|
||||
case EAST:
|
||||
cubeBuilder.addCube( 12, 5, 5, 16, 11, 11 );
|
||||
break;
|
||||
case NORTH:
|
||||
cubeBuilder.addCube( 5, 5, 0, 11, 11, 4 );
|
||||
break;
|
||||
case SOUTH:
|
||||
cubeBuilder.addCube( 5, 5, 12, 11, 11, 16 );
|
||||
break;
|
||||
case UP:
|
||||
cubeBuilder.addCube( 5, 12, 5, 11, 16, 11 );
|
||||
break;
|
||||
case WEST:
|
||||
cubeBuilder.addCube( 0, 5, 5, 4, 11, 11 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Get all textures needed for building the actual cable quads
|
||||
public static List<ResourceLocation> getTextures()
|
||||
{
|
||||
List<ResourceLocation> locations = new ArrayList<>();
|
||||
|
||||
for( CableCoreType coreType : CableCoreType.values() )
|
||||
{
|
||||
for( AEColor color : AEColor.values() )
|
||||
{
|
||||
locations.add( coreType.getTexture( color ) );
|
||||
}
|
||||
}
|
||||
|
||||
for( AECableType cableType : AECableType.VALIDCABLES )
|
||||
{
|
||||
for( AEColor color : AEColor.values() )
|
||||
{
|
||||
locations.add( cableType.getConnectionTexture( color ) );
|
||||
}
|
||||
}
|
||||
|
||||
Collections.addAll( locations, SmartCableTextures.SMART_CHANNELS_TEXTURES );
|
||||
|
||||
return locations;
|
||||
}
|
||||
|
||||
public TextureAtlasSprite getCoreTexture( CableCoreType coreType, AEColor color )
|
||||
{
|
||||
return coreTextures.get( coreType ).get( color );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
package appeng.client.render.cablebus;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
|
||||
|
||||
public class CableBusBakedModel implements IBakedModel
|
||||
{
|
||||
|
||||
private final CableBuilder cableBuilder;
|
||||
|
||||
private final Map<ResourceLocation, IBakedModel> partModels;
|
||||
|
||||
CableBusBakedModel( CableBuilder cableBuilder, Map<ResourceLocation, IBakedModel> partModels )
|
||||
{
|
||||
this.cableBuilder = cableBuilder;
|
||||
this.partModels = partModels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( @Nullable IBlockState state, @Nullable EnumFacing side, long rand )
|
||||
{
|
||||
CableBusRenderState renderState = getRenderingState( state );
|
||||
|
||||
if( renderState == null || side != null )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// First, handle the cable at the center of the cable bus
|
||||
List<BakedQuad> quads = new ArrayList<>();
|
||||
addCableQuads( renderState, quads );
|
||||
|
||||
for( EnumFacing facing : EnumFacing.values() )
|
||||
{
|
||||
List<ResourceLocation> models = renderState.getAttachments().get( facing );
|
||||
if( models == null )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for( ResourceLocation model : models )
|
||||
{
|
||||
IBakedModel bakedModel = partModels.get( model );
|
||||
|
||||
if( bakedModel == null )
|
||||
{
|
||||
throw new IllegalStateException( "Trying to use an unregistered part model: " + model );
|
||||
}
|
||||
|
||||
List<BakedQuad> partQuads = bakedModel.getQuads( state, null, rand );
|
||||
|
||||
// Rotate quads accordingly
|
||||
QuadRotator rotator = new QuadRotator();
|
||||
partQuads = rotator.rotateQuads( partQuads, facing, EnumFacing.UP );
|
||||
|
||||
quads.addAll( partQuads );
|
||||
}
|
||||
}
|
||||
|
||||
return quads;
|
||||
}
|
||||
|
||||
|
||||
// Determines whether a cable is connected to exactly two sides that are opposite each other
|
||||
private static boolean isStraightLine( Set<EnumFacing> sides )
|
||||
{
|
||||
Iterator<EnumFacing> it = sides.iterator();
|
||||
if( !it.hasNext() )
|
||||
{
|
||||
return false; // No connections
|
||||
}
|
||||
EnumFacing firstSide = it.next();
|
||||
if( !it.hasNext() )
|
||||
{
|
||||
return false; // Only a single connection
|
||||
}
|
||||
if( firstSide.getOpposite() != it.next() )
|
||||
{
|
||||
return false; // Connected to two sides that are not opposite each other
|
||||
}
|
||||
return !it.hasNext(); // Must not have any other connection points
|
||||
}
|
||||
|
||||
private void addCableQuads( CableBusRenderState renderState, List<BakedQuad> quadsOut )
|
||||
{
|
||||
AECableType cableType = renderState.getCableType();
|
||||
if( cableType == AECableType.NONE )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AEColor cableColor = renderState.getCableColor();
|
||||
EnumMap<EnumFacing, AECableType> connectionTypes = renderState.getConnectionTypes();
|
||||
|
||||
// If the connection is straight, no busses are attached, and no overed core has been forced (in case of glass
|
||||
// cables), then render the cable as a simplified straight line.
|
||||
boolean noAttachments = renderState.getAttachments().isEmpty();
|
||||
if( isStraightLine( connectionTypes.keySet() ) && noAttachments )
|
||||
{
|
||||
EnumFacing facing = connectionTypes.keySet().iterator().next();
|
||||
|
||||
switch (cableType) {
|
||||
case GLASS:
|
||||
cableBuilder.addStraightGlassConnection( facing, cableColor, quadsOut );
|
||||
break;
|
||||
case COVERED:
|
||||
cableBuilder.addStraightCoveredConnection( facing, cableColor, quadsOut );
|
||||
break;
|
||||
case SMART:
|
||||
cableBuilder.addStraightSmartConnection( facing, cableColor, renderState.getChannelsOnSide().get(facing), quadsOut );
|
||||
break;
|
||||
case DENSE:
|
||||
cableBuilder.addStraightDenseConnection( facing, cableColor, renderState.getChannelsOnSide().get(facing), quadsOut );
|
||||
break;
|
||||
}
|
||||
|
||||
return; // Don't render the other form of connection
|
||||
}
|
||||
|
||||
cableBuilder.addCableCore( renderState.getCoreType(), cableColor, quadsOut );
|
||||
|
||||
// Render all internal connections to attachments
|
||||
EnumMap<EnumFacing, Integer> attachmentConnections = renderState.getAttachmentConnections();
|
||||
for( EnumFacing facing : attachmentConnections.keySet() )
|
||||
{
|
||||
int distance = attachmentConnections.get( facing );
|
||||
int channels = renderState.getChannelsOnSide().get( facing );
|
||||
|
||||
switch( cableType )
|
||||
{
|
||||
case GLASS:
|
||||
cableBuilder.addConstrainedGlassConnection( facing, cableColor, distance, quadsOut );
|
||||
break;
|
||||
case COVERED:
|
||||
cableBuilder.addConstrainedCoveredConnection( facing, cableColor, distance, quadsOut );
|
||||
break;
|
||||
case SMART:
|
||||
cableBuilder.addConstrainedSmartConnection( facing, cableColor, distance, channels, quadsOut );
|
||||
break;
|
||||
case DENSE:
|
||||
// Dense cables do not render connections to parts since none can be attached
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Render all outgoing connections using the appropriate type
|
||||
for( EnumFacing facing : connectionTypes.keySet() )
|
||||
{
|
||||
AECableType connectionType = connectionTypes.get( facing );
|
||||
boolean cableBusAdjacent = renderState.getCableBusAdjacent().contains( facing );
|
||||
int channels = renderState.getChannelsOnSide().get( facing );
|
||||
|
||||
switch( cableType )
|
||||
{
|
||||
case GLASS:
|
||||
cableBuilder.addGlassConnection( facing, cableColor, connectionType, cableBusAdjacent, quadsOut );
|
||||
break;
|
||||
case COVERED:
|
||||
cableBuilder.addCoveredConnection( facing, cableColor, connectionType, cableBusAdjacent, quadsOut );
|
||||
break;
|
||||
case SMART:
|
||||
cableBuilder.addSmartConnection( facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut );
|
||||
break;
|
||||
case DENSE:
|
||||
cableBuilder.addDenseConnection( facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of texture sprites appropriate for particles (digging, etc.) given the render state for a cable bus.
|
||||
*/
|
||||
public List<TextureAtlasSprite> getParticleTextures( CableBusRenderState renderState )
|
||||
{
|
||||
CableCoreType coreType = renderState.getCableType().getCoreType();
|
||||
AEColor cableColor = renderState.getCableColor();
|
||||
|
||||
if( coreType != null )
|
||||
{
|
||||
return Collections.singletonList( cableBuilder.getCoreTexture( coreType, cableColor ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// TODO: Add break particles even for the attachments, not just the cable
|
||||
|
||||
}
|
||||
|
||||
private static CableBusRenderState getRenderingState( IBlockState state )
|
||||
{
|
||||
if( state == null || !( state instanceof IExtendedBlockState ) )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
IExtendedBlockState extendedBlockState = (IExtendedBlockState) state;
|
||||
return extendedBlockState.getValue( BlockCableBus.RENDER_STATE_PROPERTY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
{
|
||||
return ItemCameraTransforms.DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return ItemOverrideList.NONE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package appeng.client.render.cablebus;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.features.registries.PartModels;
|
||||
|
||||
|
||||
/**
|
||||
* The built-in model for the cable bus block.
|
||||
*/
|
||||
public class CableBusModel implements IModel
|
||||
{
|
||||
|
||||
private final PartModels partModels;
|
||||
|
||||
public CableBusModel( PartModels partModels )
|
||||
{
|
||||
this.partModels = partModels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
partModels.setInitialized( true );
|
||||
return partModels.getModels();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
{
|
||||
return CableBuilder.getTextures();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
|
||||
Map<ResourceLocation, IBakedModel> partModels = loadPartModels( state, format, bakedTextureGetter );
|
||||
|
||||
CableBuilder cableBuilder = new CableBuilder( format, bakedTextureGetter );
|
||||
return new CableBusBakedModel( cableBuilder, partModels );
|
||||
}
|
||||
|
||||
private Map<ResourceLocation, IBakedModel> loadPartModels(
|
||||
IModelState state,
|
||||
VertexFormat format,
|
||||
Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
ImmutableMap.Builder<ResourceLocation, IBakedModel> result = ImmutableMap.builder();
|
||||
|
||||
for( ResourceLocation location : partModels.getModels() )
|
||||
{
|
||||
IModel model = tryLoadPartModel( location );
|
||||
IBakedModel bakedModel = model.bake( state, format, bakedTextureGetter );
|
||||
result.put( location, bakedModel );
|
||||
}
|
||||
|
||||
return result.build();
|
||||
}
|
||||
|
||||
private IModel tryLoadPartModel( ResourceLocation location )
|
||||
{
|
||||
try
|
||||
{
|
||||
return ModelLoaderRegistry.getModel( location );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
AELog.error( e, "Unable to load part model " + location );
|
||||
return ModelLoaderRegistry.getMissingModel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelState getDefaultState()
|
||||
{
|
||||
return TRSRTransformation.identity();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package appeng.client.render.cablebus;
|
||||
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
|
||||
|
||||
/**
|
||||
* This class captures the entire rendering state needed for a cable bus and transports it to the rendering thread
|
||||
* for processing.
|
||||
*/
|
||||
public class CableBusRenderState
|
||||
{
|
||||
|
||||
// The cable type used for rendering the outgoing connections to other blocks and attached parts
|
||||
private AECableType cableType = AECableType.NONE;
|
||||
|
||||
// The type to use for rendering the core of the cable.
|
||||
private CableCoreType coreType;
|
||||
|
||||
private AEColor cableColor = AEColor.Transparent;
|
||||
|
||||
// Describes the outgoing connections of this cable bus to other blocks, and how they should be rendered
|
||||
private EnumMap<EnumFacing, AECableType> connectionTypes = new EnumMap<>( EnumFacing.class );
|
||||
|
||||
// Indicate on which sides signified by connectionTypes above, there is another cable bus. If a side is connected, but it is absent from this
|
||||
// set, then it means that there is a Grid host, but not a cable bus on that side (i.e. an interface, a controller, etc.)
|
||||
private EnumSet<EnumFacing> cableBusAdjacent = EnumSet.noneOf( EnumFacing.class );
|
||||
|
||||
// Specifies the number of channels used for the connection to a given side. Only contains entries if
|
||||
// connections contains a corresponding entry.
|
||||
private EnumMap<EnumFacing, Integer> channelsOnSide = new EnumMap<>( EnumFacing.class );
|
||||
|
||||
private EnumMap<EnumFacing, List<ResourceLocation>> attachments = new EnumMap<>( EnumFacing.class );
|
||||
|
||||
// For each attachment, this contains the distance from the edge until which a cable connection should be drawn
|
||||
private EnumMap<EnumFacing, Integer> attachmentConnections = new EnumMap<>( EnumFacing.class );
|
||||
|
||||
public CableCoreType getCoreType()
|
||||
{
|
||||
return coreType;
|
||||
}
|
||||
|
||||
public void setCoreType( CableCoreType coreType )
|
||||
{
|
||||
this.coreType = coreType;
|
||||
}
|
||||
|
||||
public AECableType getCableType()
|
||||
{
|
||||
return cableType;
|
||||
}
|
||||
|
||||
public void setCableType( AECableType cableType )
|
||||
{
|
||||
this.cableType = cableType;
|
||||
}
|
||||
|
||||
public AEColor getCableColor()
|
||||
{
|
||||
return cableColor;
|
||||
}
|
||||
|
||||
public void setCableColor( AEColor cableColor )
|
||||
{
|
||||
this.cableColor = cableColor;
|
||||
}
|
||||
|
||||
public EnumMap<EnumFacing, Integer> getChannelsOnSide()
|
||||
{
|
||||
return channelsOnSide;
|
||||
}
|
||||
|
||||
public EnumMap<EnumFacing, AECableType> getConnectionTypes()
|
||||
{
|
||||
return connectionTypes;
|
||||
}
|
||||
|
||||
public void setConnectionTypes( EnumMap<EnumFacing, AECableType> connectionTypes )
|
||||
{
|
||||
this.connectionTypes = connectionTypes;
|
||||
}
|
||||
|
||||
public void setChannelsOnSide( EnumMap<EnumFacing, Integer> channelsOnSide )
|
||||
{
|
||||
this.channelsOnSide = channelsOnSide;
|
||||
}
|
||||
|
||||
public EnumSet<EnumFacing> getCableBusAdjacent()
|
||||
{
|
||||
return cableBusAdjacent;
|
||||
}
|
||||
|
||||
public void setCableBusAdjacent( EnumSet<EnumFacing> cableBusAdjacent )
|
||||
{
|
||||
this.cableBusAdjacent = cableBusAdjacent;
|
||||
}
|
||||
|
||||
public EnumMap<EnumFacing, List<ResourceLocation>> getAttachments()
|
||||
{
|
||||
return attachments;
|
||||
}
|
||||
|
||||
public EnumMap<EnumFacing, Integer> getAttachmentConnections()
|
||||
{
|
||||
return attachmentConnections;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package appeng.client.render.cablebus;
|
||||
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
|
||||
/**
|
||||
* AE can render the core of a cable (the core that connections are made to, in case the cable is not a straight line)
|
||||
* in three different ways:
|
||||
* - Glass
|
||||
* - Covered (also used by the Smart Cable)
|
||||
* - Dense
|
||||
*/
|
||||
public enum CableCoreType
|
||||
{
|
||||
GLASS( "parts/cable/core/glass" ),
|
||||
COVERED( "parts/cable/core/covered" ),
|
||||
DENSE( "parts/cable/core/dense" );
|
||||
|
||||
private final String textureFolder;
|
||||
|
||||
CableCoreType( String textureFolder )
|
||||
{
|
||||
this.textureFolder = textureFolder;
|
||||
}
|
||||
|
||||
public ResourceLocation getTexture( AEColor color )
|
||||
{
|
||||
return new ResourceLocation( AppEng.MOD_ID, textureFolder + "/" + color.name().toLowerCase() );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
package appeng.client.render.cablebus;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import javax.vecmath.Vector4f;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
|
||||
|
||||
|
||||
/**
|
||||
* Builds the quads for a cube.
|
||||
*/
|
||||
public class CubeBuilder {
|
||||
|
||||
private VertexFormat format;
|
||||
|
||||
private final List<BakedQuad> output;
|
||||
|
||||
private final EnumMap<EnumFacing, TextureAtlasSprite> textures = new EnumMap<>(EnumFacing.class);
|
||||
|
||||
private EnumSet<EnumFacing> drawFaces = EnumSet.allOf(EnumFacing.class);
|
||||
|
||||
private final EnumMap<EnumFacing, Vector4f> customUv = new EnumMap<>(EnumFacing.class);
|
||||
|
||||
private int color = 0xFFFFFFFF;
|
||||
|
||||
private boolean renderFullBright;
|
||||
|
||||
public CubeBuilder(VertexFormat format, List<BakedQuad> output) {
|
||||
this.output = output;
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public CubeBuilder(VertexFormat format) {
|
||||
this(format, new ArrayList<>(6));
|
||||
}
|
||||
|
||||
public void addCube(float x1, float y1, float z1, float x2, float y2, float z2) {
|
||||
x1 /= 16.0f;
|
||||
y1 /= 16.0f;
|
||||
z1 /= 16.0f;
|
||||
x2 /= 16.0f;
|
||||
y2 /= 16.0f;
|
||||
z2 /= 16.0f;
|
||||
|
||||
// If brightness is forced to specific values, extend the vertex format to contain the multi-texturing lightmap offset
|
||||
VertexFormat savedFormat = null;
|
||||
if (renderFullBright) {
|
||||
savedFormat = format;
|
||||
format = new VertexFormat(savedFormat);
|
||||
if (!format.getElements().contains(DefaultVertexFormats.TEX_2S)) {
|
||||
format.addElement(DefaultVertexFormats.TEX_2S);
|
||||
}
|
||||
}
|
||||
|
||||
for (EnumFacing face : drawFaces) {
|
||||
putFace(face, x1, y1, z1, x2, y2, z2);
|
||||
}
|
||||
|
||||
// Restore old format
|
||||
if (savedFormat != null) {
|
||||
format = savedFormat;
|
||||
}
|
||||
}
|
||||
|
||||
private void putFace(EnumFacing face,
|
||||
float x1, float y1, float z1,
|
||||
float x2, float y2, float z2
|
||||
) {
|
||||
|
||||
TextureAtlasSprite texture = textures.get(face);
|
||||
|
||||
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
|
||||
builder.setTexture(texture);
|
||||
builder.setQuadOrientation(face);
|
||||
|
||||
float u1 = 0;
|
||||
float v1 = 0;
|
||||
float u2 = 0;
|
||||
float v2 = 0;
|
||||
|
||||
// The user might have set specific UV coordinates for this face
|
||||
Vector4f customUv = this.customUv.get( face );
|
||||
if( customUv != null )
|
||||
{
|
||||
u1 = texture.getInterpolatedU( customUv.x );
|
||||
v1 = texture.getInterpolatedV( customUv.y );
|
||||
u2 = texture.getInterpolatedU( customUv.z );
|
||||
v2 = texture.getInterpolatedV( customUv.w );
|
||||
}
|
||||
|
||||
switch (face) {
|
||||
case DOWN:
|
||||
if (customUv == null)
|
||||
{
|
||||
u1 = texture.getInterpolatedU( x1 * 16 );
|
||||
v1 = texture.getInterpolatedV( z1 * 16 );
|
||||
u2 = texture.getInterpolatedU( x2 * 16 );
|
||||
v2 = texture.getInterpolatedV( z2 * 16 );
|
||||
}
|
||||
|
||||
putVertex(builder, face, x2, y1, z1, u2, v1);
|
||||
putVertex(builder, face, x2, y1, z2, u2, v2);
|
||||
putVertex(builder, face, x1, y1, z2, u1, v2);
|
||||
putVertex(builder, face, x1, y1, z1, u1, v1);
|
||||
break;
|
||||
case UP:
|
||||
if (customUv == null)
|
||||
{
|
||||
u1 = texture.getInterpolatedU( x1 * 16 );
|
||||
v1 = texture.getInterpolatedV( z1 * 16 );
|
||||
u2 = texture.getInterpolatedU( x2 * 16 );
|
||||
v2 = texture.getInterpolatedV( z2 * 16 );
|
||||
}
|
||||
|
||||
putVertex(builder, face, x1, y2, z1, u1, v1);
|
||||
putVertex(builder, face, x1, y2, z2, u1, v2);
|
||||
putVertex(builder, face, x2, y2, z2, u2, v2);
|
||||
putVertex(builder, face, x2, y2, z1, u2, v1);
|
||||
break;
|
||||
case NORTH:
|
||||
if (customUv == null)
|
||||
{
|
||||
u1 = texture.getInterpolatedU( x1 * 16 );
|
||||
v1 = texture.getInterpolatedV( 16 - y1 * 16 );
|
||||
u2 = texture.getInterpolatedU( x2 * 16 );
|
||||
v2 = texture.getInterpolatedV( 16 - y2 * 16 );
|
||||
}
|
||||
|
||||
putVertex(builder, face, x2, y2, z1, u1, v2);
|
||||
putVertex(builder, face, x2, y1, z1, u1, v1);
|
||||
putVertex(builder, face, x1, y1, z1, u2, v1);
|
||||
putVertex(builder, face, x1, y2, z1, u2, v2);
|
||||
break;
|
||||
case SOUTH:
|
||||
if (customUv == null)
|
||||
{
|
||||
u1 = texture.getInterpolatedU( x1 * 16 );
|
||||
v1 = texture.getInterpolatedV( 16 - y1 * 16 );
|
||||
u2 = texture.getInterpolatedU( x2 * 16 );
|
||||
v2 = texture.getInterpolatedV( 16 - y2 * 16 );
|
||||
}
|
||||
|
||||
putVertex(builder, face, x1, y2, z2, u1, v2);
|
||||
putVertex(builder, face, x1, y1, z2, u1, v1);
|
||||
putVertex(builder, face, x2, y1, z2, u2, v1);
|
||||
putVertex(builder, face, x2, y2, z2, u2, v2);
|
||||
break;
|
||||
case WEST:
|
||||
if (customUv == null)
|
||||
{
|
||||
u1 = texture.getInterpolatedU( z1 * 16 );
|
||||
v1 = texture.getInterpolatedV( 16 - y1 * 16 );
|
||||
u2 = texture.getInterpolatedU( z2 * 16 );
|
||||
v2 = texture.getInterpolatedV( 16 - y2 * 16 );
|
||||
}
|
||||
|
||||
putVertex(builder, face, x1, y1, z1, u1, v1);
|
||||
putVertex(builder, face, x1, y1, z2, u2, v1);
|
||||
putVertex(builder, face, x1, y2, z2, u2, v2);
|
||||
putVertex(builder, face, x1, y2, z1, u1, v2);
|
||||
break;
|
||||
case EAST:
|
||||
if (customUv == null)
|
||||
{
|
||||
u1 = texture.getInterpolatedU( z2 * 16 );
|
||||
v1 = texture.getInterpolatedV( 16 - y1 * 16 );
|
||||
u2 = texture.getInterpolatedU( z1 * 16 );
|
||||
v2 = texture.getInterpolatedV( 16 - y2 * 16 );
|
||||
}
|
||||
|
||||
putVertex(builder, face, x2, y2, z1, u1, v2);
|
||||
putVertex(builder, face, x2, y2, z2, u2, v2);
|
||||
putVertex(builder, face, x2, y1, z2, u2, v1);
|
||||
putVertex(builder, face, x2, y1, z1, u1, v1);
|
||||
break;
|
||||
}
|
||||
|
||||
int[] vertexData = builder.build().getVertexData();
|
||||
output.add(new BakedQuad(vertexData, -1, face, texture, true, format));
|
||||
}
|
||||
|
||||
private void putVertex(UnpackedBakedQuad.Builder builder, EnumFacing face, float x, float y, float z, float u, float v) {
|
||||
VertexFormat format = builder.getVertexFormat();
|
||||
|
||||
for (int i = 0; i < format.getElementCount(); i++) {
|
||||
VertexFormatElement e = format.getElement(i);
|
||||
switch (e.getUsage()) {
|
||||
case POSITION:
|
||||
builder.put(i, x, y, z);
|
||||
break;
|
||||
case NORMAL:
|
||||
builder.put(i,
|
||||
face.getFrontOffsetX(),
|
||||
face.getFrontOffsetY(),
|
||||
face.getFrontOffsetZ());
|
||||
break;
|
||||
case COLOR:
|
||||
// Color format is RGBA
|
||||
float r = (color >> 16 & 0xFF) / 255f;
|
||||
float g = (color >> 8 & 0xFF) / 255f;
|
||||
float b = (color & 0xFF) / 255f;
|
||||
float a = (color >> 24 & 0xFF) / 255f;
|
||||
builder.put(i, r, g, b, a);
|
||||
break;
|
||||
case UV:
|
||||
if (e.getIndex() == 0) {
|
||||
builder.put(i, u, v);
|
||||
} else {
|
||||
// Force Brightness to 15, this is for full bright mode
|
||||
// this vertex element will only be present in that case
|
||||
final float lightMapU = (float) (15 * 0x20) / 0xFFFF;
|
||||
final float lightMapV = (float) (15 * 0x20) / 0xFFFF;
|
||||
builder.put(i, lightMapU, lightMapV);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
builder.put(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTexture(TextureAtlasSprite texture) {
|
||||
for (EnumFacing face : EnumFacing.values()) {
|
||||
textures.put(face, texture);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTextures(TextureAtlasSprite up, TextureAtlasSprite down, TextureAtlasSprite north, TextureAtlasSprite south, TextureAtlasSprite east, TextureAtlasSprite west) {
|
||||
textures.put(EnumFacing.UP, up);
|
||||
textures.put(EnumFacing.DOWN, down);
|
||||
textures.put(EnumFacing.NORTH, north);
|
||||
textures.put(EnumFacing.SOUTH, south);
|
||||
textures.put(EnumFacing.EAST, east);
|
||||
textures.put(EnumFacing.WEST, west);
|
||||
}
|
||||
|
||||
public void setDrawFaces(EnumSet<EnumFacing> drawFaces) {
|
||||
this.drawFaces = drawFaces;
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vertex color for future vertices to the given RGB value, and forces the alpha component to 255.
|
||||
*/
|
||||
public void setColorRGB(int color) {
|
||||
setColor(color | 0xFF000000);
|
||||
}
|
||||
|
||||
public void setRenderFullBright(boolean renderFullBright) {
|
||||
this.renderFullBright = renderFullBright;
|
||||
}
|
||||
|
||||
public void setCustomUv( EnumFacing facing, float u1, float v1, float u2, float v2 )
|
||||
{
|
||||
customUv.put( facing, new Vector4f( u1, v1, u2, v2 ) );
|
||||
}
|
||||
|
||||
public List<BakedQuad> getOutput() {
|
||||
return output;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package appeng.client.render.cablebus;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Point3f;
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import appeng.client.render.FacingToRotation;
|
||||
import appeng.core.AELog;
|
||||
|
||||
|
||||
/**
|
||||
* Assuming a default-orientation of forward=NORTH and up=UP, this class rotates a given list of quads to the desired facing
|
||||
*/
|
||||
public class QuadRotator
|
||||
{
|
||||
|
||||
public List<BakedQuad> rotateQuads( List<BakedQuad> quads, EnumFacing newForward, EnumFacing newUp )
|
||||
{
|
||||
if( newForward == EnumFacing.NORTH && newUp == EnumFacing.UP )
|
||||
{
|
||||
return quads; // This is the default orientation
|
||||
}
|
||||
|
||||
List<BakedQuad> result = new ArrayList<>( quads.size() );
|
||||
|
||||
for( BakedQuad quad : quads )
|
||||
{
|
||||
result.add( rotateQuad( quad, newForward, newUp ) );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private BakedQuad rotateQuad( BakedQuad quad, EnumFacing forward, EnumFacing up )
|
||||
{
|
||||
// Sanitize forward/up
|
||||
if (forward.getAxis() == up.getAxis()) {
|
||||
if (up.getAxis() == EnumFacing.Axis.Y) {
|
||||
up = EnumFacing.NORTH;
|
||||
} else {
|
||||
up = EnumFacing.UP;
|
||||
}
|
||||
}
|
||||
|
||||
FacingToRotation rotation = FacingToRotation.get( forward, up );
|
||||
Matrix4f mat = rotation.getMat();
|
||||
|
||||
// Clone the vertex data used by the quad
|
||||
int[] newData = quad.getVertexData().clone();
|
||||
|
||||
// Figure out where the position is in the array
|
||||
VertexFormat format = quad.getFormat();
|
||||
int posIdx = findPositionOffset( format ) / 4;
|
||||
int stride = format.getNextOffset() / 4;
|
||||
int normalIdx = format.getNormalOffset();
|
||||
VertexFormatElement.EnumType normalType = null;
|
||||
// Figure out the type of the normals
|
||||
if( normalIdx != -1 )
|
||||
{
|
||||
for( int i = 0; i < format.getElements().size(); i++ )
|
||||
{
|
||||
VertexFormatElement element = format.getElement( i );
|
||||
if( element.getUsage() == VertexFormatElement.EnumUsage.NORMAL )
|
||||
{
|
||||
normalType = element.getType();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
Point3f pos = new Point3f(
|
||||
Float.intBitsToFloat( newData[i * stride + posIdx] ) - 0.5f,
|
||||
Float.intBitsToFloat( newData[i * stride + posIdx + 1] ) - 0.5f,
|
||||
Float.intBitsToFloat( newData[i * stride + posIdx + 2] ) - 0.5f
|
||||
);
|
||||
|
||||
// Rotate stuff around
|
||||
mat.transform( pos );
|
||||
|
||||
// Write back
|
||||
newData[i * stride + posIdx] = Float.floatToIntBits( pos.getX() + 0.5f );
|
||||
newData[i * stride + posIdx + 1] = Float.floatToIntBits( pos.getY() + 0.5f );
|
||||
newData[i * stride + posIdx + 2] = Float.floatToIntBits( pos.getZ() + 0.5f );
|
||||
|
||||
// Transform the normal if one is present
|
||||
if ( normalIdx != -1 ) {
|
||||
if( normalType == VertexFormatElement.EnumType.FLOAT )
|
||||
{
|
||||
Vector3f normal = new Vector3f(
|
||||
Float.intBitsToFloat( newData[i * stride + normalIdx] ),
|
||||
Float.intBitsToFloat( newData[i * stride + normalIdx + 1] ),
|
||||
Float.intBitsToFloat( newData[i * stride + normalIdx + 2] )
|
||||
);
|
||||
|
||||
// Rotate stuff around
|
||||
mat.transform( normal );
|
||||
|
||||
// Write back
|
||||
newData[i * stride + normalIdx] = Float.floatToIntBits( normal.getX() );
|
||||
newData[i * stride + normalIdx + 1] = Float.floatToIntBits( normal.getY() );
|
||||
newData[i * stride + normalIdx + 2] = Float.floatToIntBits( normal.getZ() );
|
||||
}
|
||||
else if( normalType == VertexFormatElement.EnumType.BYTE )
|
||||
{
|
||||
int idx = i * stride * 4 + normalIdx;
|
||||
Vector3f normal = new Vector3f( getByte( newData, idx ) / 127.0f, getByte( newData, idx + 1 ) / 127.0f, getByte( newData, idx + 2 ) / 127.0f );
|
||||
|
||||
// Rotate stuff around
|
||||
mat.transform( normal );
|
||||
|
||||
// Write back
|
||||
setByte( newData, idx, (int) ( normal.getX() * 127 ) );
|
||||
setByte( newData, idx + 1, (int) ( normal.getY() * 127 ) );
|
||||
setByte( newData, idx + 2, (int) ( normal.getZ() * 127 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
AELog.warn( "Unsupported normal format: {}", normalType );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EnumFacing newFace = rotation.rotate( quad.getFace() );
|
||||
return new BakedQuad( newData, quad.getTintIndex(), newFace, quad.getSprite(), quad.shouldApplyDiffuseLighting(), quad.getFormat() );
|
||||
}
|
||||
|
||||
private static int getByte( int[] data, int offset )
|
||||
{
|
||||
int idx = offset / 4;
|
||||
int subOffset = offset % 4;
|
||||
return (byte) ( data[idx] >> ( subOffset * 8 ) );
|
||||
}
|
||||
|
||||
private static void setByte( int[] data, int offset, int value )
|
||||
{
|
||||
int idx = offset / 4;
|
||||
int subOffset = offset % 4;
|
||||
int mask = 0xFF << ( subOffset * 8 );
|
||||
data[idx] = data[idx] & ( ~mask ) | ( (value & 0xFF) << (subOffset * 8) );
|
||||
}
|
||||
|
||||
private int findPositionOffset( VertexFormat format )
|
||||
{
|
||||
List<VertexFormatElement> elements = format.getElements();
|
||||
for( int i = 0; i < elements.size(); i++ )
|
||||
{
|
||||
VertexFormatElement e = elements.get( i );
|
||||
if( e.isPositionElement() )
|
||||
{
|
||||
if( e.getType() != VertexFormatElement.EnumType.FLOAT )
|
||||
{
|
||||
throw new IllegalArgumentException( "Only floating point positions are supported" );
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException( "Vertex format " + format + " has no position attribute!" );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package appeng.client.render.cablebus;
|
||||
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
|
||||
/**
|
||||
* Manages the channel textures for smart cables.
|
||||
*/
|
||||
public class SmartCableTextures
|
||||
{
|
||||
|
||||
public static final ResourceLocation[] SMART_CHANNELS_TEXTURES = {
|
||||
new ResourceLocation( AppEng.MOD_ID, "parts/cable/smart/channels_00" ),
|
||||
new ResourceLocation( AppEng.MOD_ID, "parts/cable/smart/channels_01" ),
|
||||
new ResourceLocation( AppEng.MOD_ID, "parts/cable/smart/channels_02" ),
|
||||
new ResourceLocation( AppEng.MOD_ID, "parts/cable/smart/channels_03" ),
|
||||
new ResourceLocation( AppEng.MOD_ID, "parts/cable/smart/channels_04" ),
|
||||
new ResourceLocation( AppEng.MOD_ID, "parts/cable/smart/channels_10" ),
|
||||
new ResourceLocation( AppEng.MOD_ID, "parts/cable/smart/channels_11" ),
|
||||
new ResourceLocation( AppEng.MOD_ID, "parts/cable/smart/channels_12" ),
|
||||
new ResourceLocation( AppEng.MOD_ID, "parts/cable/smart/channels_13" ),
|
||||
new ResourceLocation( AppEng.MOD_ID, "parts/cable/smart/channels_14" )
|
||||
};
|
||||
|
||||
// Textures used to display channels on smart cables. There's two sets of 5 textures each, and
|
||||
// one of each set are composed together to get even/odd colored channels
|
||||
private final TextureAtlasSprite[] textures;
|
||||
|
||||
public SmartCableTextures( Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
textures = Arrays.stream( SMART_CHANNELS_TEXTURES )
|
||||
.map( bakedTextureGetter::apply )
|
||||
.toArray( TextureAtlasSprite[]::new );
|
||||
}
|
||||
|
||||
/**
|
||||
* The odd variant is used for displaying channels 1-4 as in use.
|
||||
*/
|
||||
public TextureAtlasSprite getOddTextureForChannels( int channels )
|
||||
{
|
||||
if( channels < 0 )
|
||||
{
|
||||
return textures[0];
|
||||
}
|
||||
else if( channels <= 4 )
|
||||
{
|
||||
return textures[channels];
|
||||
}
|
||||
else
|
||||
{
|
||||
return textures[4];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The odd variant is used for displaying channels 5-8 as in use.
|
||||
*/
|
||||
public TextureAtlasSprite getEvenTextureForChannels( int channels )
|
||||
{
|
||||
if( channels < 5 )
|
||||
{
|
||||
return textures[5];
|
||||
}
|
||||
else if( channels <= 9 )
|
||||
{
|
||||
return textures[channels];
|
||||
}
|
||||
else
|
||||
{
|
||||
return textures[9];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package appeng.client.render.model;
|
||||
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
|
||||
/**
|
||||
* Used as the cache key for caching automatically rotated baked models.
|
||||
*/
|
||||
final class AutoRotatingCacheKey
|
||||
{
|
||||
private final IBlockState blockState;
|
||||
private final EnumFacing forward;
|
||||
private final EnumFacing up;
|
||||
private final EnumFacing side;
|
||||
|
||||
AutoRotatingCacheKey( IBlockState blockState, EnumFacing forward, EnumFacing up, EnumFacing side )
|
||||
{
|
||||
this.blockState = blockState;
|
||||
this.forward = forward;
|
||||
this.up = up;
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
public IBlockState getBlockState()
|
||||
{
|
||||
return blockState;
|
||||
}
|
||||
|
||||
public EnumFacing getForward()
|
||||
{
|
||||
return forward;
|
||||
}
|
||||
|
||||
public EnumFacing getUp()
|
||||
{
|
||||
return up;
|
||||
}
|
||||
|
||||
public EnumFacing getSide()
|
||||
{
|
||||
return side;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( Object o )
|
||||
{
|
||||
if( this == o )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if( o == null || getClass() != o.getClass() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
AutoRotatingCacheKey cacheKey = (AutoRotatingCacheKey) o;
|
||||
return blockState.equals( cacheKey.blockState ) && forward == cacheKey.forward && up == cacheKey.up && side == cacheKey.side;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int result = blockState.hashCode();
|
||||
result = 31 * result + forward.hashCode();
|
||||
result = 31 * result + up.hashCode();
|
||||
result = 31 * result + ( side != null ? side.hashCode() : 0 );
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
|
||||
package appeng.client.render.model;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.vecmath.Vector3f;
|
||||
import javax.vecmath.Vector4f;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraftforge.client.model.pipeline.IVertexConsumer;
|
||||
import net.minecraftforge.client.model.pipeline.QuadGatheringTransformer;
|
||||
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.FacingToRotation;
|
||||
|
||||
|
||||
public class AutoRotatingModel implements IBakedModel
|
||||
{
|
||||
|
||||
private final IBakedModel parent;
|
||||
private final LoadingCache<AutoRotatingCacheKey, List<BakedQuad>> quadCache;
|
||||
|
||||
public AutoRotatingModel( IBakedModel parent )
|
||||
{
|
||||
this.parent = parent;
|
||||
// 6 (DUNSWE) * 6 (DUNSWE) * 7 (DUNSWE + null) = 252
|
||||
this.quadCache = CacheBuilder.newBuilder().maximumSize( 252 ).build( new CacheLoader<AutoRotatingCacheKey, List<BakedQuad>>()
|
||||
{
|
||||
@Override
|
||||
public List<BakedQuad> load( AutoRotatingCacheKey key ) throws Exception
|
||||
{
|
||||
return getRotatedModel( key.getBlockState(), key.getSide(), key.getForward(), key.getUp() );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private List<BakedQuad> getRotatedModel( IBlockState state, EnumFacing side, EnumFacing forward, EnumFacing up )
|
||||
{
|
||||
FacingToRotation f2r = FacingToRotation.get( forward, up );
|
||||
List<BakedQuad> original = AutoRotatingModel.this.parent.getQuads( state, f2r.resultingRotate( side ), 0 );
|
||||
List<BakedQuad> rotated = new ArrayList<>( original.size() );
|
||||
for( BakedQuad quad : original )
|
||||
{
|
||||
VertexFormat format = quad.getFormat();
|
||||
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder( format );
|
||||
VertexRotator rot = new VertexRotator( f2r, quad.getFace() );
|
||||
rot.setParent( builder );
|
||||
quad.pipe( rot );
|
||||
builder.setQuadOrientation( f2r.rotate( quad.getFace() ) );
|
||||
BakedQuad q = builder.build();
|
||||
rotated.add( q );
|
||||
}
|
||||
return rotated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
{
|
||||
return parent.isAmbientOcclusion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d()
|
||||
{
|
||||
return parent.isGui3d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
return parent.isBuiltInRenderer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
return parent.getParticleTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
{
|
||||
return parent.getItemCameraTransforms();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return parent.getOverrides();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
if( !( state instanceof IExtendedBlockState ) )
|
||||
{
|
||||
return parent.getQuads( state, side, rand );
|
||||
}
|
||||
|
||||
IExtendedBlockState extState = (IExtendedBlockState) state;
|
||||
|
||||
EnumFacing forward = extState.getValue( AEBaseTileBlock.FORWARD );
|
||||
EnumFacing up = extState.getValue( AEBaseTileBlock.UP );
|
||||
|
||||
if( forward == null || up == null )
|
||||
{
|
||||
return parent.getQuads( state, side, rand );
|
||||
}
|
||||
|
||||
// The model has other properties than just forward/up, so it would cause our cache to inadvertendly also cache these
|
||||
// additional states, possibly leading to huge isseus if the other extended state properties do not implement equals/hashCode correctly
|
||||
if( extState.getUnlistedProperties().size() != 2 )
|
||||
{
|
||||
return getRotatedModel( extState, side, forward, up );
|
||||
}
|
||||
|
||||
AutoRotatingCacheKey key = new AutoRotatingCacheKey( extState.getClean(), forward, up, side );
|
||||
|
||||
return quadCache.getUnchecked( key );
|
||||
}
|
||||
|
||||
public static class VertexRotator extends QuadGatheringTransformer
|
||||
{
|
||||
private final FacingToRotation f2r;
|
||||
private final EnumFacing face;
|
||||
|
||||
public VertexRotator( FacingToRotation f2r, EnumFacing face )
|
||||
{
|
||||
this.f2r = f2r;
|
||||
this.face = face;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParent( IVertexConsumer parent )
|
||||
{
|
||||
super.setParent( parent );
|
||||
if( Objects.equal( getVertexFormat(), parent.getVertexFormat() ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
setVertexFormat( parent.getVertexFormat() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processQuad()
|
||||
{
|
||||
VertexFormat format = parent.getVertexFormat();
|
||||
int count = format.getElementCount();
|
||||
|
||||
for( int v = 0; v < 4; v++ )
|
||||
{
|
||||
for( int e = 0; e < count; e++ )
|
||||
{
|
||||
VertexFormatElement element = format.getElement( e );
|
||||
if( element.getUsage() == VertexFormatElement.EnumUsage.POSITION )
|
||||
{
|
||||
parent.put( e, transform( quadData[e][v] ) );
|
||||
}
|
||||
else if( element.getUsage() == VertexFormatElement.EnumUsage.NORMAL )
|
||||
{
|
||||
parent.put( e, transformNormal( quadData[e][v] ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
parent.put( e, quadData[e][v] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float[] transform( float[] fs )
|
||||
{
|
||||
switch( fs.length )
|
||||
{
|
||||
case 3:
|
||||
Vector3f vec = new Vector3f( fs[0], fs[1], fs[2] );
|
||||
vec.x -= 0.5f;
|
||||
vec.y -= 0.5f;
|
||||
vec.z -= 0.5f;
|
||||
f2r.getMat().transform( vec );
|
||||
vec.x += 0.5f;
|
||||
vec.y += 0.5f;
|
||||
vec.z += 0.5f;
|
||||
return new float[] {
|
||||
vec.x,
|
||||
vec.y,
|
||||
vec.z
|
||||
};
|
||||
case 4:
|
||||
Vector4f vecc = new Vector4f( fs[0], fs[1], fs[2], fs[3] );
|
||||
vecc.x -= 0.5f;
|
||||
vecc.y -= 0.5f;
|
||||
vecc.z -= 0.5f;
|
||||
f2r.getMat().transform( vecc );
|
||||
vecc.x += 0.5f;
|
||||
vecc.y += 0.5f;
|
||||
vecc.z += 0.5f;
|
||||
return new float[] {
|
||||
vecc.x,
|
||||
vecc.y,
|
||||
vecc.z,
|
||||
vecc.w
|
||||
};
|
||||
|
||||
default:
|
||||
return fs;
|
||||
}
|
||||
}
|
||||
|
||||
private float[] transformNormal( float[] fs )
|
||||
{
|
||||
switch( fs.length )
|
||||
{
|
||||
case 3:
|
||||
Vec3i vec = f2r.rotate( face ).getDirectionVec();
|
||||
return new float[] {
|
||||
vec.getX(),
|
||||
vec.getY(),
|
||||
vec.getZ()
|
||||
};
|
||||
case 4:
|
||||
Vector4f veccc = new Vector4f( fs[0], fs[1], fs[2], fs[3] );
|
||||
Vec3i vecc = f2r.rotate( face ).getDirectionVec();
|
||||
return new float[] {
|
||||
vecc.getX(),
|
||||
vecc.getY(),
|
||||
vecc.getZ(),
|
||||
veccc.w
|
||||
};
|
||||
|
||||
default:
|
||||
return fs;
|
||||
}
|
||||
}
|
||||
|
||||
public void setQuadTint( int tint )
|
||||
{
|
||||
parent.setQuadTint( tint );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQuadOrientation( EnumFacing orientation )
|
||||
{
|
||||
parent.setQuadOrientation( orientation );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplyDiffuseLighting( boolean diffuse )
|
||||
{
|
||||
parent.setApplyDiffuseLighting( diffuse );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTexture( TextureAtlasSprite texture )
|
||||
{
|
||||
parent.setTexture( texture );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
|
||||
package appeng.client.render.model;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import appeng.api.client.BakingPipeline;
|
||||
import appeng.client.render.model.pipeline.DoubleFacingQuadRotator;
|
||||
import appeng.client.render.model.pipeline.ParentQuads;
|
||||
import appeng.client.render.model.pipeline.TypeTransformer;
|
||||
|
||||
|
||||
public class CachingRotatingBakedModel implements IBakedModel
|
||||
{
|
||||
|
||||
private static final BakingPipeline<Void, BakedQuad> pipeline = new BakingPipeline<>( new ParentQuads(), TypeTransformer.quads2vecs, new DoubleFacingQuadRotator(), TypeTransformer.vecs2quads );
|
||||
private final IBakedModel parent;
|
||||
private final LoadingCache<Pair<IBlockState, EnumFacing>, List<BakedQuad>> quadCache;
|
||||
|
||||
public CachingRotatingBakedModel( IBakedModel parent )
|
||||
{
|
||||
this.parent = parent;
|
||||
// 6 (DUNSWE) * 6 (DUNSWE) * 7 (DUNSWE + null) = 252
|
||||
this.quadCache = CacheBuilder.newBuilder().maximumSize( 252 ).build( new CacheLoader<Pair<IBlockState, EnumFacing>, List<BakedQuad>>(){
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> load( Pair<IBlockState, EnumFacing> key ) throws Exception
|
||||
{
|
||||
return pipeline.pipe( null, parent, key.getLeft(), key.getRight(), 0 );
|
||||
}
|
||||
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
{
|
||||
return parent.isAmbientOcclusion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d()
|
||||
{
|
||||
return parent.isGui3d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
return parent.isBuiltInRenderer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
return parent.getParticleTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
{
|
||||
return parent.getItemCameraTransforms();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return parent.getOverrides();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
if( state == null )
|
||||
{
|
||||
return parent.getQuads( state, side, rand );
|
||||
}
|
||||
return quadCache.getUnchecked( new ImmutablePair<IBlockState, EnumFacing>( state, side ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
/*
|
||||
* 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.client.render.model;
|
||||
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
|
||||
|
||||
public class ModelCompass extends ModelBase
|
||||
{
|
||||
|
||||
private final ModelRenderer Ring1;
|
||||
private final ModelRenderer Ring2;
|
||||
private final ModelRenderer Ring3;
|
||||
private final ModelRenderer Ring4;
|
||||
private final ModelRenderer Middle;
|
||||
private final ModelRenderer Base;
|
||||
|
||||
private final ModelRenderer Pointer;
|
||||
|
||||
public ModelCompass()
|
||||
{
|
||||
this.textureWidth = 16;
|
||||
this.textureHeight = 8;
|
||||
|
||||
this.Ring1 = new ModelRenderer( this, 0, 0 );
|
||||
this.Ring1.addBox( 0F, 0F, 0F, 4, 1, 1 );
|
||||
this.Ring1.setRotationPoint( -2F, 22F, 2F );
|
||||
this.Ring1.setTextureSize( 16, 8 );
|
||||
this.Ring1.mirror = true;
|
||||
this.setRotation( this.Ring1, 0F, 0F, 0F );
|
||||
|
||||
this.Ring2 = new ModelRenderer( this, 0, 0 );
|
||||
this.Ring2.addBox( 0F, 0F, 0F, 1, 1, 4 );
|
||||
this.Ring2.setRotationPoint( -3F, 22F, -2F );
|
||||
this.Ring2.setTextureSize( 16, 8 );
|
||||
this.Ring2.mirror = true;
|
||||
this.setRotation( this.Ring2, 0F, 0F, 0F );
|
||||
|
||||
this.Ring3 = new ModelRenderer( this, 0, 0 );
|
||||
this.Ring3.addBox( 0F, 0F, 0F, 4, 1, 1 );
|
||||
this.Ring3.setRotationPoint( -2F, 22F, -3F );
|
||||
this.Ring3.setTextureSize( 16, 8 );
|
||||
this.Ring3.mirror = true;
|
||||
this.setRotation( this.Ring3, 0F, 0F, 0F );
|
||||
|
||||
this.Ring4 = new ModelRenderer( this, 0, 0 );
|
||||
this.Ring4.addBox( 0F, 0F, 0F, 1, 1, 4 );
|
||||
this.Ring4.setRotationPoint( 2F, 22F, -2F );
|
||||
this.Ring4.setTextureSize( 16, 8 );
|
||||
this.Ring4.mirror = true;
|
||||
this.setRotation( this.Ring4, 0F, 0F, 0F );
|
||||
|
||||
this.Middle = new ModelRenderer( this, 0, 0 );
|
||||
this.Middle.addBox( 0F, 0F, 0F, 1, 1, 1 );
|
||||
this.Middle.setRotationPoint( -0.5333334F, 22F, -0.5333334F );
|
||||
this.Middle.setTextureSize( 16, 8 );
|
||||
this.Middle.mirror = true;
|
||||
this.setRotation( this.Middle, 0F, 0F, 0F );
|
||||
|
||||
this.Pointer = new ModelRenderer( this, 0, 0 );
|
||||
this.Pointer.setTextureOffset( 0, 5 );
|
||||
this.Pointer.addBox( -0.5F, 0F, 0F, 1, 1, 2 );
|
||||
this.Pointer.setRotationPoint( 0.5F, 22.5F, 0.5F );
|
||||
this.Pointer.setTextureSize( 16, 8 );
|
||||
this.Pointer.mirror = true;
|
||||
this.Pointer.offsetZ = -0.034f;
|
||||
this.Pointer.offsetX = -0.034f;
|
||||
this.setRotation( this.Pointer, 0F, 0F, 0F );
|
||||
|
||||
this.Base = new ModelRenderer( this, 0, 0 );
|
||||
this.Base.addBox( 0F, 0F, 0F, 4, 1, 4 );
|
||||
this.Base.setRotationPoint( -2F, 23F, -2F );
|
||||
this.Base.setTextureSize( 16, 8 );
|
||||
this.Base.mirror = true;
|
||||
this.setRotation( this.Base, 0F, 0F, 0F );
|
||||
}
|
||||
|
||||
private void setRotation( final ModelRenderer model, final float x, final float y, final float z )
|
||||
{
|
||||
model.rotateAngleX = x;
|
||||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
public void renderAll( final float rad )
|
||||
{
|
||||
this.setRotation( this.Pointer, 0F, 0F, 0F );
|
||||
|
||||
this.Pointer.rotateAngleY = rad;
|
||||
|
||||
this.Base.render( 0.0625F );
|
||||
this.Middle.render( 0.0625F );
|
||||
|
||||
this.Pointer.render( 0.0625F );
|
||||
|
||||
this.Ring1.render( 0.0625F );
|
||||
this.Ring2.render( 0.0625F );
|
||||
this.Ring3.render( 0.0625F );
|
||||
this.Ring4.render( 0.0625F );
|
||||
}
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
|
||||
package appeng.client.render.model;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
|
||||
|
||||
public enum ModelsCache implements IResourceManagerReloadListener
|
||||
{
|
||||
|
||||
INSTANCE;
|
||||
|
||||
public static final IModelState DEFAULTMODELSTATE = opt -> Optional.absent();
|
||||
public static final VertexFormat DEFAULTVERTEXFORMAT = DefaultVertexFormats.BLOCK;
|
||||
public static final Function<ResourceLocation, TextureAtlasSprite> DEFAULTTEXTUREGETTER = texture -> Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite( texture.toString() );
|
||||
|
||||
private final Map<ResourceLocation, IModel> cache = new HashMap<>();
|
||||
private final Map<ResourceLocation, IBakedModel> bakedCache = new HashMap<>();
|
||||
|
||||
public IModel getOrLoadModel( ResourceLocation location )
|
||||
{
|
||||
IModel model = cache.get( location );
|
||||
if( model == null )
|
||||
{
|
||||
try
|
||||
{
|
||||
model = ModelLoaderRegistry.getModel( location );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// TODO 1.10.2-R - log this in pretty way
|
||||
e.printStackTrace();
|
||||
model = ModelLoaderRegistry.getMissingModel();
|
||||
}
|
||||
cache.put( location, model );
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
public IBakedModel getModel( ResourceLocation key )
|
||||
{
|
||||
return bakedCache.get( key );
|
||||
}
|
||||
|
||||
public IBakedModel getOrLoadModel( ResourceLocation key, ResourceLocation location, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> textureGetter )
|
||||
{
|
||||
IBakedModel model = getModel( key );
|
||||
if( model == null )
|
||||
{
|
||||
model = getOrLoadModel( location ).bake( state, format, textureGetter );
|
||||
bakedCache.put( key, model );
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
public IBakedModel getOrLoadModel( ResourceLocation key, ResourceLocation location, IModelState state, VertexFormat format )
|
||||
{
|
||||
return getOrLoadModel( key, location, state, format, DEFAULTTEXTUREGETTER );
|
||||
}
|
||||
|
||||
public IBakedModel getOrLoadModel( ResourceLocation key, ResourceLocation location, IModelState state, Function<ResourceLocation, TextureAtlasSprite> textureGetter )
|
||||
{
|
||||
return getOrLoadModel( key, location, state, DEFAULTVERTEXFORMAT, textureGetter );
|
||||
}
|
||||
|
||||
public IBakedModel getOrLoadModel( ResourceLocation key, ResourceLocation location, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> textureGetter )
|
||||
{
|
||||
return getOrLoadModel( key, location, DEFAULTMODELSTATE, format, textureGetter );
|
||||
}
|
||||
|
||||
public IBakedModel getOrLoadModel( ResourceLocation key, ResourceLocation location, IModelState state )
|
||||
{
|
||||
return getOrLoadModel( key, location, state, DEFAULTVERTEXFORMAT, DEFAULTTEXTUREGETTER );
|
||||
}
|
||||
|
||||
public IBakedModel getOrLoadModel( ResourceLocation key, ResourceLocation location, VertexFormat format )
|
||||
{
|
||||
return getOrLoadModel( key, location, DEFAULTMODELSTATE, format, DEFAULTTEXTUREGETTER );
|
||||
}
|
||||
|
||||
public IBakedModel getOrLoadModel( ResourceLocation key, ResourceLocation location, Function<ResourceLocation, TextureAtlasSprite> textureGetter )
|
||||
{
|
||||
return getOrLoadModel( key, location, DEFAULTMODELSTATE, DEFAULTVERTEXFORMAT, textureGetter );
|
||||
}
|
||||
|
||||
public IBakedModel getOrLoadModel( ResourceLocation key, ResourceLocation location )
|
||||
{
|
||||
return getOrLoadModel( key, location, DEFAULTMODELSTATE, DEFAULTVERTEXFORMAT, DEFAULTTEXTUREGETTER );
|
||||
}
|
||||
|
||||
public IBakedModel getOrLoadBakedModel( ResourceLocation location )
|
||||
{
|
||||
return getOrLoadModel( location, location, DEFAULTMODELSTATE, DEFAULTVERTEXFORMAT, DEFAULTTEXTUREGETTER );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload( IResourceManager resourceManager )
|
||||
{
|
||||
cache.clear();
|
||||
bakedCache.clear();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,7 +27,7 @@ import com.google.common.collect.Lists;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
|
||||
// TODO: Investigate use of CubeBuilder instead
|
||||
final class RenderHelper
|
||||
{
|
||||
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
|
||||
package appeng.client.render.model.pipeline;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import appeng.api.client.BakingPipeline;
|
||||
import appeng.api.client.BakingPipelineElement;
|
||||
|
||||
|
||||
public class BakingPipelineBakedModel extends BakingPipeline implements IBakedModel
|
||||
{
|
||||
|
||||
private final IBakedModel parent;
|
||||
public BakingPipelineBakedModel( IBakedModel parent, BakingPipelineElement<?, ?>... pipeline )
|
||||
{
|
||||
super( pipeline );
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
return pipe( new ArrayList(), parent, state, side, rand );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
{
|
||||
return parent.isAmbientOcclusion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d()
|
||||
{
|
||||
return parent.isGui3d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
return parent.isBuiltInRenderer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
return parent.getParticleTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
{
|
||||
return parent.getItemCameraTransforms();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return parent.getOverrides();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
|
||||
package appeng.client.render.model.pipeline;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.vecmath.Vector3f;
|
||||
import javax.vecmath.Vector4f;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import appeng.api.client.BakingPipelineElement;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.FacingToRotation;
|
||||
|
||||
|
||||
public class DoubleFacingQuadRotator implements BakingPipelineElement<QuadVertexData, QuadVertexData>
|
||||
{
|
||||
|
||||
@Override
|
||||
public List<QuadVertexData> pipe( List<QuadVertexData> elements, IBakedModel parent, IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
if( state != null )
|
||||
{
|
||||
IExtendedBlockState extState = (IExtendedBlockState) state;
|
||||
|
||||
EnumFacing forward = extState.getValue( AEBaseTileBlock.FORWARD );
|
||||
if( forward == null )
|
||||
{
|
||||
forward = EnumFacing.NORTH;
|
||||
}
|
||||
EnumFacing up = extState.getValue( AEBaseTileBlock.UP );
|
||||
if( up == null )
|
||||
{
|
||||
up = EnumFacing.UP;
|
||||
}
|
||||
final FacingToRotation f2r = FacingToRotation.get( forward, up );
|
||||
List<QuadVertexData> rotated = new ArrayList<>();
|
||||
for( QuadVertexData data : elements )
|
||||
{
|
||||
data.setFace( f2r.rotate( data.getFace() ) );
|
||||
float[][][] qd = data.getData();
|
||||
for( int v = 0; v < 4; v++ )
|
||||
{
|
||||
for( int e = 0; e < data.getFormat().getElementCount(); e++ )
|
||||
{
|
||||
VertexFormatElement element = data.getFormat().getElement( e );
|
||||
if( element.getUsage() == VertexFormatElement.EnumUsage.POSITION )
|
||||
{
|
||||
qd[v][e] = transform( f2r, qd[v][e] );
|
||||
}
|
||||
else if( element.getUsage() == VertexFormatElement.EnumUsage.NORMAL )
|
||||
{
|
||||
qd[v][e] = transformNormal( f2r, qd[v][e] );
|
||||
}
|
||||
}
|
||||
}
|
||||
rotated.add( new QuadVertexData( data.getFormat(), qd, data.getTintIndex(), data.getFace(), data.getSprite(), data.shouldApplyDiffuseLighting() ) );
|
||||
}
|
||||
return rotated;
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
private float[] transform( FacingToRotation f2r, float[] fs )
|
||||
{
|
||||
switch( fs.length )
|
||||
{
|
||||
case 3:
|
||||
Vector3f vec = new Vector3f( fs[0], fs[1], fs[2] );
|
||||
vec.x -= 0.5f;
|
||||
vec.y -= 0.5f;
|
||||
vec.z -= 0.5f;
|
||||
f2r.getMat().transform( vec );
|
||||
vec.x += 0.5f;
|
||||
vec.y += 0.5f;
|
||||
vec.z += 0.5f;
|
||||
return new float[] { vec.x, vec.y, vec.z };
|
||||
case 4:
|
||||
Vector4f vecc = new Vector4f( fs[0], fs[1], fs[2], fs[3] );
|
||||
vecc.x -= 0.5f;
|
||||
vecc.y -= 0.5f;
|
||||
vecc.z -= 0.5f;
|
||||
f2r.getMat().transform( vecc );
|
||||
vecc.x += 0.5f;
|
||||
vecc.y += 0.5f;
|
||||
vecc.z += 0.5f;
|
||||
return new float[] { vecc.x, vecc.y, vecc.z, vecc.w };
|
||||
|
||||
default:
|
||||
return fs;
|
||||
}
|
||||
}
|
||||
|
||||
private float[] transformNormal( FacingToRotation f2r, float[] fs )
|
||||
{
|
||||
switch( fs.length )
|
||||
{
|
||||
case 3:
|
||||
Vector3f vec = new Vector3f( fs[0], fs[1], fs[2] );
|
||||
f2r.getMat().transform( vec );
|
||||
return new float[] { vec.x, vec.y, vec.z };
|
||||
case 4:
|
||||
Vector4f vecc = new Vector4f( fs[0], fs[1], fs[2], fs[3] );
|
||||
f2r.getMat().transform( vecc );
|
||||
return new float[] { vecc.x, vecc.y, vecc.z, vecc.w };
|
||||
|
||||
default:
|
||||
return fs;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
|
||||
package appeng.client.render.model.pipeline;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
|
||||
public class FacingQuadRotator extends MatVecApplicator
|
||||
{
|
||||
|
||||
private EnumFacing override;
|
||||
|
||||
public FacingQuadRotator( EnumFacing override )
|
||||
{
|
||||
super( TRSRTransformation.getMatrix( override ) );
|
||||
this.override = override;
|
||||
}
|
||||
|
||||
public FacingQuadRotator()
|
||||
{
|
||||
this.override = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QuadVertexData> pipe( List<QuadVertexData> elements, IBakedModel parent, IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
if( override == null )
|
||||
{
|
||||
setMatrix( TRSRTransformation.getMatrix( side ) );
|
||||
}
|
||||
return super.pipe( elements, parent, state, side, rand );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
|
||||
package appeng.client.render.model.pipeline;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Vector3f;
|
||||
import javax.vecmath.Vector4f;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
import appeng.api.client.BakingPipelineElement;
|
||||
|
||||
|
||||
public class MatVecApplicator implements BakingPipelineElement<QuadVertexData, QuadVertexData>
|
||||
{
|
||||
|
||||
private Matrix4f matrix;
|
||||
private boolean forceTranslate;
|
||||
|
||||
public MatVecApplicator( Matrix4f matrix, boolean forceTranslate )
|
||||
{
|
||||
this.matrix = matrix;
|
||||
this.forceTranslate = forceTranslate;
|
||||
}
|
||||
|
||||
public MatVecApplicator( Matrix4f matrix )
|
||||
{
|
||||
this( matrix, false );
|
||||
}
|
||||
|
||||
public MatVecApplicator()
|
||||
{
|
||||
this( new Matrix4f() );
|
||||
}
|
||||
|
||||
public Matrix4f getMatrix()
|
||||
{
|
||||
return matrix;
|
||||
}
|
||||
|
||||
public void setMatrix( Matrix4f matrix )
|
||||
{
|
||||
this.matrix = matrix;
|
||||
}
|
||||
|
||||
public boolean forceTranslate()
|
||||
{
|
||||
return forceTranslate;
|
||||
}
|
||||
|
||||
public void setForceTranslate( boolean forceTranslate )
|
||||
{
|
||||
this.forceTranslate = forceTranslate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QuadVertexData> pipe( List<QuadVertexData> elements, IBakedModel parent, IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
List<QuadVertexData> rotated = new ArrayList();
|
||||
for( QuadVertexData data : elements )
|
||||
{
|
||||
float[][][] qd = data.getData();
|
||||
data.setFace( side != null ? TRSRTransformation.rotate( matrix, side ) : side );
|
||||
for( int v = 0; v < 4; v++ )
|
||||
{
|
||||
for( int e = 0; e < data.getFormat().getElementCount(); e++ )
|
||||
{
|
||||
VertexFormatElement element = data.getFormat().getElement( e );
|
||||
if( element.getUsage() == VertexFormatElement.EnumUsage.POSITION )
|
||||
{
|
||||
qd[v][e] = transform( qd[v][e] );
|
||||
}
|
||||
else if( element.getUsage() == VertexFormatElement.EnumUsage.NORMAL )
|
||||
{
|
||||
qd[v][e] = transformNormal( qd[v][e] );
|
||||
}
|
||||
}
|
||||
}
|
||||
rotated.add( new QuadVertexData( data.getFormat(), qd, data.getTintIndex(), data.getFace(), data.getSprite(), data.shouldApplyDiffuseLighting() ) );
|
||||
}
|
||||
return rotated;
|
||||
}
|
||||
|
||||
private float[] transform( float[] fs )
|
||||
{
|
||||
switch( fs.length )
|
||||
{
|
||||
case 3:
|
||||
Vector4f vec = new Vector4f( fs[0], fs[1], fs[2], forceTranslate ? 1 : 0 );
|
||||
vec.x -= 0.5f;
|
||||
vec.y -= 0.5f;
|
||||
vec.z -= 0.5f;
|
||||
this.matrix.transform( vec );
|
||||
vec.x += 0.5f;
|
||||
vec.y += 0.5f;
|
||||
vec.z += 0.5f;
|
||||
return new float[] { vec.x, vec.y, vec.z };
|
||||
case 4:
|
||||
Vector4f vecc = new Vector4f( fs[0], fs[1], fs[2], forceTranslate ? 1 : fs[3] );
|
||||
vecc.x -= 0.5f;
|
||||
vecc.y -= 0.5f;
|
||||
vecc.z -= 0.5f;
|
||||
this.matrix.transform( vecc );
|
||||
vecc.x += 0.5f;
|
||||
vecc.y += 0.5f;
|
||||
vecc.z += 0.5f;
|
||||
return new float[] { vecc.x, vecc.y, vecc.z, vecc.w };
|
||||
|
||||
default:
|
||||
return fs;
|
||||
}
|
||||
}
|
||||
|
||||
private float[] transformNormal( float[] fs )
|
||||
{
|
||||
switch( fs.length )
|
||||
{
|
||||
case 3:
|
||||
Vector3f vec = new Vector3f( fs[0], fs[1], fs[2] );
|
||||
this.matrix.transform( vec );
|
||||
vec.normalize();
|
||||
return new float[] { vec.x, vec.y, vec.z };
|
||||
case 4:
|
||||
Vector4f vecc = new Vector4f( fs[0], fs[1], fs[2], fs[3] );
|
||||
this.matrix.transform( vecc );
|
||||
vecc.normalize();
|
||||
return new float[] { vecc.x, vecc.y, vecc.z, vecc.w };
|
||||
|
||||
default:
|
||||
return fs;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
|
||||
package appeng.client.render.model.pipeline;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import appeng.api.client.BakingPipelineElement;
|
||||
|
||||
|
||||
public class Merge<F, T> implements BakingPipelineElement<F, T>
|
||||
{
|
||||
|
||||
private final ImmutableList<BakingPipelineElement<?, ?>> pipeline;
|
||||
|
||||
public Merge( BakingPipelineElement<?, ?>... pipeline )
|
||||
{
|
||||
this.pipeline = ImmutableList.copyOf( pipeline );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List pipe( List elements, IBakedModel parent, IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
for( BakingPipelineElement<?, ?> element : pipeline )
|
||||
{
|
||||
elements.addAll( element.pipe( new ArrayList<>(), parent, state, side, rand ) );
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package appeng.client.render.model.pipeline;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import appeng.api.client.BakingPipelineElement;
|
||||
|
||||
public class ParentQuads implements BakingPipelineElement<Void, BakedQuad>
|
||||
{
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> pipe( List<Void> elements, IBakedModel parent, IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
return parent.getQuads( state, side, rand );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
|
||||
package appeng.client.render.model.pipeline;
|
||||
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
|
||||
|
||||
public final class QuadVertexData
|
||||
{
|
||||
|
||||
private static final Field unpackedData = ReflectionHelper.findField( UnpackedBakedQuad.class, "unpackedData" );
|
||||
|
||||
private static float[][][] unpackedData( UnpackedBakedQuad quad )
|
||||
{
|
||||
try
|
||||
{
|
||||
return (float[][][]) unpackedData.get( quad );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
throw Throwables.propagate( e );
|
||||
}
|
||||
}
|
||||
|
||||
private VertexFormat format;
|
||||
private float[][][] data;
|
||||
|
||||
private int tintIndex;
|
||||
private EnumFacing face;
|
||||
private TextureAtlasSprite sprite;
|
||||
protected boolean applyDiffuseLighting;
|
||||
|
||||
public QuadVertexData( VertexFormat format, float[][][] data, int tintIndex, EnumFacing face, TextureAtlasSprite sprite, boolean applyDiffuseLighting )
|
||||
{
|
||||
this.format = format;
|
||||
this.data = data;
|
||||
this.tintIndex = tintIndex;
|
||||
this.face = face;
|
||||
this.sprite = sprite;
|
||||
this.applyDiffuseLighting = applyDiffuseLighting;
|
||||
}
|
||||
|
||||
public QuadVertexData( UnpackedBakedQuad quad )
|
||||
{
|
||||
this( quad.getFormat(), unpackedData( quad ), quad.getTintIndex(), quad.getFace(), quad.getSprite(), quad.shouldApplyDiffuseLighting() );
|
||||
}
|
||||
|
||||
public UnpackedBakedQuad toQuad()
|
||||
{
|
||||
return new UnpackedBakedQuad( data, tintIndex, face, sprite, applyDiffuseLighting, format );
|
||||
}
|
||||
|
||||
public VertexFormat getFormat()
|
||||
{
|
||||
return format;
|
||||
}
|
||||
|
||||
public void setFormat( VertexFormat format )
|
||||
{
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public float[][][] getData()
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData( float[][][] data )
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public int getTintIndex()
|
||||
{
|
||||
return tintIndex;
|
||||
}
|
||||
|
||||
public void setTintIndex( int tintIndex )
|
||||
{
|
||||
this.tintIndex = tintIndex;
|
||||
}
|
||||
|
||||
public EnumFacing getFace()
|
||||
{
|
||||
return face;
|
||||
}
|
||||
|
||||
public void setFace( EnumFacing face )
|
||||
{
|
||||
this.face = face;
|
||||
}
|
||||
|
||||
public TextureAtlasSprite getSprite()
|
||||
{
|
||||
return sprite;
|
||||
}
|
||||
|
||||
public void setSprite( TextureAtlasSprite sprite )
|
||||
{
|
||||
this.sprite = sprite;
|
||||
}
|
||||
|
||||
public boolean shouldApplyDiffuseLighting()
|
||||
{
|
||||
return applyDiffuseLighting;
|
||||
}
|
||||
|
||||
public void setApplyDiffuseLighting( boolean applyDiffuseLighting )
|
||||
{
|
||||
this.applyDiffuseLighting = applyDiffuseLighting;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
|
||||
package appeng.client.render.model.pipeline;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import appeng.api.client.BakingPipelineElement;
|
||||
|
||||
|
||||
public class StatePosRecolorator implements BakingPipelineElement<QuadVertexData, QuadVertexData>
|
||||
{
|
||||
|
||||
private IBlockAccess blockAccess;
|
||||
private BlockPos pos;
|
||||
private IBlockState state;
|
||||
|
||||
public StatePosRecolorator( IBlockAccess blockAccess, BlockPos pos, IBlockState state )
|
||||
{
|
||||
this.blockAccess = blockAccess;
|
||||
this.pos = pos;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public IBlockAccess getBlockAccess()
|
||||
{
|
||||
return blockAccess;
|
||||
}
|
||||
|
||||
public void setBlockAccess( IBlockAccess blockAccess )
|
||||
{
|
||||
this.blockAccess = blockAccess;
|
||||
}
|
||||
|
||||
public BlockPos getPos()
|
||||
{
|
||||
return pos;
|
||||
}
|
||||
|
||||
public void setPos( BlockPos pos )
|
||||
{
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
public IBlockState getState()
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState( IBlockState state )
|
||||
{
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QuadVertexData> pipe( List<QuadVertexData> elements, IBakedModel parent, IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
for( QuadVertexData data : elements )
|
||||
{
|
||||
data.setTintIndex( Minecraft.getMinecraft().getBlockColors().colorMultiplier( this.state, blockAccess, this.pos, data.getTintIndex() ) );
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
|
||||
package appeng.client.render.model.pipeline;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import appeng.api.client.BakingPipelineElement;
|
||||
|
||||
|
||||
public class TintIndexModifier implements BakingPipelineElement<QuadVertexData, QuadVertexData>
|
||||
{
|
||||
|
||||
private Function<Integer, Integer> tintTransformer;
|
||||
|
||||
public TintIndexModifier( Function<Integer, Integer> tintTransformer )
|
||||
{
|
||||
this.tintTransformer = tintTransformer;
|
||||
}
|
||||
|
||||
public Function<Integer, Integer> getTintTransformer()
|
||||
{
|
||||
return tintTransformer;
|
||||
}
|
||||
|
||||
public void setTintTransformer( Function<Integer, Integer> tintTransformer )
|
||||
{
|
||||
this.tintTransformer = tintTransformer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QuadVertexData> pipe( List<QuadVertexData> elements, IBakedModel parent, IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
for( QuadVertexData quad : elements )
|
||||
{
|
||||
quad.setTintIndex( tintTransformer.apply( quad.getTintIndex() ) );
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
|
||||
package appeng.client.render.model.pipeline;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.client.model.pipeline.LightUtil;
|
||||
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
|
||||
|
||||
import appeng.api.client.BakingPipelineElement;
|
||||
|
||||
|
||||
public class TypeTransformer
|
||||
{
|
||||
|
||||
public static final BakingPipelineElement<BakedQuad, QuadVertexData> quads2vecs = new BakingPipelineElement<BakedQuad, QuadVertexData>(){
|
||||
|
||||
@Override
|
||||
public List<QuadVertexData> pipe( List<BakedQuad> elements, IBakedModel parent, IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
return Lists.transform( elements != null ? elements : new ArrayList<>(), ( quad ) -> {
|
||||
if( quad instanceof UnpackedBakedQuad )
|
||||
{
|
||||
return new QuadVertexData( (UnpackedBakedQuad) quad );
|
||||
}
|
||||
else
|
||||
{
|
||||
int[] qdata = quad.getVertexData();
|
||||
float[][][] data = new float[4][quad.getFormat().getElementCount()][4];
|
||||
for( int v = 0; v < data.length; v++ )
|
||||
{
|
||||
float[][] vd = data[v];
|
||||
for( int e = 0; e < vd.length; e++ )
|
||||
{
|
||||
LightUtil.unpack( qdata, vd[e], quad.getFormat(), v, e );
|
||||
}
|
||||
}
|
||||
return new QuadVertexData( quad.getFormat(), data, quad.getTintIndex(), quad.getFace(), quad.getSprite(), quad.shouldApplyDiffuseLighting() );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public static final BakingPipelineElement<QuadVertexData, BakedQuad> vecs2quads = new BakingPipelineElement<QuadVertexData, BakedQuad>(){
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> pipe( List<QuadVertexData> elements, IBakedModel parent, IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
return Lists.transform( elements != null ? elements : new ArrayList<>(), data -> data.toQuad() );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
|
||||
package appeng.client.render.model.pipeline.cable;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import appeng.api.client.BakingPipeline;
|
||||
import appeng.api.client.BakingPipelineElement;
|
||||
import appeng.api.implementations.parts.IPartCable;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import appeng.client.render.model.pipeline.TintIndexModifier;
|
||||
import appeng.parts.CableBusContainer;
|
||||
|
||||
|
||||
public class CableAndConnections implements BakingPipelineElement<BakedQuad, BakedQuad>
|
||||
{
|
||||
|
||||
private final BakingPipeline rotatingPipeline;
|
||||
private final TintIndexModifier tintIndexModifier;
|
||||
private final BakingPipeline tintIndexFixPipeline;
|
||||
|
||||
public CableAndConnections( BakingPipeline rotatingPipeline, TintIndexModifier tintIndexModifier, BakingPipeline tintIndexFixPipeline )
|
||||
{
|
||||
this.rotatingPipeline = rotatingPipeline;
|
||||
this.tintIndexModifier = tintIndexModifier;
|
||||
this.tintIndexFixPipeline = tintIndexFixPipeline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> pipe( List<BakedQuad> elements, IBakedModel parent, IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
if( state != null )
|
||||
{
|
||||
CableBusContainer cableBus = ( (IExtendedBlockState) state ).getValue( BlockCableBus.cableBus );
|
||||
IPart part = cableBus.getPart( AEPartLocation.INTERNAL );
|
||||
if( part instanceof IPartCable )
|
||||
{
|
||||
tintIndexModifier.setTintTransformer( tint -> ( AEPartLocation.INTERNAL.ordinal() << 2 ) | tint );
|
||||
elements.addAll( tintIndexFixPipeline.pipe( ( (IPartCable) part ).getOrBakeQuads( rotatingPipeline, state, side, rand ), parent, state, side, rand ) );
|
||||
}
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
|
||||
package appeng.client.render.model.pipeline.cable;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import appeng.api.client.BakingPipeline;
|
||||
import appeng.api.client.BakingPipelineElement;
|
||||
import appeng.api.parts.IFacadePart;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import appeng.client.render.model.pipeline.TintIndexModifier;
|
||||
import appeng.parts.CableBusContainer;
|
||||
|
||||
|
||||
public class Facades implements BakingPipelineElement<BakedQuad, BakedQuad>
|
||||
{
|
||||
|
||||
private final BakingPipeline rotatingPipeline;
|
||||
private final TintIndexModifier tintIndexModifier;
|
||||
private final BakingPipeline tintIndexFixPipeline;
|
||||
|
||||
public Facades( BakingPipeline rotatingPipeline, TintIndexModifier tintIndexModifier, BakingPipeline tintIndexFixPipeline )
|
||||
{
|
||||
this.rotatingPipeline = rotatingPipeline;
|
||||
this.tintIndexModifier = tintIndexModifier;
|
||||
this.tintIndexFixPipeline = tintIndexFixPipeline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> pipe( List<BakedQuad> elements, IBakedModel parent, IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
if( state != null )
|
||||
{
|
||||
CableBusContainer cableBus = ( (IExtendedBlockState) state ).getValue( BlockCableBus.cableBus );
|
||||
for( AEPartLocation facing : AEPartLocation.SIDE_LOCATIONS )
|
||||
{
|
||||
IFacadePart facade = cableBus.getFacadeContainer().getFacade( facing );
|
||||
if( facade != null )
|
||||
{
|
||||
tintIndexModifier.setTintTransformer( tint -> ( facing.ordinal() << 2 ) | tint );
|
||||
elements.addAll( tintIndexFixPipeline.pipe( facade.getOrBakeQuads( cableBus, rotatingPipeline, state, side, rand ), parent, state, side, rand ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
|
||||
package appeng.client.render.model.pipeline.cable;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import appeng.api.client.BakingPipeline;
|
||||
import appeng.api.client.BakingPipelineElement;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import appeng.client.render.model.pipeline.TintIndexModifier;
|
||||
import appeng.parts.CableBusContainer;
|
||||
|
||||
|
||||
public class Parts implements BakingPipelineElement<BakedQuad, BakedQuad>
|
||||
{
|
||||
|
||||
private final BakingPipeline rotatingPipeline;
|
||||
private final TintIndexModifier tintIndexModifier;
|
||||
private final BakingPipeline tintIndexFixPipeline;
|
||||
|
||||
public Parts( BakingPipeline rotatingPipeline, TintIndexModifier tintIndexModifier, BakingPipeline tintIndexFixPipeline )
|
||||
{
|
||||
this.rotatingPipeline = rotatingPipeline;
|
||||
this.tintIndexModifier = tintIndexModifier;
|
||||
this.tintIndexFixPipeline = tintIndexFixPipeline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> pipe( List<BakedQuad> elements, IBakedModel parent, IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
if( state != null )
|
||||
{
|
||||
CableBusContainer cableBus = ( (IExtendedBlockState) state ).getValue( BlockCableBus.cableBus );
|
||||
for( AEPartLocation facing : AEPartLocation.SIDE_LOCATIONS )
|
||||
{
|
||||
IPart part = cableBus.getPart( facing );
|
||||
if( part != null )
|
||||
{
|
||||
tintIndexModifier.setTintTransformer( tint -> ( facing.ordinal() << 2 ) | tint );
|
||||
elements.addAll( tintIndexFixPipeline.pipe( part.getOrBakeQuads( rotatingPipeline, state, side, rand ), parent, state, side, rand ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user