Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public boolean render(final IWorldReader worldIn, final BlockPos pos, final BufferBuilder buffer, final IFluidState state) {
- boolean isLava = state.isTagged(FluidTags.LAVA);
- TextureAtlasSprite[] atextureatlassprite = isLava ? this.atlasSpritesLava : this.atlasSpritesWater;
- int waterColor = isLava ? 0xFFFFFF : BiomeColors.getWaterColor(worldIn, pos);
- float red = (float) (waterColor >> 16 & 255) / 255.0F;
- float green = (float) (waterColor >> 8 & 255) / 255.0F;
- float blue = (float) (waterColor & 255) / 255.0F;
- boolean renderUp = !isAdjacentFluidSameAs(worldIn, pos, EnumFacing.UP, state);
- boolean renderDown = !isAdjacentFluidSameAs(worldIn, pos, EnumFacing.DOWN, state) && !func_209556_a(worldIn, pos, EnumFacing.DOWN, 0.8888889F);
- boolean renderNorth = !isAdjacentFluidSameAs(worldIn, pos, EnumFacing.NORTH, state);
- boolean renderSouth = !isAdjacentFluidSameAs(worldIn, pos, EnumFacing.SOUTH, state);
- boolean renderWest = !isAdjacentFluidSameAs(worldIn, pos, EnumFacing.WEST, state);
- boolean renderEast = !isAdjacentFluidSameAs(worldIn, pos, EnumFacing.EAST, state);
- if (!renderUp && !renderDown && !renderEast && !renderWest && !renderNorth && !renderSouth) {
- return false;
- } else {
- boolean wasAnythingRendered = false;
- // float f3 = 0.5F;
- // float f4 = 1.0F;
- // float f5 = 0.8F;
- // float f6 = 0.6F;
- float yAdd0 = this.getFluidHeight(worldIn, pos, state.getFluid());
- float yAdd1 = this.getFluidHeight(worldIn, pos.south(), state.getFluid());
- float yAdd2 = this.getFluidHeight(worldIn, pos.east().south(), state.getFluid());
- float yAdd3 = this.getFluidHeight(worldIn, pos.east(), state.getFluid());
- double x = (double) pos.getX();
- double y = (double) pos.getY();
- double z = (double) pos.getZ();
- // float f11 = 0.001F;
- if (renderUp && !func_209556_a(worldIn, pos, EnumFacing.UP, Math.min(Math.min(yAdd0, yAdd1), Math.min(yAdd2, yAdd3)))) {
- wasAnythingRendered = true;
- yAdd0 -= 0.001F;
- yAdd1 -= 0.001F;
- yAdd2 -= 0.001F;
- yAdd3 -= 0.001F;
- Vec3d flow = state.getFlow(worldIn, pos);
- float u0;
- float u1;
- float u2;
- float u3;
- float v0;
- float v1;
- float v2;
- float v3;
- if (flow.x == 0.0D && flow.z == 0.0D) {
- TextureAtlasSprite textureatlassprite1 = atextureatlassprite[0];
- // u0 = textureatlassprite1.getInterpolatedU(0.0D);
- // v0 = textureatlassprite1.getInterpolatedV(0.0D);
- u0 = UVHelper.getMinU(textureatlassprite1);
- v0 = UVHelper.getMinV(textureatlassprite1);
- u1 = u0;
- // v1 = textureatlassprite1.getInterpolatedV(16.0D);
- // u2 = textureatlassprite1.getInterpolatedU(16.0D);
- v1 = UVHelper.getMaxV(textureatlassprite1);
- u2 = UVHelper.getMaxU(textureatlassprite1);
- v2 = v1;
- u3 = u2;
- v3 = v0;
- } else {
- TextureAtlasSprite textureatlassprite = atextureatlassprite[1];
- float f20 = (float) MathHelper.atan2(flow.z, flow.x) - ((float) Math.PI / 2F);
- float f21 = MathHelper.sin(f20) * 0.25F;
- float f22 = MathHelper.cos(f20) * 0.25F;
- // float f23 = 8.0F;
- u0 = textureatlassprite.getInterpolatedU((double) (8.0F + (-f22 - f21) * 16.0F));
- v0 = textureatlassprite.getInterpolatedV((double) (8.0F + (-f22 + f21) * 16.0F));
- u1 = textureatlassprite.getInterpolatedU((double) (8.0F + (-f22 + f21) * 16.0F));
- v1 = textureatlassprite.getInterpolatedV((double) (8.0F + (f22 + f21) * 16.0F));
- u2 = textureatlassprite.getInterpolatedU((double) (8.0F + (f22 + f21) * 16.0F));
- v2 = textureatlassprite.getInterpolatedV((double) (8.0F + (f22 - f21) * 16.0F));
- u3 = textureatlassprite.getInterpolatedU((double) (8.0F + (f22 - f21) * 16.0F));
- v3 = textureatlassprite.getInterpolatedV((double) (8.0F + (-f22 - f21) * 16.0F));
- }
- int combinedLightUpMax = this.getCombinedLightUpMax(worldIn, pos);
- int skyLight = combinedLightUpMax >> 16 & '\uffff';
- int blockLight = combinedLightUpMax & '\uffff';
- float r = 1.0F * red;
- float g = 1.0F * green;
- float b = 1.0F * blue;
- buffer.pos(x + 0.0D, y + (double) yAdd0, z + 0.0D).color(r, g, b, 1.0F).tex((double) u0, (double) v0).lightmap(skyLight, blockLight).endVertex();
- buffer.pos(x + 0.0D, y + (double) yAdd1, z + 1.0D).color(r, g, b, 1.0F).tex((double) u1, (double) v1).lightmap(skyLight, blockLight).endVertex();
- buffer.pos(x + 1.0D, y + (double) yAdd2, z + 1.0D).color(r, g, b, 1.0F).tex((double) u2, (double) v2).lightmap(skyLight, blockLight).endVertex();
- buffer.pos(x + 1.0D, y + (double) yAdd3, z + 0.0D).color(r, g, b, 1.0F).tex((double) u3, (double) v3).lightmap(skyLight, blockLight).endVertex();
- if (state.shouldRenderSides(worldIn, pos.up())) {
- buffer.pos(x + 0.0D, y + (double) yAdd0, z + 0.0D).color(r, g, b, 1.0F).tex((double) u0, (double) v0).lightmap(skyLight, blockLight).endVertex();
- buffer.pos(x + 1.0D, y + (double) yAdd3, z + 0.0D).color(r, g, b, 1.0F).tex((double) u3, (double) v3).lightmap(skyLight, blockLight).endVertex();
- buffer.pos(x + 1.0D, y + (double) yAdd2, z + 1.0D).color(r, g, b, 1.0F).tex((double) u2, (double) v2).lightmap(skyLight, blockLight).endVertex();
- buffer.pos(x + 0.0D, y + (double) yAdd1, z + 1.0D).color(r, g, b, 1.0F).tex((double) u1, (double) v1).lightmap(skyLight, blockLight).endVertex();
- }
- }
- if (renderDown) {
- // float minU = atextureatlassprite[0].getMinU();
- // float maxU = atextureatlassprite[0].getMaxU();
- // float minV = atextureatlassprite[0].getMinV();
- // float maxV = atextureatlassprite[0].getMaxV();
- final TextureAtlasSprite textureatlassprite0 = atextureatlassprite[0];
- float minU = UVHelper.getMinU(textureatlassprite0);
- float maxU = UVHelper.getMaxU(textureatlassprite0);
- float minV = UVHelper.getMinV(textureatlassprite0);
- float maxV = UVHelper.getMaxV(textureatlassprite0);
- int combinedLightUpMax = this.getCombinedLightUpMax(worldIn, pos.down());
- int skyLight = combinedLightUpMax >> 16 & '\uffff';
- int blockLight = combinedLightUpMax & '\uffff';
- float r = 0.5F * red;
- float g = 0.5F * green;
- float b = 0.5F * blue;
- buffer.pos(x, y, z + 1.0D).color(r, g, b, 1.0F).tex((double) minU, (double) maxV).lightmap(skyLight, blockLight).endVertex();
- buffer.pos(x, y, z).color(r, g, b, 1.0F).tex((double) minU, (double) minV).lightmap(skyLight, blockLight).endVertex();
- buffer.pos(x + 1.0D, y, z).color(r, g, b, 1.0F).tex((double) maxU, (double) minV).lightmap(skyLight, blockLight).endVertex();
- buffer.pos(x + 1.0D, y, z + 1.0D).color(r, g, b, 1.0F).tex((double) maxU, (double) maxV).lightmap(skyLight, blockLight).endVertex();
- wasAnythingRendered = true;
- }
- for (int facingIndex = 0; facingIndex < 4; ++facingIndex) {
- float yAdd_0;
- float yadd_1;
- double d3;
- double z0;
- double d5;
- double z1;
- EnumFacing enumfacing;
- boolean renderSide;
- if (facingIndex == 0) {
- yAdd_0 = yAdd0;
- yadd_1 = yAdd3;
- d3 = x;
- d5 = x + 1.0D;
- z0 = z + (double) 0.001F;
- z1 = z + (double) 0.001F;
- enumfacing = EnumFacing.NORTH;
- renderSide = renderNorth;
- } else if (facingIndex == 1) {
- yAdd_0 = yAdd2;
- yadd_1 = yAdd1;
- d3 = x + 1.0D;
- d5 = x;
- z0 = z + 1.0D - (double) 0.001F;
- z1 = z + 1.0D - (double) 0.001F;
- enumfacing = EnumFacing.SOUTH;
- renderSide = renderSouth;
- } else if (facingIndex == 2) {
- yAdd_0 = yAdd1;
- yadd_1 = yAdd0;
- d3 = x + (double) 0.001F;
- d5 = x + (double) 0.001F;
- z0 = z + 1.0D;
- z1 = z;
- enumfacing = EnumFacing.WEST;
- renderSide = renderWest;
- } else {
- yAdd_0 = yAdd3;
- yadd_1 = yAdd2;
- d3 = x + 1.0D - (double) 0.001F;
- d5 = x + 1.0D - (double) 0.001F;
- z0 = z;
- z1 = z + 1.0D;
- enumfacing = EnumFacing.EAST;
- renderSide = renderEast;
- }
- if (renderSide && !func_209556_a(worldIn, pos, enumfacing, Math.max(yAdd_0, yadd_1))) {
- wasAnythingRendered = true;
- BlockPos blockpos = pos.offset(enumfacing);
- TextureAtlasSprite textureatlassprite2 = atextureatlassprite[1];
- if (!isLava) {
- IBlockState blockstate = worldIn.getBlockState(blockpos);
- if (blockstate.getBlockFaceShape(worldIn, blockpos, enumfacing) == net.minecraft.block.state.BlockFaceShape.SOLID) {
- textureatlassprite2 = this.atlasSpriteWaterOverlay;
- }
- }
- float minU = textureatlassprite2.getInterpolatedU(0.0D);
- float halfU = textureatlassprite2.getInterpolatedU(8.0D);
- float v0 = textureatlassprite2.getInterpolatedV((double) ((1.0F - yAdd_0) * 16.0F * 0.5F));
- float v1 = textureatlassprite2.getInterpolatedV((double) ((1.0F - yadd_1) * 16.0F * 0.5F));
- float halfV = textureatlassprite2.getInterpolatedV(8.0D);
- int combinedLightUpMax = this.getCombinedLightUpMax(worldIn, blockpos);
- int skyLight = combinedLightUpMax >> 16 & '\uffff';
- int blockLight = combinedLightUpMax & '\uffff';
- float diffuse = facingIndex < 2 ? 0.8F : 0.6F;
- float r = 1.0F * diffuse * red;
- float g = 1.0F * diffuse * green;
- float b = 1.0F * diffuse * blue;
- buffer.pos(d3, y + (double) yAdd_0, z0).color(r, g, b, 1.0F).tex((double) minU, (double) v0).lightmap(skyLight, blockLight).endVertex();
- buffer.pos(d5, y + (double) yadd_1, z1).color(r, g, b, 1.0F).tex((double) halfU, (double) v1).lightmap(skyLight, blockLight).endVertex();
- buffer.pos(d5, y + 0.0D, z1).color(r, g, b, 1.0F).tex((double) halfU, (double) halfV).lightmap(skyLight, blockLight).endVertex();
- buffer.pos(d3, y + 0.0D, z0).color(r, g, b, 1.0F).tex((double) minU, (double) halfV).lightmap(skyLight, blockLight).endVertex();
- if (textureatlassprite2 != this.atlasSpriteWaterOverlay) {
- buffer.pos(d3, y + 0.0D, z0).color(r, g, b, 1.0F).tex((double) minU, (double) halfV).lightmap(skyLight, blockLight).endVertex();
- buffer.pos(d5, y + 0.0D, z1).color(r, g, b, 1.0F).tex((double) halfU, (double) halfV).lightmap(skyLight, blockLight).endVertex();
- buffer.pos(d5, y + (double) yadd_1, z1).color(r, g, b, 1.0F).tex((double) halfU, (double) v1).lightmap(skyLight, blockLight).endVertex();
- buffer.pos(d3, y + (double) yAdd_0, z0).color(r, g, b, 1.0F).tex((double) minU, (double) v0).lightmap(skyLight, blockLight).endVertex();
- }
- }
- }
- return wasAnythingRendered;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement