Jump to content

Recommended Posts

Posted

Hello all,

 

Today I started to dive into modding Minecraft (with Forge 4).

I'm thinking of generating some pretty big structures, so I started messing around with a custom world generator. But one of my tests (simply adding some sort of brick stone roof with glass windows over the complete world) is generating really slow.

 

My IWorldGenerator implementation:

 

public class QWorldGenerator implements IWorldGenerator 
{
    protected WorldGenRoof roofGenerator = new WorldGenRoof();

    // left out some inherited methods

    private void generateSurface(World world, Random random, int x, int z) 
    {
        roofGenerator.generate(world, random, x, 0, z);
    }
}

 

The actual WorldGenerator:

 

public class WorldGenRoof extends WorldGenerator
{
    public boolean generate(World world, Random random, int chunkX, int chunkY, int chunkZ)
    {
        int blockId = 0;
        for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
                blockId = Block.stoneBrick.blockID;
                if (x > 6 && x < 13 && z > 6 && z < 13) {
                    blockId = Block.glass.blockID;
                }
                world.setBlock(chunkX + x, 100, chunkZ + z, blockId);
            }
        }
        return true;
    }
}

 

The code works fine, but as I said, really slow. It takes like five minutes instead of the normal couple of seconds to generate a new world.

When I remove the world.setBlock(...) there is no real drop in performance.

 

So is there some kind of other process I should use when doing things like this? Or maybe some mode to set while setting blocks in a loop? (I tried world.editingBlocks, but that didn't really help :P)

 

Any ideas welcome! :)

Posted
  On 9/16/2012 at 9:53 PM, jrockjake said:

I'm not good at code, but could it be because generateSurface is private and WorldGenRoof is protected? I usually set all my code to public, and everything loads fine for me.

 

Those aren't really relevant to the problem (private/protected/package/public keywords only define where the properties can be accessed, and in this case private would be enough, since it's only the owner class accessing them). Stuff like this would also throw an exception when used incorrectly (I guess, long time since I programmed in Java).

 

My problem is just that world.setBlock seems to execute very slowly, possibly because it fires a whole range of things that need to be calculated for it. So the question here is whether there is a better way to do what I'm doing.

Posted

There are variations of setBlock that do less stuff, as well as the ability to edit things directly in the chunks.

You'd have to look into what the best code path for you would be.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted
  On 9/17/2012 at 12:06 PM, LexManos said:

There are variations of setBlock that do less stuff, as well as the ability to edit things directly in the chunks.

You'd have to look into what the best code path for you would be.

 

Thx

I'm guessing you're talking about setBlockAndNotify and the likes? Those weren't really faster. (If you meant those, but I doubt that.)

 

Editing chunks directly sounds more like it :D. But googling this stuff doesn't yield much results. I'll try some more later today (I'm at work now).

But if you or someone could just point me a bit further in the right direction (like with a link or method name), that would probably help a lot.

 

Most stuff that I find is coded roughly the same way as what I'm doing, so I'm guessing I'm missing an important keyword or something :D

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

    • I can't figure out if you're looking for help trying to steal someone elses work, or cheat at the game....
    • Title: Why Is It So Hard to Rename and Restructure Mods Like Xray or AntiXray? 🤔 Post text: Hey everyone! I’ve been digging into Minecraft modding for a while and have one big question that I can’t figure out on my own. Maybe someone with more experience could help or give me some advice. Here’s the issue: When I take a “normal” Minecraft mod — for example, one that just adds some blocks or new items — I can easily change its structure, package names, or even rebrand it entirely. It’s straightforward. But as soon as I try this with cheat-type mods like XrayMod or AntiXray, everything falls apart. Even if I just rename the classes, refactor the packages, or hide its identity somehow, the mod either breaks or stops working properly. XrayMod in particular is proving to be a nightmare to modify without losing its core function. So my question is — why is this so much harder with cheat mods like Xray? Is there something fundamentally different about how they’re coded, loaded, or protected that prevents simple renaming or restructuring? And if so, how can I actually learn to understand someone else’s cheat mod enough to safely refactor it without breaking the core features? I’ve already been spending over two months trying to figure this out and haven’t gotten anywhere. It feels like there must be some trick or knowledge I’m missing. Would really appreciate any thoughts, tips, or references — maybe there are guides or techniques for understanding cheat-mod internals? Or if you’ve successfully “disguised” a cheat mod like Xray before, I’d love to hear how you did it. Thanks in advance for any help or discussion. ✌️
    • just started making cinamatic contect check it out on my channel or check out my facebook page    Humbug City Minecraft Youtube https://www.youtube.com/watch?v=v2N6OveKwno https://www.facebook.com/profile.php?id=61575866982337  
    • Where did you get the schematic? Source/Link? And do use an own modpack or a pre-configured from curseforge? If yes, which one On a later time, I can make some tests on my own - but I need the schematic and the modpack name
  • Topics

×
×
  • Create New...

Important Information

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