2013-12-27 23:59:59 +01:00
|
|
|
package appeng.facade;
|
|
|
|
|
|
|
|
import java.util.EnumSet;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
|
|
|
import net.minecraft.client.renderer.Tessellator;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemBlock;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2014-05-05 02:51:05 +02:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraft.util.IIcon;
|
2014-05-05 02:51:05 +02:00
|
|
|
import net.minecraft.world.IBlockAccess;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
|
|
|
import appeng.api.parts.IFacadeContainer;
|
|
|
|
import appeng.api.parts.IFacadePart;
|
|
|
|
import appeng.api.parts.IPartCollsionHelper;
|
2014-05-05 02:51:05 +02:00
|
|
|
import appeng.api.parts.IPartHost;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.parts.IPartRenderHelper;
|
|
|
|
import appeng.client.render.BusRenderHelper;
|
|
|
|
import appeng.client.render.RenderBlocksWorkaround;
|
2014-02-07 21:37:22 +01:00
|
|
|
import appeng.core.AELog;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.core.AppEng;
|
2014-07-24 00:26:23 +02:00
|
|
|
import appeng.integration.IntegrationType;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.integration.abstraction.IBC;
|
2014-02-07 06:51:19 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
public class FacadePart implements IFacadePart
|
|
|
|
{
|
|
|
|
|
|
|
|
public final ItemStack facade;
|
|
|
|
public final ForgeDirection side;
|
2014-01-31 01:49:27 +01:00
|
|
|
public int thickness = 2;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
public FacadePart(ItemStack facade, ForgeDirection side) {
|
|
|
|
if ( facade == null )
|
|
|
|
throw new RuntimeException( "Facade Part constructed on null item." );
|
2014-01-26 07:46:40 +01:00
|
|
|
this.facade = facade.copy();
|
|
|
|
this.facade.stackSize = 1;
|
2013-12-27 23:59:59 +01:00
|
|
|
this.side = side;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack getItemStack()
|
|
|
|
{
|
|
|
|
return facade;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void getBoxes(IPartCollsionHelper ch)
|
|
|
|
{
|
2014-05-04 02:20:03 +02:00
|
|
|
// the box is 15.9 for transition planes to pick up collision events.
|
2014-05-04 00:11:19 +02:00
|
|
|
ch.addBox( 0.0, 0.0, 14, 16.0, 16.0, 15.9 );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isFacade(ItemStack is)
|
|
|
|
{
|
|
|
|
if ( is.getItem() instanceof IFacadeItem )
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ItemStack getTexture()
|
|
|
|
{
|
|
|
|
if ( facade.getItem() instanceof IFacadeItem )
|
|
|
|
{
|
|
|
|
IFacadeItem fi = (IFacadeItem) facade.getItem();
|
|
|
|
return fi.getTextureItem( facade );
|
|
|
|
}
|
2014-07-24 00:26:23 +02:00
|
|
|
else if ( AppEng.instance.isIntegrationEnabled( IntegrationType.BC ) )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-07-24 00:26:23 +02:00
|
|
|
IBC bc = (IBC) AppEng.instance.getIntegration( IntegrationType.BC );
|
2013-12-27 23:59:59 +01:00
|
|
|
return bc.getTextureForFacade( facade );
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-07 06:51:19 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2014-02-09 02:34:52 +01:00
|
|
|
public void renderStatic(int x, int y, int z, IPartRenderHelper instance2, RenderBlocks renderer, IFacadeContainer fc, AxisAlignedBB busBounds,
|
|
|
|
boolean renderStilt)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
if ( facade != null )
|
|
|
|
{
|
|
|
|
BusRenderHelper instance = (BusRenderHelper) instance2;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
ItemStack randomItem = getTexture();
|
|
|
|
|
2014-05-05 02:51:05 +02:00
|
|
|
RenderBlocksWorkaround rbw = null;
|
|
|
|
if ( renderer instanceof RenderBlocksWorkaround )
|
|
|
|
{
|
|
|
|
rbw = (RenderBlocksWorkaround) renderer;
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
if ( renderStilt && busBounds == null )
|
|
|
|
{
|
2014-05-05 02:51:05 +02:00
|
|
|
if ( rbw != null )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
rbw.isFacade = false;
|
|
|
|
rbw.calculations = true;
|
|
|
|
}
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
IIcon myIcon = null;
|
2013-12-27 23:59:59 +01:00
|
|
|
if ( isBC() )
|
|
|
|
{
|
2014-07-24 00:26:23 +02:00
|
|
|
IBC bc = (IBC) AppEng.instance.getIntegration( IntegrationType.BC );
|
2013-12-27 23:59:59 +01:00
|
|
|
myIcon = bc.getFacadeTexture();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( myIcon == null )
|
|
|
|
myIcon = facade.getIconIndex();
|
|
|
|
|
|
|
|
instance.setTexture( myIcon );
|
|
|
|
|
|
|
|
if ( isBC() )
|
2014-01-31 01:49:27 +01:00
|
|
|
instance.setBounds( 6, 6, 10, 10, 10, 15 );
|
2013-12-27 23:59:59 +01:00
|
|
|
else
|
2014-01-31 01:49:27 +01:00
|
|
|
instance.setBounds( 7, 7, 10, 9, 9, 15 );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
instance.renderBlock( x, y, z, renderer );
|
|
|
|
instance.setTexture( null );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( randomItem != null )
|
|
|
|
{
|
|
|
|
if ( randomItem.getItem() instanceof ItemBlock )
|
|
|
|
{
|
|
|
|
ItemBlock ib = (ItemBlock) randomItem.getItem();
|
2014-02-09 02:34:52 +01:00
|
|
|
Block blk = Block.getBlockFromItem( ib );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-05-05 02:51:05 +02:00
|
|
|
if ( blk.canRenderInPass( 1 ) )
|
|
|
|
{
|
|
|
|
instance.renderForPass( 1 );
|
|
|
|
}
|
|
|
|
|
2014-07-27 07:49:56 +02:00
|
|
|
int color = 0xffffff;
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
try
|
|
|
|
{
|
2014-07-27 07:49:56 +02:00
|
|
|
color = ib.getColorFromItemStack( randomItem, 0 );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
catch (Throwable error)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
2014-01-31 01:49:27 +01:00
|
|
|
instance.setBounds( 0, 0, 16 - getFacadeThickness(), 16, 16, 16 );
|
2013-12-27 23:59:59 +01:00
|
|
|
instance.prepareBounds( renderer );
|
|
|
|
|
2014-05-05 02:51:05 +02:00
|
|
|
if ( rbw != null )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
rbw.isFacade = true;
|
|
|
|
|
|
|
|
rbw.calculations = true;
|
|
|
|
rbw.faces = EnumSet.noneOf( ForgeDirection.class );
|
|
|
|
|
2014-07-27 07:49:56 +02:00
|
|
|
instance.setRenderColor( color );
|
|
|
|
rbw.renderStandardBlock( instance.getBlock(), x, y, z );
|
|
|
|
instance.setRenderColor( 0xffffff );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
rbw.calculations = false;
|
2014-05-05 02:51:05 +02:00
|
|
|
rbw.faces = calculateFaceOpenFaces( rbw.blockAccess, fc, x, y, z, side );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-02-13 06:33:27 +01:00
|
|
|
((RenderBlocksWorkaround) renderer).setTexture(
|
|
|
|
blk.getIcon( ForgeDirection.DOWN.ordinal(), ib.getMetadata( randomItem.getItemDamage() ) ),
|
|
|
|
blk.getIcon( ForgeDirection.UP.ordinal(), ib.getMetadata( randomItem.getItemDamage() ) ),
|
|
|
|
blk.getIcon( ForgeDirection.NORTH.ordinal(), ib.getMetadata( randomItem.getItemDamage() ) ),
|
|
|
|
blk.getIcon( ForgeDirection.SOUTH.ordinal(), ib.getMetadata( randomItem.getItemDamage() ) ),
|
|
|
|
blk.getIcon( ForgeDirection.WEST.ordinal(), ib.getMetadata( randomItem.getItemDamage() ) ),
|
|
|
|
blk.getIcon( ForgeDirection.EAST.ordinal(), ib.getMetadata( randomItem.getItemDamage() ) ) );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-02-13 06:33:27 +01:00
|
|
|
instance.setTexture( blk.getIcon( ForgeDirection.DOWN.ordinal(), ib.getMetadata( randomItem.getItemDamage() ) ),
|
|
|
|
blk.getIcon( ForgeDirection.UP.ordinal(), ib.getMetadata( randomItem.getItemDamage() ) ),
|
|
|
|
blk.getIcon( ForgeDirection.NORTH.ordinal(), ib.getMetadata( randomItem.getItemDamage() ) ),
|
|
|
|
blk.getIcon( ForgeDirection.SOUTH.ordinal(), ib.getMetadata( randomItem.getItemDamage() ) ),
|
|
|
|
blk.getIcon( ForgeDirection.WEST.ordinal(), ib.getMetadata( randomItem.getItemDamage() ) ),
|
|
|
|
blk.getIcon( ForgeDirection.EAST.ordinal(), ib.getMetadata( randomItem.getItemDamage() ) ) );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( busBounds == null )
|
|
|
|
{
|
|
|
|
if ( side == ForgeDirection.UP || side == ForgeDirection.DOWN )
|
|
|
|
{
|
|
|
|
instance.renderBlockCurrentBounds( x, y, z, renderer );
|
|
|
|
}
|
|
|
|
else if ( side == ForgeDirection.NORTH || side == ForgeDirection.SOUTH )
|
|
|
|
{
|
|
|
|
if ( fc.getFacade( ForgeDirection.UP ) != null )
|
2014-01-31 01:49:27 +01:00
|
|
|
renderer.renderMaxY -= getFacadeThickness() / 16.0;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
if ( fc.getFacade( ForgeDirection.DOWN ) != null )
|
2014-01-31 01:49:27 +01:00
|
|
|
renderer.renderMinY += getFacadeThickness() / 16.0;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
instance.renderBlockCurrentBounds( x, y, z, renderer );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( fc.getFacade( ForgeDirection.UP ) != null )
|
2014-01-31 01:49:27 +01:00
|
|
|
renderer.renderMaxY -= getFacadeThickness() / 16.0;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
if ( fc.getFacade( ForgeDirection.DOWN ) != null )
|
2014-01-31 01:49:27 +01:00
|
|
|
renderer.renderMinY += getFacadeThickness() / 16.0;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
if ( fc.getFacade( ForgeDirection.SOUTH ) != null )
|
2014-01-31 01:49:27 +01:00
|
|
|
renderer.renderMaxZ -= getFacadeThickness() / 16.0;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
if ( fc.getFacade( ForgeDirection.NORTH ) != null )
|
2014-01-31 01:49:27 +01:00
|
|
|
renderer.renderMinZ += getFacadeThickness() / 16.0;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
instance.renderBlockCurrentBounds( x, y, z, renderer );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( side == ForgeDirection.UP || side == ForgeDirection.DOWN )
|
|
|
|
{
|
|
|
|
renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, 0.0, 0.0, busBounds.maxZ, 1.0, 1.0, 1.0 );
|
|
|
|
renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, 0.0, 0.0, 0.0, 1.0, 1.0, busBounds.minZ );
|
|
|
|
renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, 0.0, 0.0, busBounds.minZ, busBounds.minX, 1.0, busBounds.maxZ );
|
|
|
|
renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, busBounds.maxX, 0.0, busBounds.minZ, 1.0, 1.0, busBounds.maxZ );
|
|
|
|
}
|
|
|
|
else if ( side == ForgeDirection.NORTH || side == ForgeDirection.SOUTH )
|
|
|
|
{
|
|
|
|
if ( fc.getFacade( ForgeDirection.UP ) != null )
|
2014-01-31 01:49:27 +01:00
|
|
|
renderer.renderMaxY -= getFacadeThickness() / 16.0;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
if ( fc.getFacade( ForgeDirection.DOWN ) != null )
|
2014-01-31 01:49:27 +01:00
|
|
|
renderer.renderMinY += getFacadeThickness() / 16.0;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, busBounds.maxX, 0.0, 0.0, 1.0, 1.0, 1.0 );
|
|
|
|
renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, 0.0, 0.0, 0.0, busBounds.minX, 1.0, 1.0 );
|
|
|
|
renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, busBounds.minX, 0.0, 0.0, busBounds.maxX, busBounds.minY, 1.0 );
|
|
|
|
renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, busBounds.minX, busBounds.maxY, 0.0, busBounds.maxX, 1.0, 1.0 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( fc.getFacade( ForgeDirection.UP ) != null )
|
2014-01-31 01:49:27 +01:00
|
|
|
renderer.renderMaxY -= getFacadeThickness() / 16.0;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
if ( fc.getFacade( ForgeDirection.DOWN ) != null )
|
2014-01-31 01:49:27 +01:00
|
|
|
renderer.renderMinY += getFacadeThickness() / 16.0;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
if ( fc.getFacade( ForgeDirection.SOUTH ) != null )
|
2014-01-31 01:49:27 +01:00
|
|
|
renderer.renderMaxZ -= getFacadeThickness() / 16.0;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
if ( fc.getFacade( ForgeDirection.NORTH ) != null )
|
2014-01-31 01:49:27 +01:00
|
|
|
renderer.renderMinZ += getFacadeThickness() / 16.0;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, 0.0, 0.0, busBounds.maxZ, 1.0, 1.0, 1.0 );
|
|
|
|
renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, 0.0, 0.0, 0.0, 1.0, 1.0, busBounds.minZ );
|
|
|
|
renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, 0.0, 0.0, busBounds.minZ, 1.0, busBounds.minY, busBounds.maxZ );
|
|
|
|
renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, 0.0, busBounds.maxY, busBounds.minZ, 1.0, 1.0, busBounds.maxZ );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-05 02:51:05 +02:00
|
|
|
if ( rbw != null )
|
|
|
|
{
|
|
|
|
rbw.faces = EnumSet.allOf( ForgeDirection.class );
|
|
|
|
}
|
|
|
|
|
|
|
|
instance.renderForPass( 0 );
|
2013-12-27 23:59:59 +01:00
|
|
|
instance.setTexture( null );
|
|
|
|
Tessellator.instance.setColorOpaque_F( 1, 1, 1 );
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Throwable t)
|
|
|
|
{
|
2014-02-07 21:37:22 +01:00
|
|
|
AELog.error( t );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-05 02:51:05 +02:00
|
|
|
private EnumSet<ForgeDirection> calculateFaceOpenFaces(IBlockAccess blockAccess, IFacadeContainer fc, int x, int y, int z, ForgeDirection side)
|
|
|
|
{
|
|
|
|
EnumSet<ForgeDirection> out = EnumSet.of( side, side.getOpposite() );
|
|
|
|
IFacadePart facade = fc.getFacade( side );
|
|
|
|
|
|
|
|
for (ForgeDirection it : ForgeDirection.VALID_DIRECTIONS)
|
|
|
|
{
|
|
|
|
if ( !out.contains( it ) && alphaDiff( blockAccess.getTileEntity( x + it.offsetX, y + it.offsetY, z + it.offsetZ ), side, facade ) )
|
|
|
|
{
|
|
|
|
out.add( it );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( out.contains( ForgeDirection.UP ) && (side.offsetX != 0 || side.offsetZ != 0) )
|
|
|
|
{
|
|
|
|
IFacadePart fp = fc.getFacade( ForgeDirection.UP );
|
|
|
|
if ( fp != null && (fp.isTransparent() == facade.isTransparent()) )
|
|
|
|
out.remove( ForgeDirection.UP );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( out.contains( ForgeDirection.DOWN ) && (side.offsetX != 0 || side.offsetZ != 0) )
|
|
|
|
{
|
|
|
|
IFacadePart fp = fc.getFacade( ForgeDirection.DOWN );
|
|
|
|
if ( fp != null && (fp.isTransparent() == facade.isTransparent()) )
|
|
|
|
out.remove( ForgeDirection.DOWN );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( out.contains( ForgeDirection.SOUTH ) && (side.offsetX != 0) )
|
|
|
|
{
|
|
|
|
IFacadePart fp = fc.getFacade( ForgeDirection.SOUTH );
|
|
|
|
if ( fp != null && (fp.isTransparent() == facade.isTransparent()) )
|
|
|
|
out.remove( ForgeDirection.SOUTH );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( out.contains( ForgeDirection.NORTH ) && (side.offsetX != 0) )
|
|
|
|
{
|
|
|
|
IFacadePart fp = fc.getFacade( ForgeDirection.NORTH );
|
|
|
|
if ( fp != null && (fp.isTransparent() == facade.isTransparent()) )
|
|
|
|
out.remove( ForgeDirection.NORTH );
|
|
|
|
}
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean alphaDiff(TileEntity tileEntity, ForgeDirection side, IFacadePart facade)
|
|
|
|
{
|
|
|
|
if ( tileEntity instanceof IPartHost )
|
|
|
|
{
|
|
|
|
IPartHost ph = (IPartHost) tileEntity;
|
|
|
|
IFacadePart fp = ph.getFacadeContainer().getFacade( side );
|
|
|
|
|
|
|
|
return fp == null || (fp.isTransparent() != facade.isTransparent());
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-07 06:51:19 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2014-02-09 02:34:52 +01:00
|
|
|
private void renderSegmentBlockCurrentBounds(BusRenderHelper instance, int x, int y, int z, RenderBlocks renderer, double minX, double minY, double minZ,
|
|
|
|
double maxX, double maxY, double maxZ)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
double oldMinX = renderer.renderMinX;
|
|
|
|
double oldMinY = renderer.renderMinY;
|
|
|
|
double oldMinZ = renderer.renderMinZ;
|
|
|
|
double oldMaxX = renderer.renderMaxX;
|
|
|
|
double oldMaxY = renderer.renderMaxY;
|
|
|
|
double oldMaxZ = renderer.renderMaxZ;
|
|
|
|
|
|
|
|
renderer.renderMinX = Math.max( renderer.renderMinX, minX );
|
|
|
|
renderer.renderMinY = Math.max( renderer.renderMinY, minY );
|
|
|
|
renderer.renderMinZ = Math.max( renderer.renderMinZ, minZ );
|
|
|
|
renderer.renderMaxX = Math.min( renderer.renderMaxX, maxX );
|
|
|
|
renderer.renderMaxY = Math.min( renderer.renderMaxY, maxY );
|
|
|
|
renderer.renderMaxZ = Math.min( renderer.renderMaxZ, maxZ );
|
|
|
|
|
|
|
|
// don't draw it if its not at least a pixel wide...
|
|
|
|
if ( renderer.renderMaxX - renderer.renderMinX >= 1.0 / 16.0 && renderer.renderMaxY - renderer.renderMinY >= 1.0 / 16.0
|
|
|
|
&& renderer.renderMaxZ - renderer.renderMinZ >= 1.0 / 16.0 )
|
|
|
|
{
|
|
|
|
instance.renderBlockCurrentBounds( x, y, z, renderer );
|
|
|
|
}
|
|
|
|
|
|
|
|
renderer.renderMinX = oldMinX;
|
|
|
|
renderer.renderMinY = oldMinY;
|
|
|
|
renderer.renderMinZ = oldMinZ;
|
|
|
|
renderer.renderMaxX = oldMaxX;
|
|
|
|
renderer.renderMaxY = oldMaxY;
|
|
|
|
renderer.renderMaxZ = oldMaxZ;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-07 06:51:19 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-12-27 23:59:59 +01:00
|
|
|
public void renderInventory(IPartRenderHelper instance, RenderBlocks renderer)
|
|
|
|
{
|
|
|
|
if ( facade != null )
|
|
|
|
{
|
|
|
|
IFacadeItem fi = (IFacadeItem) facade.getItem();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
ItemStack randomItem = fi.getTextureItem( facade );
|
|
|
|
|
|
|
|
instance.setTexture( facade.getIconIndex() );
|
|
|
|
instance.setBounds( 7, 7, 4, 9, 9, 14 );
|
|
|
|
instance.renderInventoryBox( renderer );
|
|
|
|
instance.setTexture( null );
|
|
|
|
|
|
|
|
if ( randomItem != null )
|
|
|
|
{
|
|
|
|
if ( randomItem.getItem() instanceof ItemBlock )
|
|
|
|
{
|
|
|
|
ItemBlock ib = (ItemBlock) randomItem.getItem();
|
2014-02-09 02:34:52 +01:00
|
|
|
Block blk = Block.getBlockFromItem( ib );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
int color = ib.getColorFromItemStack( randomItem, 0 );
|
|
|
|
float r = (color >> 16 & 0xff) / 255F;
|
|
|
|
float g = (color >> 8 & 0xff) / 255F;
|
|
|
|
float b = (color & 0xff) / 255F;
|
2014-07-27 07:49:56 +02:00
|
|
|
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0F );
|
|
|
|
instance.setInvColor( color );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
catch (Throwable error)
|
|
|
|
{
|
2014-02-14 06:32:16 +01:00
|
|
|
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0F );
|
2014-07-27 07:49:56 +02:00
|
|
|
instance.setInvColor( 0xffffff );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 );
|
|
|
|
Tessellator.instance.setColorOpaque_F( 1, 1, 1 );
|
|
|
|
instance.setTexture( blk.getIcon( side.ordinal(), ib.getMetadata( randomItem.getItemDamage() ) ) );
|
|
|
|
|
|
|
|
instance.setBounds( 0, 0, 14, 16, 16, 16 );
|
|
|
|
instance.renderInventoryBox( renderer );
|
|
|
|
|
|
|
|
instance.setTexture( null );
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Throwable t)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ForgeDirection getSide()
|
|
|
|
{
|
|
|
|
return side;
|
|
|
|
}
|
|
|
|
|
2014-01-31 01:49:27 +01:00
|
|
|
public int getFacadeThickness()
|
|
|
|
{
|
|
|
|
return thickness;
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@Override
|
|
|
|
public AxisAlignedBB getPrimaryBox()
|
|
|
|
{
|
|
|
|
switch (side)
|
|
|
|
{
|
|
|
|
case DOWN:
|
2014-01-31 01:49:27 +01:00
|
|
|
return AxisAlignedBB.getBoundingBox( 0.0, 0.0, 0.0, 1.0, (getFacadeThickness()) / 16.0, 1.0 );
|
2013-12-27 23:59:59 +01:00
|
|
|
case EAST:
|
2014-01-31 01:49:27 +01:00
|
|
|
return AxisAlignedBB.getBoundingBox( (16.0 - getFacadeThickness()) / 16.0, 0.0, 0.0, 1.0, 1.0, 1.0 );
|
2013-12-27 23:59:59 +01:00
|
|
|
case NORTH:
|
2014-01-31 01:49:27 +01:00
|
|
|
return AxisAlignedBB.getBoundingBox( 0.0, 0.0, 0.0, 1.0, 1.0, (getFacadeThickness()) / 16.0 );
|
2013-12-27 23:59:59 +01:00
|
|
|
case SOUTH:
|
2014-01-31 01:49:27 +01:00
|
|
|
return AxisAlignedBB.getBoundingBox( 0.0, 0.0, (16.0 - getFacadeThickness()) / 16.0, 1.0, 1.0, 1.0 );
|
2013-12-27 23:59:59 +01:00
|
|
|
case UP:
|
2014-01-31 01:49:27 +01:00
|
|
|
return AxisAlignedBB.getBoundingBox( 0.0, (16.0 - getFacadeThickness()) / 16.0, 0.0, 1.0, 1.0, 1.0 );
|
2013-12-27 23:59:59 +01:00
|
|
|
case WEST:
|
2014-01-31 01:49:27 +01:00
|
|
|
return AxisAlignedBB.getBoundingBox( 0.0, 0.0, 0.0, (getFacadeThickness()) / 16.0, 1.0, 1.0 );
|
2013-12-27 23:59:59 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
return AxisAlignedBB.getBoundingBox( 0, 0, 0, 1, 1, 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Item getItem()
|
|
|
|
{
|
|
|
|
ItemStack is = getTexture();
|
|
|
|
if ( is == null )
|
|
|
|
return null;
|
|
|
|
return is.getItem();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getItemDamage()
|
|
|
|
{
|
|
|
|
ItemStack is = getTexture();
|
|
|
|
if ( is == null )
|
|
|
|
return 0;
|
|
|
|
return is.getItemDamage();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isBC()
|
|
|
|
{
|
|
|
|
return !(facade.getItem() instanceof IFacadeItem);
|
|
|
|
}
|
2014-01-31 01:49:27 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setThinFacades(boolean useThinFacades)
|
|
|
|
{
|
|
|
|
thickness = useThinFacades ? 1 : 2;
|
|
|
|
}
|
2014-05-05 02:51:05 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isTransparent()
|
|
|
|
{
|
|
|
|
ItemStack is = getTexture();
|
|
|
|
Block blk = Block.getBlockFromItem( is.getItem() );
|
|
|
|
if ( !blk.isOpaqueCube() )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|