Pulled the pipe world renderer out of core and put it in transport, also made the actual rendering a class of its own. Legacy world rendering not touched (quarry frames)

This commit is contained in:
Krapht 2012-07-10 13:14:58 +02:00
parent 9758782f19
commit eec4aa0323
8 changed files with 348 additions and 314 deletions

View file

@ -0,0 +1,273 @@
package net.minecraft.src.buildcraft.transport;
import net.minecraft.src.Block;
import net.minecraft.src.IBlockAccess;
import net.minecraft.src.RenderBlocks;
import net.minecraft.src.TileEntity;
import net.minecraft.src.buildcraft.api.IPipe;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.IPipe.DrawingState;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.ITileBufferHolder;
import net.minecraft.src.buildcraft.core.Utils;
import net.minecraft.src.forge.MinecraftForgeClient;
public class PipeWorldRenderer {
public void pipeRender(RenderBlocks renderblocks, IBlockAccess iblockaccess, TileEntity tile, Block block, int l) {
ITileBufferHolder holder = (ITileBufferHolder) tile;
float minSize = Utils.pipeMinPos;
float maxSize = Utils.pipeMaxPos;
IPipe pipe = ((TileGenericPipe)tile).pipe;
pipe.setDrawingState(DrawingState.DrawingPipe);
pipe.prepareTextureFor(Orientations.Unknown);
block.setBlockBounds(minSize, minSize, minSize, maxSize, maxSize, maxSize);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
if (Utils.checkPipesConnections(tile, holder.getTile(Orientations.XNeg))) {
pipe.prepareTextureFor(Orientations.XNeg);
block.setBlockBounds(0.0F, minSize, minSize, minSize, maxSize, maxSize);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (Utils.checkPipesConnections(tile, holder.getTile(Orientations.XPos))) {
pipe.prepareTextureFor(Orientations.XPos);
block.setBlockBounds(maxSize, minSize, minSize, 1.0F, maxSize, maxSize);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (Utils.checkPipesConnections(tile, holder.getTile(Orientations.YNeg))) {
pipe.prepareTextureFor(Orientations.YNeg);
block.setBlockBounds(minSize, 0.0F, minSize, maxSize, minSize, maxSize);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (Utils.checkPipesConnections(tile, holder.getTile(Orientations.YPos))) {
pipe.prepareTextureFor(Orientations.YPos);
block.setBlockBounds(minSize, maxSize, minSize, maxSize, 1.0F, maxSize);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (Utils.checkPipesConnections(tile, holder.getTile(Orientations.ZNeg))) {
pipe.prepareTextureFor(Orientations.ZNeg);
block.setBlockBounds(minSize, minSize, 0.0F, maxSize, maxSize, minSize);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (Utils.checkPipesConnections(tile, holder.getTile(Orientations.ZPos))) {
pipe.prepareTextureFor(Orientations.ZPos);
block.setBlockBounds(minSize, minSize, maxSize, maxSize, maxSize, 1.0F);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
pipe.prepareTextureFor(Orientations.Unknown);
MinecraftForgeClient.bindTexture(DefaultProps.TEXTURE_BLOCKS);
if (pipe.isWired(IPipe.WireColor.Red)) {
pipe.setDrawingState(DrawingState.DrawingRedWire);
pipeRedstoneRender(renderblocks, iblockaccess, tile, pipe, block, l, 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,
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,
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,
Utils.pipeMaxPos, IPipe.WireColor.Yellow);
}
if (pipe.hasInterface())
pipeInterfaceRender(renderblocks, iblockaccess, tile, pipe, block, l);
}
private void pipeRedstoneRender(RenderBlocks renderblocks, IBlockAccess iblockaccess, TileEntity tile, IPipe pipe,
Block block, int l, float cx, float cy, float cz, IPipe.WireColor color) {
ITileBufferHolder holder = (ITileBufferHolder) tile;
float minX = Utils.pipeMinPos;
float minY = Utils.pipeMinPos;
float minZ = Utils.pipeMinPos;
float maxX = Utils.pipeMaxPos;
float maxY = Utils.pipeMaxPos;
float maxZ = Utils.pipeMaxPos;
boolean foundX = false, foundY = false, foundZ = false;
if (isConnectedWiredPipe(pipe, holder.getTile(Orientations.XNeg), color)) {
minX = 0;
foundX = true;
}
if (isConnectedWiredPipe(pipe, holder.getTile(Orientations.XPos), color)) {
maxX = 1;
foundX = true;
}
if (isConnectedWiredPipe(pipe, holder.getTile(Orientations.YNeg), color)) {
minY = 0;
foundY = true;
}
if (isConnectedWiredPipe(pipe, holder.getTile(Orientations.YPos), color)) {
maxY = 1;
foundY = true;
}
if (isConnectedWiredPipe(pipe, holder.getTile(Orientations.ZNeg), color)) {
minZ = 0;
foundZ = true;
}
if (isConnectedWiredPipe(pipe, holder.getTile(Orientations.ZPos), color)) {
maxZ = 1;
foundZ = true;
}
boolean center = false;
if (minX == 0 && maxX != 1 && (foundY || foundZ))
if (cx == Utils.pipeMinPos)
maxX = Utils.pipeMinPos;
else
center = true;
if (minX != 0 && maxX == 1 && (foundY || foundZ))
if (cx == Utils.pipeMaxPos)
minX = Utils.pipeMaxPos;
else
center = true;
if (minY == 0 && maxY != 1 && (foundX || foundZ))
if (cy == Utils.pipeMinPos)
maxY = Utils.pipeMinPos;
else
center = true;
if (minY != 0 && maxY == 1 && (foundX || foundZ))
if (cy == Utils.pipeMaxPos)
minY = Utils.pipeMaxPos;
else
center = true;
if (minZ == 0 && maxZ != 1 && (foundX || foundY))
if (cz == Utils.pipeMinPos)
maxZ = Utils.pipeMinPos;
else
center = true;
if (minZ != 0 && maxZ == 1 && (foundX || foundY))
if (cz == Utils.pipeMaxPos)
minZ = Utils.pipeMaxPos;
else
center = true;
boolean found = foundX || foundY || foundZ;
// Z render
if (minZ != Utils.pipeMinPos || maxZ != Utils.pipeMaxPos || !found) {
block.setBlockBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy, minZ,
cx == Utils.pipeMinPos ? cx : cx + 0.05F, cy == Utils.pipeMinPos ? cy : cy + 0.05F, maxZ);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
// X render
if (minX != Utils.pipeMinPos || maxX != Utils.pipeMaxPos || !found) {
block.setBlockBounds(minX, cy == Utils.pipeMinPos ? cy - 0.05F : cy, cz == Utils.pipeMinPos ? cz - 0.05F : cz, maxX,
cy == Utils.pipeMinPos ? cy : cy + 0.05F, cz == Utils.pipeMinPos ? cz : cz + 0.05F);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
// Y render
if (minY != Utils.pipeMinPos || maxY != Utils.pipeMaxPos || !found) {
block.setBlockBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, minY, cz == Utils.pipeMinPos ? cz - 0.05F : cz,
cx == Utils.pipeMinPos ? cx : cx + 0.05F, maxY, cz == Utils.pipeMinPos ? cz : cz + 0.05F);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (center || !found) {
block.setBlockBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy,
cz == Utils.pipeMinPos ? cz - 0.05F : cz, cx == Utils.pipeMinPos ? cx : cx + 0.05F,
cy == Utils.pipeMinPos ? cy : cy + 0.05F, cz == Utils.pipeMinPos ? cz : cz + 0.05F);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
}
private boolean isConnectedWiredPipe(IPipe pipe, TileEntity tile2, IPipe.WireColor color) {
return pipe.isWireConnectedTo(tile2, color);
}
private void pipeInterfaceRender(RenderBlocks renderblocks, IBlockAccess iblockaccess, TileEntity tile, IPipe pipe,
Block block, int l) {
ITileBufferHolder holder = (ITileBufferHolder) tile;
pipe.setDrawingState(DrawingState.DrawingGate);
float min = Utils.pipeMinPos + 0.05F;
float max = Utils.pipeMaxPos - 0.05F;
if (!Utils.checkPipesConnections(tile, holder.getTile(Orientations.XNeg))) {
block.setBlockBounds(Utils.pipeMinPos - 0.10F, min, min, Utils.pipeMinPos, max, max);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (!Utils.checkPipesConnections(tile, holder.getTile(Orientations.XPos))) {
block.setBlockBounds(Utils.pipeMaxPos, min, min, Utils.pipeMaxPos + 0.10F, max, max);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (!Utils.checkPipesConnections(tile, holder.getTile(Orientations.YNeg))) {
block.setBlockBounds(min, Utils.pipeMinPos - 0.10F, min, max, Utils.pipeMinPos, max);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (!Utils.checkPipesConnections(tile, holder.getTile(Orientations.YPos))) {
block.setBlockBounds(min, Utils.pipeMaxPos, min, max, Utils.pipeMaxPos + 0.10F, max);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (!Utils.checkPipesConnections(tile, holder.getTile(Orientations.ZNeg))) {
block.setBlockBounds(min, min, Utils.pipeMinPos - 0.10F, max, max, Utils.pipeMinPos);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (!Utils.checkPipesConnections(tile, holder.getTile(Orientations.ZPos))) {
block.setBlockBounds(min, min, Utils.pipeMaxPos, max, max, Utils.pipeMaxPos + 0.10F);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
}
}

View file

@ -136,16 +136,9 @@ public class mod_BuildCraftCore extends NetworkMod {
tessellator.setColorOpaque_F(f, f, f);
renderMarkerWithMeta(iblockaccess, block, i, j, k, iblockaccess.getBlockMetadata(i, j, k));
} else if (block.getRenderType() == BuildCraftCore.pipeModel) {
} else if (block.getRenderType() == BuildCraftCore.legacyPipeModel) {
TileEntity tile = iblockaccess.getBlockTileEntity(i, j, k);
if (tile != null && tile instanceof IPipeTile && ((IPipeTile)tile).isInitialized()) {
pipeRender(renderblocks, iblockaccess, tile, block, l);
}
else {
legacyPipeRender(renderblocks, iblockaccess, i, j, k, block, l);
}
} else if (block.getRenderType() == BuildCraftCore.oilModel)
renderblocks.renderBlockFluids(block, i, j, k);
@ -153,263 +146,6 @@ public class mod_BuildCraftCore extends NetworkMod {
return true;
}
private void pipeRender(RenderBlocks renderblocks, IBlockAccess iblockaccess, TileEntity tile, Block block, int l) {
ITileBufferHolder holder = (ITileBufferHolder) tile;
float minSize = Utils.pipeMinPos;
float maxSize = Utils.pipeMaxPos;
IPipe pipe = ((TileGenericPipe)tile).pipe;
pipe.setDrawingState(DrawingState.DrawingPipe);
pipe.prepareTextureFor(Orientations.Unknown);
block.setBlockBounds(minSize, minSize, minSize, maxSize, maxSize, maxSize);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
if (Utils.checkPipesConnections(tile, holder.getTile(Orientations.XNeg))) {
pipe.prepareTextureFor(Orientations.XNeg);
block.setBlockBounds(0.0F, minSize, minSize, minSize, maxSize, maxSize);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (Utils.checkPipesConnections(tile, holder.getTile(Orientations.XPos))) {
pipe.prepareTextureFor(Orientations.XPos);
block.setBlockBounds(maxSize, minSize, minSize, 1.0F, maxSize, maxSize);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (Utils.checkPipesConnections(tile, holder.getTile(Orientations.YNeg))) {
pipe.prepareTextureFor(Orientations.YNeg);
block.setBlockBounds(minSize, 0.0F, minSize, maxSize, minSize, maxSize);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (Utils.checkPipesConnections(tile, holder.getTile(Orientations.YPos))) {
pipe.prepareTextureFor(Orientations.YPos);
block.setBlockBounds(minSize, maxSize, minSize, maxSize, 1.0F, maxSize);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (Utils.checkPipesConnections(tile, holder.getTile(Orientations.ZNeg))) {
pipe.prepareTextureFor(Orientations.ZNeg);
block.setBlockBounds(minSize, minSize, 0.0F, maxSize, maxSize, minSize);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (Utils.checkPipesConnections(tile, holder.getTile(Orientations.ZPos))) {
pipe.prepareTextureFor(Orientations.ZPos);
block.setBlockBounds(minSize, minSize, maxSize, maxSize, maxSize, 1.0F);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
pipe.prepareTextureFor(Orientations.Unknown);
MinecraftForgeClient.bindTexture(DefaultProps.TEXTURE_BLOCKS);
if (pipe.isWired(IPipe.WireColor.Red)) {
pipe.setDrawingState(DrawingState.DrawingRedWire);
pipeRedstoneRender(renderblocks, iblockaccess, tile, pipe, block, l, 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,
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,
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,
Utils.pipeMaxPos, IPipe.WireColor.Yellow);
}
if (pipe.hasInterface())
pipeInterfaceRender(renderblocks, iblockaccess, tile, pipe, block, l);
}
private boolean isConnectedWiredPipe(IPipe pipe, TileEntity tile2, IPipe.WireColor color) {
return pipe.isWireConnectedTo(tile2, color);
}
private void pipeRedstoneRender(RenderBlocks renderblocks, IBlockAccess iblockaccess, TileEntity tile, IPipe pipe,
Block block, int l, float cx, float cy, float cz, IPipe.WireColor color) {
ITileBufferHolder holder = (ITileBufferHolder) tile;
float minX = Utils.pipeMinPos;
float minY = Utils.pipeMinPos;
float minZ = Utils.pipeMinPos;
float maxX = Utils.pipeMaxPos;
float maxY = Utils.pipeMaxPos;
float maxZ = Utils.pipeMaxPos;
boolean foundX = false, foundY = false, foundZ = false;
if (isConnectedWiredPipe(pipe, holder.getTile(Orientations.XNeg), color)) {
minX = 0;
foundX = true;
}
if (isConnectedWiredPipe(pipe, holder.getTile(Orientations.XPos), color)) {
maxX = 1;
foundX = true;
}
if (isConnectedWiredPipe(pipe, holder.getTile(Orientations.YNeg), color)) {
minY = 0;
foundY = true;
}
if (isConnectedWiredPipe(pipe, holder.getTile(Orientations.YPos), color)) {
maxY = 1;
foundY = true;
}
if (isConnectedWiredPipe(pipe, holder.getTile(Orientations.ZNeg), color)) {
minZ = 0;
foundZ = true;
}
if (isConnectedWiredPipe(pipe, holder.getTile(Orientations.ZPos), color)) {
maxZ = 1;
foundZ = true;
}
boolean center = false;
if (minX == 0 && maxX != 1 && (foundY || foundZ))
if (cx == Utils.pipeMinPos)
maxX = Utils.pipeMinPos;
else
center = true;
if (minX != 0 && maxX == 1 && (foundY || foundZ))
if (cx == Utils.pipeMaxPos)
minX = Utils.pipeMaxPos;
else
center = true;
if (minY == 0 && maxY != 1 && (foundX || foundZ))
if (cy == Utils.pipeMinPos)
maxY = Utils.pipeMinPos;
else
center = true;
if (minY != 0 && maxY == 1 && (foundX || foundZ))
if (cy == Utils.pipeMaxPos)
minY = Utils.pipeMaxPos;
else
center = true;
if (minZ == 0 && maxZ != 1 && (foundX || foundY))
if (cz == Utils.pipeMinPos)
maxZ = Utils.pipeMinPos;
else
center = true;
if (minZ != 0 && maxZ == 1 && (foundX || foundY))
if (cz == Utils.pipeMaxPos)
minZ = Utils.pipeMaxPos;
else
center = true;
boolean found = foundX || foundY || foundZ;
// Z render
if (minZ != Utils.pipeMinPos || maxZ != Utils.pipeMaxPos || !found) {
block.setBlockBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy, minZ,
cx == Utils.pipeMinPos ? cx : cx + 0.05F, cy == Utils.pipeMinPos ? cy : cy + 0.05F, maxZ);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
// X render
if (minX != Utils.pipeMinPos || maxX != Utils.pipeMaxPos || !found) {
block.setBlockBounds(minX, cy == Utils.pipeMinPos ? cy - 0.05F : cy, cz == Utils.pipeMinPos ? cz - 0.05F : cz, maxX,
cy == Utils.pipeMinPos ? cy : cy + 0.05F, cz == Utils.pipeMinPos ? cz : cz + 0.05F);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
// Y render
if (minY != Utils.pipeMinPos || maxY != Utils.pipeMaxPos || !found) {
block.setBlockBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, minY, cz == Utils.pipeMinPos ? cz - 0.05F : cz,
cx == Utils.pipeMinPos ? cx : cx + 0.05F, maxY, cz == Utils.pipeMinPos ? cz : cz + 0.05F);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (center || !found) {
block.setBlockBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy,
cz == Utils.pipeMinPos ? cz - 0.05F : cz, cx == Utils.pipeMinPos ? cx : cx + 0.05F,
cy == Utils.pipeMinPos ? cy : cy + 0.05F, cz == Utils.pipeMinPos ? cz : cz + 0.05F);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
}
private void pipeInterfaceRender(RenderBlocks renderblocks, IBlockAccess iblockaccess, TileEntity tile, IPipe pipe,
Block block, int l) {
ITileBufferHolder holder = (ITileBufferHolder) tile;
pipe.setDrawingState(DrawingState.DrawingGate);
float min = Utils.pipeMinPos + 0.05F;
float max = Utils.pipeMaxPos - 0.05F;
if (!Utils.checkPipesConnections(tile, holder.getTile(Orientations.XNeg))) {
block.setBlockBounds(Utils.pipeMinPos - 0.10F, min, min, Utils.pipeMinPos, max, max);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (!Utils.checkPipesConnections(tile, holder.getTile(Orientations.XPos))) {
block.setBlockBounds(Utils.pipeMaxPos, min, min, Utils.pipeMaxPos + 0.10F, max, max);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (!Utils.checkPipesConnections(tile, holder.getTile(Orientations.YNeg))) {
block.setBlockBounds(min, Utils.pipeMinPos - 0.10F, min, max, Utils.pipeMinPos, max);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (!Utils.checkPipesConnections(tile, holder.getTile(Orientations.YPos))) {
block.setBlockBounds(min, Utils.pipeMaxPos, min, max, Utils.pipeMaxPos + 0.10F, max);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (!Utils.checkPipesConnections(tile, holder.getTile(Orientations.ZNeg))) {
block.setBlockBounds(min, min, Utils.pipeMinPos - 0.10F, max, max, Utils.pipeMinPos);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (!Utils.checkPipesConnections(tile, holder.getTile(Orientations.ZPos))) {
block.setBlockBounds(min, min, Utils.pipeMaxPos, max, max, Utils.pipeMaxPos + 0.10F);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
}
private void legacyPipeRender(RenderBlocks renderblocks, IBlockAccess iblockaccess, int i, int j, int k, Block block, int l) {
float minSize = Utils.pipeMinPos;
float maxSize = Utils.pipeMaxPos;
@ -461,50 +197,50 @@ public class mod_BuildCraftCore extends NetworkMod {
RenderItem itemRenderer = new RenderItem();
@Override
public void renderInvBlock(RenderBlocks renderblocks, Block block, int i, int j) {
if (block.getRenderType() == BuildCraftCore.blockByEntityModel) {
EntityRenderIndex index = new EntityRenderIndex(block, i);
if (blockByEntityRenders.containsKey(index))
blockByEntityRenders.get(index).inventoryRender(-0.5, -0.5, -0.5, 0, 0);
} else if (block.getRenderType() == BuildCraftCore.markerModel) {
// Do nothing here...
} else if (block.getRenderType() == BuildCraftCore.pipeModel) {
Tessellator tessellator = Tessellator.instance;
block.setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos);
block.setBlockBoundsForItemRender();
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, -1F, 0.0F);
renderblocks.renderBottomFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(0, i));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
renderblocks.renderTopFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(1, i));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, -1F);
renderblocks.renderEastFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(2, i));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, 1.0F);
renderblocks.renderWestFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(3, i));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(-1F, 0.0F, 0.0F);
renderblocks.renderNorthFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(4, i));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(1.0F, 0.0F, 0.0F);
renderblocks.renderSouthFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(5, i));
tessellator.draw();
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
// @Override
// public void renderInvBlock(RenderBlocks renderblocks, Block block, int i, int j) {
// if (block.getRenderType() == BuildCraftCore.blockByEntityModel) {
//
// EntityRenderIndex index = new EntityRenderIndex(block, i);
//
// if (blockByEntityRenders.containsKey(index))
// blockByEntityRenders.get(index).inventoryRender(-0.5, -0.5, -0.5, 0, 0);
// } else if (block.getRenderType() == BuildCraftCore.markerModel) {
// // Do nothing here...
// } else if (block.getRenderType() == BuildCraftCore.legacyPipeModel) {
// Tessellator tessellator = Tessellator.instance;
//
// block.setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos);
// block.setBlockBoundsForItemRender();
// GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
// tessellator.startDrawingQuads();
// tessellator.setNormal(0.0F, -1F, 0.0F);
// renderblocks.renderBottomFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(0, i));
// tessellator.draw();
// tessellator.startDrawingQuads();
// tessellator.setNormal(0.0F, 1.0F, 0.0F);
// renderblocks.renderTopFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(1, i));
// tessellator.draw();
// tessellator.startDrawingQuads();
// tessellator.setNormal(0.0F, 0.0F, -1F);
// renderblocks.renderEastFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(2, i));
// tessellator.draw();
// tessellator.startDrawingQuads();
// tessellator.setNormal(0.0F, 0.0F, 1.0F);
// renderblocks.renderWestFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(3, i));
// tessellator.draw();
// tessellator.startDrawingQuads();
// tessellator.setNormal(-1F, 0.0F, 0.0F);
// renderblocks.renderNorthFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(4, i));
// tessellator.draw();
// tessellator.startDrawingQuads();
// tessellator.setNormal(1.0F, 0.0F, 0.0F);
// renderblocks.renderSouthFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(5, i));
// tessellator.draw();
// GL11.glTranslatef(0.5F, 0.5F, 0.5F);
// block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
// }
// }
public static double frontX[][][] = new double[6][3][4];
public static double frontZ[][][] = new double[6][3][4];

View file

@ -9,8 +9,10 @@
package net.minecraft.src;
import net.minecraft.src.buildcraft.api.IPipeTile;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.transport.PipeItemRenderer;
import net.minecraft.src.buildcraft.transport.PipeWorldRenderer;
import net.minecraft.src.buildcraft.transport.RenderPipe;
import net.minecraft.src.forge.MinecraftForgeClient;
import net.minecraft.src.forge.NetworkMod;
@ -18,7 +20,8 @@ import net.minecraft.src.forge.NetworkMod;
public class mod_BuildCraftTransport extends NetworkMod {
public static mod_BuildCraftTransport instance;
public static PipeItemRenderer pipeItemRenderer = new PipeItemRenderer();
public final static PipeItemRenderer pipeItemRenderer = new PipeItemRenderer();
public final static PipeWorldRenderer pipeWorldRenderer = new PipeWorldRenderer();
public mod_BuildCraftTransport() {
instance = this;
@ -29,6 +32,8 @@ public class mod_BuildCraftTransport extends NetworkMod {
super.modsLoaded();
BuildCraftTransport.initialize();
BuildCraftTransport.initializeModel(this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsWood.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsCobblestone.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsStone.shiftedIndex, pipeItemRenderer);
@ -78,6 +83,19 @@ public class mod_BuildCraftTransport extends NetworkMod {
return true;
}
@Override
public boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID) {
if (modelID != BuildCraftTransport.pipeModel) return true;
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile != null && tile instanceof IPipeTile && ((IPipeTile)tile).isInitialized()) {
pipeWorldRenderer.pipeRender(renderer, world, tile, block, modelID);
}
return true;
}
}

View file

@ -24,6 +24,7 @@ public class mod_BuildCraftTransport extends NetworkMod {
public void modsLoaded() {
super.modsLoaded();
BuildCraftTransport.initialize();
BuildCraftTransport.initializeModel(this);
}
public static void registerTilePipe(Class<? extends TileEntity> clas, String name) {

View file

@ -83,7 +83,7 @@ public class BuildCraftCore {
public static int transparentTexture;
public static int blockByEntityModel;
public static int pipeModel;
public static int legacyPipeModel;
public static int markerModel;
public static int oilModel;
@ -296,7 +296,7 @@ public class BuildCraftCore {
public static void initializeModel(BaseMod mod) {
blockByEntityModel = ModLoader.getUniqueBlockModelID(mod, true);
pipeModel = ModLoader.getUniqueBlockModelID(mod, true);
legacyPipeModel = ModLoader.getUniqueBlockModelID(mod, true);
markerModel = ModLoader.getUniqueBlockModelID(mod, false);
oilModel = ModLoader.getUniqueBlockModelID(mod, false);
}

View file

@ -134,6 +134,8 @@ public class BuildCraftTransport {
public static Action actionYellowSignal = new ActionSignalOutput(DefaultProps.ACTION_YELLOW_SIGNAL, IPipe.WireColor.Yellow);
public static Action actionEnergyPulser = new ActionEnergyPulser(DefaultProps.ACTION_ENERGY_PULSER);
public static int pipeModel;
private static class PipeRecipe {
boolean isShapeless = false; // pipe recipes come shaped and unshaped.
@ -366,4 +368,8 @@ public class BuildCraftTransport {
return res;
}
public static void initializeModel(mod_BuildCraftTransport mod) {
pipeModel = ModLoader.getUniqueBlockModelID(mod, true);
}
}

View file

@ -68,7 +68,7 @@ public class BlockFrame extends Block implements ILegacyPipeConnection, IBlockPi
@Override
public int getRenderType() {
return BuildCraftCore.pipeModel;
return BuildCraftCore.legacyPipeModel;
}
@Override

View file

@ -49,7 +49,7 @@ public class BlockGenericPipe extends BlockContainer implements IBlockPipe, ITex
@Override
public int getRenderType() {
return BuildCraftCore.pipeModel;
return BuildCraftTransport.pipeModel;
}
@Override