2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* 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>.
|
|
|
|
*/
|
|
|
|
|
2014-08-19 02:58:47 +02:00
|
|
|
package appeng.facade;
|
|
|
|
|
|
|
|
import java.util.EnumSet;
|
|
|
|
|
2014-12-29 21:59:05 +01:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
2014-08-19 02:58:47 +02:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
|
|
|
import net.minecraft.client.renderer.Tessellator;
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemBlock;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
|
|
|
import net.minecraft.util.IIcon;
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
|
|
|
|
2014-12-29 21:59:05 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2014-08-19 02:58:47 +02:00
|
|
|
|
|
|
|
import appeng.api.AEApi;
|
|
|
|
import appeng.api.parts.IBoxProvider;
|
|
|
|
import appeng.api.parts.IFacadeContainer;
|
|
|
|
import appeng.api.parts.IFacadePart;
|
2014-09-20 22:20:53 +02:00
|
|
|
import appeng.api.parts.IPartCollisionHelper;
|
2014-08-19 02:58:47 +02:00
|
|
|
import appeng.api.parts.IPartHost;
|
|
|
|
import appeng.api.parts.IPartRenderHelper;
|
|
|
|
import appeng.api.parts.ISimplifiedBundle;
|
|
|
|
import appeng.client.render.BusRenderHelper;
|
|
|
|
import appeng.client.render.RenderBlocksWorkaround;
|
|
|
|
import appeng.core.AELog;
|
|
|
|
import appeng.core.AppEng;
|
|
|
|
import appeng.integration.IntegrationType;
|
|
|
|
import appeng.integration.abstraction.IBC;
|
|
|
|
import appeng.util.Platform;
|
|
|
|
|
|
|
|
public class FacadePart implements IFacadePart, IBoxProvider
|
|
|
|
{
|
|
|
|
|
|
|
|
public final ItemStack facade;
|
|
|
|
public final ForgeDirection side;
|
|
|
|
public int thickness = 2;
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
ISimplifiedBundle prevLight;
|
|
|
|
|
|
|
|
public FacadePart(ItemStack facade, ForgeDirection side) {
|
|
|
|
if ( facade == null )
|
|
|
|
throw new RuntimeException( "Facade Part constructed on null item." );
|
|
|
|
this.facade = facade.copy();
|
|
|
|
this.facade.stackSize = 1;
|
|
|
|
this.side = side;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack getItemStack()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.facade;
|
2014-08-19 02:58:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-09-20 22:20:53 +02:00
|
|
|
public void getBoxes(IPartCollisionHelper ch, Entity e)
|
2014-08-19 02:58:47 +02:00
|
|
|
{
|
|
|
|
if ( e instanceof EntityLivingBase )
|
|
|
|
{
|
2014-09-21 01:23:44 +02:00
|
|
|
// prevent weird snag behavior
|
2014-08-19 02:58:47 +02:00
|
|
|
ch.addBox( 0.0, 0.0, 14, 16.0, 16.0, 16.0 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// the box is 15.9 for transition planes to pick up collision events.
|
|
|
|
ch.addBox( 0.0, 0.0, 14, 16.0, 16.0, 15.9 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-09-20 22:20:53 +02:00
|
|
|
public void getBoxes(IPartCollisionHelper bch)
|
2014-08-19 02:58:47 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.getBoxes( bch, null );
|
2014-08-19 02:58:47 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isFacade(ItemStack is)
|
|
|
|
{
|
|
|
|
if ( is.getItem() instanceof IFacadeItem )
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ItemStack getTexture()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.facade.getItem() instanceof IFacadeItem )
|
2014-08-19 02:58:47 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
IFacadeItem fi = (IFacadeItem) this.facade.getItem();
|
|
|
|
return fi.getTextureItem( this.facade );
|
2014-08-19 02:58:47 +02:00
|
|
|
}
|
|
|
|
else if ( AppEng.instance.isIntegrationEnabled( IntegrationType.BC ) )
|
|
|
|
{
|
|
|
|
IBC bc = (IBC) AppEng.instance.getIntegration( IntegrationType.BC );
|
2014-12-29 15:13:47 +01:00
|
|
|
return bc.getTextureForFacade( this.facade );
|
2014-08-19 02:58:47 +02:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void renderStatic(int x, int y, int z, IPartRenderHelper instance2, RenderBlocks renderer, IFacadeContainer fc, AxisAlignedBB busBounds,
|
|
|
|
boolean renderStilt)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.facade != null )
|
2014-08-19 02:58:47 +02:00
|
|
|
{
|
|
|
|
BusRenderHelper instance = (BusRenderHelper) instance2;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
ItemStack randomItem = this.getTexture();
|
2014-08-19 02:58:47 +02:00
|
|
|
|
|
|
|
RenderBlocksWorkaround rbw = null;
|
|
|
|
if ( renderer instanceof RenderBlocksWorkaround )
|
|
|
|
{
|
|
|
|
rbw = (RenderBlocksWorkaround) renderer;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( renderStilt && busBounds == null )
|
|
|
|
{
|
|
|
|
if ( rbw != null )
|
|
|
|
{
|
|
|
|
rbw.isFacade = false;
|
|
|
|
rbw.calculations = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
IIcon myIcon = null;
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.isBC() )
|
2014-08-19 02:58:47 +02:00
|
|
|
{
|
|
|
|
IBC bc = (IBC) AppEng.instance.getIntegration( IntegrationType.BC );
|
|
|
|
myIcon = bc.getFacadeTexture();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( myIcon == null )
|
2014-12-29 15:13:47 +01:00
|
|
|
myIcon = this.facade.getIconIndex();
|
2014-08-19 02:58:47 +02:00
|
|
|
|
|
|
|
instance.setTexture( myIcon );
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.isBC() )
|
2014-08-19 02:58:47 +02:00
|
|
|
instance.setBounds( 6, 6, 10, 10, 10, 15 );
|
|
|
|
else
|
|
|
|
instance.setBounds( 7, 7, 10, 9, 9, 15 );
|
|
|
|
|
|
|
|
instance.renderBlock( x, y, z, renderer );
|
|
|
|
instance.setTexture( null );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( randomItem != null )
|
|
|
|
{
|
|
|
|
if ( randomItem.getItem() instanceof ItemBlock )
|
|
|
|
{
|
|
|
|
ItemBlock ib = (ItemBlock) randomItem.getItem();
|
|
|
|
Block blk = Block.getBlockFromItem( ib );
|
|
|
|
|
|
|
|
if ( AEApi.instance().partHelper().getCableRenderMode().transparentFacades )
|
|
|
|
{
|
|
|
|
if ( rbw != null )
|
|
|
|
rbw.opacity = 0.3f;
|
|
|
|
instance.renderForPass( 1 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( blk.canRenderInPass( 1 ) )
|
|
|
|
{
|
|
|
|
instance.renderForPass( 1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int color = 0xffffff;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
color = ib.getColorFromItemStack( randomItem, 0 );
|
|
|
|
}
|
2014-10-01 15:20:42 +02:00
|
|
|
catch (Throwable ignored)
|
2014-08-19 02:58:47 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
2014-12-29 15:13:47 +01:00
|
|
|
instance.setBounds( 0, 0, 16 - this.getFacadeThickness(), 16, 16, 16 );
|
2014-08-19 02:58:47 +02:00
|
|
|
instance.prepareBounds( renderer );
|
|
|
|
|
|
|
|
if ( rbw != null )
|
|
|
|
{
|
|
|
|
rbw.isFacade = true;
|
|
|
|
|
|
|
|
rbw.calculations = true;
|
|
|
|
rbw.faces = EnumSet.noneOf( ForgeDirection.class );
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.prevLight != null && rbw.similarLighting( blk, rbw.blockAccess, x, y, z, this.prevLight ) )
|
|
|
|
rbw.populate( this.prevLight );
|
2014-08-19 02:58:47 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
instance.setRenderColor( color );
|
|
|
|
rbw.renderStandardBlock( instance.getBlock(), x, y, z );
|
|
|
|
instance.setRenderColor( 0xffffff );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.prevLight = rbw.getLightingCache();
|
2014-08-19 02:58:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
rbw.calculations = false;
|
2014-12-29 15:13:47 +01:00
|
|
|
rbw.faces = this.calculateFaceOpenFaces( rbw.blockAccess, fc, x, y, z, this.side );
|
2014-08-19 02:58:47 +02: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() ) ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
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() ) ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( busBounds == null )
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.side == ForgeDirection.UP || this.side == ForgeDirection.DOWN )
|
2014-08-19 02:58:47 +02:00
|
|
|
{
|
|
|
|
instance.renderBlockCurrentBounds( x, y, z, renderer );
|
|
|
|
}
|
2014-12-29 15:13:47 +01:00
|
|
|
else if ( this.side == ForgeDirection.NORTH || this.side == ForgeDirection.SOUTH )
|
2014-08-19 02:58:47 +02:00
|
|
|
{
|
|
|
|
if ( fc.getFacade( ForgeDirection.UP ) != null )
|
2014-12-29 15:13:47 +01:00
|
|
|
renderer.renderMaxY -= this.getFacadeThickness() / 16.0;
|
2014-08-19 02:58:47 +02:00
|
|
|
|
|
|
|
if ( fc.getFacade( ForgeDirection.DOWN ) != null )
|
2014-12-29 15:13:47 +01:00
|
|
|
renderer.renderMinY += this.getFacadeThickness() / 16.0;
|
2014-08-19 02:58:47 +02:00
|
|
|
|
|
|
|
instance.renderBlockCurrentBounds( x, y, z, renderer );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( fc.getFacade( ForgeDirection.UP ) != null )
|
2014-12-29 15:13:47 +01:00
|
|
|
renderer.renderMaxY -= this.getFacadeThickness() / 16.0;
|
2014-08-19 02:58:47 +02:00
|
|
|
|
|
|
|
if ( fc.getFacade( ForgeDirection.DOWN ) != null )
|
2014-12-29 15:13:47 +01:00
|
|
|
renderer.renderMinY += this.getFacadeThickness() / 16.0;
|
2014-08-19 02:58:47 +02:00
|
|
|
|
|
|
|
if ( fc.getFacade( ForgeDirection.SOUTH ) != null )
|
2014-12-29 15:13:47 +01:00
|
|
|
renderer.renderMaxZ -= this.getFacadeThickness() / 16.0;
|
2014-08-19 02:58:47 +02:00
|
|
|
|
|
|
|
if ( fc.getFacade( ForgeDirection.NORTH ) != null )
|
2014-12-29 15:13:47 +01:00
|
|
|
renderer.renderMinZ += this.getFacadeThickness() / 16.0;
|
2014-08-19 02:58:47 +02:00
|
|
|
|
|
|
|
instance.renderBlockCurrentBounds( x, y, z, renderer );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.side == ForgeDirection.UP || this.side == ForgeDirection.DOWN )
|
2014-08-19 02:58:47 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, 0.0, 0.0, busBounds.maxZ, 1.0, 1.0, 1.0 );
|
|
|
|
this.renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, 0.0, 0.0, 0.0, 1.0, 1.0, busBounds.minZ );
|
|
|
|
this.renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, 0.0, 0.0, busBounds.minZ, busBounds.minX, 1.0, busBounds.maxZ );
|
|
|
|
this.renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, busBounds.maxX, 0.0, busBounds.minZ, 1.0, 1.0, busBounds.maxZ );
|
2014-08-19 02:58:47 +02:00
|
|
|
}
|
2014-12-29 15:13:47 +01:00
|
|
|
else if ( this.side == ForgeDirection.NORTH || this.side == ForgeDirection.SOUTH )
|
2014-08-19 02:58:47 +02:00
|
|
|
{
|
|
|
|
if ( fc.getFacade( ForgeDirection.UP ) != null )
|
2014-12-29 15:13:47 +01:00
|
|
|
renderer.renderMaxY -= this.getFacadeThickness() / 16.0;
|
2014-08-19 02:58:47 +02:00
|
|
|
|
|
|
|
if ( fc.getFacade( ForgeDirection.DOWN ) != null )
|
2014-12-29 15:13:47 +01:00
|
|
|
renderer.renderMinY += this.getFacadeThickness() / 16.0;
|
2014-08-19 02:58:47 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, busBounds.maxX, 0.0, 0.0, 1.0, 1.0, 1.0 );
|
|
|
|
this.renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, 0.0, 0.0, 0.0, busBounds.minX, 1.0, 1.0 );
|
|
|
|
this.renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, busBounds.minX, 0.0, 0.0, busBounds.maxX, busBounds.minY, 1.0 );
|
|
|
|
this.renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, busBounds.minX, busBounds.maxY, 0.0, busBounds.maxX, 1.0, 1.0 );
|
2014-08-19 02:58:47 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( fc.getFacade( ForgeDirection.UP ) != null )
|
2014-12-29 15:13:47 +01:00
|
|
|
renderer.renderMaxY -= this.getFacadeThickness() / 16.0;
|
2014-08-19 02:58:47 +02:00
|
|
|
|
|
|
|
if ( fc.getFacade( ForgeDirection.DOWN ) != null )
|
2014-12-29 15:13:47 +01:00
|
|
|
renderer.renderMinY += this.getFacadeThickness() / 16.0;
|
2014-08-19 02:58:47 +02:00
|
|
|
|
|
|
|
if ( fc.getFacade( ForgeDirection.SOUTH ) != null )
|
2014-12-29 15:13:47 +01:00
|
|
|
renderer.renderMaxZ -= this.getFacadeThickness() / 16.0;
|
2014-08-19 02:58:47 +02:00
|
|
|
|
|
|
|
if ( fc.getFacade( ForgeDirection.NORTH ) != null )
|
2014-12-29 15:13:47 +01:00
|
|
|
renderer.renderMinZ += this.getFacadeThickness() / 16.0;
|
2014-08-19 02:58:47 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, 0.0, 0.0, busBounds.maxZ, 1.0, 1.0, 1.0 );
|
|
|
|
this.renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, 0.0, 0.0, 0.0, 1.0, 1.0, busBounds.minZ );
|
|
|
|
this.renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, 0.0, 0.0, busBounds.minZ, 1.0, busBounds.minY, busBounds.maxZ );
|
|
|
|
this.renderSegmentBlockCurrentBounds( instance, x, y, z, renderer, 0.0, busBounds.maxY, busBounds.minZ, 1.0, 1.0, busBounds.maxZ );
|
2014-08-19 02:58:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( rbw != null )
|
|
|
|
{
|
|
|
|
rbw.opacity = 1.0f;
|
|
|
|
rbw.faces = EnumSet.allOf( ForgeDirection.class );
|
|
|
|
}
|
|
|
|
|
|
|
|
instance.renderForPass( 0 );
|
|
|
|
instance.setTexture( null );
|
|
|
|
Tessellator.instance.setColorOpaque_F( 1, 1, 1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Throwable t)
|
|
|
|
{
|
|
|
|
AELog.error( t );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( !out.contains( it ) && this.alphaDiff( blockAccess.getTileEntity( x + it.offsetX, y + it.offsetY, z + it.offsetZ ), side, facade ) )
|
2014-08-19 02:58:47 +02:00
|
|
|
{
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if ( out.contains( ForgeDirection.EAST ) && (side.offsetZ != 0) ) { IFacadePart fp = fc.getFacade(
|
|
|
|
* ForgeDirection.EAST ); if ( fp != null && (fp.isTransparent() == facade.isTransparent()) ) out.remove(
|
|
|
|
* ForgeDirection.EAST ); }
|
|
|
|
*
|
|
|
|
* if ( out.contains( ForgeDirection.WEST ) && (side.offsetZ != 0) ) { IFacadePart fp = fc.getFacade(
|
|
|
|
* ForgeDirection.WEST ); if ( fp != null && (fp.isTransparent() == facade.isTransparent()) ) out.remove(
|
|
|
|
* ForgeDirection.WEST ); }
|
|
|
|
*
|
|
|
|
* if ( out.contains( ForgeDirection.NORTH ) && (side.offsetY != 0) ) { IFacadePart fp = fc.getFacade(
|
|
|
|
* ForgeDirection.NORTH ); if ( fp != null && (fp.isTransparent() == facade.isTransparent()) ) out.remove(
|
|
|
|
* ForgeDirection.NORTH ); }
|
|
|
|
*
|
|
|
|
* if ( out.contains( ForgeDirection.SOUTH ) && (side.offsetY != 0) ) { IFacadePart fp = fc.getFacade(
|
|
|
|
* ForgeDirection.SOUTH ); if ( fp != null && (fp.isTransparent() == facade.isTransparent()) ) out.remove(
|
|
|
|
* ForgeDirection.SOUTH ); }
|
|
|
|
*
|
|
|
|
* if ( out.contains( ForgeDirection.EAST ) && (side.offsetY != 0) ) { IFacadePart fp = fc.getFacade(
|
|
|
|
* ForgeDirection.EAST ); if ( fp != null && (fp.isTransparent() == facade.isTransparent()) ) out.remove(
|
|
|
|
* ForgeDirection.EAST ); }
|
|
|
|
*
|
|
|
|
* if ( out.contains( ForgeDirection.WEST ) && (side.offsetY != 0) ) { IFacadePart fp = fc.getFacade(
|
|
|
|
* ForgeDirection.WEST ); if ( fp != null && (fp.isTransparent() == facade.isTransparent()) ) out.remove(
|
|
|
|
* ForgeDirection.WEST ); }
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void renderInventory(IPartRenderHelper instance, RenderBlocks renderer)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.facade != null )
|
2014-08-19 02:58:47 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
IFacadeItem fi = (IFacadeItem) this.facade.getItem();
|
2014-08-19 02:58:47 +02:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
ItemStack randomItem = fi.getTextureItem( this.facade );
|
2014-08-19 02:58:47 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
instance.setTexture( this.facade.getIconIndex() );
|
2014-08-19 02:58:47 +02:00
|
|
|
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();
|
|
|
|
Block blk = Block.getBlockFromItem( ib );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
int color = ib.getColorFromItemStack( randomItem, 0 );
|
|
|
|
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0F );
|
|
|
|
instance.setInvColor( color );
|
|
|
|
}
|
|
|
|
catch (Throwable error)
|
|
|
|
{
|
|
|
|
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0F );
|
|
|
|
instance.setInvColor( 0xffffff );
|
|
|
|
}
|
|
|
|
|
|
|
|
Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 );
|
|
|
|
Tessellator.instance.setColorOpaque_F( 1, 1, 1 );
|
2014-12-29 15:13:47 +01:00
|
|
|
instance.setTexture( blk.getIcon( this.side.ordinal(), ib.getMetadata( randomItem.getItemDamage() ) ) );
|
2014-08-19 02:58:47 +02:00
|
|
|
|
|
|
|
instance.setBounds( 0, 0, 14, 16, 16, 16 );
|
|
|
|
instance.renderInventoryBox( renderer );
|
|
|
|
|
|
|
|
instance.setTexture( null );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-10-01 15:20:42 +02:00
|
|
|
catch (Throwable ignored)
|
2014-08-19 02:58:47 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ForgeDirection getSide()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.side;
|
2014-08-19 02:58:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getFacadeThickness()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.thickness;
|
2014-08-19 02:58:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public AxisAlignedBB getPrimaryBox()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return Platform.getPrimaryBox( this.side, this.getFacadeThickness() );
|
2014-08-19 02:58:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Item getItem()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
ItemStack is = this.getTexture();
|
2014-08-19 02:58:47 +02:00
|
|
|
if ( is == null )
|
|
|
|
return null;
|
|
|
|
return is.getItem();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getItemDamage()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
ItemStack is = this.getTexture();
|
2014-08-19 02:58:47 +02:00
|
|
|
if ( is == null )
|
|
|
|
return 0;
|
|
|
|
return is.getItemDamage();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isBC()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return !(this.facade.getItem() instanceof IFacadeItem);
|
2014-08-19 02:58:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setThinFacades(boolean useThinFacades)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.thickness = useThinFacades ? 1 : 2;
|
2014-08-19 02:58:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isTransparent()
|
|
|
|
{
|
|
|
|
if ( AEApi.instance().partHelper().getCableRenderMode().transparentFacades )
|
|
|
|
return true;
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
ItemStack is = this.getTexture();
|
2014-08-19 02:58:47 +02:00
|
|
|
Block blk = Block.getBlockFromItem( is.getItem() );
|
|
|
|
if ( !blk.isOpaqueCube() )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|