Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.08 KB | None | 0 0
  1. @Override
  2. public boolean render(final IWorldReader worldIn, final BlockPos pos, final BufferBuilder buffer, final IFluidState state) {
  3. boolean isLava = state.isTagged(FluidTags.LAVA);
  4. TextureAtlasSprite[] atextureatlassprite = isLava ? this.atlasSpritesLava : this.atlasSpritesWater;
  5. int waterColor = isLava ? 0xFFFFFF : BiomeColors.getWaterColor(worldIn, pos);
  6. float red = (float) (waterColor >> 16 & 255) / 255.0F;
  7. float green = (float) (waterColor >> 8 & 255) / 255.0F;
  8. float blue = (float) (waterColor & 255) / 255.0F;
  9. boolean renderUp = !isAdjacentFluidSameAs(worldIn, pos, EnumFacing.UP, state);
  10. boolean renderDown = !isAdjacentFluidSameAs(worldIn, pos, EnumFacing.DOWN, state) && !func_209556_a(worldIn, pos, EnumFacing.DOWN, 0.8888889F);
  11. boolean renderNorth = !isAdjacentFluidSameAs(worldIn, pos, EnumFacing.NORTH, state);
  12. boolean renderSouth = !isAdjacentFluidSameAs(worldIn, pos, EnumFacing.SOUTH, state);
  13. boolean renderWest = !isAdjacentFluidSameAs(worldIn, pos, EnumFacing.WEST, state);
  14. boolean renderEast = !isAdjacentFluidSameAs(worldIn, pos, EnumFacing.EAST, state);
  15. if (!renderUp && !renderDown && !renderEast && !renderWest && !renderNorth && !renderSouth) {
  16. return false;
  17. } else {
  18. boolean wasAnythingRendered = false;
  19. // float f3 = 0.5F;
  20. // float f4 = 1.0F;
  21. // float f5 = 0.8F;
  22. // float f6 = 0.6F;
  23. float yAdd0 = this.getFluidHeight(worldIn, pos, state.getFluid());
  24. float yAdd1 = this.getFluidHeight(worldIn, pos.south(), state.getFluid());
  25. float yAdd2 = this.getFluidHeight(worldIn, pos.east().south(), state.getFluid());
  26. float yAdd3 = this.getFluidHeight(worldIn, pos.east(), state.getFluid());
  27. double x = (double) pos.getX();
  28. double y = (double) pos.getY();
  29. double z = (double) pos.getZ();
  30. // float f11 = 0.001F;
  31. if (renderUp && !func_209556_a(worldIn, pos, EnumFacing.UP, Math.min(Math.min(yAdd0, yAdd1), Math.min(yAdd2, yAdd3)))) {
  32. wasAnythingRendered = true;
  33. yAdd0 -= 0.001F;
  34. yAdd1 -= 0.001F;
  35. yAdd2 -= 0.001F;
  36. yAdd3 -= 0.001F;
  37. Vec3d flow = state.getFlow(worldIn, pos);
  38. float u0;
  39. float u1;
  40. float u2;
  41. float u3;
  42. float v0;
  43. float v1;
  44. float v2;
  45. float v3;
  46. if (flow.x == 0.0D && flow.z == 0.0D) {
  47. TextureAtlasSprite textureatlassprite1 = atextureatlassprite[0];
  48. // u0 = textureatlassprite1.getInterpolatedU(0.0D);
  49. // v0 = textureatlassprite1.getInterpolatedV(0.0D);
  50. u0 = UVHelper.getMinU(textureatlassprite1);
  51. v0 = UVHelper.getMinV(textureatlassprite1);
  52. u1 = u0;
  53. // v1 = textureatlassprite1.getInterpolatedV(16.0D);
  54. // u2 = textureatlassprite1.getInterpolatedU(16.0D);
  55. v1 = UVHelper.getMaxV(textureatlassprite1);
  56. u2 = UVHelper.getMaxU(textureatlassprite1);
  57. v2 = v1;
  58. u3 = u2;
  59. v3 = v0;
  60. } else {
  61. TextureAtlasSprite textureatlassprite = atextureatlassprite[1];
  62. float f20 = (float) MathHelper.atan2(flow.z, flow.x) - ((float) Math.PI / 2F);
  63. float f21 = MathHelper.sin(f20) * 0.25F;
  64. float f22 = MathHelper.cos(f20) * 0.25F;
  65. // float f23 = 8.0F;
  66. u0 = textureatlassprite.getInterpolatedU((double) (8.0F + (-f22 - f21) * 16.0F));
  67. v0 = textureatlassprite.getInterpolatedV((double) (8.0F + (-f22 + f21) * 16.0F));
  68. u1 = textureatlassprite.getInterpolatedU((double) (8.0F + (-f22 + f21) * 16.0F));
  69. v1 = textureatlassprite.getInterpolatedV((double) (8.0F + (f22 + f21) * 16.0F));
  70. u2 = textureatlassprite.getInterpolatedU((double) (8.0F + (f22 + f21) * 16.0F));
  71. v2 = textureatlassprite.getInterpolatedV((double) (8.0F + (f22 - f21) * 16.0F));
  72. u3 = textureatlassprite.getInterpolatedU((double) (8.0F + (f22 - f21) * 16.0F));
  73. v3 = textureatlassprite.getInterpolatedV((double) (8.0F + (-f22 - f21) * 16.0F));
  74. }
  75.  
  76. int combinedLightUpMax = this.getCombinedLightUpMax(worldIn, pos);
  77. int skyLight = combinedLightUpMax >> 16 & '\uffff';
  78. int blockLight = combinedLightUpMax & '\uffff';
  79. float r = 1.0F * red;
  80. float g = 1.0F * green;
  81. float b = 1.0F * blue;
  82. 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();
  83. 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();
  84. 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();
  85. 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();
  86. if (state.shouldRenderSides(worldIn, pos.up())) {
  87. 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();
  88. 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();
  89. 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();
  90. 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();
  91. }
  92. }
  93.  
  94. if (renderDown) {
  95. // float minU = atextureatlassprite[0].getMinU();
  96. // float maxU = atextureatlassprite[0].getMaxU();
  97. // float minV = atextureatlassprite[0].getMinV();
  98. // float maxV = atextureatlassprite[0].getMaxV();
  99. final TextureAtlasSprite textureatlassprite0 = atextureatlassprite[0];
  100. float minU = UVHelper.getMinU(textureatlassprite0);
  101. float maxU = UVHelper.getMaxU(textureatlassprite0);
  102. float minV = UVHelper.getMinV(textureatlassprite0);
  103. float maxV = UVHelper.getMaxV(textureatlassprite0);
  104. int combinedLightUpMax = this.getCombinedLightUpMax(worldIn, pos.down());
  105. int skyLight = combinedLightUpMax >> 16 & '\uffff';
  106. int blockLight = combinedLightUpMax & '\uffff';
  107. float r = 0.5F * red;
  108. float g = 0.5F * green;
  109. float b = 0.5F * blue;
  110. buffer.pos(x, y, z + 1.0D).color(r, g, b, 1.0F).tex((double) minU, (double) maxV).lightmap(skyLight, blockLight).endVertex();
  111. buffer.pos(x, y, z).color(r, g, b, 1.0F).tex((double) minU, (double) minV).lightmap(skyLight, blockLight).endVertex();
  112. buffer.pos(x + 1.0D, y, z).color(r, g, b, 1.0F).tex((double) maxU, (double) minV).lightmap(skyLight, blockLight).endVertex();
  113. buffer.pos(x + 1.0D, y, z + 1.0D).color(r, g, b, 1.0F).tex((double) maxU, (double) maxV).lightmap(skyLight, blockLight).endVertex();
  114. wasAnythingRendered = true;
  115. }
  116.  
  117. for (int facingIndex = 0; facingIndex < 4; ++facingIndex) {
  118. float yAdd_0;
  119. float yadd_1;
  120. double d3;
  121. double z0;
  122. double d5;
  123. double z1;
  124. EnumFacing enumfacing;
  125. boolean renderSide;
  126. if (facingIndex == 0) {
  127. yAdd_0 = yAdd0;
  128. yadd_1 = yAdd3;
  129. d3 = x;
  130. d5 = x + 1.0D;
  131. z0 = z + (double) 0.001F;
  132. z1 = z + (double) 0.001F;
  133. enumfacing = EnumFacing.NORTH;
  134. renderSide = renderNorth;
  135. } else if (facingIndex == 1) {
  136. yAdd_0 = yAdd2;
  137. yadd_1 = yAdd1;
  138. d3 = x + 1.0D;
  139. d5 = x;
  140. z0 = z + 1.0D - (double) 0.001F;
  141. z1 = z + 1.0D - (double) 0.001F;
  142. enumfacing = EnumFacing.SOUTH;
  143. renderSide = renderSouth;
  144. } else if (facingIndex == 2) {
  145. yAdd_0 = yAdd1;
  146. yadd_1 = yAdd0;
  147. d3 = x + (double) 0.001F;
  148. d5 = x + (double) 0.001F;
  149. z0 = z + 1.0D;
  150. z1 = z;
  151. enumfacing = EnumFacing.WEST;
  152. renderSide = renderWest;
  153. } else {
  154. yAdd_0 = yAdd3;
  155. yadd_1 = yAdd2;
  156. d3 = x + 1.0D - (double) 0.001F;
  157. d5 = x + 1.0D - (double) 0.001F;
  158. z0 = z;
  159. z1 = z + 1.0D;
  160. enumfacing = EnumFacing.EAST;
  161. renderSide = renderEast;
  162. }
  163.  
  164. if (renderSide && !func_209556_a(worldIn, pos, enumfacing, Math.max(yAdd_0, yadd_1))) {
  165. wasAnythingRendered = true;
  166. BlockPos blockpos = pos.offset(enumfacing);
  167. TextureAtlasSprite textureatlassprite2 = atextureatlassprite[1];
  168. if (!isLava) {
  169. IBlockState blockstate = worldIn.getBlockState(blockpos);
  170. if (blockstate.getBlockFaceShape(worldIn, blockpos, enumfacing) == net.minecraft.block.state.BlockFaceShape.SOLID) {
  171. textureatlassprite2 = this.atlasSpriteWaterOverlay;
  172. }
  173. }
  174.  
  175. float minU = textureatlassprite2.getInterpolatedU(0.0D);
  176. float halfU = textureatlassprite2.getInterpolatedU(8.0D);
  177. float v0 = textureatlassprite2.getInterpolatedV((double) ((1.0F - yAdd_0) * 16.0F * 0.5F));
  178. float v1 = textureatlassprite2.getInterpolatedV((double) ((1.0F - yadd_1) * 16.0F * 0.5F));
  179. float halfV = textureatlassprite2.getInterpolatedV(8.0D);
  180. int combinedLightUpMax = this.getCombinedLightUpMax(worldIn, blockpos);
  181. int skyLight = combinedLightUpMax >> 16 & '\uffff';
  182. int blockLight = combinedLightUpMax & '\uffff';
  183. float diffuse = facingIndex < 2 ? 0.8F : 0.6F;
  184. float r = 1.0F * diffuse * red;
  185. float g = 1.0F * diffuse * green;
  186. float b = 1.0F * diffuse * blue;
  187. buffer.pos(d3, y + (double) yAdd_0, z0).color(r, g, b, 1.0F).tex((double) minU, (double) v0).lightmap(skyLight, blockLight).endVertex();
  188. buffer.pos(d5, y + (double) yadd_1, z1).color(r, g, b, 1.0F).tex((double) halfU, (double) v1).lightmap(skyLight, blockLight).endVertex();
  189. buffer.pos(d5, y + 0.0D, z1).color(r, g, b, 1.0F).tex((double) halfU, (double) halfV).lightmap(skyLight, blockLight).endVertex();
  190. buffer.pos(d3, y + 0.0D, z0).color(r, g, b, 1.0F).tex((double) minU, (double) halfV).lightmap(skyLight, blockLight).endVertex();
  191. if (textureatlassprite2 != this.atlasSpriteWaterOverlay) {
  192. buffer.pos(d3, y + 0.0D, z0).color(r, g, b, 1.0F).tex((double) minU, (double) halfV).lightmap(skyLight, blockLight).endVertex();
  193. buffer.pos(d5, y + 0.0D, z1).color(r, g, b, 1.0F).tex((double) halfU, (double) halfV).lightmap(skyLight, blockLight).endVertex();
  194. buffer.pos(d5, y + (double) yadd_1, z1).color(r, g, b, 1.0F).tex((double) halfU, (double) v1).lightmap(skyLight, blockLight).endVertex();
  195. buffer.pos(d3, y + (double) yAdd_0, z0).color(r, g, b, 1.0F).tex((double) minU, (double) v0).lightmap(skyLight, blockLight).endVertex();
  196. }
  197. }
  198. }
  199.  
  200. return wasAnythingRendered;
  201. }
  202. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement