Jump to content

[1.7.10] Generating temporarily empty chunks.


lynge

Recommended Posts

Hi.

I am trying to make a mod that will have a completely empty world. I would then like to be able to "recreate" chunks at will so that they look like they would if Minecraft had just done its thing as it normally would.

 

So far I have tried creating a custom WorldType in order to inject my own WorldChunkProvider and override the provideCunk method. The idea was to just return an instance of EmptyChunk if the chunk was not in my list of "living" chunks, but when I run that it just spews out this error:

 

java.lang.NoClassDefFoundError: net/minecraft/world/World$2

 

So I am guessing Minecraft still needs to do some work on the chunks that it expects to be full of blocks, but its just guesswork.

 

I have also made my own EmptyChunk class that only has an override for the getBlock method so that it always return a Blocks.air, but that only provided me with more of the same error.

 

If I change it to return Blocks.bedrock all the time, it gives me this error instead:

 

java.lang.ClassCastException: net.minecraft.block.Block cannot be cast to net.minecraft.block.BlockRailBase

 

That is ofcourse only when there is a mineshaft below. If that is not the case, the game starts, but instead of the affected chunks being bedrock, they instead appear to be air. Until one tries to walk over the edge that is. There is an invisible wall so it looks like the chunks really are 100% bedrock but they are not being rendered as such. Fluids will not flow over the edge and arrows get stuck on the invisible wall so clearly some blocks are there but not being shown. If the world is shut down and reloaded, the chunks are now really just air, but any new chunks created will have the invisible bedrock in them.

 

 

I am thinking I am trying to do this in the wrong place in the code. A lot of other things seem to depend on the (now invalid) information that this chunk should hold something like a landscape inside it. Where else can I make this change so that it is reversible. Ideally it should just be a single "if" statement to check if the chunk is in my small list of "living" chunks and if not, then just fill it with air.

 

I have tried looking at how the end is created, but with no luck. The only other place I could think of to look for inspiration is Mystcraft, but that does not seem to be opensource.

 

Any help would be greatly appreciated.

Link to comment
Share on other sites

I'm not sure if this would help, but when I was playing with dimensions, this chunk provider creates an empty world:

public class ChunkProviderEmpty extends ChunkProviderFlat {
    public ChunkProviderEmpty(World w, long l) {
        super(w, l, false, "2;0x1;0;");
    }
    
    @Override
    public void populate(IChunkProvider par1IChunkProvider, int i, int j) {
        
    }
}

It uses the superflat chunk provider, but I tell it to generate no layers. More information on the string format can be found here: http://minecraft.gamepedia.com/Superflat#Preset_code_format

 

Then I can create the chunks individually using

world.setBlock()

.

Link to comment
Share on other sites

Thank you for the tip. I got it mostly working, but it turns out that getting rid of mineshafts floating in mid air is non-trivial unless mapfeatures is disabled all together.

 

So I think I am giving up on this idea for now. Maybe some day I will stumble across the way to make it happen.

Link to comment
Share on other sites

If you want the world to skip out on generate chunks, in your WorldChunkManage or your WorldType (no idea which one it is off the top of my head) you should try to return false for a chunkExists method. I have no idea if this will achieve the desired effect, but I would assume it would stop a chunk from generating until that condition is true.

Link to comment
Share on other sites

That seemed like a really good idea, but sadly not working. Or at least not for me.

 

I put a call to System.out.println("running custom chunkExists"); in my override and it never showed up in the log. I have no idea what minecraft uses those chunkexists methods for, but I have been unable to coax it into calling it.

 

But thanks for the suggestion. :) If you have any other input, I'm all ears. It would be fun to get this working, but I am all out of clues at this point.

 

The only thing I have not tried is rebuilding the MapGenerate classes, but they are pretty scrambled and a bit hard to follow. Plus it's not exactly a clean solution.

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.