Jump to content

[Solved]redoing world generation with custom ores


aw_wolfe

Recommended Posts

1.11.2

 

I lack in understanding how minecraft generates the world block information. I had been assuming that everything is generated on the fly when the system asks for a chunk of blocks and then minecraft data only stores things that the players have changed. So it 'overlays' the changes onto the procedural generation.--This may not be correct.

My issue is that I created some ores and set them to generate (using one of many examples) and they all did (or so I thought).  One ore was meant to be very rare, much rarer than diamonds. I am using this modding to teach my kids java, so for fun, I sent them looking for the rare or ('mithril'). They couldn't find it. So I created a custom command "/find [object] [radius]" that searches a given radius of blocks for a specific object(block).  Anyway, my rare ore wasn't generating at all. Testing it out, the minimum parameters I found actually generated any ore were (size=3, chances=1),so calling WorldGenMinable(ore, [size<3]) never produced any ore, ever.

 

genSurface(...){
	....
	generateOre(ModBlocks.oreMithril.getDefaultState(),world,random,chunkX*16,chunkZ*16,2,30,3,1);//min to spawn any
}

private void generateOre(IBlockState ore, World world, Random random, int x, int z, int minY, int maxY, int size, int chances) {
		int deltaY = maxY - minY;
	
		for (int i = 0; i < chances; i++) {
			BlockPos pos = new BlockPos(x + random.nextInt(16), minY + random.nextInt(deltaY), z + random.nextInt(16));
	
			WorldGenMinable generator = new WorldGenMinable(ore, size);
			generator.generate(world, random, pos);
		}
	}

I'm sure there is some reason in the WorldGenMinable code why...but, while doing all this, my kids were building their little world. After fixing the mithril ore, I tested in newly created world and it worked, generating at a rate of about 1/10 of diamond ore. Updating the mod in the game my kids were enjoying, and reloading the game. I once again checked with my /find command and the mithril was still not being generated. This I'm not sure why. my find searches over 8,000,000 blocks. I did not think that the blocks were created and stored at game creation, only a table or registered blocks and a procedural generation was done...if so, the new updated mod should have created some mithril.

 

Obviously, I don't know what is going on. If anyone can state how the minecraft world gen, data, overlay works, I'd appreciate it.  Also, if there is anything I can do to update a previous world with new worldgen (no new ores, just changing the chances of creating), I'd more than appreciate it (kids too).

 

Thanks,

Tony

Edited by aw_wolfe
solved
Link to comment
Share on other sites

35 minutes ago, aw_wolfe said:

So it 'overlays' the changes onto the procedural generation.--This may not be correct.

It is not.

When a chunk is generated fresh, it gets saved, regardless of if anything changed or not.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

4 hours ago, aw_wolfe said:

minecraft data only stores things that the players have changed.

 
 
 
 
 
 

Minecraft has no concept of what you've changed unless you explicitly code it to. When a chunk generates, it looks at what biome it is supposed to be, generates the height map (placing the biome-specific surface blocks as well), and then decorates it with ores, trees, structures, etc. Then that's it; it will not be generated/populated again. Once a chunk has been generated, it stays in that state forever (unless a mod regens the chunk manually, like Rejuvenation Missiles from ICBM). In your case, if a chunk generates before your ore is set to spawn, it will not spawn in that chunk. Any new world decorating you do (like fixing the spawn rate of your ore ) will only occur in freshly generated chunks.

 

Edit:

4 hours ago, aw_wolfe said:

8,000,000

 

 The fact that you were iterating over such a huge number of blocks also probably led you to think nothing was happening, when in fact it either crashed internally, was just taking a ridiculously long time, both, or something in between.

Edited by TheMasterGabriel
Link to comment
Share on other sites

Thanks.

 

I do get a return on /find command, even for the large searches...even if to say '0 found'. I figured the large search area would be well outside anything generated when my player is first created. I am testing against searching for diamonds and can search a radius of 300 in about 6 seconds.

 

I loaded new ore mod in a new world (generated with old ore mod and no mithril) and it did not find any. Then spend a few minutes flying off in one direction and re-searched,  and found some. So Draco is correct.  I did not expect minecraft to create that many chunks at start of game.

 

I think I'll write a custom command to turn some stone into mithril and use it once to 'patch' a world and then rely on the worldgen to take care of new areas.

Thanks.

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

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