Most of the 1.8 Port.
This commit is contained in:
@@ -24,30 +24,31 @@ import java.util.EnumSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.client.texture.IAESprite;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
@@ -64,6 +65,9 @@ public class BaseBlockRender<B extends AEBaseBlock, T extends AEBaseTile>
|
||||
private final double renderDistance;
|
||||
private final FloatBuffer rotMat = BufferUtils.createFloatBuffer( 16 );
|
||||
|
||||
private static int dynRender = 0;
|
||||
private final ModelResourceLocation modelPath = new ModelResourceLocation( new ResourceLocation( AppEng.MOD_ID, "DynamicRender"+dynRender++ ), "inventory" );
|
||||
|
||||
public BaseBlockRender()
|
||||
{
|
||||
this( false, 20 );
|
||||
@@ -280,10 +284,8 @@ public class BaseBlockRender<B extends AEBaseBlock, T extends AEBaseTile>
|
||||
return this.renderDistance;
|
||||
}
|
||||
|
||||
public void renderInventory( B block, ItemStack item, RenderBlocks renderer, ItemRenderType type, Object[] data )
|
||||
public void renderInventory( B block, ItemStack item, IRenderHelper renderer, ItemRenderType type, Object[] data )
|
||||
{
|
||||
Tessellator tess = Tessellator.instance;
|
||||
|
||||
BlockRenderInfo info = block.getRendererInstance();
|
||||
if( info.isValid() )
|
||||
{
|
||||
@@ -292,17 +294,17 @@ public class BaseBlockRender<B extends AEBaseBlock, T extends AEBaseTile>
|
||||
block.setRenderStateByMeta( item.getItemDamage() );
|
||||
}
|
||||
|
||||
renderer.uvRotateBottom = info.getTexture( ForgeDirection.DOWN ).setFlip( getOrientation( ForgeDirection.DOWN, ForgeDirection.SOUTH, ForgeDirection.UP ) );
|
||||
renderer.uvRotateTop = info.getTexture( ForgeDirection.UP ).setFlip( getOrientation( ForgeDirection.UP, ForgeDirection.SOUTH, ForgeDirection.UP ) );
|
||||
renderer.uvRotateBottom = info.getTexture( AEPartLocation.DOWN ).setFlip( getOrientation( EnumFacing.DOWN, EnumFacing.SOUTH, EnumFacing.UP ) );
|
||||
renderer.uvRotateTop = info.getTexture( AEPartLocation.UP ).setFlip( getOrientation( EnumFacing.UP, EnumFacing.SOUTH, EnumFacing.UP ) );
|
||||
|
||||
renderer.uvRotateEast = info.getTexture( ForgeDirection.EAST ).setFlip( getOrientation( ForgeDirection.EAST, ForgeDirection.SOUTH, ForgeDirection.UP ) );
|
||||
renderer.uvRotateWest = info.getTexture( ForgeDirection.WEST ).setFlip( getOrientation( ForgeDirection.WEST, ForgeDirection.SOUTH, ForgeDirection.UP ) );
|
||||
renderer.uvRotateEast = info.getTexture( AEPartLocation.EAST ).setFlip( getOrientation( EnumFacing.EAST, EnumFacing.SOUTH, EnumFacing.UP ) );
|
||||
renderer.uvRotateWest = info.getTexture( AEPartLocation.WEST ).setFlip( getOrientation( EnumFacing.WEST, EnumFacing.SOUTH, EnumFacing.UP ) );
|
||||
|
||||
renderer.uvRotateNorth = info.getTexture( ForgeDirection.NORTH ).setFlip( getOrientation( ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.UP ) );
|
||||
renderer.uvRotateSouth = info.getTexture( ForgeDirection.SOUTH ).setFlip( getOrientation( ForgeDirection.SOUTH, ForgeDirection.SOUTH, ForgeDirection.UP ) );
|
||||
renderer.uvRotateNorth = info.getTexture( AEPartLocation.NORTH ).setFlip( getOrientation( EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.UP ) );
|
||||
renderer.uvRotateSouth = info.getTexture( AEPartLocation.SOUTH ).setFlip( getOrientation( EnumFacing.SOUTH, EnumFacing.SOUTH, EnumFacing.UP ) );
|
||||
}
|
||||
|
||||
this.renderInvBlock( EnumSet.allOf( ForgeDirection.class ), block, item, tess, 0xffffff, renderer );
|
||||
this.renderInvBlock( EnumSet.allOf( AEPartLocation.class ), block, item, 0xffffff, renderer );
|
||||
|
||||
if( block.hasSubtypes() )
|
||||
{
|
||||
@@ -312,11 +314,11 @@ public class BaseBlockRender<B extends AEBaseBlock, T extends AEBaseTile>
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
||||
}
|
||||
|
||||
public static int getOrientation( ForgeDirection in, ForgeDirection forward, ForgeDirection up )
|
||||
public static int getOrientation( EnumFacing in, EnumFacing forward, EnumFacing up )
|
||||
{
|
||||
if( in == null || in == ForgeDirection.UNKNOWN // 1
|
||||
|| forward == null || forward == ForgeDirection.UNKNOWN // 2
|
||||
|| up == null || up == ForgeDirection.UNKNOWN )
|
||||
if( in == null // 1
|
||||
|| forward == null // 2
|
||||
|| up == null )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -328,7 +330,7 @@ public class BaseBlockRender<B extends AEBaseBlock, T extends AEBaseTile>
|
||||
return ORIENTATION_MAP[a][b][c];
|
||||
}
|
||||
|
||||
public void renderInvBlock( EnumSet<ForgeDirection> sides, B block, ItemStack item, Tessellator tess, int color, RenderBlocks renderer )
|
||||
public void renderInvBlock( EnumSet<AEPartLocation> sides, B block, ItemStack item, int color, IRenderHelper tess )
|
||||
{
|
||||
int meta = 0;
|
||||
if( block != null && block.hasSubtypes() && item != null )
|
||||
@@ -336,64 +338,55 @@ public class BaseBlockRender<B extends AEBaseBlock, T extends AEBaseTile>
|
||||
meta = item.getItemDamage();
|
||||
}
|
||||
|
||||
if( sides.contains( ForgeDirection.DOWN ) )
|
||||
IAESprite[] icons = tess.getIcon( item == null ? block.getDefaultState() : block.getStateFromMeta( item.getMetadata() ) );
|
||||
BlockPos zero = new BlockPos(0,0,0);
|
||||
|
||||
if( sides.contains( AEPartLocation.DOWN ) )
|
||||
{
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal( 0.0F, -1.0F, 0.0F );
|
||||
tess.setColorOpaque_I( color );
|
||||
renderer.renderFaceYNeg( block, 0.0D, 0.0D, 0.0D, this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.DOWN ), block.getIcon( ForgeDirection.DOWN.ordinal(), meta ) ) );
|
||||
tess.draw();
|
||||
tess.renderFaceYNeg( block, zero, this.firstNotNull( tess.overrideBlockTexture, block.getRendererInstance().getTexture( AEPartLocation.DOWN ), icons[ AEPartLocation.DOWN.ordinal() ] ) );
|
||||
}
|
||||
|
||||
if( sides.contains( ForgeDirection.UP ) )
|
||||
if( sides.contains( AEPartLocation.UP ) )
|
||||
{
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal( 0.0F, 1.0F, 0.0F );
|
||||
tess.setColorOpaque_I( color );
|
||||
renderer.renderFaceYPos( block, 0.0D, 0.0D, 0.0D, this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.UP ), block.getIcon( ForgeDirection.UP.ordinal(), meta ) ) );
|
||||
tess.draw();
|
||||
tess.renderFaceYPos( block, zero, this.firstNotNull( tess.overrideBlockTexture, block.getRendererInstance().getTexture( AEPartLocation.UP ), icons[ AEPartLocation.UP.ordinal() ] ) );
|
||||
}
|
||||
|
||||
if( sides.contains( ForgeDirection.NORTH ) )
|
||||
if( sides.contains( AEPartLocation.NORTH ) )
|
||||
{
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal( 0.0F, 0.0F, -1.0F );
|
||||
tess.setColorOpaque_I( color );
|
||||
renderer.renderFaceZNeg( block, 0.0D, 0.0D, 0.0D, this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.NORTH ), block.getIcon( ForgeDirection.NORTH.ordinal(), meta ) ) );
|
||||
tess.draw();
|
||||
tess.renderFaceZNeg( block, zero, this.firstNotNull( tess.overrideBlockTexture, block.getRendererInstance().getTexture( AEPartLocation.NORTH ), icons[ AEPartLocation.NORTH.ordinal() ] ) );
|
||||
}
|
||||
|
||||
if( sides.contains( ForgeDirection.SOUTH ) )
|
||||
if( sides.contains( AEPartLocation.SOUTH ) )
|
||||
{
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal( 0.0F, 0.0F, 1.0F );
|
||||
tess.setColorOpaque_I( color );
|
||||
renderer.renderFaceZPos( block, 0.0D, 0.0D, 0.0D, this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.SOUTH ), block.getIcon( ForgeDirection.SOUTH.ordinal(), meta ) ) );
|
||||
tess.draw();
|
||||
tess.renderFaceZPos( block, zero, this.firstNotNull( tess.overrideBlockTexture, block.getRendererInstance().getTexture( AEPartLocation.SOUTH ), icons[ AEPartLocation.SOUTH.ordinal() ] ) );
|
||||
}
|
||||
|
||||
if( sides.contains( ForgeDirection.WEST ) )
|
||||
if( sides.contains( AEPartLocation.WEST ) )
|
||||
{
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal( -1.0F, 0.0F, 0.0F );
|
||||
tess.setColorOpaque_I( color );
|
||||
renderer.renderFaceXNeg( block, 0.0D, 0.0D, 0.0D, this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.WEST ), block.getIcon( ForgeDirection.WEST.ordinal(), meta ) ) );
|
||||
tess.draw();
|
||||
tess.renderFaceXNeg( block, zero, this.firstNotNull( tess.overrideBlockTexture, block.getRendererInstance().getTexture( AEPartLocation.WEST ), icons[ AEPartLocation.WEST.ordinal() ] ) );
|
||||
}
|
||||
|
||||
if( sides.contains( ForgeDirection.EAST ) )
|
||||
if( sides.contains( AEPartLocation.EAST ) )
|
||||
{
|
||||
tess.startDrawingQuads();
|
||||
tess.setNormal( 1.0F, 0.0F, 0.0F );
|
||||
tess.setColorOpaque_I( color );
|
||||
renderer.renderFaceXPos( block, 0.0D, 0.0D, 0.0D, this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.EAST ), block.getIcon( ForgeDirection.EAST.ordinal(), meta ) ) );
|
||||
tess.draw();
|
||||
tess.renderFaceXPos( block, zero, this.firstNotNull( tess.overrideBlockTexture, block.getRendererInstance().getTexture( AEPartLocation.EAST ), icons[ AEPartLocation.EAST.ordinal() ]) );
|
||||
}
|
||||
}
|
||||
|
||||
public IIcon firstNotNull( IIcon... s )
|
||||
public IAESprite firstNotNull( IAESprite... s )
|
||||
{
|
||||
for( IIcon o : s )
|
||||
for( IAESprite o : s )
|
||||
{
|
||||
if( o != null )
|
||||
{
|
||||
@@ -403,62 +396,62 @@ public class BaseBlockRender<B extends AEBaseBlock, T extends AEBaseTile>
|
||||
return ExtraBlockTextures.getMissing();
|
||||
}
|
||||
|
||||
public boolean renderInWorld( B block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer )
|
||||
public boolean renderInWorld( B block, IBlockAccess world, BlockPos pos, IRenderHelper renderer )
|
||||
{
|
||||
this.preRenderInWorld( block, world, x, y, z, renderer );
|
||||
this.preRenderInWorld( block, world, pos, renderer );
|
||||
|
||||
boolean o = renderer.renderStandardBlock( block, x, y, z );
|
||||
boolean o = renderer.renderStandardBlock( block, pos );
|
||||
|
||||
this.postRenderInWorld( renderer );
|
||||
return o;
|
||||
}
|
||||
|
||||
public void preRenderInWorld( B block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer )
|
||||
public void preRenderInWorld( B block, IBlockAccess world, BlockPos pos, IRenderHelper renderer )
|
||||
{
|
||||
ForgeDirection forward = ForgeDirection.SOUTH;
|
||||
ForgeDirection up = ForgeDirection.UP;
|
||||
EnumFacing forward = EnumFacing.SOUTH;
|
||||
EnumFacing up = EnumFacing.UP;
|
||||
|
||||
BlockRenderInfo info = block.getRendererInstance();
|
||||
IOrientable te = this.getOrientable( block, world, x, y, z );
|
||||
IOrientable te = this.getOrientable( block, world, pos );
|
||||
if( te != null )
|
||||
{
|
||||
forward = te.getForward();
|
||||
up = te.getUp();
|
||||
forward = te.getForward() ;
|
||||
up = te.getUp() ;
|
||||
|
||||
renderer.uvRotateBottom = info.getTexture( ForgeDirection.DOWN ).setFlip( getOrientation( ForgeDirection.DOWN, forward, up ) );
|
||||
renderer.uvRotateTop = info.getTexture( ForgeDirection.UP ).setFlip( getOrientation( ForgeDirection.UP, forward, up ) );
|
||||
renderer.uvRotateBottom = info.getTexture( AEPartLocation.DOWN ).setFlip( getOrientation( EnumFacing.DOWN, forward, up ) );
|
||||
renderer.uvRotateTop = info.getTexture( AEPartLocation.UP ).setFlip( getOrientation( EnumFacing.UP, forward, up ) );
|
||||
|
||||
renderer.uvRotateEast = info.getTexture( ForgeDirection.EAST ).setFlip( getOrientation( ForgeDirection.EAST, forward, up ) );
|
||||
renderer.uvRotateWest = info.getTexture( ForgeDirection.WEST ).setFlip( getOrientation( ForgeDirection.WEST, forward, up ) );
|
||||
renderer.uvRotateEast = info.getTexture( AEPartLocation.EAST ).setFlip( getOrientation( EnumFacing.EAST, forward, up ) );
|
||||
renderer.uvRotateWest = info.getTexture( AEPartLocation.WEST ).setFlip( getOrientation( EnumFacing.WEST, forward, up ) );
|
||||
|
||||
renderer.uvRotateNorth = info.getTexture( ForgeDirection.NORTH ).setFlip( getOrientation( ForgeDirection.NORTH, forward, up ) );
|
||||
renderer.uvRotateSouth = info.getTexture( ForgeDirection.SOUTH ).setFlip( getOrientation( ForgeDirection.SOUTH, forward, up ) );
|
||||
renderer.uvRotateNorth = info.getTexture( AEPartLocation.NORTH ).setFlip( getOrientation( EnumFacing.NORTH, forward, up ) );
|
||||
renderer.uvRotateSouth = info.getTexture( AEPartLocation.SOUTH ).setFlip( getOrientation( EnumFacing.SOUTH, forward, up ) );
|
||||
}
|
||||
}
|
||||
|
||||
public void postRenderInWorld( RenderBlocks renderer )
|
||||
public void postRenderInWorld( IRenderHelper renderer )
|
||||
{
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public IOrientable getOrientable( B block, IBlockAccess w, int x, int y, int z )
|
||||
public IOrientable getOrientable( B block, IBlockAccess w, BlockPos pos )
|
||||
{
|
||||
return block.getOrientable( w, x, y, z );
|
||||
return block.getOrientable( w, pos );
|
||||
}
|
||||
|
||||
protected void setInvRenderBounds( RenderBlocks renderer, int i, int j, int k, int l, int m, int n )
|
||||
protected void setInvRenderBounds( IRenderHelper renderer, int i, int j, int k, int l, int m, int n )
|
||||
{
|
||||
renderer.setRenderBounds( i / 16.0, j / 16.0, k / 16.0, l / 16.0, m / 16.0, n / 16.0 );
|
||||
}
|
||||
|
||||
protected void renderBlockBounds( RenderBlocks renderer,
|
||||
protected void renderBlockBounds( IRenderHelper renderer,
|
||||
|
||||
double minX, double minY, double minZ,
|
||||
|
||||
double maxX, double maxY, double maxZ,
|
||||
|
||||
ForgeDirection x, ForgeDirection y, ForgeDirection z )
|
||||
EnumFacing x, EnumFacing y, EnumFacing z )
|
||||
{
|
||||
minX /= 16.0;
|
||||
minY /= 16.0;
|
||||
@@ -467,27 +460,27 @@ public class BaseBlockRender<B extends AEBaseBlock, T extends AEBaseTile>
|
||||
maxY /= 16.0;
|
||||
maxZ /= 16.0;
|
||||
|
||||
double aX = minX * x.offsetX + minY * y.offsetX + minZ * z.offsetX;
|
||||
double aY = minX * x.offsetY + minY * y.offsetY + minZ * z.offsetY;
|
||||
double aZ = minX * x.offsetZ + minY * y.offsetZ + minZ * z.offsetZ;
|
||||
double aX = minX * x.getFrontOffsetX() + minY * y.getFrontOffsetX() + minZ * z.getFrontOffsetX();
|
||||
double aY = minX * x.getFrontOffsetY() + minY * y.getFrontOffsetY() + minZ * z.getFrontOffsetY();
|
||||
double aZ = minX * x.getFrontOffsetZ() + minY * y.getFrontOffsetZ() + minZ * z.getFrontOffsetZ();
|
||||
|
||||
double bX = maxX * x.offsetX + maxY * y.offsetX + maxZ * z.offsetX;
|
||||
double bY = maxX * x.offsetY + maxY * y.offsetY + maxZ * z.offsetY;
|
||||
double bZ = maxX * x.offsetZ + maxY * y.offsetZ + maxZ * z.offsetZ;
|
||||
double bX = maxX * x.getFrontOffsetX() + maxY * y.getFrontOffsetX() + maxZ * z.getFrontOffsetX();
|
||||
double bY = maxX * x.getFrontOffsetY() + maxY * y.getFrontOffsetY() + maxZ * z.getFrontOffsetY();
|
||||
double bZ = maxX * x.getFrontOffsetZ() + maxY * y.getFrontOffsetZ() + maxZ * z.getFrontOffsetZ();
|
||||
|
||||
if( x.offsetX + y.offsetX + z.offsetX < 0 )
|
||||
if( x.getFrontOffsetX() + y.getFrontOffsetX() + z.getFrontOffsetX() < 0 )
|
||||
{
|
||||
aX += 1;
|
||||
bX += 1;
|
||||
}
|
||||
|
||||
if( x.offsetY + y.offsetY + z.offsetY < 0 )
|
||||
if( x.getFrontOffsetY() + y.getFrontOffsetY() + z.getFrontOffsetY() < 0 )
|
||||
{
|
||||
aY += 1;
|
||||
bY += 1;
|
||||
}
|
||||
|
||||
if( x.offsetZ + y.offsetZ + z.offsetZ < 0 )
|
||||
if( x.getFrontOffsetZ() + y.getFrontOffsetZ() + z.getFrontOffsetZ() < 0 )
|
||||
{
|
||||
aZ += 1;
|
||||
bZ += 1;
|
||||
@@ -502,10 +495,8 @@ public class BaseBlockRender<B extends AEBaseBlock, T extends AEBaseTile>
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
protected void renderCutoutFace( B block, IIcon ico, int x, int y, int z, RenderBlocks renderer, ForgeDirection orientation, float edgeThickness )
|
||||
protected void renderCutoutFace( B block, IAESprite ico, BlockPos pos, IRenderHelper tess, EnumFacing orientation, float edgeThickness )
|
||||
{
|
||||
Tessellator tess = Tessellator.instance;
|
||||
|
||||
double offsetX = 0.0;
|
||||
double offsetY = 0.0;
|
||||
double offsetZ = 0.0;
|
||||
@@ -565,29 +556,29 @@ public class BaseBlockRender<B extends AEBaseBlock, T extends AEBaseTile>
|
||||
break;
|
||||
}
|
||||
|
||||
offsetX += x;
|
||||
offsetY += y;
|
||||
offsetZ += z;
|
||||
offsetX += pos.getX();
|
||||
offsetY += pos.getY();
|
||||
offsetZ += pos.getZ();
|
||||
|
||||
this.renderFace( tess, offsetX, offsetY, offsetZ, layerAX, layerAY, layerAZ, layerBX, layerBY, layerBZ,
|
||||
this.renderFace(orientation, tess, offsetX, offsetY, offsetZ, layerAX, layerAY, layerAZ, layerBX, layerBY, layerBZ,
|
||||
// u -> u
|
||||
0, 1.0,
|
||||
// v -> v
|
||||
0, edgeThickness, ico, flip );
|
||||
|
||||
this.renderFace( tess, offsetX, offsetY, offsetZ, layerAX, layerAY, layerAZ, layerBX, layerBY, layerBZ,
|
||||
this.renderFace( orientation,tess, offsetX, offsetY, offsetZ, layerAX, layerAY, layerAZ, layerBX, layerBY, layerBZ,
|
||||
// u -> u
|
||||
0.0, edgeThickness,
|
||||
// v -> v
|
||||
edgeThickness, 1.0 - edgeThickness, ico, flip );
|
||||
|
||||
this.renderFace( tess, offsetX, offsetY, offsetZ, layerAX, layerAY, layerAZ, layerBX, layerBY, layerBZ,
|
||||
this.renderFace( orientation,tess, offsetX, offsetY, offsetZ, layerAX, layerAY, layerAZ, layerBX, layerBY, layerBZ,
|
||||
// u -> u
|
||||
1.0 - edgeThickness, 1.0,
|
||||
// v -> v
|
||||
edgeThickness, 1.0 - edgeThickness, ico, flip );
|
||||
|
||||
this.renderFace( tess, offsetX, offsetY, offsetZ, layerAX, layerAY, layerAZ, layerBX, layerBY, layerBZ,
|
||||
this.renderFace( orientation,tess, offsetX, offsetY, offsetZ, layerAX, layerAY, layerAZ, layerBX, layerBY, layerBZ,
|
||||
// u -> u
|
||||
0, 1.0,
|
||||
// v -> v
|
||||
@@ -595,73 +586,73 @@ public class BaseBlockRender<B extends AEBaseBlock, T extends AEBaseTile>
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private void renderFace( Tessellator tess, double offsetX, double offsetY, double offsetZ, double ax, double ay, double az, double bx, double by, double bz, double ua, double ub, double va, double vb, IIcon ico, boolean flip )
|
||||
private void renderFace( EnumFacing face, IRenderHelper tess, double offsetX, double offsetY, double offsetZ, double ax, double ay, double az, double bx, double by, double bz, double ua, double ub, double va, double vb, IAESprite ico, boolean flip )
|
||||
{
|
||||
if( flip )
|
||||
{
|
||||
tess.addVertexWithUV( offsetX + ax * ua + bx * va, offsetY + ay * ua + by * va, offsetZ + az * ua + bz * va, ico.getInterpolatedU( ua * 16.0 ), ico.getInterpolatedV( va * 16.0 ) );
|
||||
tess.addVertexWithUV( offsetX + ax * ua + bx * vb, offsetY + ay * ua + by * vb, offsetZ + az * ua + bz * vb, ico.getInterpolatedU( ua * 16.0 ), ico.getInterpolatedV( vb * 16.0 ) );
|
||||
tess.addVertexWithUV( offsetX + ax * ub + bx * vb, offsetY + ay * ub + by * vb, offsetZ + az * ub + bz * vb, ico.getInterpolatedU( ub * 16.0 ), ico.getInterpolatedV( vb * 16.0 ) );
|
||||
tess.addVertexWithUV( offsetX + ax * ub + bx * va, offsetY + ay * ub + by * va, offsetZ + az * ub + bz * va, ico.getInterpolatedU( ub * 16.0 ), ico.getInterpolatedV( va * 16.0 ) );
|
||||
tess.addVertexWithUV( face,offsetX + ax * ua + bx * va, offsetY + ay * ua + by * va, offsetZ + az * ua + bz * va, ico.getInterpolatedU( ua * 16.0 ), ico.getInterpolatedV( va * 16.0 ) );
|
||||
tess.addVertexWithUV( face,offsetX + ax * ua + bx * vb, offsetY + ay * ua + by * vb, offsetZ + az * ua + bz * vb, ico.getInterpolatedU( ua * 16.0 ), ico.getInterpolatedV( vb * 16.0 ) );
|
||||
tess.addVertexWithUV( face,offsetX + ax * ub + bx * vb, offsetY + ay * ub + by * vb, offsetZ + az * ub + bz * vb, ico.getInterpolatedU( ub * 16.0 ), ico.getInterpolatedV( vb * 16.0 ) );
|
||||
tess.addVertexWithUV( face,offsetX + ax * ub + bx * va, offsetY + ay * ub + by * va, offsetZ + az * ub + bz * va, ico.getInterpolatedU( ub * 16.0 ), ico.getInterpolatedV( va * 16.0 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
tess.addVertexWithUV( offsetX + ax * ua + bx * va, offsetY + ay * ua + by * va, offsetZ + az * ua + bz * va, ico.getInterpolatedU( ua * 16.0 ), ico.getInterpolatedV( va * 16.0 ) );
|
||||
tess.addVertexWithUV( offsetX + ax * ub + bx * va, offsetY + ay * ub + by * va, offsetZ + az * ub + bz * va, ico.getInterpolatedU( ub * 16.0 ), ico.getInterpolatedV( va * 16.0 ) );
|
||||
tess.addVertexWithUV( offsetX + ax * ub + bx * vb, offsetY + ay * ub + by * vb, offsetZ + az * ub + bz * vb, ico.getInterpolatedU( ub * 16.0 ), ico.getInterpolatedV( vb * 16.0 ) );
|
||||
tess.addVertexWithUV( offsetX + ax * ua + bx * vb, offsetY + ay * ua + by * vb, offsetZ + az * ua + bz * vb, ico.getInterpolatedU( ua * 16.0 ), ico.getInterpolatedV( vb * 16.0 ) );
|
||||
tess.addVertexWithUV( face, offsetX + ax * ua + bx * va, offsetY + ay * ua + by * va, offsetZ + az * ua + bz * va, ico.getInterpolatedU( ua * 16.0 ), ico.getInterpolatedV( va * 16.0 ) );
|
||||
tess.addVertexWithUV( face, offsetX + ax * ub + bx * va, offsetY + ay * ub + by * va, offsetZ + az * ub + bz * va, ico.getInterpolatedU( ub * 16.0 ), ico.getInterpolatedV( va * 16.0 ) );
|
||||
tess.addVertexWithUV( face, offsetX + ax * ub + bx * vb, offsetY + ay * ub + by * vb, offsetZ + az * ub + bz * vb, ico.getInterpolatedU( ub * 16.0 ), ico.getInterpolatedV( vb * 16.0 ) );
|
||||
tess.addVertexWithUV( face, offsetX + ax * ua + bx * vb, offsetY + ay * ua + by * vb, offsetZ + az * ua + bz * vb, ico.getInterpolatedU( ua * 16.0 ), ico.getInterpolatedV( vb * 16.0 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
protected void renderFace( int x, int y, int z, B block, IIcon ico, RenderBlocks renderer, ForgeDirection orientation )
|
||||
protected void renderFace( BlockPos pos, B block, IAESprite ico, IRenderHelper renderer, EnumFacing orientation )
|
||||
{
|
||||
switch( orientation )
|
||||
{
|
||||
case NORTH:
|
||||
renderer.renderFaceZNeg( block, x, y, z, ico );
|
||||
renderer.renderFaceZNeg( block, pos, ico );
|
||||
break;
|
||||
case SOUTH:
|
||||
renderer.renderFaceZPos( block, x, y, z, ico );
|
||||
renderer.renderFaceZPos( block, pos, ico );
|
||||
break;
|
||||
case EAST:
|
||||
renderer.renderFaceXPos( block, x, y, z, ico );
|
||||
renderer.renderFaceXPos( block, pos, ico );
|
||||
break;
|
||||
case WEST:
|
||||
renderer.renderFaceXNeg( block, x, y, z, ico );
|
||||
renderer.renderFaceXNeg( block, pos, ico );
|
||||
break;
|
||||
case UP:
|
||||
renderer.renderFaceYPos( block, x, y, z, ico );
|
||||
renderer.renderFaceYPos( block, pos, ico );
|
||||
break;
|
||||
case DOWN:
|
||||
renderer.renderFaceYNeg( block, x, y, z, ico );
|
||||
renderer.renderFaceYNeg( block, pos, ico );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void selectFace( RenderBlocks renderer, ForgeDirection west, ForgeDirection up, ForgeDirection forward, int u1, int u2, int v1, int v2 )
|
||||
public void selectFace( IRenderHelper renderer, EnumFacing west, EnumFacing up, EnumFacing forward, int u1, int u2, int v1, int v2 )
|
||||
{
|
||||
v1 = 16 - v1;
|
||||
v2 = 16 - v2;
|
||||
|
||||
double minX = ( forward.offsetX > 0 ? 1 : 0 ) + this.mapFaceUV( west.offsetX, u1 ) + this.mapFaceUV( up.offsetX, v1 );
|
||||
double minY = ( forward.offsetY > 0 ? 1 : 0 ) + this.mapFaceUV( west.offsetY, u1 ) + this.mapFaceUV( up.offsetY, v1 );
|
||||
double minZ = ( forward.offsetZ > 0 ? 1 : 0 ) + this.mapFaceUV( west.offsetZ, u1 ) + this.mapFaceUV( up.offsetZ, v1 );
|
||||
double minX = ( forward.getFrontOffsetX() > 0 ? 1 : 0 ) + this.mapFaceUV( west.getFrontOffsetX(), u1 ) + this.mapFaceUV( up.getFrontOffsetX(), v1 );
|
||||
double minY = ( forward.getFrontOffsetY() > 0 ? 1 : 0 ) + this.mapFaceUV( west.getFrontOffsetY(), u1 ) + this.mapFaceUV( up.getFrontOffsetY(), v1 );
|
||||
double minZ = ( forward.getFrontOffsetZ() > 0 ? 1 : 0 ) + this.mapFaceUV( west.getFrontOffsetZ(), u1 ) + this.mapFaceUV( up.getFrontOffsetZ(), v1 );
|
||||
|
||||
double maxX = ( forward.offsetX > 0 ? 1 : 0 ) + this.mapFaceUV( west.offsetX, u2 ) + this.mapFaceUV( up.offsetX, v2 );
|
||||
double maxY = ( forward.offsetY > 0 ? 1 : 0 ) + this.mapFaceUV( west.offsetY, u2 ) + this.mapFaceUV( up.offsetY, v2 );
|
||||
double maxZ = ( forward.offsetZ > 0 ? 1 : 0 ) + this.mapFaceUV( west.offsetZ, u2 ) + this.mapFaceUV( up.offsetZ, v2 );
|
||||
double maxX = ( forward.getFrontOffsetX() > 0 ? 1 : 0 ) + this.mapFaceUV( west.getFrontOffsetX(), u2 ) + this.mapFaceUV( up.getFrontOffsetX(), v2 );
|
||||
double maxY = ( forward.getFrontOffsetY() > 0 ? 1 : 0 ) + this.mapFaceUV( west.getFrontOffsetY(), u2 ) + this.mapFaceUV( up.getFrontOffsetY(), v2 );
|
||||
double maxZ = ( forward.getFrontOffsetZ() > 0 ? 1 : 0 ) + this.mapFaceUV( west.getFrontOffsetZ(), u2 ) + this.mapFaceUV( up.getFrontOffsetZ(), v2 );
|
||||
|
||||
renderer.renderMinX = Math.max( 0.0, Math.min( minX, maxX ) - ( forward.offsetX != 0 ? 0 : 0.001 ) );
|
||||
renderer.renderMaxX = Math.min( 1.0, Math.max( minX, maxX ) + ( forward.offsetX != 0 ? 0 : 0.001 ) );
|
||||
renderer.renderMinX = Math.max( 0.0, Math.min( minX, maxX ) - ( forward.getFrontOffsetX() != 0 ? 0 : 0.001 ) );
|
||||
renderer.renderMaxX = Math.min( 1.0, Math.max( minX, maxX ) + ( forward.getFrontOffsetX() != 0 ? 0 : 0.001 ) );
|
||||
|
||||
renderer.renderMinY = Math.max( 0.0, Math.min( minY, maxY ) - ( forward.offsetY != 0 ? 0 : 0.001 ) );
|
||||
renderer.renderMaxY = Math.min( 1.0, Math.max( minY, maxY ) + ( forward.offsetY != 0 ? 0 : 0.001 ) );
|
||||
renderer.renderMinY = Math.max( 0.0, Math.min( minY, maxY ) - ( forward.getFrontOffsetY() != 0 ? 0 : 0.001 ) );
|
||||
renderer.renderMaxY = Math.min( 1.0, Math.max( minY, maxY ) + ( forward.getFrontOffsetY() != 0 ? 0 : 0.001 ) );
|
||||
|
||||
renderer.renderMinZ = Math.max( 0.0, Math.min( minZ, maxZ ) - ( forward.offsetZ != 0 ? 0 : 0.001 ) );
|
||||
renderer.renderMaxZ = Math.min( 1.0, Math.max( minZ, maxZ ) + ( forward.offsetZ != 0 ? 0 : 0.001 ) );
|
||||
renderer.renderMinZ = Math.max( 0.0, Math.min( minZ, maxZ ) - ( forward.getFrontOffsetZ() != 0 ? 0 : 0.001 ) );
|
||||
renderer.renderMaxZ = Math.min( 1.0, Math.max( minZ, maxZ ) + ( forward.getFrontOffsetZ() != 0 ? 0 : 0.001 ) );
|
||||
}
|
||||
|
||||
private double mapFaceUV( int offset, int uv )
|
||||
@@ -679,14 +670,14 @@ public class BaseBlockRender<B extends AEBaseBlock, T extends AEBaseTile>
|
||||
return ( 16.0 - uv ) / 16.0;
|
||||
}
|
||||
|
||||
public void renderTile( B block, T tile, Tessellator tess, double x, double y, double z, float f, RenderBlocks renderer )
|
||||
public void renderTile( B block, T tile, WorldRenderer tess, double x, double y, double z, float f, IRenderHelper renderer )
|
||||
{
|
||||
ForgeDirection forward = ForgeDirection.SOUTH;
|
||||
ForgeDirection up = ForgeDirection.UP;
|
||||
AEPartLocation forward = AEPartLocation.SOUTH;
|
||||
AEPartLocation up = AEPartLocation.UP;
|
||||
|
||||
renderer.uvRotateBottom = renderer.uvRotateTop = renderer.uvRotateEast = renderer.uvRotateWest = renderer.uvRotateNorth = renderer.uvRotateSouth = 0;
|
||||
|
||||
this.applyTESRRotation( x, y, z, forward, up );
|
||||
this.applyTESRRotation( x, y, z, forward.getFacing(), up.getFacing() );
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture( TextureMap.locationBlocksTexture );
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
@@ -702,49 +693,38 @@ public class BaseBlockRender<B extends AEBaseBlock, T extends AEBaseTile>
|
||||
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
|
||||
tess.setTranslation( -tile.xCoord, -tile.yCoord, -tile.zCoord );
|
||||
tess.startDrawingQuads();
|
||||
BlockPos pos = tile.getPos();
|
||||
renderer.setTranslation( -pos.getX(), -pos.getY(), -pos.getZ() );
|
||||
|
||||
// note that this is a terrible approach...
|
||||
renderer.setRenderBoundsFromBlock( block );
|
||||
renderer.renderStandardBlock( block, tile.xCoord, tile.yCoord, tile.zCoord );
|
||||
renderer.renderStandardBlock( block, pos );
|
||||
|
||||
tess.draw();
|
||||
tess.setTranslation( 0, 0, 0 );
|
||||
renderer.setTranslation( 0, 0, 0 );
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
|
||||
renderer.uvRotateBottom = renderer.uvRotateTop = renderer.uvRotateEast = renderer.uvRotateWest = renderer.uvRotateNorth = renderer.uvRotateSouth = 0;
|
||||
}
|
||||
|
||||
protected void applyTESRRotation( double x, double y, double z, ForgeDirection forward, ForgeDirection up )
|
||||
protected void applyTESRRotation( double x, double y, double z, EnumFacing forward, EnumFacing up )
|
||||
{
|
||||
if( forward != null && up != null )
|
||||
{
|
||||
if( forward == ForgeDirection.UNKNOWN )
|
||||
{
|
||||
forward = ForgeDirection.SOUTH;
|
||||
}
|
||||
EnumFacing west = Platform.crossProduct( forward, up );
|
||||
|
||||
if( up == ForgeDirection.UNKNOWN )
|
||||
{
|
||||
up = ForgeDirection.UP;
|
||||
}
|
||||
|
||||
ForgeDirection west = Platform.crossProduct( forward, up );
|
||||
|
||||
this.rotMat.put( 0, west.offsetX );
|
||||
this.rotMat.put( 1, west.offsetY );
|
||||
this.rotMat.put( 2, west.offsetZ );
|
||||
this.rotMat.put( 0, west.getFrontOffsetX() );
|
||||
this.rotMat.put( 1, west.getFrontOffsetY() );
|
||||
this.rotMat.put( 2, west.getFrontOffsetZ() );
|
||||
this.rotMat.put( 3, 0 );
|
||||
|
||||
this.rotMat.put( 4, up.offsetX );
|
||||
this.rotMat.put( 5, up.offsetY );
|
||||
this.rotMat.put( 6, up.offsetZ );
|
||||
this.rotMat.put( 4, up.getFrontOffsetX() );
|
||||
this.rotMat.put( 5, up.getFrontOffsetY() );
|
||||
this.rotMat.put( 6, up.getFrontOffsetZ() );
|
||||
this.rotMat.put( 7, 0 );
|
||||
|
||||
this.rotMat.put( 8, forward.offsetX );
|
||||
this.rotMat.put( 9, forward.offsetY );
|
||||
this.rotMat.put( 10, forward.offsetZ );
|
||||
this.rotMat.put( 8, forward.getFrontOffsetX() );
|
||||
this.rotMat.put( 9, forward.getFrontOffsetY() );
|
||||
this.rotMat.put( 10, forward.getFrontOffsetZ() );
|
||||
this.rotMat.put( 11, 0 );
|
||||
|
||||
this.rotMat.put( 12, 0 );
|
||||
@@ -765,22 +745,27 @@ public class BaseBlockRender<B extends AEBaseBlock, T extends AEBaseTile>
|
||||
{
|
||||
if( itemstack != null )
|
||||
{
|
||||
EntityItem entityitem = new EntityItem( par1EntityItemFrame.getWorldObj(), 0.0D, 0.0D, 0.0D, itemstack );
|
||||
EntityItem entityitem = new EntityItem( par1EntityItemFrame.getWorld(), 0.0D, 0.0D, 0.0D, itemstack );
|
||||
entityitem.getEntityItem().stackSize = 1;
|
||||
|
||||
// set all this stuff and then do shit? meh?
|
||||
entityitem.hoverStart = 0;
|
||||
entityitem.age = 0;
|
||||
entityitem.setNoDespawn();
|
||||
entityitem.rotationYaw = 0;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef( 0, -0.14F, 0 );
|
||||
|
||||
RenderItem.renderInFrame = true;
|
||||
RenderManager.instance.renderEntityWithPosYaw( entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F );
|
||||
RenderItem.renderInFrame = false;
|
||||
//RenderItem.renderInFrame = true;
|
||||
Minecraft.getMinecraft().getRenderManager().renderEntityWithPosYaw( entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F );
|
||||
//RenderItem.renderInFrame = false;
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
public ModelResourceLocation getResourcePath()
|
||||
{
|
||||
return modelPath;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user