Merge pull request #1937 from Itaros/facadesexposure

Redesigned texture state system
This commit is contained in:
SpaceToad 2014-07-25 08:45:36 +02:00
commit 8006427a0b
8 changed files with 268 additions and 127 deletions

View file

@ -66,6 +66,7 @@ import buildcraft.transport.gates.ItemGate;
import buildcraft.transport.render.PipeRendererWorld;
import buildcraft.transport.utils.FacadeMatrix;
public class BlockGenericPipe extends BlockBuildCraft {
public static int facadeRenderColor = -1;
@ -73,7 +74,9 @@ public class BlockGenericPipe extends BlockBuildCraft {
public static Map<BlockIndex, Pipe<?>> pipeRemoved = new HashMap<BlockIndex, Pipe<?>>();
private static long lastRemovedDate = -1;
private static final ForgeDirection[] DIR_VALUES = ForgeDirection.values();
static enum Part {
Pipe,
Gate,
@ -81,7 +84,7 @@ public class BlockGenericPipe extends BlockBuildCraft {
Plug,
RobotStation
}
static class RaytraceResult {
public final Part hitPart;
public final MovingObjectPosition movingObjectPosition;
@ -100,14 +103,12 @@ public class BlockGenericPipe extends BlockBuildCraft {
return String.format("RayTraceResult: %s, %s", hitPart == null ? "null" : hitPart.name(), boundingBox == null ? "null" : boundingBox.toString());
}
}
private static final ForgeDirection[] DIR_VALUES = ForgeDirection.values();
private boolean skippedFirstIconRegister;
private int renderMask = 0;
/* Defined subprograms ************************************************* */
public BlockGenericPipe() {
super(Material.glass);
setRenderAllSides();
setCreativeTab(null);
}
@ -116,6 +117,7 @@ public class BlockGenericPipe extends BlockBuildCraft {
return BuildCraftTransport.pipeDurability;
}
/* Rendering Delegation Attributes ************************************* */
@Override
public int getRenderType() {
return TransportProxy.pipeModel;
@ -136,39 +138,17 @@ public class BlockGenericPipe extends BlockBuildCraft {
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
public void setRenderMask(int mask) {
renderMask = mask;
}
public final void setRenderAllSides() {
renderMask = 0x3f;
}
public void setRenderSide(ForgeDirection side, boolean render) {
if (render) {
renderMask |= 1 << side.ordinal();
} else {
renderMask &= ~(1 << side.ordinal());
}
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess blockAccess, int x, int y, int z, int side) {
return (renderMask & (1 << side)) != 0;
}
@Override
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
TileEntity tile = world.getTileEntity(x, y, z);
@ -1027,21 +1007,8 @@ public class BlockGenericPipe extends BlockBuildCraft {
private void dropWire(PipeWire pipeWire, Pipe<?> pipe) {
pipe.dropItem(pipeWire.getStack());
}
@SuppressWarnings({"all"})
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(IBlockAccess iblockaccess, int x, int y, int z, int side) {
TileEntity tile = iblockaccess.getTileEntity(x, y, z);
if (!(tile instanceof TileGenericPipe)) {
return null;
}
if (((TileGenericPipe) tile).renderState.textureArray != null) {
return ((TileGenericPipe) tile).renderState.textureArray[side];
}
return ((TileGenericPipe) tile).renderState.currentTexture;
}
@Override
public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity) {
super.onEntityCollidedWithBlock(world, i, j, k, entity);
@ -1207,12 +1174,6 @@ public class BlockGenericPipe extends BlockBuildCraft {
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int par1, int par2) {
return BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.Stripes.ordinal());
}
/**
* Spawn a digging particle effect in the world, this is a wrapper around
* EffectRenderer.addBlockHitEffects to allow the block more control over
@ -1337,4 +1298,9 @@ public class BlockGenericPipe extends BlockBuildCraft {
}
}
}
@Override
public IIcon getIcon(int side, int meta) {
return PipeIconProvider.TYPE.PipeItemsStone.getIcon();
}
}

View file

@ -10,11 +10,6 @@ package buildcraft.transport;
import io.netty.buffer.ByteBuf;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import buildcraft.core.network.IClientState;
import buildcraft.transport.utils.ConnectionMatrix;
import buildcraft.transport.utils.FacadeMatrix;
@ -33,14 +28,6 @@ public class PipeRenderState implements IClientState {
public final FacadeMatrix facadeMatrix = new FacadeMatrix();
public final GateMatrix gateMatrix = new GateMatrix();
/*
* This is a placeholder for the pipe renderer to set to a value that the BlockGenericPipe->TileGenericPipe will then return the the WorldRenderer
*/
@SideOnly(Side.CLIENT)
public IIcon currentTexture;
@SideOnly(Side.CLIENT)
public IIcon[] textureArray;
private boolean dirty = true;
public void clean() {

View file

@ -13,7 +13,6 @@ import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftTransport;
@ -93,9 +92,12 @@ public final class FacadeRenderHelper {
rotated[2][1] - zOffsets[side.ordinal()]);
}
public static void pipeFacadeRenderer(RenderBlocks renderblocks, BlockGenericPipe block, PipeRenderState state, int x, int y, int z) {
state.textureArray = new IIcon[6];
public static void pipeFacadeRenderer(RenderBlocks renderblocks, ITextureStates blockStateMachine, PipeRenderState state, int x, int y, int z) {
ITextureStates textureManager = (ITextureStates) blockStateMachine;
IIcon[] textures = textureManager.getTextureState().popArray();
//block_statemachine.setRenderAllSides();
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
Block renderBlock = state.facadeMatrix.getFacadeBlock(direction);
@ -105,11 +107,11 @@ public final class FacadeRenderHelper {
int renderMeta = state.facadeMatrix.getFacadeMetaId(direction);
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
state.textureArray[side.ordinal()] = renderBlock.getIcon(side.ordinal(), renderMeta);
textures[side.ordinal()] = renderBlock.getIcon(side.ordinal(), renderMeta);
if (side == direction || side == direction.getOpposite()) {
block.setRenderSide(side, true);
blockStateMachine.setRenderSide(side, true);
} else {
block.setRenderSide(side, state.facadeMatrix.getFacadeBlock(side) == null);
blockStateMachine.setRenderSide(side, state.facadeMatrix.getFacadeBlock(side) == null);
}
}
@ -139,7 +141,7 @@ public final class FacadeRenderHelper {
rotated[2][1] = CoreConstants.PIPE_MIN_POS - zFightOffset * 2;
MatrixTranformations.transform(rotated, direction);
setRenderBounds(renderblocks, rotated, direction);
renderblocks.renderStandardBlock(block, x, y, z);
renderblocks.renderStandardBlock(blockStateMachine.getBlock(), x, y, z);
rotated = MatrixTranformations.deepClone(zeroStateFacade);
rotated[0][0] = CoreConstants.PIPE_MIN_POS - zFightOffset * 4;
@ -147,26 +149,26 @@ public final class FacadeRenderHelper {
rotated[2][0] = CoreConstants.PIPE_MAX_POS + zFightOffset * 2;
MatrixTranformations.transform(rotated, direction);
setRenderBounds(renderblocks, rotated, direction);
renderblocks.renderStandardBlock(block, x, y, z);
renderblocks.renderStandardBlock(blockStateMachine.getBlock(), x, y, z);
rotated = MatrixTranformations.deepClone(zeroStateFacade);
rotated[0][0] = 0.0F;
rotated[0][1] = CoreConstants.PIPE_MIN_POS - zFightOffset * 2;
MatrixTranformations.transform(rotated, direction);
setRenderBounds(renderblocks, rotated, direction);
renderblocks.renderStandardBlock(block, x, y, z);
renderblocks.renderStandardBlock(blockStateMachine.getBlock(), x, y, z);
rotated = MatrixTranformations.deepClone(zeroStateFacade);
rotated[0][0] = CoreConstants.PIPE_MAX_POS + zFightOffset * 2;
rotated[0][1] = 1F;
MatrixTranformations.transform(rotated, direction);
setRenderBounds(renderblocks, rotated, direction);
renderblocks.renderStandardBlock(block, x, y, z);
renderblocks.renderStandardBlock(blockStateMachine.getBlock(), x, y, z);
} else { // Solid facade
float[][] rotated = MatrixTranformations.deepClone(zeroStateFacade);
MatrixTranformations.transform(rotated, direction);
setRenderBounds(renderblocks, rotated, direction);
renderblocks.renderStandardBlock(block, x, y, z);
renderblocks.renderStandardBlock(blockStateMachine.getBlock(), x, y, z);
}
if (renderBlock.getRenderType() == 31) {
@ -183,10 +185,10 @@ public final class FacadeRenderHelper {
BlockGenericPipe.facadeRenderColor = -1;
}
state.textureArray = null;
block.setRenderAllSides();
textureManager.getTextureState().pushArray();
blockStateMachine.setRenderAllSides();
state.currentTexture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure Pipe
textureManager.getTextureState().set(BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal())); // Structure Pipe
// Always render connectors in pass 0
if (PipeRendererWorld.renderPass == 0) {
@ -196,7 +198,7 @@ public final class FacadeRenderHelper {
MatrixTranformations.transform(rotated, direction);
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
renderblocks.renderStandardBlock(block, x, y, z);
renderblocks.renderStandardBlock(blockStateMachine.getBlock(), x, y, z);
}
}
}

View file

@ -0,0 +1,75 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.transport.render;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.ForgeDirection;
/*
* This is fake block to render pluggables and pipes without altering host state
* May prove useful if we will make API for roboports, pipes, plugs and facades
*/
@SideOnly(Side.CLIENT)
public final class FakeBlock extends Block implements ITextureStates {
public static final FakeBlock INSTANCE = new FakeBlock();
private int renderMask = 0;
private TextureStateManager textureState;
private FakeBlock() {
super(Material.glass);
textureState = new TextureStateManager(null); //Always Clientside
}
public TextureStateManager getTextureState() {
return textureState;
}
@Override
public IIcon getIcon(int side, int meta) {
return textureState.isSided() ? textureState.getTextureArray()[side] : textureState.getTexture();
}
@Override
public void setRenderSide(ForgeDirection side, boolean render) {
if (render) {
renderMask |= 1 << side.ordinal();
} else {
renderMask &= ~(1 << side.ordinal());
}
}
@Override
public void setRenderAllSides() {
renderMask = 0x3f;
}
@Override
public void setRenderMask(int mask) {
renderMask = mask;
}
@Override
public Block getBlock() {
return this;
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess blockAccess, int x, int y, int z, int side) {
return (renderMask & (1 << side)) != 0;
}
}

View file

@ -0,0 +1,32 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.transport.render;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
/*
* This interface designates a block as a state machine responsible for culling
* For implementation details look into FakeBlock implementation
*/
public interface ICullable {
//Side Rendering States
//They are used to effectively cull obstructed sides while processing facades.
//Make sure your implementation is correct otherwise expect FPS drop
void setRenderSide(ForgeDirection side, boolean render);
void setRenderAllSides();
boolean shouldSideBeRendered(IBlockAccess blockAccess, int x, int y, int z, int side);
void setRenderMask(int mask);
}

View file

@ -0,0 +1,22 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.transport.render;
import net.minecraft.block.Block;
import net.minecraft.util.IIcon;
public interface ITextureStates extends ICullable {
TextureStateManager getTextureState();
IIcon getIcon(int side, int meta);
Block getBlock();
}

View file

@ -22,23 +22,23 @@ import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
import buildcraft.core.CoreConstants;
import buildcraft.core.utils.MatrixTranformations;
import buildcraft.transport.BlockGenericPipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeRenderState;
import buildcraft.transport.TileGenericPipe;
import buildcraft.transport.TransportProxy;
public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
public static int renderPass = -1;
public void renderPipe(RenderBlocks renderblocks, IBlockAccess iblockaccess, BlockGenericPipe block, TileGenericPipe tile, int x, int y, int z) {
public static int renderPass = -1;
public void renderPipe(RenderBlocks renderblocks, IBlockAccess iblockaccess, TileGenericPipe tile, int x, int y, int z) {
PipeRenderState state = tile.renderState;
IIconProvider icons = tile.getPipeIcons();
FakeBlock fakeBlock = FakeBlock.INSTANCE;
if (icons == null) {
return;
}
}
// Force pipe render into pass 0
if (renderPass == 0) {
@ -49,9 +49,9 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
if (connectivity != 0x3f) { // note: 0x3f = 0x111111 = all sides
resetToCenterDimensions(dim);
state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.UNKNOWN));
renderTwoWayBlock(renderblocks, block, x, y, z, dim, connectivity ^ 0x3f);
fakeBlock.getTextureState().set(icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.UNKNOWN)));
renderTwoWayBlock(renderblocks, fakeBlock, x, y, z, dim, connectivity ^ 0x3f);
}
// render the connecting pipe faces
@ -74,21 +74,22 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
int renderMask = (3 << (dir / 2 * 2)) ^ 0x3f;
// render sub block
state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.VALID_DIRECTIONS[dir]));
fakeBlock.getTextureState().set(icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.VALID_DIRECTIONS[dir])));
renderTwoWayBlock(renderblocks, block, x, y, z, dim, renderMask);
renderTwoWayBlock(renderblocks, fakeBlock, x, y, z, dim, renderMask);
}
}
renderblocks.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
// Facade renderer handles rendering in both passes
pipeFacadeRenderer(renderblocks, block, state, x, y, z);
pipeFacadeRenderer(renderblocks, fakeBlock, state, x, y, z);
//block.setRenderAllSides();//Start fresh
// Force other opaque renders into pass 0
if (renderPass == 0) {
pipePlugRenderer(renderblocks, block, state, x, y, z);
pipeRobotStationRenderer(renderblocks, block, state, x, y, z);
pipePlugRenderer(renderblocks, fakeBlock, state, x, y, z);
pipeRobotStationRenderer(renderblocks, fakeBlock, state, x, y, z);
}
}
@ -106,22 +107,22 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
* Render a block with normal and inverted vertex order so back face culling
* doesn't have any effect.
*/
private void renderTwoWayBlock(RenderBlocks renderblocks, BlockGenericPipe block, int x, int y, int z, float[] dim, int mask) {
private void renderTwoWayBlock(RenderBlocks renderblocks, FakeBlock stateHost, int x, int y, int z, float[] dim, int mask) {
assert mask != 0;
block.setRenderMask(mask);
stateHost.setRenderMask(mask);
renderblocks.setRenderBounds(dim[2], dim[0], dim[1], dim[5], dim[3], dim[4]);
renderblocks.renderStandardBlock(block, x, y, z);
block.setRenderMask((mask & 0x15) << 1 | (mask & 0x2a) >> 1); // pairwise swapped mask
renderblocks.renderStandardBlock(stateHost, x, y, z);
stateHost.setRenderMask((mask & 0x15) << 1 | (mask & 0x2a) >> 1); // pairwise swapped mask
renderblocks.setRenderBounds(dim[5], dim[3], dim[4], dim[2], dim[0], dim[1]);
renderblocks.renderStandardBlock(block, x, y, z);
renderblocks.renderStandardBlock(stateHost, x, y, z);
}
private void pipeFacadeRenderer(RenderBlocks renderblocks, BlockGenericPipe block, PipeRenderState state, int x, int y, int z) {
FacadeRenderHelper.pipeFacadeRenderer(renderblocks, block, state, x, y, z);
private void pipeFacadeRenderer(RenderBlocks renderblocks, ITextureStates blockStateMachine, PipeRenderState state, int x, int y, int z) {
FacadeRenderHelper.pipeFacadeRenderer(renderblocks, blockStateMachine, state, x, y, z);
}
private void pipePlugRenderer(RenderBlocks renderblocks, Block block, PipeRenderState state, int x, int y, int z) {
private void pipePlugRenderer(RenderBlocks renderblocks, ITextureStates blockStateMachine, PipeRenderState state, int x, int y, int z) {
float zFightOffset = 1F / 4096F;
float[][] zeroState = new float[3][2];
@ -135,7 +136,7 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
zeroState[2][0] = 0.25F + zFightOffset;
zeroState[2][1] = 0.75F - zFightOffset;
state.currentTexture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure Pipe
blockStateMachine.getTextureState().set(BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal())); // Structure Pipe
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
if (state.plugMatrix.isConnected(direction)) {
@ -143,7 +144,7 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
MatrixTranformations.transform(rotated, direction);
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
renderblocks.renderStandardBlock(block, x, y, z);
renderblocks.renderStandardBlock(blockStateMachine.getBlock(), x, y, z);
}
}
@ -157,7 +158,7 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
zeroState[2][0] = 0.25F + 0.125F / 2;
zeroState[2][1] = 0.75F - 0.125F / 2;
state.currentTexture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure Pipe
blockStateMachine.getTextureState().set(BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal())); // Structure Pipe
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
if (state.plugMatrix.isConnected(direction)) {
@ -165,14 +166,14 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
MatrixTranformations.transform(rotated, direction);
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
renderblocks.renderStandardBlock(block, x, y, z);
renderblocks.renderStandardBlock(blockStateMachine.getBlock(), x, y, z);
}
}
}
private void pipeRobotStationPartRender(RenderBlocks renderblocks,
Block block, PipeRenderState state, int x, int y, int z,
ITextureStates blockStateMachine, PipeRenderState state, int x, int y, int z,
float xStart, float xEnd, float yStart, float yEnd, float zStart,
float zEnd) {
@ -194,16 +195,16 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
switch (state.robotStationMatrix.getState(direction)) {
case None:
case Available:
state.currentTexture = BuildCraftTransport.instance.pipeIconProvider
.getIcon(PipeIconProvider.TYPE.PipeRobotStation.ordinal());
blockStateMachine.getTextureState().set(BuildCraftTransport.instance.pipeIconProvider
.getIcon(PipeIconProvider.TYPE.PipeRobotStation.ordinal()));
break;
case Reserved:
state.currentTexture = BuildCraftTransport.instance.pipeIconProvider
.getIcon(PipeIconProvider.TYPE.PipeRobotStationReserved.ordinal());
blockStateMachine.getTextureState().set(BuildCraftTransport.instance.pipeIconProvider
.getIcon(PipeIconProvider.TYPE.PipeRobotStationReserved.ordinal()));
break;
case Linked:
state.currentTexture = BuildCraftTransport.instance.pipeIconProvider
.getIcon(PipeIconProvider.TYPE.PipeRobotStationLinked.ordinal());
blockStateMachine.getTextureState().set(BuildCraftTransport.instance.pipeIconProvider
.getIcon(PipeIconProvider.TYPE.PipeRobotStationLinked.ordinal()));
break;
}
@ -213,16 +214,16 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0],
rotated[2][0], rotated[0][1], rotated[1][1],
rotated[2][1]);
renderblocks.renderStandardBlock(block, x, y, z);
renderblocks.renderStandardBlock(blockStateMachine.getBlock(), x, y, z);
}
}
}
private void pipeRobotStationRenderer(RenderBlocks renderblocks, Block block, PipeRenderState state, int x, int y, int z) {
private void pipeRobotStationRenderer(RenderBlocks renderblocks, ITextureStates blockStateMachine, PipeRenderState state, int x, int y, int z) {
//float width = 0.075F;
pipeRobotStationPartRender (renderblocks, block, state, x, y, z,
pipeRobotStationPartRender (renderblocks, blockStateMachine, state, x, y, z,
0.45F, 0.55F,
0.0F, 0.224F,
0.45F, 0.55F);
@ -268,16 +269,16 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
switch (state.robotStationMatrix.getState(direction)) {
case None:
case Available:
state.currentTexture = BuildCraftTransport.instance.pipeIconProvider
.getIcon(PipeIconProvider.TYPE.PipeRobotStation.ordinal());
blockStateMachine.getTextureState().set(BuildCraftTransport.instance.pipeIconProvider
.getIcon(PipeIconProvider.TYPE.PipeRobotStation.ordinal()));
break;
case Reserved:
state.currentTexture = BuildCraftTransport.instance.pipeIconProvider
.getIcon(PipeIconProvider.TYPE.PipeRobotStationReserved.ordinal());
blockStateMachine.getTextureState().set(BuildCraftTransport.instance.pipeIconProvider
.getIcon(PipeIconProvider.TYPE.PipeRobotStationReserved.ordinal()));
break;
case Linked:
state.currentTexture = BuildCraftTransport.instance.pipeIconProvider
.getIcon(PipeIconProvider.TYPE.PipeRobotStationLinked.ordinal());
blockStateMachine.getTextureState().set(BuildCraftTransport.instance.pipeIconProvider
.getIcon(PipeIconProvider.TYPE.PipeRobotStationLinked.ordinal()));
break;
}
@ -287,7 +288,7 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0],
rotated[2][0], rotated[0][1], rotated[1][1],
rotated[2][1]);
renderblocks.renderStandardBlock(block, x, y, z);
renderblocks.renderStandardBlock(blockStateMachine.getBlock(), x, y, z);
}
}
}
@ -309,7 +310,7 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
if (tile instanceof TileGenericPipe) {
TileGenericPipe pipeTile = (TileGenericPipe) tile;
renderPipe(renderer, world, (BlockGenericPipe) block, pipeTile, x, y, z);
renderPipe(renderer, world, pipeTile, x, y, z);
}
return true;

View file

@ -0,0 +1,56 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.transport.render;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/*
* This class moves texture management from PipeRenderState
* to be filled while rendering as efficient as possible
*/
@SideOnly(Side.CLIENT)
public final class TextureStateManager {
private IIcon currentTexture;
private IIcon[] textureArray;
private IIcon[] textureArrayCache;
public TextureStateManager(IIcon placeholder) {
currentTexture = placeholder;
textureArrayCache = new IIcon[6];
}
public IIcon[] popArray() {
textureArray = textureArrayCache;
return textureArrayCache; //Thread safety. Seriously.
}
public void pushArray() {
textureArray = null;
}
public IIcon getTexture() {
return currentTexture;
}
public IIcon[] getTextureArray() {
return textureArray;
}
public boolean isSided() {
return textureArray != null;
}
public void set(IIcon icon) {
currentTexture = icon;
}
}