use of logisticspipes.renderer.state.PipeRenderState in project LogisticsPipes by RS485.
the class LogisticsPipeWorldRenderer method renderPipe.
public static boolean renderPipe(RenderBlocks renderblocks, IBlockAccess iblockaccess, LogisticsBlockGenericPipe block, LogisticsTileGenericPipe pipe, int x, int y, int z) {
if (pipe.pipe instanceof PipeBlockRequestTable) {
if (LogisticsPipeWorldRenderer.renderPass != 0) {
return false;
}
PipeRenderState state = pipe.renderState;
IIconProvider icons = pipe.getPipeIcons();
if (icons == null) {
return false;
}
state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.UNKNOWN));
block.setRenderAllSides();
block.setBlockBounds(0, 0, 0, 1, 1, 1);
renderblocks.setRenderBoundsFromBlock(block);
renderblocks.renderStandardBlock(block, x, y, z);
return true;
}
// Here to prevent Minecraft from crashing when nothing renders on render pass zero
// This is likely a bug, and has been submitted as an issue to the Forge team
renderblocks.setRenderBounds(0, 0, 0, 0, 0, 0);
renderblocks.renderStandardBlock(Blocks.stone, x, y, z);
renderblocks.setRenderBoundsFromBlock(block);
PipeRenderState state = pipe.renderState;
IIconProvider icons = pipe.getPipeIcons();
if (icons == null) {
return false;
}
if (LogisticsPipeWorldRenderer.renderPass == 0) {
int connectivity = state.pipeConnectionMatrix.getMask();
float[] dim = new float[6];
if (!pipe.isOpaque()) {
// render the unconnected pipe faces of the center block (if any)
if (connectivity != 0x3f) {
// note: 0x3f = 0x111111 = all sides
LogisticsPipeWorldRenderer.resetToCenterDimensions(dim);
state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.UNKNOWN));
LogisticsPipeWorldRenderer.renderTwoWayBlock(renderblocks, block, x, y, z, dim, connectivity ^ 0x3f);
}
// render the connecting pipe faces
for (int dir = 0; dir < 6; dir++) {
int mask = 1 << dir;
if ((connectivity & mask) == 0) {
// no connection towards dir
continue;
}
// center piece offsets
LogisticsPipeWorldRenderer.resetToCenterDimensions(dim);
// extend block towards dir as it's connected to there
dim[dir / 2] = dir % 2 == 0 ? 0 : LPConstants.BC_PIPE_MAX_POS;
dim[dir / 2 + 3] = dir % 2 == 0 ? LPConstants.BC_PIPE_MIN_POS : 1;
// the mask points to all faces perpendicular to dir, i.e. dirs 0+1 -> mask 111100, 1+2 -> 110011, 3+5 -> 001111
int renderMask = (3 << (dir / 2 * 2)) ^ 0x3f;
//workaround for 1.6 texture weirdness, rotate texture for N/S/E/W connections
renderblocks.uvRotateEast = renderblocks.uvRotateNorth = renderblocks.uvRotateWest = renderblocks.uvRotateSouth = (dir < 2) ? 0 : 1;
// render sub block
state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.VALID_DIRECTIONS[dir]));
LogisticsPipeWorldRenderer.renderTwoWayBlock(renderblocks, block, x, y, z, dim, renderMask);
renderblocks.uvRotateEast = renderblocks.uvRotateNorth = renderblocks.uvRotateWest = renderblocks.uvRotateSouth = 0;
}
} else {
// render the unconnected pipe faces of the center block (if any)
if (connectivity != 0x3f) {
// note: 0x3f = 0x111111 = all sides
LogisticsPipeWorldRenderer.resetToCenterDimensions(dim);
//Render opaque Layer
state.currentTexture = icons.getIcon(Textures.LOGISTICSPIPE_OPAQUE_TEXTURE.normal);
LogisticsPipeWorldRenderer.renderOneWayBlock(renderblocks, block, x, y, z, dim, connectivity ^ 0x3f);
//Render Pipe Texture
state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.UNKNOWN));
LogisticsPipeWorldRenderer.renderOneWayBlock(renderblocks, block, x, y, z, dim, connectivity ^ 0x3f);
}
// render the connecting pipe faces
for (int dir = 0; dir < 6; dir++) {
int mask = 1 << dir;
if ((connectivity & mask) == 0) {
// no connection towards dir
continue;
}
// center piece offsets
LogisticsPipeWorldRenderer.resetToCenterDimensions(dim);
// extend block towards dir as it's connected to there
dim[dir / 2] = dir % 2 == 0 ? 0 : LPConstants.BC_PIPE_MAX_POS;
dim[dir / 2 + 3] = dir % 2 == 0 ? LPConstants.BC_PIPE_MIN_POS : 1;
// the mask points to all faces perpendicular to dir, i.e. dirs 0+1 -> mask 111100, 1+2 -> 110011, 3+5 -> 001111
int renderMask = (3 << (dir / 2 * 2)) ^ 0x3f;
//workaround for 1.6 texture weirdness, rotate texture for N/S/E/W connections
renderblocks.uvRotateEast = renderblocks.uvRotateNorth = renderblocks.uvRotateWest = renderblocks.uvRotateSouth = (dir < 2) ? 0 : 1;
//Render opaque Layer
state.currentTexture = icons.getIcon(Textures.LOGISTICSPIPE_OPAQUE_TEXTURE.normal);
LogisticsPipeWorldRenderer.renderOneWayBlock(renderblocks, block, x, y, z, dim, 0x3f);
// render sub block
state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.VALID_DIRECTIONS[dir]));
LogisticsPipeWorldRenderer.renderOneWayBlock(renderblocks, block, x, y, z, dim, renderMask);
renderblocks.uvRotateEast = renderblocks.uvRotateNorth = renderblocks.uvRotateWest = renderblocks.uvRotateSouth = 0;
}
}
}
renderblocks.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (pipe.tilePart.hasPipePluggable(dir)) {
IBCPipePluggable p = pipe.tilePart.getBCPipePluggable(dir);
p.renderPluggable(renderblocks, dir, LogisticsPipeWorldRenderer.renderPass, x, y, z);
}
}
return true;
}
use of logisticspipes.renderer.state.PipeRenderState in project LogisticsPipes by RS485.
the class LogisticsNewPipeWorldRenderer method renderWorldBlock.
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
Tessellator tess = Tessellator.instance;
TileEntity tile = world.getTileEntity(x, y, z);
LogisticsTileGenericPipe pipeTile = (LogisticsTileGenericPipe) tile;
PipeRenderState renderState = pipeTile.renderState;
if (pipeTile.pipe instanceof PipeBlockRequestTable) {
if (LogisticsPipeWorldRenderer.renderPass != 0) {
return false;
}
IIconProvider icons = pipeTile.getPipeIcons();
if (icons == null) {
return false;
}
if (requestBlock == null || true) {
requestBlock = new HashMap<>();
for (BlockRotation rot : BlockRotation.values()) {
requestBlock.put(rot, LogisticsNewSolidBlockWorldRenderer.block.get(rot).copy().apply(new LPScale(0.999)).apply(new LPTranslation(0.0005, 0.0005, 0.0005)));
}
}
SimpleServiceLocator.cclProxy.getRenderState().reset();
SimpleServiceLocator.cclProxy.getRenderState().setUseNormals(true);
SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0xff);
BlockRotation rotation = BlockRotation.getRotation(((PipeBlockRequestTable) pipeTile.pipe).getRotation());
int brightness = new DoubleCoordinates(x, y, z).getBlock(world).getMixedBrightnessForBlock(world, x, y, z);
tess.setColorOpaque_F(1F, 1F, 1F);
tess.setBrightness(brightness);
IIconTransformation icon = SimpleServiceLocator.cclProxy.createIconTransformer(Textures.LOGISTICS_REQUEST_TABLE_NEW);
requestBlock.get(rotation).render(new LPTranslation(x, y, z), icon);
for (CoverSides side : CoverSides.values()) {
if (!pipeTile.renderState.pipeConnectionMatrix.isConnected(side.getDir(rotation))) {
LogisticsNewSolidBlockWorldRenderer.texturePlate_Outer.get(side).get(rotation).render(new LPTranslation(x, y, z), icon);
LogisticsNewSolidBlockWorldRenderer.texturePlate_Inner.get(side).get(rotation).render(new LPTranslation(x, y, z), icon);
}
}
return true;
}
boolean hasRendered = false;
tess.addTranslation(0.00002F, 0.00002F, 0.00002F);
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (pipeTile.tilePart.hasPipePluggable(dir)) {
IBCPipePluggable p = pipeTile.tilePart.getBCPipePluggable(dir);
p.renderPluggable(renderer, dir, LogisticsPipeWorldRenderer.renderPass, x, y, z);
hasRendered = true;
}
}
tess.addTranslation(-0.00002F, -0.00002F, -0.00002F);
boolean[] solidSides = new boolean[6];
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
DoubleCoordinates pos = CoordinateUtils.add(new DoubleCoordinates((TileEntity) pipeTile), dir);
Block blockSide = pos.getBlock(pipeTile.getWorldObj());
if (blockSide != null && blockSide.isSideSolid(pipeTile.getWorldObj(), pos.getXInt(), pos.getYInt(), pos.getZInt(), dir.getOpposite()) && !renderState.pipeConnectionMatrix.isConnected(dir)) {
solidSides[dir.ordinal()] = true;
}
}
if (!Arrays.equals(solidSides, renderState.solidSidesCache)) {
renderState.solidSidesCache = solidSides.clone();
renderState.cachedRenderer = null;
}
if (hasRendered) {
block.setBlockBounds(0, 0, 0, 0, 0, 0);
renderer.setRenderBoundsFromBlock(block);
renderer.renderStandardBlock(block, x, y, z);
block.setBlockBounds(0, 0, 0, 1, 1, 1);
}
return hasRendered;
}
use of logisticspipes.renderer.state.PipeRenderState in project LogisticsPipes by RS485.
the class LogisticsNewRenderPipe method checkAndCalculateRenderCache.
public static boolean checkAndCalculateRenderCache(LogisticsTileGenericPipe pipeTile) {
PipeRenderState renderState = pipeTile.renderState;
if (renderState.cachedRenderIndex != MainProxy.proxy.getRenderIndex()) {
renderState.clearRenderCaches();
}
if (renderState.cachedRenderer == null) {
ArrayList<RenderEntry> objectsToRender = new ArrayList<>();
if (pipeTile.pipe != null && pipeTile.pipe.actAsNormalPipe()) {
fillObjectsToRenderList(objectsToRender, pipeTile, renderState);
}
if (pipeTile.pipe != null && pipeTile.pipe.getSpecialRenderer() != null) {
pipeTile.pipe.getSpecialRenderer().renderToList(pipeTile.pipe, objectsToRender);
}
renderState.cachedRenderIndex = MainProxy.proxy.getRenderIndex();
renderState.cachedRenderer = Collections.unmodifiableList(objectsToRender);
return true;
}
return false;
}
use of logisticspipes.renderer.state.PipeRenderState in project LogisticsPipes by RS485.
the class LogisticsNewRenderPipe method fillObjectsToRenderList.
private static void fillObjectsToRenderList(List<RenderEntry> objectsToRender, LogisticsTileGenericPipe pipeTile, PipeRenderState renderState) {
List<Edge> edgesToRender = new ArrayList<>(Arrays.asList(Edge.values()));
Map<Corner, Integer> connectionAtCorner = new HashMap<>();
List<PipeMount> mountCanidates = new ArrayList<>(Arrays.asList(PipeMount.values()));
int connectionCount = 0;
for (EnumFacing dir : EnumFacing.VALUES) {
if (renderState.pipeConnectionMatrix.isConnected(dir) || pipeTile.pipe.hasSpecialPipeEndAt(dir)) {
connectionCount++;
if (renderState.pipeConnectionMatrix.isTDConnected(dir) || renderState.pipeConnectionMatrix.isBCConnected(dir)) {
I3DOperation[] texture = new I3DOperation[] { LogisticsNewRenderPipe.basicPipeTexture };
if (renderState.textureMatrix.isRouted()) {
if (renderState.textureMatrix.isRoutedInDir(dir)) {
if (renderState.textureMatrix.isSubPowerInDir(dir)) {
texture = new I3DOperation[] { new LPUVTransformationList(new LPUVTranslation(0, +23F / 100), LogisticsNewRenderPipe.statusBCTexture) };
} else {
texture = new I3DOperation[] { LogisticsNewRenderPipe.statusBCTexture };
}
} else {
texture = new I3DOperation[] { new LPUVTransformationList(new LPUVTranslation(0, -23F / 100), LogisticsNewRenderPipe.statusBCTexture) };
}
}
for (IModel3D model : LogisticsNewRenderPipe.sideBC.get(dir)) {
objectsToRender.add(new RenderEntry(model, texture));
}
} else if (!pipeTile.pipe.hasSpecialPipeEndAt(dir)) {
I3DOperation[] texture = new I3DOperation[] { LogisticsNewRenderPipe.basicPipeTexture };
if (renderState.textureMatrix.isRouted()) {
if (renderState.textureMatrix.isRoutedInDir(dir)) {
if (renderState.textureMatrix.isSubPowerInDir(dir)) {
texture = new I3DOperation[] { new LPUVTransformationList(new LPUVTranslation(-2.5F / 10, 0), LogisticsNewRenderPipe.statusTexture) };
} else {
texture = new I3DOperation[] { LogisticsNewRenderPipe.statusTexture };
}
} else {
if (renderState.textureMatrix.isHasPowerUpgrade()) {
if (renderState.textureMatrix.getPointedOrientation() == dir) {
texture = new I3DOperation[] { new LPUVTransformationList(new LPUVTranslation(+2.5F / 10, 0), LogisticsNewRenderPipe.statusTexture) };
} else {
texture = new I3DOperation[] { new LPUVTransformationList(new LPUVTranslation(-2.5F / 10, 37F / 100), LogisticsNewRenderPipe.statusTexture) };
}
} else {
if (renderState.textureMatrix.getPointedOrientation() == dir) {
texture = new I3DOperation[] { new LPUVTransformationList(new LPUVTranslation(+2.5F / 10, 37F / 100), LogisticsNewRenderPipe.statusTexture) };
} else {
texture = new I3DOperation[] { new LPUVTransformationList(new LPUVTranslation(0, 37F / 100), LogisticsNewRenderPipe.statusTexture) };
}
}
}
}
for (IModel3D model : LogisticsNewRenderPipe.sideNormal.get(dir)) {
double[] bounds = { Block.FULL_BLOCK_AABB.minY, Block.FULL_BLOCK_AABB.minZ, Block.FULL_BLOCK_AABB.minX, Block.FULL_BLOCK_AABB.maxY, Block.FULL_BLOCK_AABB.maxZ, Block.FULL_BLOCK_AABB.maxX };
if (pipeTile.getWorld() != null) {
// This can be null in some cases now !!!
DoubleCoordinates coords = CoordinateUtils.add(new DoubleCoordinates((TileEntity) pipeTile), dir);
Block block = coords.getBlock(pipeTile.getWorld());
AxisAlignedBB bb = block.getCollisionBoundingBox(coords.getBlockState(pipeTile.getWorld()), pipeTile.getWorld(), coords.getBlockPos());
if (bb == null)
bb = Block.FULL_BLOCK_AABB;
bounds = new double[] { bb.minY, bb.minZ, bb.minX, bb.maxY, bb.maxZ, bb.maxX };
if (SimpleServiceLocator.enderIOProxy.isItemConduit(coords.getTileEntity(pipeTile.getWorld()), dir.getOpposite()) || SimpleServiceLocator.enderIOProxy.isFluidConduit(coords.getTileEntity(pipeTile.getWorld()), dir.getOpposite())) {
bounds = new double[] { 0.0249D, 0.0249D, 0.0249D, 0.9751D, 0.9751D, 0.9751D };
}
}
double bound = bounds[dir.ordinal() / 2 + (dir.ordinal() % 2 == 0 ? 3 : 0)];
ScaleObject key = new ScaleObject(model, bound);
IModel3D model2 = LogisticsNewRenderPipe.scaleMap.get(key);
if (model2 == null) {
model2 = model.copy();
IVec3 min = model2.bounds().min();
model2.apply(new LPTranslation(min).inverse());
double toAdd;
if (dir.ordinal() % 2 == 1) {
toAdd = 1 + (bound / LPConstants.PIPE_MIN_POS);
model2.apply(new LPScale(dir.getDirectionVec().getX() != 0 ? toAdd : 1, dir.getDirectionVec().getY() != 0 ? toAdd : 1, dir.getDirectionVec().getZ() != 0 ? toAdd : 1));
} else {
bound = 1 - bound;
toAdd = 1 + (bound / LPConstants.PIPE_MIN_POS);
model2.apply(new LPScale(dir.getDirectionVec().getX() != 0 ? toAdd : 1, dir.getDirectionVec().getY() != 0 ? toAdd : 1, dir.getDirectionVec().getZ() != 0 ? toAdd : 1));
model2.apply(new LPTranslation(dir.getDirectionVec().getX() * bound, dir.getDirectionVec().getY() * bound, dir.getDirectionVec().getZ() * bound));
}
model2.apply(new LPTranslation(min));
LogisticsNewRenderPipe.scaleMap.put(key, model2);
}
objectsToRender.add(new RenderEntry(model2, texture));
}
}
for (Edge edge : Edge.values()) {
if (edge.part1 == dir || edge.part2 == dir) {
edgesToRender.remove(edge);
for (PipeMount mount : PipeMount.values()) {
if ((mount.dir == edge.part1 && mount.side == edge.part2) || (mount.dir == edge.part2 && mount.side == edge.part1)) {
mountCanidates.remove(mount);
}
}
}
}
for (Corner corner : Corner.values()) {
if (corner.ew.dir == dir || corner.ns.dir == dir || corner.ud.dir == dir) {
if (!connectionAtCorner.containsKey(corner)) {
connectionAtCorner.put(corner, 1);
} else {
connectionAtCorner.put(corner, connectionAtCorner.get(corner) + 1);
}
}
}
}
}
for (Corner corner : Corner.values()) {
TextureTransformation cornerTexture = LogisticsNewRenderPipe.basicPipeTexture;
if (!renderState.textureMatrix.isHasPower() && renderState.textureMatrix.isRouted()) {
cornerTexture = LogisticsNewRenderPipe.inactiveTexture;
} else if (!renderState.textureMatrix.isRouted() && connectionCount > 2) {
cornerTexture = LogisticsNewRenderPipe.inactiveTexture;
}
int count = connectionAtCorner.containsKey(corner) ? connectionAtCorner.get(corner) : 0;
if (count == 0) {
for (IModel3D model : LogisticsNewRenderPipe.corners_M.get(corner)) {
objectsToRender.add(new RenderEntry(model, cornerTexture));
}
} else if (count == 1) {
for (PipeTurnCorner turn : PipeTurnCorner.values()) {
if (turn.corner != corner) {
continue;
}
if (renderState.pipeConnectionMatrix.isConnected(turn.getPointer()) || pipeTile.pipe.hasSpecialPipeEndAt(turn.getPointer())) {
objectsToRender.add(new RenderEntry(LogisticsNewRenderPipe.spacers.get(turn), cornerTexture));
break;
}
}
} else if (count == 2) {
for (PipeTurnCorner turn : PipeTurnCorner.values()) {
if (turn.corner != corner) {
continue;
}
if (!renderState.pipeConnectionMatrix.isConnected(turn.getPointer()) || pipeTile.pipe.hasSpecialPipeEndAt(turn.getPointer())) {
objectsToRender.add(new RenderEntry(LogisticsNewRenderPipe.corners_I.get(turn), cornerTexture));
break;
}
}
} else if (count == 3) {
for (IModel3D model : LogisticsNewRenderPipe.corners_I3.get(corner)) {
objectsToRender.add(new RenderEntry(model, cornerTexture));
}
}
}
edgesToRender.stream().map(edge -> new RenderEntry(LogisticsNewRenderPipe.edges.get(edge), LogisticsNewRenderPipe.basicPipeTexture)).forEach(objectsToRender::add);
for (int i = 0; i < 6; i += 2) {
EnumFacing dir = EnumFacing.getFront(i);
List<EnumFacing> list = new ArrayList<>(Arrays.asList(EnumFacing.VALUES));
list.remove(dir);
list.remove(dir.getOpposite());
if (renderState.pipeConnectionMatrix.isConnected(dir) && renderState.pipeConnectionMatrix.isConnected(dir.getOpposite())) {
boolean found = false;
for (EnumFacing dir2 : list) {
if (renderState.pipeConnectionMatrix.isConnected(dir2)) {
found = true;
break;
}
}
if (!found) {
switch(dir) {
case DOWN:
objectsToRender.add(new RenderEntry(LogisticsNewRenderPipe.supports.get(PipeSupport.EAST_SIDE), LogisticsNewRenderPipe.basicPipeTexture));
objectsToRender.add(new RenderEntry(LogisticsNewRenderPipe.supports.get(PipeSupport.WEST_SIDE), LogisticsNewRenderPipe.basicPipeTexture));
objectsToRender.add(new RenderEntry(LogisticsNewRenderPipe.supports.get(PipeSupport.NORTH_SIDE), LogisticsNewRenderPipe.basicPipeTexture));
objectsToRender.add(new RenderEntry(LogisticsNewRenderPipe.supports.get(PipeSupport.SOUTH_SIDE), LogisticsNewRenderPipe.basicPipeTexture));
break;
case NORTH:
objectsToRender.add(new RenderEntry(LogisticsNewRenderPipe.supports.get(PipeSupport.EAST_UP), LogisticsNewRenderPipe.basicPipeTexture));
objectsToRender.add(new RenderEntry(LogisticsNewRenderPipe.supports.get(PipeSupport.WEST_UP), LogisticsNewRenderPipe.basicPipeTexture));
objectsToRender.add(new RenderEntry(LogisticsNewRenderPipe.supports.get(PipeSupport.UP_SIDE), LogisticsNewRenderPipe.basicPipeTexture));
objectsToRender.add(new RenderEntry(LogisticsNewRenderPipe.supports.get(PipeSupport.DOWN_SIDE), LogisticsNewRenderPipe.basicPipeTexture));
break;
case WEST:
objectsToRender.add(new RenderEntry(LogisticsNewRenderPipe.supports.get(PipeSupport.UP_UP), LogisticsNewRenderPipe.basicPipeTexture));
objectsToRender.add(new RenderEntry(LogisticsNewRenderPipe.supports.get(PipeSupport.DOWN_UP), LogisticsNewRenderPipe.basicPipeTexture));
objectsToRender.add(new RenderEntry(LogisticsNewRenderPipe.supports.get(PipeSupport.NORTH_UP), LogisticsNewRenderPipe.basicPipeTexture));
objectsToRender.add(new RenderEntry(LogisticsNewRenderPipe.supports.get(PipeSupport.SOUTH_UP), LogisticsNewRenderPipe.basicPipeTexture));
break;
default:
break;
}
}
}
}
boolean[] solidSides = new boolean[6];
if (pipeTile.getWorld() != null) {
// This can be null in some cases now !!!
for (EnumFacing dir : EnumFacing.VALUES) {
DoubleCoordinates pos = CoordinateUtils.add(new DoubleCoordinates((TileEntity) pipeTile), dir);
Block blockSide = pos.getBlock(pipeTile.getWorld());
if (blockSide == null || !blockSide.isSideSolid(pos.getBlockState(pipeTile.getWorld()), pipeTile.getWorld(), pos.getBlockPos(), dir.getOpposite()) || renderState.pipeConnectionMatrix.isConnected(dir)) {
mountCanidates.removeIf(mount -> mount.dir == dir);
} else {
solidSides[dir.ordinal()] = true;
}
}
mountCanidates.removeIf(mount -> SimpleServiceLocator.mcmpProxy.hasParts(pipeTile));
} else {
mountCanidates.clear();
}
if (!mountCanidates.isEmpty()) {
if (solidSides[EnumFacing.DOWN.ordinal()]) {
findOponentOnSameSide(mountCanidates, EnumFacing.DOWN);
} else if (solidSides[EnumFacing.UP.ordinal()]) {
findOponentOnSameSide(mountCanidates, EnumFacing.UP);
} else {
removeFromSide(mountCanidates, EnumFacing.DOWN);
removeFromSide(mountCanidates, EnumFacing.UP);
if (mountCanidates.size() > 2) {
removeIfHasOponentSide(mountCanidates);
}
if (mountCanidates.size() > 2) {
removeIfHasConnectedSide(mountCanidates);
}
if (mountCanidates.size() > 2) {
findOponentOnSameSide(mountCanidates, mountCanidates.get(0).dir);
}
}
if (LogisticsPipes.isDEBUG() && mountCanidates.size() > 2) {
new RuntimeException("Trying to render " + mountCanidates.size() + " Mounts").printStackTrace();
}
mountCanidates.stream().map(mount -> new RenderEntry(LogisticsNewRenderPipe.mounts.get(mount), LogisticsNewRenderPipe.basicPipeTexture)).forEach(objectsToRender::add);
}
for (EnumFacing dir : EnumFacing.VALUES) {
if (!renderState.pipeConnectionMatrix.isConnected(dir)) {
for (IModel3D model : LogisticsNewRenderPipe.texturePlate_Outer.get(dir)) {
TextureTransformation icon = Textures.LPnewPipeIconProvider.getIcon(renderState.textureMatrix.getTextureIndex());
if (icon != null) {
objectsToRender.add(new RenderEntry(model, new LPUVTransformationList(new LPUVScale(12f / 16, 12f / 16), icon)));
}
}
}
}
if (renderState.textureMatrix.isFluid()) {
for (EnumFacing dir : EnumFacing.VALUES) {
if (!renderState.pipeConnectionMatrix.isConnected(dir)) {
LogisticsNewRenderPipe.texturePlate_Inner.get(dir).stream().map(model -> new RenderEntry(model, new I3DOperation[] { LogisticsNewRenderPipe.glassCenterTexture })).forEach(objectsToRender::add);
} else {
if (!renderState.textureMatrix.isRoutedInDir(dir)) {
LogisticsNewRenderPipe.sideTexturePlate.get(dir).getValue1().stream().map(model -> new RenderEntry(model, new I3DOperation[] { LogisticsNewRenderPipe.basicPipeTexture })).forEach(objectsToRender::add);
}
}
}
}
SimpleServiceLocator.thermalDynamicsProxy.renderPipeConnections(pipeTile, objectsToRender);
}
use of logisticspipes.renderer.state.PipeRenderState in project LogisticsPipes by RS485.
the class LogisticsNewRenderPipe method renderTileEntityAt.
public void renderTileEntityAt(LogisticsTileGenericPipe pipeTile, double x, double y, double z, float partialTickTime, double distance) {
boolean inHand = false;
if (pipeTile == null) {
}
if (pipeTile.pipe instanceof PipeBlockRequestTable) {
return;
}
if (pipeTile.pipe == null) {
return;
}
PipeRenderState renderState = pipeTile.renderState;
if (renderState.renderLists != null && renderState.renderLists.values().stream().anyMatch(GLRenderList::isInvalid)) {
renderState.renderLists = null;
}
if (renderState.renderLists == null) {
renderState.renderLists = new HashMap<>();
}
if (distance > config.getRenderPipeDistance() * config.getRenderPipeDistance()) {
/*if (config.isUseFallbackRenderer()) {
renderState.forceRenderOldPipe = true;
}*/
} else {
renderState.forceRenderOldPipe = false;
boolean recalculateList = checkAndCalculateRenderCache(pipeTile);
renderList(x, y, z, renderState.renderLists, renderState.cachedRenderer, recalculateList);
if (recalculateList) {
pipeTile.getWorld().markBlockRangeForRenderUpdate(pipeTile.getPos(), pipeTile.getPos());
}
}
}
Aggregations