Jump to content

[1.7.10] Questions about Bounding boxes and World renderers


Elix_x

Recommended Posts

Hi there,

I'm working on new mod, and i want to force to update world rendering in certain cases in certain areas. Force, because rendering of certain blocks depends of player's position.

I already found array of all world renderers (and i can access it), but now i want to choose only those responsible for my area (i have the area specified via AxisAlignedBB)... Afterwards marking them needsUpdate will do the thing...

Any ideas are welcome...

 

And also, i can't mark all of them to be updated: this produces little frame drop and freezing...

Link to comment
Share on other sites

Do you mean this code?

    /**
     * Will update this chunk renderer
     */
    public void updateRenderer(EntityLivingBase p_147892_1_)
    {
        if (this.needsUpdate) //needsUpdate
        {
            this.needsUpdate = false;

            //Rendering bound for Chunk. (posX~posX+16, ...)
            int i = this.posX;
            int j = this.posY;
            int k = this.posZ;
            int l = this.posX + 16;
            int i1 = this.posY + 16;
            int j1 = this.posZ + 16;

            for (int k1 = 0; k1 < 2; ++k1)
            {
                this.skipRenderPass[k1] = true; //Mark render pass to skip
            }

            Chunk.isLit = false; //isLit Determines if the chunk is lit or not at a light value greater than 0.
            HashSet hashset = new HashSet();
            hashset.addAll(this.tileEntityRenderers); //Tileentity Renderer HashSet.
            this.tileEntityRenderers.clear();
            Minecraft minecraft = Minecraft.getMinecraft();
            EntityLivingBase entitylivingbase1 = minecraft.renderViewEntity; //The Viewing Entity.
            int l1 = MathHelper.floor_double(entitylivingbase1.posX); //l1 is posX
            int i2 = MathHelper.floor_double(entitylivingbase1.posY); // i2 is posY
            int j2 = MathHelper.floor_double(entitylivingbase1.posZ); // j2 is posZ
            byte b0 = 1;
            //gets chunk cache which is for rendering bound for Chunk. (posX~posX+16, ...). Regardless of viewing entity.
            ChunkCache chunkcache = new ChunkCache(this.worldObj, i - b0, j - b0, k - b0, l + b0, i1 + b0, j1 + b0, b0);

            if (!chunkcache.extendedLevelsInChunkCache()) //if(chunk.getAreLevelsEmpty) .. IDK
            {
                ++chunksUpdated; //Increases update count.

                //Gets RendeBlocks.
                RenderBlocks renderblocks = new RenderBlocks(chunkcache);

                //Forge Hook for setting world renderer.
                net.minecraftforge.client.ForgeHooksClient.setWorldRendererRB(renderblocks); 
                this.bytesDrawn = 0;
                this.vertexState = null;

                for (int k2 = 0; k2 < 2; ++k2) //RenderPass loop
                {
                    boolean flag = false;
                    boolean flag1 = false;
                    boolean flag2 = false;

                    for (int l2 = j; l2 < i1; ++l2) //X axis loop
                    {
                        for (int i3 = k; i3 < j1; ++i3) //Y axis loop
                        {
                            for (int j3 = i; j3 < l; ++j3) //Z axis loop
                            {
                                Block block = chunkcache.getBlock(j3, l2, i3); //get block on the position to render

                                if (block.getMaterial() != Material.air) //If it is not air, render the block.
                                {
                                    if (!flag2)
                                    {
                                        //sets flag2 to true
                                        flag2 = true;
                                        //pre render blocks.
                                        this.preRenderBlocks(k2);
                                    }

                                   //Rendering TileEntity.
                                    if (k2 == 0 && block.hasTileEntity(chunkcache.getBlockMetadata(j3, l2, i3)))
                                    {
                                        TileEntity tileentity = chunkcache.getTileEntity(j3, l2, i3);

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

                                    //Gets render pass of a block.
                                    int k3 = block.getRenderBlockPass();

                                    if (k3 > k2)
                                    {
                                        //blockpass is bigger than current pass,
                                        flag = true;
                                    }

                                    //Can render on RenderPass check.
                                    if (!block.canRenderInPass(k2)) continue;

                                    {
                                        //Render blocks by type
                                        flag1 |= renderblocks.renderBlockByRenderType(block, j3, l2, i3);

                                        if (block.getRenderType() == 0 && j3 == l1 && l2 == i2 && i3 == j2)
                                        {
                                            //Block Rendering Settings for Default Blocks at Player Location.
                                            renderblocks.setRenderFromInside(true);
                                            renderblocks.setRenderAllFaces(true);
                                            renderblocks.renderBlockByRenderType(block, j3, l2, i3);
                                            renderblocks.setRenderFromInside(false);
                                            renderblocks.setRenderAllFaces(false);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (flag1)
                    {
                        this.skipRenderPass[k2] = false; //Do not skip RenderPass
                    }

                    if (flag2)
                    {
                        //when pre render got called, , post render block.
                        this.postRenderBlocks(k2, p_147892_1_);
                    }
                    else
                    {
                        //Set skip render pass.
                        flag1 = false;
                    }

                    if (!flag)
                    {
                        break;
                    }
                }
                //Forge Hooks (finalization?).
                net.minecraftforge.client.ForgeHooksClient.setWorldRendererRB(null);
            }

            //Some refreshing.
            HashSet hashset1 = new HashSet();
            hashset1.addAll(this.tileEntityRenderers);
            hashset1.removeAll(hashset);
            this.tileEntities.addAll(hashset1);
            hashset.removeAll(this.tileEntityRenderers);
            this.tileEntities.removeAll(hashset);
            this.isChunkLit = Chunk.isLit;
            this.isInitialized = true;
        }
    }

 

So  basically one WorldRenderer renders a chunk.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.