Moved Pipe Gate/Wire rendering to the TESR
Should greatly improve performance of wire/gate switching.
This commit is contained in:
parent
fb0ee91183
commit
3a39b289a2
15 changed files with 556 additions and 338 deletions
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
package buildcraft.core.render;
|
||||
|
||||
import buildcraft.core.render.RenderEntityBlock.BlockInterface;
|
||||
import buildcraft.core.render.RenderEntityBlock.RenderInfo;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -31,7 +31,7 @@ public class FluidRenderer {
|
|||
private static Map<Fluid, int[]> flowingRenderCache = new HashMap<Fluid, int[]>();
|
||||
private static Map<Fluid, int[]> stillRenderCache = new HashMap<Fluid, int[]>();
|
||||
public static final int DISPLAY_STAGES = 100;
|
||||
private static final BlockInterface liquidBlock = new BlockInterface();
|
||||
private static final RenderInfo liquidBlock = new RenderInfo();
|
||||
|
||||
public static Icon getFluidTexture(FluidStack fluidStack, boolean flowing) {
|
||||
if (fluidStack == null) {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
package buildcraft.core.render;
|
||||
|
||||
import buildcraft.core.EntityBlock;
|
||||
import java.util.Arrays;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
|
@ -28,7 +29,7 @@ public class RenderEntityBlock extends Render {
|
|||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public static class BlockInterface {
|
||||
public static class RenderInfo {
|
||||
|
||||
public double minX;
|
||||
public double minY;
|
||||
|
@ -38,17 +39,81 @@ public class RenderEntityBlock extends Render {
|
|||
public double maxZ;
|
||||
public Block baseBlock = Block.sand;
|
||||
public Icon texture = null;
|
||||
public Icon[] textureArray = null;
|
||||
public boolean[] renderSide = new boolean[6];
|
||||
public float light = -1f;
|
||||
public int brightness = -1;
|
||||
|
||||
public Icon getBlockTextureFromSide(int i) {
|
||||
if (texture == null)
|
||||
return baseBlock.getBlockTextureFromSide(i);
|
||||
else
|
||||
return texture;
|
||||
public RenderInfo() {
|
||||
setRenderAllSides();
|
||||
}
|
||||
|
||||
public RenderInfo(Block template, Icon[] texture) {
|
||||
this();
|
||||
this.baseBlock = template;
|
||||
this.textureArray = texture;
|
||||
}
|
||||
|
||||
public RenderInfo(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
|
||||
this();
|
||||
setBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
public float getBlockBrightness(IBlockAccess iblockaccess, int i, int j, int k) {
|
||||
return baseBlock.getBlockBrightness(iblockaccess, i, j, k);
|
||||
}
|
||||
|
||||
public final void setBounds(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
|
||||
this.minX = minX;
|
||||
this.minY = minY;
|
||||
this.minZ = minZ;
|
||||
this.maxX = maxX;
|
||||
this.maxY = maxY;
|
||||
this.maxZ = maxZ;
|
||||
}
|
||||
|
||||
public final void setRenderSingleSide(int side) {
|
||||
Arrays.fill(renderSide, false);
|
||||
renderSide[side] = true;
|
||||
}
|
||||
|
||||
public final void setRenderAllSides() {
|
||||
Arrays.fill(renderSide, true);
|
||||
}
|
||||
|
||||
public void rotate() {
|
||||
double temp = minX;
|
||||
minX = minZ;
|
||||
minZ = temp;
|
||||
|
||||
temp = maxX;
|
||||
maxX = maxZ;
|
||||
maxZ = temp;
|
||||
}
|
||||
|
||||
public void reverseX() {
|
||||
double temp = minX;
|
||||
minX = 1 - maxX;
|
||||
maxX = 1 - temp;
|
||||
}
|
||||
|
||||
public void reverseZ() {
|
||||
double temp = minZ;
|
||||
minZ = 1 - maxZ;
|
||||
maxZ = 1 - temp;
|
||||
}
|
||||
|
||||
public Icon getBlockTextureFromSide(int i) {
|
||||
if (texture != null)
|
||||
return texture;
|
||||
if (textureArray == null || textureArray.length == 0)
|
||||
return baseBlock.getBlockTextureFromSide(i);
|
||||
else {
|
||||
if (i >= textureArray.length)
|
||||
i = 0;
|
||||
return textureArray[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private RenderEntityBlock() {
|
||||
|
@ -65,7 +130,7 @@ public class RenderEntityBlock extends Render {
|
|||
|
||||
shadowSize = entity.shadowSize;
|
||||
World world = entity.worldObj;
|
||||
BlockInterface util = new BlockInterface();
|
||||
RenderInfo util = new RenderInfo();
|
||||
util.texture = entity.texture;
|
||||
bindTexture(TextureMap.locationBlocksTexture);
|
||||
|
||||
|
@ -108,92 +173,169 @@ public class RenderEntityBlock extends Render {
|
|||
}
|
||||
}
|
||||
|
||||
public void renderBlock(BlockInterface block, IBlockAccess blockAccess, int i, int j, int k, boolean doLight, boolean doTessellating) {
|
||||
float f = 0.5F;
|
||||
float f1 = 1.0F;
|
||||
float f2 = 0.8F;
|
||||
float f3 = 0.6F;
|
||||
|
||||
renderBlocks.renderMaxX = block.maxX;
|
||||
renderBlocks.renderMinX = block.minX;
|
||||
renderBlocks.renderMaxY = block.maxY;
|
||||
renderBlocks.renderMinY = block.minY;
|
||||
renderBlocks.renderMaxZ = block.maxZ;
|
||||
renderBlocks.renderMinZ = block.minZ;
|
||||
renderBlocks.enableAO = false;
|
||||
public void renderBlock(RenderInfo info, IBlockAccess blockAccess, int x, int y, int z, boolean doLight, boolean doTessellating) {
|
||||
renderBlock(info, blockAccess, x, y, z, x, y, z, doLight, doTessellating);
|
||||
}
|
||||
|
||||
public void renderBlock(RenderInfo info, IBlockAccess blockAccess, double x, double y, double z, int lightX, int lightY, int lightZ, boolean doLight, boolean doTessellating) {
|
||||
float lightBottom = 0.5F;
|
||||
float lightTop = 1.0F;
|
||||
float lightEastWest = 0.8F;
|
||||
float lightNorthSouth = 0.6F;
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
if (doTessellating) {
|
||||
if (blockAccess == null)
|
||||
doLight = false;
|
||||
|
||||
if (doTessellating && !tessellator.isDrawing)
|
||||
tessellator.startDrawingQuads();
|
||||
}
|
||||
|
||||
float f4 = 0, f5 = 0;
|
||||
|
||||
float light = 0;
|
||||
if (doLight) {
|
||||
f4 = block.getBlockBrightness(blockAccess, i, j, k);
|
||||
f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
||||
if (f5 < f4) {
|
||||
f5 = f4;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f * f5, f * f5, f * f5);
|
||||
if (info.light < 0) {
|
||||
light = info.baseBlock.getBlockBrightness(blockAccess, (int) lightX, (int) lightY, (int) lightZ);
|
||||
light = light + ((1.0f - light) * 0.4f);
|
||||
} else
|
||||
light = info.light;
|
||||
int brightness = 0;
|
||||
if (info.brightness < 0)
|
||||
brightness = info.baseBlock.getMixedBrightnessForBlock(blockAccess, lightX, lightY, lightZ);
|
||||
else
|
||||
brightness = info.brightness;
|
||||
tessellator.setBrightness(brightness);
|
||||
tessellator.setColorOpaque_F(lightBottom * light, lightBottom * light, lightBottom * light);
|
||||
} else {
|
||||
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
|
||||
if (info.brightness >= 0)
|
||||
tessellator.setBrightness(info.brightness);
|
||||
}
|
||||
|
||||
renderBlocks.renderFaceYNeg(null, 0, 0, 0, block.getBlockTextureFromSide(0));
|
||||
renderBlocks.setRenderBounds(info.minX, info.minY, info.minZ, info.maxX, info.maxY, info.maxZ);
|
||||
|
||||
if (doLight) {
|
||||
f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
||||
if (f5 < f4) {
|
||||
f5 = f4;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f1 * f5, f1 * f5, f1 * f5);
|
||||
}
|
||||
if (info.renderSide[0])
|
||||
renderBlocks.renderFaceYNeg(info.baseBlock, x, y, z, info.getBlockTextureFromSide(0));
|
||||
|
||||
renderBlocks.renderFaceYPos(null, 0, 0, 0, block.getBlockTextureFromSide(1));
|
||||
if (doLight)
|
||||
tessellator.setColorOpaque_F(lightTop * light, lightTop * light, lightTop * light);
|
||||
|
||||
if (doLight) {
|
||||
f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
||||
if (f5 < f4) {
|
||||
f5 = f4;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5);
|
||||
}
|
||||
if (info.renderSide[1])
|
||||
renderBlocks.renderFaceYPos(info.baseBlock, x, y, z, info.getBlockTextureFromSide(1));
|
||||
|
||||
renderBlocks.renderFaceZNeg(null, 0, 0, 0, block.getBlockTextureFromSide(2));
|
||||
if (doLight)
|
||||
tessellator.setColorOpaque_F(lightEastWest * light, lightEastWest * light, lightEastWest * light);
|
||||
|
||||
if (doLight) {
|
||||
f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
||||
if (f5 < f4) {
|
||||
f5 = f4;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5);
|
||||
}
|
||||
if (info.renderSide[2])
|
||||
renderBlocks.renderFaceZNeg(info.baseBlock, x, y, z, info.getBlockTextureFromSide(2));
|
||||
|
||||
renderBlocks.renderFaceZPos(null, 0, 0, 0, block.getBlockTextureFromSide(3));
|
||||
if (doLight)
|
||||
tessellator.setColorOpaque_F(lightEastWest * light, lightEastWest * light, lightEastWest * light);
|
||||
|
||||
if (doLight) {
|
||||
f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
||||
if (f5 < f4) {
|
||||
f5 = f4;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5);
|
||||
}
|
||||
if (info.renderSide[3])
|
||||
renderBlocks.renderFaceZPos(info.baseBlock, x, y, z, info.getBlockTextureFromSide(3));
|
||||
|
||||
renderBlocks.renderFaceXNeg(null, 0, 0, 0, block.getBlockTextureFromSide(4));
|
||||
if (doLight)
|
||||
tessellator.setColorOpaque_F(lightNorthSouth * light, lightNorthSouth * light, lightNorthSouth * light);
|
||||
|
||||
if (doLight) {
|
||||
f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
||||
if (f5 < f4) {
|
||||
f5 = f4;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5);
|
||||
}
|
||||
if (info.renderSide[4])
|
||||
renderBlocks.renderFaceXNeg(info.baseBlock, x, y, z, info.getBlockTextureFromSide(4));
|
||||
|
||||
renderBlocks.renderFaceXPos(null, 0, 0, 0, block.getBlockTextureFromSide(5));
|
||||
if (doLight)
|
||||
tessellator.setColorOpaque_F(lightNorthSouth * light, lightNorthSouth * light, lightNorthSouth * light);
|
||||
|
||||
if (doTessellating) {
|
||||
if (info.renderSide[5])
|
||||
renderBlocks.renderFaceXPos(info.baseBlock, x, y, z, info.getBlockTextureFromSide(5));
|
||||
|
||||
if (doTessellating && tessellator.isDrawing)
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
//
|
||||
// public void renderBlock(RenderInfo block, IBlockAccess blockAccess, int i, int j, int k, boolean doLight, boolean doTessellating) {
|
||||
// float f = 0.5F;
|
||||
// float f1 = 1.0F;
|
||||
// float f2 = 0.8F;
|
||||
// float f3 = 0.6F;
|
||||
//
|
||||
// renderBlocks.renderMaxX = block.maxX;
|
||||
// renderBlocks.renderMinX = block.minX;
|
||||
// renderBlocks.renderMaxY = block.maxY;
|
||||
// renderBlocks.renderMinY = block.minY;
|
||||
// renderBlocks.renderMaxZ = block.maxZ;
|
||||
// renderBlocks.renderMinZ = block.minZ;
|
||||
// renderBlocks.enableAO = false;
|
||||
//
|
||||
//
|
||||
// Tessellator tessellator = Tessellator.instance;
|
||||
//
|
||||
// if (doTessellating) {
|
||||
// tessellator.startDrawingQuads();
|
||||
// }
|
||||
//
|
||||
// float f4 = 0, f5 = 0;
|
||||
//
|
||||
// if (doLight) {
|
||||
// f4 = block.getBlockBrightness(blockAccess, i, j, k);
|
||||
// f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
||||
// if (f5 < f4) {
|
||||
// f5 = f4;
|
||||
// }
|
||||
// tessellator.setColorOpaque_F(f * f5, f * f5, f * f5);
|
||||
// }
|
||||
//
|
||||
// renderBlocks.renderFaceYNeg(null, 0, 0, 0, block.getBlockTextureFromSide(0));
|
||||
//
|
||||
// if (doLight) {
|
||||
// f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
||||
// if (f5 < f4) {
|
||||
// f5 = f4;
|
||||
// }
|
||||
// tessellator.setColorOpaque_F(f1 * f5, f1 * f5, f1 * f5);
|
||||
// }
|
||||
//
|
||||
// renderBlocks.renderFaceYPos(null, 0, 0, 0, block.getBlockTextureFromSide(1));
|
||||
//
|
||||
// if (doLight) {
|
||||
// f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
||||
// if (f5 < f4) {
|
||||
// f5 = f4;
|
||||
// }
|
||||
// tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5);
|
||||
// }
|
||||
//
|
||||
// renderBlocks.renderFaceZNeg(null, 0, 0, 0, block.getBlockTextureFromSide(2));
|
||||
//
|
||||
// if (doLight) {
|
||||
// f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
||||
// if (f5 < f4) {
|
||||
// f5 = f4;
|
||||
// }
|
||||
// tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5);
|
||||
// }
|
||||
//
|
||||
// renderBlocks.renderFaceZPos(null, 0, 0, 0, block.getBlockTextureFromSide(3));
|
||||
//
|
||||
// if (doLight) {
|
||||
// f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
||||
// if (f5 < f4) {
|
||||
// f5 = f4;
|
||||
// }
|
||||
// tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5);
|
||||
// }
|
||||
//
|
||||
// renderBlocks.renderFaceXNeg(null, 0, 0, 0, block.getBlockTextureFromSide(4));
|
||||
//
|
||||
// if (doLight) {
|
||||
// f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
||||
// if (f5 < f4) {
|
||||
// f5 = f4;
|
||||
// }
|
||||
// tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5);
|
||||
// }
|
||||
//
|
||||
// renderBlocks.renderFaceXPos(null, 0, 0, 0, block.getBlockTextureFromSide(5));
|
||||
//
|
||||
// if (doTessellating) {
|
||||
// tessellator.draw();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ import buildcraft.api.transport.ISolidSideTile;
|
|||
import buildcraft.core.BlockIndex;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.transport.render.PipeWorldRenderer;
|
||||
import buildcraft.transport.render.PipeRendererWorld;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
@ -167,7 +167,7 @@ public class BlockGenericPipe extends BlockContainer {
|
|||
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
|
||||
}
|
||||
|
||||
float facadeThickness = PipeWorldRenderer.facadeThickness;
|
||||
float facadeThickness = PipeRendererWorld.facadeThickness;
|
||||
|
||||
if (tileG.hasFacade(ForgeDirection.EAST)) {
|
||||
setBlockBounds(1 - facadeThickness, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
|
|
@ -16,14 +16,11 @@ public class PipeRenderState implements IClientState {
|
|||
|
||||
private boolean hasGate = false;
|
||||
private int gateIconIndex = 0;
|
||||
|
||||
public final ConnectionMatrix pipeConnectionMatrix = new ConnectionMatrix();
|
||||
public final TextureMatrix textureMatrix = new TextureMatrix();
|
||||
public final WireMatrix wireMatrix = new WireMatrix();
|
||||
public final ConnectionMatrix plugMatrix = new ConnectionMatrix();
|
||||
|
||||
public final FacadeMatrix facadeMatrix = new FacadeMatrix();
|
||||
|
||||
private boolean dirty = true;
|
||||
|
||||
/*
|
||||
|
@ -58,14 +55,18 @@ public class PipeRenderState implements IClientState {
|
|||
dirty = false;
|
||||
pipeConnectionMatrix.clean();
|
||||
textureMatrix.clean();
|
||||
wireMatrix.clean();
|
||||
facadeMatrix.clean();
|
||||
wireMatrix.clean();
|
||||
}
|
||||
|
||||
public boolean isDirty() {
|
||||
return dirty || pipeConnectionMatrix.isDirty() || textureMatrix.isDirty() || wireMatrix.isDirty() || facadeMatrix.isDirty() || plugMatrix.isDirty();
|
||||
}
|
||||
|
||||
public boolean needsRenderUpdate() {
|
||||
return pipeConnectionMatrix.isDirty() || textureMatrix.isDirty() || facadeMatrix.isDirty() || plugMatrix.isDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
data.writeBoolean(hasGate);
|
||||
|
|
|
@ -35,7 +35,6 @@ import buildcraft.api.gates.ITrigger;
|
|||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.transport.IPipeConnectionForced;
|
||||
import buildcraft.api.transport.IPipe;
|
||||
import buildcraft.api.transport.IPipeConnection;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
|
@ -52,6 +51,8 @@ import buildcraft.core.network.PacketTileState;
|
|||
import buildcraft.transport.Gate.GateKind;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.server.management.PlayerInstance;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFluidHandler, IPipeTile, IOverrideDefaultTriggers, ITileBufferHolder,
|
||||
IDropControlInventory, IPipeRenderState, ISyncedTile, ISolidSideTile, IGuiReturnHandler {
|
||||
|
@ -80,6 +81,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
|
|||
public boolean[] pipeConnectionsBuffer = new boolean[6];
|
||||
public SafeTimeTracker networkSyncTracker = new SafeTimeTracker();
|
||||
public Pipe pipe;
|
||||
private boolean sendClientUpdate = false;
|
||||
private boolean blockNeighborChange = false;
|
||||
private boolean refreshRenderState = false;
|
||||
private boolean pipeBound = false;
|
||||
|
@ -186,6 +188,17 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
|
|||
PowerReceiver provider = getPowerReceiver(null);
|
||||
if (provider != null)
|
||||
provider.update();
|
||||
|
||||
if (sendClientUpdate) {
|
||||
sendClientUpdate = false;
|
||||
if (worldObj instanceof WorldServer) {
|
||||
WorldServer world = (WorldServer) worldObj;
|
||||
PlayerInstance playerInstance = world.getPlayerManager().getOrCreateChunkWatcher(xCoord >> 4, zCoord >> 4, false);
|
||||
if (playerInstance != null) {
|
||||
playerInstance.sendToAllPlayersWatchingChunk(getDescriptionPacket());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PRECONDITION: worldObj must not be null
|
||||
|
@ -244,8 +257,8 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
|
|||
}
|
||||
|
||||
if (renderState.isDirty()) {
|
||||
markBlockForUpdate();
|
||||
renderState.clean();
|
||||
sendUpdateToClient();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,6 +376,10 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
|
|||
return packet.getPacket();
|
||||
}
|
||||
|
||||
public void sendUpdateToClient() {
|
||||
sendClientUpdate = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkedList<ITrigger> getTriggers() {
|
||||
LinkedList<ITrigger> result = new LinkedList<ITrigger>();
|
||||
|
@ -428,12 +445,12 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
|
|||
if (!BlockGenericPipe.isValid(pipe))
|
||||
return false;
|
||||
|
||||
if(!(pipe instanceof IPipeConnectionForced) || !((IPipeConnectionForced) pipe).ignoreConnectionOverrides(side))
|
||||
if (!(pipe instanceof IPipeConnectionForced) || !((IPipeConnectionForced) pipe).ignoreConnectionOverrides(side))
|
||||
if (with instanceof IPipeConnection) {
|
||||
IPipeConnection.ConnectOverride override = ((IPipeConnection) with).overridePipeConnection(pipe.transport.getPipeType(), side.getOpposite());
|
||||
if (override != IPipeConnection.ConnectOverride.DEFAULT)
|
||||
return override == IPipeConnection.ConnectOverride.CONNECT ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
if (with instanceof TileGenericPipe) {
|
||||
if (((TileGenericPipe) with).hasPlug(side.getOpposite()))
|
||||
|
@ -618,9 +635,16 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
|
|||
pipe.gate = new GateVanilla(pipe);
|
||||
pipe.gate.kind = GateKind.values()[coreState.gateKind];
|
||||
}
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
break;
|
||||
case 1: {
|
||||
if (renderState.needsRenderUpdate()) {
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
renderState.clean();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -691,10 +715,6 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
|
|||
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this;
|
||||
}
|
||||
|
||||
public void markBlockForUpdate() {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGuiData(DataOutputStream data) throws IOException {
|
||||
if (BlockGenericPipe.isValid(pipe) && pipe instanceof IGuiReturnHandler)
|
||||
|
|
|
@ -3,23 +3,23 @@ package buildcraft.transport;
|
|||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.transport.render.FacadeItemRenderer;
|
||||
import buildcraft.transport.render.PipeItemRenderer;
|
||||
import buildcraft.transport.render.PipeWorldRenderer;
|
||||
import buildcraft.transport.render.PipeRendererWorld;
|
||||
import buildcraft.transport.render.PlugItemRenderer;
|
||||
import buildcraft.transport.render.RenderPipe;
|
||||
import buildcraft.transport.render.PipeRendererTESR;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
public class TransportProxyClient extends TransportProxy {
|
||||
public final static PipeItemRenderer pipeItemRenderer = new PipeItemRenderer();
|
||||
public final static PipeWorldRenderer pipeWorldRenderer = new PipeWorldRenderer();
|
||||
public final static PipeRendererWorld pipeWorldRenderer = new PipeRendererWorld();
|
||||
public final static FacadeItemRenderer facadeItemRenderer = new FacadeItemRenderer();
|
||||
public final static PlugItemRenderer plugItemRenderer = new PlugItemRenderer();
|
||||
|
||||
@Override
|
||||
public void registerTileEntities() {
|
||||
super.registerTileEntities();
|
||||
RenderPipe rp = new RenderPipe();
|
||||
PipeRendererTESR rp = new PipeRendererTESR();
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileDummyGenericPipe.class, rp);
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileDummyGenericPipe2.class, rp);
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileGenericPipe.class, rp);
|
||||
|
|
|
@ -72,7 +72,6 @@ public class PipeItemsDaizuli extends Pipe<PipeTransportItems> implements IPipeT
|
|||
if (color != c.ordinal()) {
|
||||
this.color = c.ordinal();
|
||||
container.scheduleRenderUpdate();
|
||||
container.markBlockForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,6 @@ public class PipeItemsLapis extends Pipe<PipeTransportItems> implements IItemTra
|
|||
if (color.ordinal() != container.getBlockMetadata()) {
|
||||
container.worldObj.setBlockMetadataWithNotify(container.xCoord, container.yCoord, container.zCoord, color.ordinal(), 3);
|
||||
container.scheduleRenderUpdate();
|
||||
container.markBlockForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ public abstract class PipeLogicIron {
|
|||
Item equipped = entityplayer.getCurrentEquippedItem() != null ? entityplayer.getCurrentEquippedItem().getItem() : null;
|
||||
if (equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(entityplayer, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord)) {
|
||||
switchPosition();
|
||||
pipe.container.worldObj.markBlockForUpdate(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord);
|
||||
pipe.container.scheduleRenderUpdate();
|
||||
((IToolWrench) equipped).wrenchUsed(entityplayer, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -99,7 +99,6 @@ public class PipePowerIron extends Pipe<PipeTransportPower> {
|
|||
if (mode.ordinal() != container.getBlockMetadata()) {
|
||||
container.worldObj.setBlockMetadataWithNotify(container.xCoord, container.yCoord, container.zCoord, mode.ordinal(), 3);
|
||||
container.scheduleRenderUpdate();
|
||||
container.markBlockForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,13 +10,16 @@ package buildcraft.transport.render;
|
|||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.BuildCraftCore.RenderMode;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.transport.IPipe;
|
||||
import buildcraft.api.transport.IPipe.WireColor;
|
||||
import buildcraft.core.render.FluidRenderer;
|
||||
import buildcraft.core.render.RenderEntityBlock;
|
||||
import buildcraft.core.render.RenderEntityBlock.BlockInterface;
|
||||
import buildcraft.core.render.RenderEntityBlock.RenderInfo;
|
||||
import buildcraft.core.utils.EnumColor;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
import buildcraft.transport.PipeRenderState;
|
||||
import buildcraft.transport.PipeTransportFluids;
|
||||
import buildcraft.transport.PipeTransportItems;
|
||||
import buildcraft.transport.PipeTransportPower;
|
||||
|
@ -26,6 +29,7 @@ import com.google.common.collect.Maps;
|
|||
import java.util.HashMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
|
@ -40,7 +44,7 @@ import net.minecraftforge.fluids.FluidRegistry;
|
|||
import net.minecraftforge.fluids.FluidStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RenderPipe extends TileEntitySpecialRenderer {
|
||||
public class PipeRendererTESR extends TileEntitySpecialRenderer {
|
||||
|
||||
final static private int LIQUID_STAGES = 40;
|
||||
final static private int MAX_ITEMS_TO_RENDER = 10;
|
||||
|
@ -61,7 +65,7 @@ public class RenderPipe extends TileEntitySpecialRenderer {
|
|||
public int[] displayPowerList = new int[POWER_STAGES];
|
||||
public int[] displayPowerListOverload = new int[POWER_STAGES];
|
||||
|
||||
public RenderPipe() {
|
||||
public PipeRendererTESR() {
|
||||
customRenderItem = new RenderItem() {
|
||||
@Override
|
||||
public boolean shouldBob() {
|
||||
|
@ -84,7 +88,7 @@ public class RenderPipe extends TileEntitySpecialRenderer {
|
|||
DisplayFluidList d = new DisplayFluidList();
|
||||
displayFluidLists.put(liquidId, d);
|
||||
|
||||
BlockInterface block = new BlockInterface();
|
||||
RenderInfo block = new RenderInfo();
|
||||
|
||||
Fluid fluid = FluidRegistry.getFluid(liquidId);
|
||||
if (fluid.getBlockID() > 0) {
|
||||
|
@ -185,7 +189,7 @@ public class RenderPipe extends TileEntitySpecialRenderer {
|
|||
|
||||
initialized = true;
|
||||
|
||||
BlockInterface block = new BlockInterface();
|
||||
RenderInfo block = new RenderInfo();
|
||||
block.texture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.Power_Normal.ordinal());
|
||||
|
||||
float size = Utils.pipeMaxPos - Utils.pipeMinPos;
|
||||
|
@ -250,6 +254,8 @@ public class RenderPipe extends TileEntitySpecialRenderer {
|
|||
if (pipe.pipe == null)
|
||||
return;
|
||||
|
||||
renderGatesWires(pipe, x, y, z);
|
||||
|
||||
switch (pipe.getPipeType()) {
|
||||
case ITEM:
|
||||
renderSolids(pipe.pipe, x, y, z);
|
||||
|
@ -263,6 +269,254 @@ public class RenderPipe extends TileEntitySpecialRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
private void renderGatesWires(TileGenericPipe pipe, double x, double y, double z) {
|
||||
PipeRenderState state = pipe.getRenderState();
|
||||
|
||||
if (state.wireMatrix.hasWire(WireColor.Red)) {
|
||||
pipeWireRender(pipe, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMinPos, IPipe.WireColor.Red, x, y, z);
|
||||
}
|
||||
|
||||
if (state.wireMatrix.hasWire(WireColor.Blue)) {
|
||||
pipeWireRender(pipe, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos, IPipe.WireColor.Blue, x, y, z);
|
||||
}
|
||||
|
||||
if (state.wireMatrix.hasWire(WireColor.Green)) {
|
||||
pipeWireRender(pipe, Utils.pipeMaxPos, Utils.pipeMinPos, Utils.pipeMinPos, IPipe.WireColor.Green, x, y, z);
|
||||
}
|
||||
|
||||
if (state.wireMatrix.hasWire(WireColor.Yellow)) {
|
||||
pipeWireRender(pipe, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, IPipe.WireColor.Yellow, x, y, z);
|
||||
}
|
||||
|
||||
if (state.hasGate()) {
|
||||
pipeGateRender(pipe, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
private void pipeWireRender(TileGenericPipe pipe, float cx, float cy, float cz, IPipe.WireColor color, double x, double y, double z) {
|
||||
|
||||
PipeRenderState state = pipe.getRenderState();
|
||||
|
||||
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 (state.wireMatrix.isWireConnected(color, ForgeDirection.WEST)) {
|
||||
minX = 0;
|
||||
foundX = true;
|
||||
}
|
||||
|
||||
if (state.wireMatrix.isWireConnected(color, ForgeDirection.EAST)) {
|
||||
maxX = 1;
|
||||
foundX = true;
|
||||
}
|
||||
|
||||
if (state.wireMatrix.isWireConnected(color, ForgeDirection.DOWN)) {
|
||||
minY = 0;
|
||||
foundY = true;
|
||||
}
|
||||
|
||||
if (state.wireMatrix.isWireConnected(color, ForgeDirection.UP)) {
|
||||
maxY = 1;
|
||||
foundY = true;
|
||||
}
|
||||
|
||||
if (state.wireMatrix.isWireConnected(color, ForgeDirection.NORTH)) {
|
||||
minZ = 0;
|
||||
foundZ = true;
|
||||
}
|
||||
|
||||
if (state.wireMatrix.isWireConnected(color, ForgeDirection.SOUTH)) {
|
||||
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;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
GL11.glTranslatef((float) x, (float) y, (float) z);
|
||||
|
||||
bindTexture(TextureMap.locationBlocksTexture);
|
||||
|
||||
RenderInfo box = new RenderInfo();
|
||||
box.texture = BuildCraftTransport.instance.wireIconProvider.getIcon(state.wireMatrix.getWireIconIndex(color));
|
||||
|
||||
// Z render
|
||||
|
||||
if (minZ != Utils.pipeMinPos || maxZ != Utils.pipeMaxPos || !found) {
|
||||
box.setBounds(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);
|
||||
RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
|
||||
}
|
||||
|
||||
// X render
|
||||
|
||||
if (minX != Utils.pipeMinPos || maxX != Utils.pipeMaxPos || !found) {
|
||||
box.setBounds(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);
|
||||
RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
|
||||
}
|
||||
|
||||
// Y render
|
||||
|
||||
if (minY != Utils.pipeMinPos || maxY != Utils.pipeMaxPos || !found) {
|
||||
box.setBounds(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);
|
||||
RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
|
||||
}
|
||||
|
||||
if (center || !found) {
|
||||
box.setBounds(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);
|
||||
RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
|
||||
}
|
||||
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void pipeGateRender(TileGenericPipe pipe, double x, double y, double z) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
// GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
// GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
GL11.glTranslatef((float) x, (float) y, (float) z);
|
||||
|
||||
bindTexture(TextureMap.locationBlocksTexture);
|
||||
|
||||
PipeRenderState state = pipe.getRenderState();
|
||||
|
||||
float min = Utils.pipeMinPos + 0.05F;
|
||||
float max = Utils.pipeMaxPos - 0.05F;
|
||||
|
||||
RenderInfo box = new RenderInfo();
|
||||
box.texture = BuildCraftTransport.instance.gateIconProvider.getIcon(state.getGateIconIndex());
|
||||
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.WEST)) {
|
||||
box.setBounds(Utils.pipeMinPos - 0.10F, min, min, Utils.pipeMinPos + 0.001F, max, max);
|
||||
RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
|
||||
}
|
||||
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.EAST)) {
|
||||
box.setBounds(Utils.pipeMaxPos + 0.001F, min, min, Utils.pipeMaxPos + 0.10F, max, max);
|
||||
RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
|
||||
}
|
||||
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.DOWN)) {
|
||||
box.setBounds(min, Utils.pipeMinPos - 0.10F, min, max, Utils.pipeMinPos + 0.001F, max);
|
||||
RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
|
||||
}
|
||||
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.UP)) {
|
||||
box.setBounds(min, Utils.pipeMaxPos + 0.001F, min, max, Utils.pipeMaxPos + 0.10F, max);
|
||||
RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
|
||||
}
|
||||
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.NORTH)) {
|
||||
box.setBounds(min, min, Utils.pipeMinPos - 0.10F, max, max, Utils.pipeMinPos + 0.001F);
|
||||
RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
|
||||
}
|
||||
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.SOUTH)) {
|
||||
box.setBounds(min, min, Utils.pipeMaxPos + 0.001F, max, max, Utils.pipeMaxPos + 0.10F);
|
||||
RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
|
||||
}
|
||||
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private boolean shouldRenderNormalPipeSide(PipeRenderState state, ForgeDirection direction) {
|
||||
return !state.pipeConnectionMatrix.isConnected(direction) && state.facadeMatrix.getFacadeBlockId(direction) == 0 && !state.plugMatrix.isConnected(direction) && !isOpenOrientation(state, direction);
|
||||
}
|
||||
|
||||
public boolean isOpenOrientation(PipeRenderState state, ForgeDirection direction) {
|
||||
int connections = 0;
|
||||
|
||||
ForgeDirection targetOrientation = ForgeDirection.UNKNOWN;
|
||||
|
||||
for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (state.pipeConnectionMatrix.isConnected(o)) {
|
||||
|
||||
connections++;
|
||||
|
||||
if (connections == 1)
|
||||
targetOrientation = o;
|
||||
}
|
||||
}
|
||||
|
||||
if (connections > 1 || connections == 0)
|
||||
return false;
|
||||
|
||||
return targetOrientation.getOpposite() == direction;
|
||||
}
|
||||
|
||||
private void renderPower(Pipe<PipeTransportPower> pipe, double x, double y, double z) {
|
||||
initializeDisplayPowerList(pipe.container.worldObj);
|
||||
|
||||
|
@ -449,7 +703,7 @@ public class RenderPipe extends TileEntitySpecialRenderer {
|
|||
customRenderItem.doRenderItem(dummyEntityItem, 0, 0, 0, 0, 0);
|
||||
if (color != null) {
|
||||
bindTexture(TextureMap.locationBlocksTexture);
|
||||
BlockInterface block = new BlockInterface();
|
||||
RenderInfo block = new RenderInfo();
|
||||
|
||||
block.texture = PipeIconProvider.TYPE.ItemBox.getIcon();
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@ package buildcraft.transport.render;
|
|||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.transport.IPipe;
|
||||
import buildcraft.api.transport.IPipe.WireColor;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.transport.BlockGenericPipe;
|
||||
import buildcraft.transport.IPipeRenderState;
|
||||
|
@ -20,7 +18,7 @@ import net.minecraft.util.Icon;
|
|||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
||||
public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public static final float facadeThickness = 1F / 16F;
|
||||
|
||||
|
@ -197,31 +195,6 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
|
||||
renderblocks.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
if (state.wireMatrix.hasWire(WireColor.Red)) {
|
||||
state.currentTexture = BuildCraftTransport.instance.wireIconProvider.getIcon(state.wireMatrix.getWireIconIndex(WireColor.Red));
|
||||
|
||||
pipeWireRender(renderblocks, block, state, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMinPos, IPipe.WireColor.Red, x, y, z);
|
||||
}
|
||||
|
||||
if (state.wireMatrix.hasWire(WireColor.Blue)) {
|
||||
state.currentTexture = BuildCraftTransport.instance.wireIconProvider.getIcon(state.wireMatrix.getWireIconIndex(WireColor.Blue));
|
||||
pipeWireRender(renderblocks, block, state, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos, IPipe.WireColor.Blue, x, y, z);
|
||||
}
|
||||
|
||||
if (state.wireMatrix.hasWire(WireColor.Green)) {
|
||||
state.currentTexture = BuildCraftTransport.instance.wireIconProvider.getIcon(state.wireMatrix.getWireIconIndex(WireColor.Green));
|
||||
pipeWireRender(renderblocks, block, state, Utils.pipeMaxPos, Utils.pipeMinPos, Utils.pipeMinPos, IPipe.WireColor.Green, x, y, z);
|
||||
}
|
||||
|
||||
if (state.wireMatrix.hasWire(WireColor.Yellow)) {
|
||||
state.currentTexture = BuildCraftTransport.instance.wireIconProvider.getIcon(state.wireMatrix.getWireIconIndex(WireColor.Yellow));
|
||||
pipeWireRender(renderblocks, block, state, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, IPipe.WireColor.Yellow, x, y, z);
|
||||
}
|
||||
|
||||
if (state.hasGate()) {
|
||||
pipeGateRender(renderblocks, block, state, x, y, z);
|
||||
}
|
||||
|
||||
pipeFacadeRenderer(renderblocks, block, state, x, y, z);
|
||||
pipePlugRenderer(renderblocks, block, state, x, y, z);
|
||||
|
||||
|
@ -392,190 +365,6 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
|
||||
}
|
||||
|
||||
private void pipeWireRender(RenderBlocks renderblocks, Block block, PipeRenderState state, float cx, float cy, float cz, IPipe.WireColor color, int x,
|
||||
int y, int z) {
|
||||
|
||||
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 (state.wireMatrix.isWireConnected(color, ForgeDirection.WEST)) {
|
||||
minX = 0;
|
||||
foundX = true;
|
||||
}
|
||||
|
||||
if (state.wireMatrix.isWireConnected(color, ForgeDirection.EAST)) {
|
||||
maxX = 1;
|
||||
foundX = true;
|
||||
}
|
||||
|
||||
if (state.wireMatrix.isWireConnected(color, ForgeDirection.DOWN)) {
|
||||
minY = 0;
|
||||
foundY = true;
|
||||
}
|
||||
|
||||
if (state.wireMatrix.isWireConnected(color, ForgeDirection.UP)) {
|
||||
maxY = 1;
|
||||
foundY = true;
|
||||
}
|
||||
|
||||
if (state.wireMatrix.isWireConnected(color, ForgeDirection.NORTH)) {
|
||||
minZ = 0;
|
||||
foundZ = true;
|
||||
}
|
||||
|
||||
if (state.wireMatrix.isWireConnected(color, ForgeDirection.SOUTH)) {
|
||||
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) {
|
||||
renderblocks.setRenderBounds(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, x, y, z);
|
||||
}
|
||||
|
||||
// X render
|
||||
|
||||
if (minX != Utils.pipeMinPos || maxX != Utils.pipeMaxPos || !found) {
|
||||
renderblocks.setRenderBounds(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, x, y, z);
|
||||
}
|
||||
|
||||
// Y render
|
||||
|
||||
if (minY != Utils.pipeMinPos || maxY != Utils.pipeMaxPos || !found) {
|
||||
renderblocks.setRenderBounds(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, x, y, z);
|
||||
}
|
||||
|
||||
if (center || !found) {
|
||||
renderblocks.setRenderBounds(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, x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void pipeGateRender(RenderBlocks renderblocks, Block block, PipeRenderState state, int x, int y, int z) {
|
||||
|
||||
state.currentTexture = BuildCraftTransport.instance.gateIconProvider.getIcon(state.getGateIconIndex());
|
||||
|
||||
float min = Utils.pipeMinPos + 0.05F;
|
||||
float max = Utils.pipeMaxPos - 0.05F;
|
||||
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.WEST)) {
|
||||
renderblocks.setRenderBounds(Utils.pipeMinPos - 0.10F, min, min, Utils.pipeMinPos + 0.001F, max, max);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.EAST)) {
|
||||
renderblocks.setRenderBounds(Utils.pipeMaxPos + 0.001F, min, min, Utils.pipeMaxPos + 0.10F, max, max);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.DOWN)) {
|
||||
renderblocks.setRenderBounds(min, Utils.pipeMinPos - 0.10F, min, max, Utils.pipeMinPos + 0.001F, max);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.UP)) {
|
||||
renderblocks.setRenderBounds(min, Utils.pipeMaxPos + 0.001F, min, max, Utils.pipeMaxPos + 0.10F, max);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.NORTH)) {
|
||||
renderblocks.setRenderBounds(min, min, Utils.pipeMinPos - 0.10F, max, max, Utils.pipeMinPos + 0.001F);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.SOUTH)) {
|
||||
renderblocks.setRenderBounds(min, min, Utils.pipeMaxPos + 0.001F, max, max, Utils.pipeMaxPos + 0.10F);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldRenderNormalPipeSide(PipeRenderState state, ForgeDirection direction) {
|
||||
return !state.pipeConnectionMatrix.isConnected(direction) && state.facadeMatrix.getFacadeBlockId(direction) == 0 && !state.plugMatrix.isConnected(direction) && !isOpenOrientation(state, direction);
|
||||
}
|
||||
|
||||
public boolean isOpenOrientation(PipeRenderState state, ForgeDirection direction) {
|
||||
int connections = 0;
|
||||
|
||||
ForgeDirection targetOrientation = ForgeDirection.UNKNOWN;
|
||||
|
||||
for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (state.pipeConnectionMatrix.isConnected(o)) {
|
||||
|
||||
connections++;
|
||||
|
||||
if (connections == 1)
|
||||
targetOrientation = o;
|
||||
}
|
||||
}
|
||||
|
||||
if (connections > 1 || connections == 0)
|
||||
return false;
|
||||
|
||||
return targetOrientation.getOpposite() == direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
|
||||
// TODO Auto-generated method stub
|
||||
|
|
|
@ -8,9 +8,8 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
|
||||
public class ConnectionMatrix {
|
||||
|
||||
private final BitSet _connected = new BitSet(ForgeDirection.VALID_DIRECTIONS.length);
|
||||
private BitSet _connected = new BitSet(ForgeDirection.VALID_DIRECTIONS.length);
|
||||
private final BitSetCodec _bitSetCodec = new BitSetCodec();
|
||||
|
||||
private boolean dirty = false;
|
||||
|
||||
public boolean isConnected(ForgeDirection direction) {
|
||||
|
@ -18,7 +17,7 @@ public class ConnectionMatrix {
|
|||
}
|
||||
|
||||
public void setConnected(ForgeDirection direction, boolean value) {
|
||||
if (_connected.get(direction.ordinal()) != value){
|
||||
if (_connected.get(direction.ordinal()) != value) {
|
||||
_connected.set(direction.ordinal(), value);
|
||||
dirty = true;
|
||||
}
|
||||
|
@ -37,6 +36,11 @@ public class ConnectionMatrix {
|
|||
}
|
||||
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
_bitSetCodec.decode(data.readByte(), _connected);
|
||||
BitSet connection = new BitSet(ForgeDirection.VALID_DIRECTIONS.length);
|
||||
_bitSetCodec.decode(data.readByte(), connection);
|
||||
if (!_connected.equals(connection)) {
|
||||
_connected = connection;
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,27 +6,27 @@ import java.io.IOException;
|
|||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class FacadeMatrix {
|
||||
|
||||
private final int[] _blockIds = new int[ForgeDirection.VALID_DIRECTIONS.length];
|
||||
private final int[] _blockMetas = new int[ForgeDirection.VALID_DIRECTIONS.length];
|
||||
|
||||
private boolean dirty = false;
|
||||
|
||||
public FacadeMatrix() {
|
||||
}
|
||||
|
||||
public void setFacade(ForgeDirection direction, int blockId, int blockMeta){
|
||||
if (_blockIds[direction.ordinal()] != blockId || _blockMetas[direction.ordinal()] != blockMeta){
|
||||
public void setFacade(ForgeDirection direction, int blockId, int blockMeta) {
|
||||
if (_blockIds[direction.ordinal()] != blockId || _blockMetas[direction.ordinal()] != blockMeta) {
|
||||
_blockIds[direction.ordinal()] = blockId;
|
||||
_blockMetas[direction.ordinal()] = blockMeta;
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int getFacadeBlockId(ForgeDirection direction){
|
||||
public int getFacadeBlockId(ForgeDirection direction) {
|
||||
return _blockIds[direction.ordinal()];
|
||||
}
|
||||
|
||||
public int getFacadeMetaId(ForgeDirection direction){
|
||||
public int getFacadeMetaId(ForgeDirection direction) {
|
||||
return _blockMetas[direction.ordinal()];
|
||||
}
|
||||
|
||||
|
@ -38,17 +38,25 @@ public class FacadeMatrix {
|
|||
dirty = false;
|
||||
}
|
||||
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
|
||||
_blockIds[i] = data.readShort();
|
||||
_blockMetas[i] = data.readByte();
|
||||
}
|
||||
}
|
||||
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
|
||||
data.writeShort(_blockIds[i]);
|
||||
data.writeByte(_blockMetas[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
|
||||
short id = data.readShort();
|
||||
if (_blockIds[i] != id) {
|
||||
_blockIds[i] = id;
|
||||
dirty = true;
|
||||
}
|
||||
byte meta = data.readByte();
|
||||
if (_blockMetas[i] != meta) {
|
||||
_blockMetas[i] = meta;
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
public class TextureMatrix {
|
||||
|
||||
private final int[] _iconIndexes = new int[7];
|
||||
|
||||
private boolean dirty = false;
|
||||
|
||||
public int getTextureIndex(ForgeDirection direction) {
|
||||
|
@ -38,7 +37,11 @@ public class TextureMatrix {
|
|||
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
for (int i = 0; i < _iconIndexes.length; i++) {
|
||||
_iconIndexes[i] = data.readByte();
|
||||
int icon = data.readByte();
|
||||
if (_iconIndexes[i] != icon) {
|
||||
_iconIndexes[i] = icon;
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue