Beispiel #1
0
  /** Will update this chunk renderer */
  public void updateRenderer(EntityLivingBase p_147892_1_) {
    if (this.needsUpdate) {
      this.needsUpdate = false;
      int var2 = this.posX;
      int var3 = this.posY;
      int var4 = this.posZ;
      int var5 = this.posX + 16;
      int var6 = this.posY + 16;
      int var7 = this.posZ + 16;

      for (int var8 = 0; var8 < 2; ++var8) {
        this.skipRenderPass[var8] = true;
      }

      Chunk.isLit = false;
      HashSet var26 = new HashSet();
      var26.addAll(this.tileEntityRenderers);
      this.tileEntityRenderers.clear();
      Minecraft var9 = Minecraft.getMinecraft();
      EntityLivingBase var10 = var9.renderViewEntity;
      int var11 = MathHelper.floor_double(var10.posX);
      int var12 = MathHelper.floor_double(var10.posY);
      int var13 = MathHelper.floor_double(var10.posZ);
      byte var14 = 1;
      ChunkCache var15 =
          new ChunkCache(
              this.worldObj,
              var2 - var14,
              var3 - var14,
              var4 - var14,
              var5 + var14,
              var6 + var14,
              var7 + var14,
              var14);

      if (!var15.extendedLevelsInChunkCache()) {
        ++chunksUpdated;
        RenderBlocks var16 = new RenderBlocks(var15);
        this.bytesDrawn = 0;
        this.vertexState = null;

        for (int var17 = 0; var17 < 2; ++var17) {
          boolean var18 = false;
          boolean var19 = false;
          boolean var20 = false;

          for (int var21 = var3; var21 < var6; ++var21) {
            for (int var22 = var4; var22 < var7; ++var22) {
              for (int var23 = var2; var23 < var5; ++var23) {
                Block var24 = var15.getBlock(var23, var21, var22);

                if (var24.getMaterial() != Material.air) {
                  if (!var20) {
                    var20 = true;
                    this.preRenderBlocks(var17);
                  }

                  if (var17 == 0 && var24.hasTileEntity()) {
                    TileEntity var25 = var15.getTileEntity(var23, var21, var22);

                    if (TileEntityRendererDispatcher.instance.hasSpecialRenderer(var25)) {
                      this.tileEntityRenderers.add(var25);
                    }
                  }

                  int var28 = var24.getRenderBlockPass();

                  if (var28 > var17) {
                    var18 = true;
                  } else if (var28 == var17) {
                    var19 |= var16.renderBlockByRenderType(var24, var23, var21, var22);

                    if (var24.getRenderType() == 0
                        && var23 == var11
                        && var21 == var12
                        && var22 == var13) {
                      var16.setRenderFromInside(true);
                      var16.setRenderAllFaces(true);
                      var16.renderBlockByRenderType(var24, var23, var21, var22);
                      var16.setRenderFromInside(false);
                      var16.setRenderAllFaces(false);
                    }
                  }
                }
              }
            }
          }

          if (var19) {
            this.skipRenderPass[var17] = false;
          }

          if (var20) {
            this.postRenderBlocks(var17, p_147892_1_);
          } else {
            var19 = false;
          }

          if (!var18) {
            break;
          }
        }
      }

      HashSet var27 = new HashSet();
      var27.addAll(this.tileEntityRenderers);
      var27.removeAll(var26);
      this.tileEntities.addAll(var27);
      var26.removeAll(this.tileEntityRenderers);
      this.tileEntities.removeAll(var26);
      this.isChunkLit = Chunk.isLit;
      this.isInitialized = true;
    }
  }
  public boolean updateRenderer(long var1) {
    if (this.worldObj == null) {
      return true;
    } else {
      this.needsUpdate = false;

      if (!this.isUpdating) {
        if (this.needsBoxUpdate) {
          float var3 = 0.0F;
          GL11.glNewList(this.glRenderList + 2, GL11.GL_COMPILE);
          RenderItem.renderAABB(
              AxisAlignedBB.getAABBPool()
                  .getAABB(
                      (double) ((float) this.posXClip - var3),
                      (double) ((float) this.posYClip - var3),
                      (double) ((float) this.posZClip - var3),
                      (double) ((float) (this.posXClip + 16) + var3),
                      (double) ((float) (this.posYClip + 16) + var3),
                      (double) ((float) (this.posZClip + 16) + var3)));
          GL11.glEndList();
          this.needsBoxUpdate = false;
        }

        if (Reflector.LightCache.exists()) {
          Object var25 = Reflector.getFieldValue(Reflector.LightCache_cache);
          Reflector.callVoid(var25, Reflector.LightCache_clear, new Object[0]);
          Reflector.callVoid(Reflector.BlockCoord_resetPool, new Object[0]);
        }

        Chunk.isLit = false;
      }

      int var26 = this.posX;
      int var4 = this.posY;
      int var5 = this.posZ;
      int var6 = this.posX + 16;
      int var7 = this.posY + 16;
      int var8 = this.posZ + 16;
      ChunkCache var9 = null;
      RenderBlocks var10 = null;
      HashSet var11 = null;

      if (!this.isUpdating) {
        for (int var12 = 0; var12 < 2; ++var12) {
          this.tempSkipRenderPass[var12] = true;
        }

        byte var27 = 1;
        var9 =
            new ChunkCache(
                this.worldObj,
                var26 - var27,
                var4 - var27,
                var5 - var27,
                var6 + var27,
                var7 + var27,
                var8 + var27,
                var27);
        var10 = new RenderBlocks(var9);
        var11 = new HashSet();
        var11.addAll(this.tileEntityRenderers);
        this.tileEntityRenderers.clear();
      }

      if (this.isUpdating || !var9.extendedLevelsInChunkCache()) {
        this.bytesDrawn = 0;
        Tessellator var28 = Tessellator.instance;
        boolean var13 = Reflector.ForgeHooksClient.exists();

        for (int var14 = 0; var14 < 2; ++var14) {
          boolean var15 = false;
          boolean var16 = false;
          boolean var17 = false;

          for (int var18 = var4; var18 < var7; ++var18) {
            if (this.isUpdating) {
              this.isUpdating = false;
              var9 = this.updateState.chunkcache;
              var10 = this.updateState.renderblocks;
              var11 = this.updateState.setOldEntityRenders;
              var14 = this.updateState.renderPass;
              var18 = this.updateState.y;
              var15 = this.updateState.flag;
              var16 = this.updateState.hasRenderedBlocks;
              var17 = this.updateState.hasGlList;

              if (var17) {
                GL11.glNewList(
                    this.glWorkLists[this.activeSet][var14][this.activeListIndex[var14]],
                    GL11.GL_COMPILE);
                var28.setRenderingChunk(true);
                var28.startDrawingQuads();
                var28.setTranslation(
                    (double) (-globalChunkOffsetX), 0.0D, (double) (-globalChunkOffsetZ));
              }
            } else if (var17
                && var1 != 0L
                && System.nanoTime() - var1 > 0L
                && this.activeListIndex[var14] < 15) {
              var28.draw();
              GL11.glEndList();
              var28.setRenderingChunk(false);
              var28.setTranslation(0.0D, 0.0D, 0.0D);
              ++this.activeListIndex[var14];
              this.updateState.chunkcache = var9;
              this.updateState.renderblocks = var10;
              this.updateState.setOldEntityRenders = var11;
              this.updateState.renderPass = var14;
              this.updateState.y = var18;
              this.updateState.flag = var15;
              this.updateState.hasRenderedBlocks = var16;
              this.updateState.hasGlList = var17;
              this.isUpdating = true;
              return false;
            }

            for (int var19 = var5; var19 < var8; ++var19) {
              for (int var20 = var26; var20 < var6; ++var20) {
                int var21 = var9.getBlockId(var20, var18, var19);

                if (var21 > 0) {
                  if (!var17) {
                    var17 = true;
                    GL11.glNewList(
                        this.glWorkLists[this.activeSet][var14][this.activeListIndex[var14]],
                        GL11.GL_COMPILE);
                    var28.setRenderingChunk(true);
                    var28.startDrawingQuads();
                    var28.setTranslation(
                        (double) (-globalChunkOffsetX), 0.0D, (double) (-globalChunkOffsetZ));
                  }

                  Block var22 = Block.blocksList[var21];

                  if (var14 == 0 && var22.hasTileEntity()) {
                    TileEntity var23 = var9.getBlockTileEntity(var20, var18, var19);

                    if (TileEntityRenderer.instance.hasSpecialRenderer(var23)) {
                      this.tileEntityRenderers.add(var23);
                    }
                  }

                  int var30 = var22.getRenderBlockPass();
                  boolean var24 = true;

                  if (var30 != var14) {
                    var15 = true;
                    var24 = false;
                  }

                  if (var13) {
                    var24 =
                        Reflector.callBoolean(
                            var22,
                            Reflector.ForgeBlock_canRenderInPass,
                            new Object[] {Integer.valueOf(var14)});
                  }

                  if (var24) {
                    var16 |= var10.renderBlockByRenderType(var22, var20, var18, var19);
                  }
                }
              }
            }
          }

          if (var17) {
            this.bytesDrawn += var28.draw();
            GL11.glEndList();
            var28.setRenderingChunk(false);
            var28.setTranslation(0.0D, 0.0D, 0.0D);
          } else {
            var16 = false;
          }

          if (var16) {
            this.tempSkipRenderPass[var14] = false;
          }

          if (!var15) {
            break;
          }
        }
      }

      HashSet var29 = new HashSet();
      var29.addAll(this.tileEntityRenderers);
      var29.removeAll(var11);
      this.tileEntities.addAll(var29);
      var11.removeAll(this.tileEntityRenderers);
      this.tileEntities.removeAll(var11);
      this.isChunkLit = Chunk.isLit;
      this.isInitialized = true;
      ++chunksUpdated;
      this.isVisible = true;
      this.isVisibleFromPosition = false;
      this.skipRenderPass[0] = this.tempSkipRenderPass[0];
      this.skipRenderPass[1] = this.tempSkipRenderPass[1];
      this.isUpdating = false;
      return true;
    }
  }