Posted January 6, 20205 yr I am trying to create a tank to contain fluids. Everything seems to be working, except when it contains a transparent fluid (water), I can see the opposite sides of the fluid. How can I only render the faces that the player can see? public class TileEntityTankRenderer extends TileEntityRenderer< TileEntityTank > { private static AtlasTexture textureAtlas; @Override public void renderTileEntityFast( TileEntityTank tileEntity, double x, double y, double z, float partialTicks, int destroyStage, BufferBuilder buffer ) { final int capacity = tileEntity.getCapacity(); final FluidStack fluidStack = tileEntity.getFluid(); final Fluid fluid = fluidStack.getFluid(); if( !fluidStack.isEmpty() ) { if( textureAtlas == null ) textureAtlas = Minecraft.getInstance().getTextureMap(); final ResourceLocation fuildStillTexture = fluid.getAttributes().getStillTexture(); final TextureAtlasSprite fluidStillSprite = textureAtlas.getAtlasSprite( fuildStillTexture.toString() ); final double posY = 0.0625 + 0.875 * ( (float)fluidStack.getAmount() / (float)capacity ); final int color = fluid.getAttributes().getColor(); final float alpha = ( color >> 24 & 255 ) / 255.0F; final float red = ( color >> 16 & 255 ) / 255.0F; final float green = ( color >> 8 & 255 ) / 255.0F; final float blue = ( color & 255 ) / 255.0F; final BlockPos pos = tileEntity.getPos(); final BlockState blockState = tileEntity.getBlockState(); final int packedLightMap = blockState.getPackedLightmapCoords( getWorld(), pos ); final int skyLight = packedLightMap >> 16 & 0xFFFF; final int blockLight = packedLightMap & 0xFFFF; final double height = 0.875 + ( blockState.get( BlockTank.UP ) ? 0.0625 : 0.0 ) + ( blockState.get( BlockTank.DOWN ) ? 0.0625 : 0.0 ); final double x1 = 0.125; final double y1 = blockState.get( BlockTank.DOWN ) ? 0.0 : 0.0625; final double z1 = 0.125; final double x2 = 0.875; final double y2 = y1 + height * ( (float)fluidStack.getAmount() / (float)capacity ); final double z2 = 0.875; final double u1 = fluidStillSprite.getInterpolatedU( x1 * 16 ); final double v1 = fluidStillSprite.getInterpolatedV( z1 * 16 ); final double u2 = fluidStillSprite.getInterpolatedU( x2 * 16 ); final double v2 = fluidStillSprite.getInterpolatedV( z2 * 16 ); final double u3 = fluidStillSprite.getInterpolatedU( z1 * 16 ); final double v3 = fluidStillSprite.getInterpolatedV( y1 * 16 ); final double u4 = fluidStillSprite.getInterpolatedU( z2 * 16 ); final double v4 = fluidStillSprite.getInterpolatedV( y2 * 16 ); buffer.setTranslation( x, y, z ); // Top if( y2 < 1.0 || tileEntity.getFluidAmountAbove() == 0 ) { buffer.pos( x1, y2, z1 ).color( red, green, blue, alpha ).tex( u1, v1 ).lightmap( skyLight, blockLight ).endVertex(); buffer.pos( x1, y2, z2 ).color( red, green, blue, alpha ).tex( u1, v2 ).lightmap( skyLight, blockLight ).endVertex(); buffer.pos( x2, y2, z2 ).color( red, green, blue, alpha ).tex( u2, v2 ).lightmap( skyLight, blockLight ).endVertex(); buffer.pos( x2, y2, z1 ).color( red, green, blue, alpha ).tex( u2, v1 ).lightmap( skyLight, blockLight ).endVertex(); } // Bottom if( y1 > 0.0 || tileEntity.getFluidAmountBelow() == 0 ) { buffer.pos( x1, y1, z1 ).color( red, green, blue, alpha ).tex( u1, v1 ).lightmap( skyLight, blockLight ).endVertex(); buffer.pos( x2, y1, z1 ).color( red, green, blue, alpha ).tex( u2, v1 ).lightmap( skyLight, blockLight ).endVertex(); buffer.pos( x2, y1, z2 ).color( red, green, blue, alpha ).tex( u2, v2 ).lightmap( skyLight, blockLight ).endVertex(); buffer.pos( x1, y1, z2 ).color( red, green, blue, alpha ).tex( u1, v2 ).lightmap( skyLight, blockLight ).endVertex(); } // North buffer.pos( x2, y2, z1 ).color( red, green, blue, alpha ).tex( u2, v4 ).lightmap( skyLight, blockLight ).endVertex(); buffer.pos( x2, y1, z1 ).color( red, green, blue, alpha ).tex( u2, v3 ).lightmap( skyLight, blockLight ).endVertex(); buffer.pos( x1, y1, z1 ).color( red, green, blue, alpha ).tex( u1, v3 ).lightmap( skyLight, blockLight ).endVertex(); buffer.pos( x1, y2, z1 ).color( red, green, blue, alpha ).tex( u1, v4 ).lightmap( skyLight, blockLight ).endVertex(); // East buffer.pos( x2, y2, z2 ).color( red, green, blue, alpha ).tex( u4, v4 ).lightmap( skyLight, blockLight ).endVertex(); buffer.pos( x2, y1, z2 ).color( red, green, blue, alpha ).tex( u4, v3 ).lightmap( skyLight, blockLight ).endVertex(); buffer.pos( x2, y1, z1 ).color( red, green, blue, alpha ).tex( u3, v3 ).lightmap( skyLight, blockLight ).endVertex(); buffer.pos( x2, y2, z1 ).color( red, green, blue, alpha ).tex( u3, v4 ).lightmap( skyLight, blockLight ).endVertex(); // South buffer.pos( x1, y2, z2 ).color( red, green, blue, alpha ).tex( u1, v4 ).lightmap( skyLight, blockLight ).endVertex(); buffer.pos( x1, y1, z2 ).color( red, green, blue, alpha ).tex( u1, v3 ).lightmap( skyLight, blockLight ).endVertex(); buffer.pos( x2, y1, z2 ).color( red, green, blue, alpha ).tex( u2, v3 ).lightmap( skyLight, blockLight ).endVertex(); buffer.pos( x2, y2, z2 ).color( red, green, blue, alpha ).tex( u2, v4 ).lightmap( skyLight, blockLight ).endVertex(); // West buffer.pos( x1, y2, z1 ).color( red, green, blue, alpha ).tex( u3, v4 ).lightmap( skyLight, blockLight ).endVertex(); buffer.pos( x1, y1, z1 ).color( red, green, blue, alpha ).tex( u3, v3 ).lightmap( skyLight, blockLight ).endVertex(); buffer.pos( x1, y1, z2 ).color( red, green, blue, alpha ).tex( u4, v3 ).lightmap( skyLight, blockLight ).endVertex(); buffer.pos( x1, y2, z2 ).color( red, green, blue, alpha ).tex( u4, v4 ).lightmap( skyLight, blockLight ).endVertex(); } } } My mods: http://www.curse.com/mc-mods/minecraft/225548-greenscreen http://mods.curse.com/mc-mods/minecraft/238981-cash-craft
January 7, 20205 yr AFAIK only faces facing towards the player will be rendered anyway. Can you please provide a screenshot example of this? About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
January 7, 20205 yr Author You can see here where the back of the faces are being rendered behind the front faces. This can be particularly seen with the lava below the water. (Stacked tanks shouldn't really have different flids in them, but that check has not been implemented yet) My mods: http://www.curse.com/mc-mods/minecraft/225548-greenscreen http://mods.curse.com/mc-mods/minecraft/238981-cash-craft
January 9, 20205 yr That is interesting. I'm not sure what would be causing this because I played around with block rendering, TESRs and the fluid renderer a lot in 1.12.2 & 1.14.4 and you needed to explicitly draw the backing quad for both sides to be drawn. An example of this is how you can see through the world in spectator mode and do not see the insides of walls. Can you try simplifying your code to just draw a single quad and see if this still occurs? About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
January 10, 20205 yr Author When I was using a regular TESR, the backface wasn't being drawn, but this is a FastTESR (renderTileEntityFast). In looking at how they are rendered, it appears that Forge turns off backface culling before drawing the buffer. As OpenGL calls can't be used in a FastTESR, would I have to go back to using a regular TESR? My mods: http://www.curse.com/mc-mods/minecraft/225548-greenscreen http://mods.curse.com/mc-mods/minecraft/238981-cash-craft
January 10, 20205 yr Yeah and FastTESR is gone in 1.15.1 anyway - everything changed and is more like a FastTESR with the new render system. About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
January 10, 20205 yr Author OK, thanks. I'll go back to using a regular TESR. My mods: http://www.curse.com/mc-mods/minecraft/225548-greenscreen http://mods.curse.com/mc-mods/minecraft/238981-cash-craft
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.