Jump to content

[1.7.10] Questions about Bounding boxes and World renderers


Recommended Posts

Posted

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...

Posted

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.

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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