Refactoring of PipeWorldRenderer and initial commit of PipeRenderState

This commit is contained in:
Krapht 2012-07-10 13:46:15 +02:00
parent eec4aa0323
commit 19c4de5a1c
6 changed files with 63 additions and 13 deletions
buildcraft_client/net/minecraft/src
common/net/minecraft/src/buildcraft/transport

View file

@ -14,7 +14,7 @@ import net.minecraft.src.forge.MinecraftForgeClient;
public class PipeWorldRenderer {
public void pipeRender(RenderBlocks renderblocks, IBlockAccess iblockaccess, TileEntity tile, Block block, int l) {
public void renderPipe(RenderBlocks renderblocks, IBlockAccess iblockaccess, TileEntity tile, Block block, PipeRenderState state) {
ITileBufferHolder holder = (ITileBufferHolder) tile;
@ -72,34 +72,34 @@ public class PipeWorldRenderer {
if (pipe.isWired(IPipe.WireColor.Red)) {
pipe.setDrawingState(DrawingState.DrawingRedWire);
pipeRedstoneRender(renderblocks, iblockaccess, tile, pipe, block, l, Utils.pipeMinPos, Utils.pipeMaxPos,
pipeRedstoneRender(renderblocks, iblockaccess, tile, pipe, block, Utils.pipeMinPos, Utils.pipeMaxPos,
Utils.pipeMinPos, IPipe.WireColor.Red);
}
if (pipe.isWired(IPipe.WireColor.Blue)) {
pipe.setDrawingState(DrawingState.DrawingBlueWire);
pipeRedstoneRender(renderblocks, iblockaccess, tile, pipe, block, l, Utils.pipeMaxPos, Utils.pipeMaxPos,
pipeRedstoneRender(renderblocks, iblockaccess, tile, pipe, block, Utils.pipeMaxPos, Utils.pipeMaxPos,
Utils.pipeMaxPos, IPipe.WireColor.Blue);
}
if (pipe.isWired(IPipe.WireColor.Green)) {
pipe.setDrawingState(DrawingState.DrawingGreenWire);
pipeRedstoneRender(renderblocks, iblockaccess, tile, pipe, block, l, Utils.pipeMaxPos, Utils.pipeMinPos,
pipeRedstoneRender(renderblocks, iblockaccess, tile, pipe, block, Utils.pipeMaxPos, Utils.pipeMinPos,
Utils.pipeMinPos, IPipe.WireColor.Green);
}
if (pipe.isWired(IPipe.WireColor.Yellow)) {
pipe.setDrawingState(DrawingState.DrawingYellowWire);
pipeRedstoneRender(renderblocks, iblockaccess, tile, pipe, block, l, Utils.pipeMinPos, Utils.pipeMinPos,
pipeRedstoneRender(renderblocks, iblockaccess, tile, pipe, block, Utils.pipeMinPos, Utils.pipeMinPos,
Utils.pipeMaxPos, IPipe.WireColor.Yellow);
}
if (pipe.hasInterface())
pipeInterfaceRender(renderblocks, iblockaccess, tile, pipe, block, l);
pipeInterfaceRender(renderblocks, iblockaccess, tile, pipe, block);
}
private void pipeRedstoneRender(RenderBlocks renderblocks, IBlockAccess iblockaccess, TileEntity tile, IPipe pipe,
Block block, int l, float cx, float cy, float cz, IPipe.WireColor color) {
private void pipeRedstoneRender(RenderBlocks renderblocks, IBlockAccess iblockaccess, TileEntity tile, IPipe pipe,
Block block, float cx, float cy, float cz, IPipe.WireColor color) {
ITileBufferHolder holder = (ITileBufferHolder) tile;
@ -224,8 +224,7 @@ public class PipeWorldRenderer {
return pipe.isWireConnectedTo(tile2, color);
}
private void pipeInterfaceRender(RenderBlocks renderblocks, IBlockAccess iblockaccess, TileEntity tile, IPipe pipe,
Block block, int l) {
private void pipeInterfaceRender(RenderBlocks renderblocks, IBlockAccess iblockaccess, TileEntity tile, IPipe pipe, Block block) {
ITileBufferHolder holder = (ITileBufferHolder) tile;

View file

@ -11,6 +11,7 @@ package net.minecraft.src;
import net.minecraft.src.buildcraft.api.IPipeTile;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.transport.IPipeRenderState;
import net.minecraft.src.buildcraft.transport.PipeItemRenderer;
import net.minecraft.src.buildcraft.transport.PipeWorldRenderer;
import net.minecraft.src.buildcraft.transport.RenderPipe;
@ -89,9 +90,12 @@ public class mod_BuildCraftTransport extends NetworkMod {
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile != null && tile instanceof IPipeTile && ((IPipeTile)tile).isInitialized()) {
pipeWorldRenderer.pipeRender(renderer, world, tile, block, modelID);
if (tile instanceof IPipeRenderState){
pipeWorldRenderer.renderPipe(renderer, world, tile, block, ((IPipeRenderState)tile).getRenderState());
}
// if (tile != null && tile instanceof IPipeTile && ((IPipeTile)tile).isInitialized()) {
// pipeWorldRenderer.renderPipe(renderer, world, tile, block);
// }
return true;
}

View file

@ -0,0 +1,5 @@
package net.minecraft.src.buildcraft.transport;
public interface IPipeRenderState {
public PipeRenderState getRenderState();
}

View file

@ -0,0 +1,10 @@
package net.minecraft.src.buildcraft.transport;
import net.minecraft.src.buildcraft.transport.utils.ConnectionMatrix;
public class PipeRenderState {
public ConnectionMatrix pipeConnection = new ConnectionMatrix();
}

View file

@ -49,7 +49,9 @@ import net.minecraft.src.buildcraft.core.network.PacketTileUpdate;
import net.minecraft.src.buildcraft.core.network.PacketUpdate;
public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiquidContainer, IPipeEntry,
IPipeTile, ISynchronizedTile, IOverrideDefaultTriggers, ITileBufferHolder, IPipeConnection, IDropControlInventory {
IPipeTile, ISynchronizedTile, IOverrideDefaultTriggers, ITileBufferHolder, IPipeConnection, IDropControlInventory, IPipeRenderState {
private final PipeRenderState renderState = new PipeRenderState();
public TileBuffer[] tileBuffer;
public boolean[] pipeConnectionsBuffer = new boolean[6];
@ -430,4 +432,11 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiqu
else
return false;
}
/** IPipeRenderState implementation **/
@Override
public PipeRenderState getRenderState() {
return renderState;
}
}

View file

@ -0,0 +1,23 @@
package net.minecraft.src.buildcraft.transport.utils;
import net.minecraft.src.buildcraft.api.Orientations;
public class ConnectionMatrix {
private final boolean[] _connected = new boolean[Orientations.dirs().length];
public void reset(){
for (int i = 0; i < Orientations.dirs().length; i++){
_connected[i] = false;
}
}
public boolean isConnected(Orientations direction){
return _connected[direction.ordinal()];
}
public void setConnected(Orientations direction, boolean value){
_connected[direction.ordinal()] = value;
}
}