2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Applied Energistics 2.
|
2015-05-18 00:09:09 +02:00
|
|
|
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
2014-11-14 12:02:52 +01:00
|
|
|
*
|
|
|
|
* 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-09-24 02:26:27 +02:00
|
|
|
package appeng.client.render;
|
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
|
2014-09-24 02:26:27 +02:00
|
|
|
import java.util.EnumSet;
|
2015-08-06 18:31:46 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
import javax.annotation.Nullable;
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-05-08 23:25:19 +02:00
|
|
|
import com.google.common.base.Function;
|
|
|
|
import com.google.common.base.Optional;
|
|
|
|
|
2014-09-24 02:26:27 +02:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
|
|
|
import net.minecraft.client.renderer.Tessellator;
|
|
|
|
import net.minecraft.util.IIcon;
|
|
|
|
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-09-24 02:26:27 +02:00
|
|
|
import appeng.api.AEApi;
|
2015-01-03 02:53:14 +01:00
|
|
|
import appeng.api.exceptions.MissingDefinition;
|
2014-09-24 02:26:27 +02:00
|
|
|
import appeng.api.parts.IBoxProvider;
|
|
|
|
import appeng.api.parts.IPartCollisionHelper;
|
|
|
|
import appeng.api.parts.IPartRenderHelper;
|
|
|
|
import appeng.api.parts.ISimplifiedBundle;
|
|
|
|
import appeng.block.AEBaseBlock;
|
|
|
|
import appeng.block.networking.BlockCableBus;
|
|
|
|
import appeng.core.AEConfig;
|
|
|
|
import appeng.core.features.AEFeature;
|
2015-05-09 12:18:43 +02:00
|
|
|
import appeng.tile.AEBaseTile;
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
|
|
|
|
@SideOnly( Side.CLIENT )
|
|
|
|
public final class BusRenderHelper implements IPartRenderHelper
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
public static final BusRenderHelper INSTANCE = new BusRenderHelper();
|
|
|
|
private static final int HEX_WHITE = 0xffffff;
|
|
|
|
|
|
|
|
private final BoundBoxCalculator bbc;
|
|
|
|
private final boolean noAlphaPass;
|
2015-09-16 18:03:07 +02:00
|
|
|
private final BaseBlockRender<AEBaseBlock, AEBaseTile> bbr;
|
2015-01-03 02:53:14 +01:00
|
|
|
private final Optional<Block> maybeBlock;
|
|
|
|
private final Optional<AEBaseBlock> maybeBaseBlock;
|
|
|
|
private int renderingForPass;
|
|
|
|
private int currentPass;
|
|
|
|
private int itemsRendered;
|
|
|
|
private double minX;
|
|
|
|
private double minY;
|
|
|
|
private double minZ;
|
|
|
|
private double maxX;
|
|
|
|
private double maxY;
|
|
|
|
private double maxZ;
|
|
|
|
private ForgeDirection ax;
|
|
|
|
private ForgeDirection ay;
|
|
|
|
private ForgeDirection az;
|
|
|
|
private int color;
|
|
|
|
|
|
|
|
public BusRenderHelper()
|
|
|
|
{
|
|
|
|
this.bbc = new BoundBoxCalculator( this );
|
|
|
|
this.noAlphaPass = !AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass );
|
2015-05-09 12:18:43 +02:00
|
|
|
this.bbr = new BaseBlockRender<AEBaseBlock, AEBaseTile>();
|
2015-01-03 02:53:14 +01:00
|
|
|
this.renderingForPass = 0;
|
|
|
|
this.currentPass = 0;
|
|
|
|
this.itemsRendered = 0;
|
|
|
|
this.minX = 0;
|
|
|
|
this.minY = 0;
|
|
|
|
this.minZ = 0;
|
|
|
|
this.maxX = 16;
|
|
|
|
this.maxY = 16;
|
|
|
|
this.maxZ = 16;
|
|
|
|
this.ax = ForgeDirection.EAST;
|
|
|
|
this.az = ForgeDirection.SOUTH;
|
|
|
|
this.ay = ForgeDirection.UP;
|
|
|
|
this.color = HEX_WHITE;
|
2015-04-03 08:54:31 +02:00
|
|
|
this.maybeBlock = AEApi.instance().definitions().blocks().multiPart().maybeBlock();
|
2015-01-03 02:53:14 +01:00
|
|
|
this.maybeBaseBlock = this.maybeBlock.transform( new BaseBlockTransformFunction() );
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getItemsRendered()
|
|
|
|
{
|
|
|
|
return this.itemsRendered;
|
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
public void setPass( final int pass )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
this.renderingForPass = 0;
|
|
|
|
this.currentPass = pass;
|
|
|
|
this.itemsRendered = 0;
|
|
|
|
}
|
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
public double getBound( final ForgeDirection side )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
switch( side )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
case UNKNOWN:
|
|
|
|
return 0.5;
|
|
|
|
case DOWN:
|
|
|
|
return this.minY;
|
|
|
|
case EAST:
|
|
|
|
return this.maxX;
|
|
|
|
case NORTH:
|
|
|
|
return this.minZ;
|
|
|
|
case SOUTH:
|
|
|
|
return this.maxZ;
|
|
|
|
case UP:
|
|
|
|
return this.maxY;
|
|
|
|
case WEST:
|
|
|
|
return this.minX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
public void setRenderColor( final int color )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final Block block : AEApi.instance().definitions().blocks().multiPart().maybeBlock().asSet() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
final BlockCableBus cableBus = (BlockCableBus) block;
|
|
|
|
cableBus.setRenderColor( color );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
public void setOrientation( final ForgeDirection dx, final ForgeDirection dy, final ForgeDirection dz )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
this.ax = dx == null ? ForgeDirection.EAST : dx;
|
|
|
|
this.ay = dy == null ? ForgeDirection.UP : dy;
|
|
|
|
this.az = dz == null ? ForgeDirection.SOUTH : dz;
|
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
public double[] getBounds()
|
|
|
|
{
|
|
|
|
return new double[] { this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ };
|
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
public void setBounds( final double[] bounds )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( bounds == null || bounds.length != 6 )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
return;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
this.minX = bounds[0];
|
|
|
|
this.minY = bounds[1];
|
|
|
|
this.minZ = bounds[2];
|
|
|
|
this.maxX = bounds[3];
|
|
|
|
this.maxY = bounds[4];
|
|
|
|
this.maxZ = bounds[5];
|
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
private static class BoundBoxCalculator implements IPartCollisionHelper
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
private final BusRenderHelper helper;
|
|
|
|
private boolean started = false;
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
private float minX;
|
|
|
|
private float minY;
|
|
|
|
private float minZ;
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
private float maxX;
|
|
|
|
private float maxY;
|
|
|
|
private float maxZ;
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
public BoundBoxCalculator( final BusRenderHelper helper )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
this.helper = helper;
|
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void addBox( final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.started )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
|
|
|
this.minX = Math.min( this.minX, (float) minX );
|
|
|
|
this.minY = Math.min( this.minY, (float) minY );
|
|
|
|
this.minZ = Math.min( this.minZ, (float) minZ );
|
|
|
|
this.maxX = Math.max( this.maxX, (float) maxX );
|
|
|
|
this.maxY = Math.max( this.maxY, (float) maxY );
|
|
|
|
this.maxZ = Math.max( this.maxZ, (float) maxZ );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.started = true;
|
2014-09-24 02:26:27 +02:00
|
|
|
this.minX = (float) minX;
|
|
|
|
this.minY = (float) minY;
|
|
|
|
this.minZ = (float) minZ;
|
|
|
|
this.maxX = (float) maxX;
|
|
|
|
this.maxY = (float) maxY;
|
|
|
|
this.maxZ = (float) maxZ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ForgeDirection getWorldX()
|
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
return this.helper.ax;
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ForgeDirection getWorldY()
|
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
return this.helper.ay;
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ForgeDirection getWorldZ()
|
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
return this.helper.az;
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isBBCollision()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private static final class BaseBlockTransformFunction implements Function<Block, AEBaseBlock>
|
|
|
|
{
|
|
|
|
@Nullable
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public AEBaseBlock apply( final Block input )
|
2015-04-03 08:54:31 +02:00
|
|
|
{
|
|
|
|
if( input instanceof AEBaseBlock )
|
|
|
|
{
|
2015-05-09 12:18:43 +02:00
|
|
|
return( (AEBaseBlock) input );
|
2015-04-03 08:54:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void renderForPass( final int pass )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
this.renderingForPass = pass;
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
2015-10-08 15:42:42 +02:00
|
|
|
private boolean renderThis()
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.renderingForPass == this.currentPass || this.noAlphaPass )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.itemsRendered++;
|
2014-09-24 02:26:27 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void normalRendering()
|
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
final RenderBlocksWorkaround rbw = BusRenderer.INSTANCE.getRenderer();
|
|
|
|
rbw.setCalculations( true );
|
|
|
|
rbw.setUseTextures( true );
|
2014-09-24 02:26:27 +02:00
|
|
|
rbw.enableAO = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public ISimplifiedBundle useSimplifiedRendering( final int x, final int y, final int z, final IBoxProvider p, final ISimplifiedBundle sim )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
final RenderBlocksWorkaround rbw = BusRenderer.INSTANCE.getRenderer();
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( sim != null && this.maybeBlock.isPresent() && rbw.similarLighting( this.maybeBlock.get(), rbw.blockAccess, x, y, z, sim ) )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
|
|
|
rbw.populate( sim );
|
2015-10-08 15:42:42 +02:00
|
|
|
rbw.setFaces( EnumSet.allOf( ForgeDirection.class ) );
|
|
|
|
rbw.setCalculations( false );
|
|
|
|
rbw.setUseTextures( false );
|
2014-09-24 02:26:27 +02:00
|
|
|
|
|
|
|
return sim;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
final boolean allFaces = rbw.renderAllFaces;
|
2014-09-24 02:26:27 +02:00
|
|
|
rbw.renderAllFaces = true;
|
2015-10-08 15:42:42 +02:00
|
|
|
rbw.setCalculations( true );
|
|
|
|
rbw.getFaces().clear();
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.bbc.started = false;
|
2015-04-03 08:54:31 +02:00
|
|
|
if( p == null )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.bbc.minX = this.bbc.minY = this.bbc.minZ = 0;
|
|
|
|
this.bbc.maxX = this.bbc.maxY = this.bbc.maxZ = 16;
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
p.getBoxes( this.bbc );
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.bbc.minX < 1 )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.bbc.minX = 1;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.bbc.minY < 1 )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.bbc.minY = 1;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.bbc.minZ < 1 )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.bbc.minZ = 1;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-12-29 15:13:47 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.bbc.maxX > 15 )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.bbc.maxX = 15;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.bbc.maxY > 15 )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.bbc.maxY = 15;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.bbc.maxZ > 15 )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.bbc.maxZ = 15;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.setBounds( this.bbc.minX, this.bbc.minY, this.bbc.minZ, this.bbc.maxX, this.bbc.maxY, this.bbc.maxZ );
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.bbr.renderBlockBounds( rbw, this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ, this.ax, this.ay, this.az );
|
2015-01-03 02:53:14 +01:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final Block block : this.maybeBlock.asSet() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
rbw.renderStandardBlock( block, x, y, z );
|
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-10-08 15:42:42 +02:00
|
|
|
rbw.setFaces( EnumSet.allOf( ForgeDirection.class ) );
|
2014-09-24 02:26:27 +02:00
|
|
|
rbw.renderAllFaces = allFaces;
|
2015-10-08 15:42:42 +02:00
|
|
|
rbw.setCalculations( false );
|
|
|
|
rbw.setUseTextures( false );
|
2014-09-24 02:26:27 +02:00
|
|
|
|
|
|
|
return rbw.getLightingCache();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void setBounds( final float minX, final float minY, final float minZ, final float maxX, final float maxY, final float maxZ )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2014-09-28 11:47:17 +02:00
|
|
|
this.minX = minX;
|
|
|
|
this.minY = minY;
|
|
|
|
this.minZ = minZ;
|
|
|
|
this.maxX = maxX;
|
|
|
|
this.maxY = maxY;
|
|
|
|
this.maxZ = maxZ;
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void setInvColor( final int newColor )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.color = newColor;
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void setTexture( final IIcon ico )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final AEBaseBlock baseBlock : this.maybeBaseBlock.asSet() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
baseBlock.getRendererInstance().setTemporaryRenderIcon( ico );
|
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void setTexture( final IIcon down, final IIcon up, final IIcon north, final IIcon south, final IIcon west, final IIcon east )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
final IIcon[] list = new IIcon[6];
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-05-08 23:25:19 +02:00
|
|
|
list[0] = down;
|
|
|
|
list[1] = up;
|
|
|
|
list[2] = north;
|
|
|
|
list[3] = south;
|
|
|
|
list[4] = west;
|
|
|
|
list[5] = east;
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final AEBaseBlock baseBlock : this.maybeBaseBlock.asSet() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
baseBlock.getRendererInstance().setTemporaryRenderIcons( list[this.mapRotation( ForgeDirection.UP ).ordinal()], list[this.mapRotation( ForgeDirection.DOWN ).ordinal()], list[this.mapRotation( ForgeDirection.SOUTH ).ordinal()], list[this.mapRotation( ForgeDirection.NORTH ).ordinal()], list[this.mapRotation( ForgeDirection.EAST ).ordinal()], list[this.mapRotation( ForgeDirection.WEST ).ordinal()] );
|
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
2015-10-08 15:42:42 +02:00
|
|
|
private ForgeDirection mapRotation( final ForgeDirection dir )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
final ForgeDirection forward = this.az;
|
|
|
|
final ForgeDirection up = this.ay;
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( forward == null || up == null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-09-24 02:26:27 +02:00
|
|
|
return dir;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
final int west_x = forward.offsetY * up.offsetZ - forward.offsetZ * up.offsetY;
|
|
|
|
final int west_y = forward.offsetZ * up.offsetX - forward.offsetX * up.offsetZ;
|
|
|
|
final int west_z = forward.offsetX * up.offsetY - forward.offsetY * up.offsetX;
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-09-25 22:52:41 +02:00
|
|
|
ForgeDirection west = ForgeDirection.UNKNOWN;
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final ForgeDirection dx : ForgeDirection.VALID_DIRECTIONS )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( dx.offsetX == west_x && dx.offsetY == west_y && dx.offsetZ == west_z )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-09-24 02:26:27 +02:00
|
|
|
west = dx;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( dir == forward )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-09-24 02:26:27 +02:00
|
|
|
return ForgeDirection.SOUTH;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
if( dir == forward.getOpposite() )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-09-24 02:26:27 +02:00
|
|
|
return ForgeDirection.NORTH;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( dir == up )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-09-24 02:26:27 +02:00
|
|
|
return ForgeDirection.UP;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
if( dir == up.getOpposite() )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-09-24 02:26:27 +02:00
|
|
|
return ForgeDirection.DOWN;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( dir == west )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-09-24 02:26:27 +02:00
|
|
|
return ForgeDirection.WEST;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
if( dir == west.getOpposite() )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-09-24 02:26:27 +02:00
|
|
|
return ForgeDirection.EAST;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
|
|
|
|
return ForgeDirection.UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void renderInventoryBox( final RenderBlocks renderer )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
renderer.setRenderBounds( this.minX / 16.0, this.minY / 16.0, this.minZ / 16.0, this.maxX / 16.0, this.maxY / 16.0, this.maxZ / 16.0 );
|
2015-01-03 02:53:14 +01:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final AEBaseBlock baseBlock : this.maybeBaseBlock.asSet() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
this.bbr.renderInvBlock( EnumSet.allOf( ForgeDirection.class ), baseBlock, null, Tessellator.instance, this.color, renderer );
|
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void renderInventoryFace( final IIcon icon, final ForgeDirection face, final RenderBlocks renderer )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
renderer.setRenderBounds( this.minX / 16.0, this.minY / 16.0, this.minZ / 16.0, this.maxX / 16.0, this.maxY / 16.0, this.maxZ / 16.0 );
|
2015-05-18 00:09:09 +02:00
|
|
|
this.setTexture( icon );
|
2015-01-03 02:53:14 +01:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final AEBaseBlock baseBlock : this.maybeBaseBlock.asSet() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
this.bbr.renderInvBlock( EnumSet.of( face ), baseBlock, null, Tessellator.instance, this.color, renderer );
|
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void renderBlock( final int x, final int y, final int z, final RenderBlocks renderer )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( !this.renderThis() )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-09-24 02:26:27 +02:00
|
|
|
return;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final Block multiPart : AEApi.instance().definitions().blocks().multiPart().maybeBlock().asSet() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
final AEBaseBlock block = (AEBaseBlock) multiPart;
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
final BlockRenderInfo info = block.getRendererInstance();
|
|
|
|
final ForgeDirection forward = BusRenderHelper.INSTANCE.az;
|
|
|
|
final ForgeDirection up = BusRenderHelper.INSTANCE.ay;
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
renderer.uvRotateBottom = info.getTexture( ForgeDirection.DOWN ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.DOWN, forward, up ) );
|
|
|
|
renderer.uvRotateTop = info.getTexture( ForgeDirection.UP ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.UP, forward, up ) );
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
renderer.uvRotateEast = info.getTexture( ForgeDirection.EAST ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.EAST, forward, up ) );
|
|
|
|
renderer.uvRotateWest = info.getTexture( ForgeDirection.WEST ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.WEST, forward, up ) );
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
renderer.uvRotateNorth = info.getTexture( ForgeDirection.NORTH ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.NORTH, forward, up ) );
|
|
|
|
renderer.uvRotateSouth = info.getTexture( ForgeDirection.SOUTH ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.SOUTH, forward, up ) );
|
|
|
|
|
|
|
|
this.bbr.renderBlockBounds( renderer, this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ, this.ax, this.ay, this.az );
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
renderer.renderStandardBlock( block, x, y, z );
|
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Block getBlock()
|
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final Block block : AEApi.instance().definitions().blocks().multiPart().maybeBlock().asSet() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
return block;
|
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-03-23 10:14:35 +01:00
|
|
|
throw new MissingDefinition( "Tried to access the multi part block without it being defined." );
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
public void prepareBounds( final RenderBlocks renderer )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.bbr.renderBlockBounds( renderer, this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ, this.ax, this.ay, this.az );
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void setFacesToRender( final EnumSet<ForgeDirection> faces )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
BusRenderer.INSTANCE.getRenderer().setRenderFaces( faces );
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
2014-09-28 20:34:00 +02:00
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void renderBlockCurrentBounds( final int x, final int y, final int z, final RenderBlocks renderer )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( !this.renderThis() )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-09-24 02:26:27 +02:00
|
|
|
return;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final Block block : this.maybeBlock.asSet() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
renderer.renderStandardBlock( block, x, y, z );
|
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void renderFaceCutout( final int x, final int y, final int z, final IIcon ico, ForgeDirection face, final float edgeThickness, final RenderBlocks renderer )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( !this.renderThis() )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-09-24 02:26:27 +02:00
|
|
|
return;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
switch( face )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
case DOWN:
|
|
|
|
face = this.ay.getOpposite();
|
|
|
|
break;
|
|
|
|
case EAST:
|
|
|
|
face = this.ax;
|
|
|
|
break;
|
|
|
|
case NORTH:
|
|
|
|
face = this.az.getOpposite();
|
|
|
|
break;
|
|
|
|
case SOUTH:
|
|
|
|
face = this.az;
|
|
|
|
break;
|
|
|
|
case UP:
|
|
|
|
face = this.ay;
|
|
|
|
break;
|
|
|
|
case WEST:
|
|
|
|
face = this.ax.getOpposite();
|
|
|
|
break;
|
|
|
|
case UNKNOWN:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final AEBaseBlock block : this.maybeBaseBlock.asSet() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
this.bbr.renderCutoutFace( block, ico, x, y, z, renderer, face, edgeThickness );
|
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void renderFace( final int x, final int y, final int z, final IIcon ico, ForgeDirection face, final RenderBlocks renderer )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( !this.renderThis() )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-09-24 02:26:27 +02:00
|
|
|
return;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.prepareBounds( renderer );
|
2015-04-03 08:54:31 +02:00
|
|
|
switch( face )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
case DOWN:
|
|
|
|
face = this.ay.getOpposite();
|
|
|
|
break;
|
|
|
|
case EAST:
|
|
|
|
face = this.ax;
|
|
|
|
break;
|
|
|
|
case NORTH:
|
|
|
|
face = this.az.getOpposite();
|
|
|
|
break;
|
|
|
|
case SOUTH:
|
|
|
|
face = this.az;
|
|
|
|
break;
|
|
|
|
case UP:
|
|
|
|
face = this.ay;
|
|
|
|
break;
|
|
|
|
case WEST:
|
|
|
|
face = this.ax.getOpposite();
|
|
|
|
break;
|
|
|
|
case UNKNOWN:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final AEBaseBlock block : this.maybeBaseBlock.asSet() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
this.bbr.renderFace( x, y, z, block, ico, renderer, face );
|
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ForgeDirection getWorldX()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.ax;
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ForgeDirection getWorldY()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.ay;
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ForgeDirection getWorldZ()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.az;
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
}
|