Jump to content

[1.12] Modifying a Vanilla World Generation Feature


FilthyNoob

Recommended Posts

Hello all -

I'm trying to add a particular world generation feature and I would like some input from the veterans here as to the best way to approach it.

I would like to add to/alter/modify/replace the vanilla WorldGenLakes WorldGenerator so that when a lava lake is generated, a particular ore block is placed nearby. I am interested in, in order of importance:

1) Placing these ore blocks above or immediately adjacent to the edges of the lava lake.

2) Adding this feature to all generated lava lakes

3) Adding this feature in such a way that vanilla generation is otherwise unchanged - that is, for a given seed, the lava lakes would be found in identical places regardless of whether my mod is installed.

4) Respecting the vanilla ChunkGeneratorOverworld settings, particularly lavaLakeChance and useLavaLakes.

I have tried the following approaches:
- I've looked into the PopulateChunkEvent family, but as this event seems to be a gatekeeper only, the event does not give me the ultimate location of the lava lake, only the coordinates of the chunk the feature could be placed in.

- I've tried canceling the aforementioned event and replacing it with my own generator (extending vanilla WorldGenLakes). This gives me access to the position, but I still don't have access to the ChunkGeneratorOverworld settings from the event, effectively changing the position of all vanilla lava lakes (since I don't know how to access lavaLakeChance or useLavaLakes). Furthermore this seems like a brittle approach as if I want the lakes to generate in the same place as vanilla, I will have to copy-paste vanilla code (as the actual feature positioning logic is in ChunkGeneratorOverworld).

- I've tried simply adding a new generator object, but I'm not very satisfied with this approach as it not only creates an overabundance of lava lakes, but creates lava lakes without the ore blocks as vanilla will still be generating.

I'm sure there's something I'm overlooking or missing here, thank you for reading.

Link to comment
Share on other sites

Thank you for the reply.

I've tried that approach, but since I don't know how to access the ChunkGeneratorOverworld settings object, the lakes I generate will be in a different place than in vanilla. The fields lavaLakeChance and useLavaLakes are of particular interest. If I could figure out how to respect vanilla settings this approach would work fine.

Link to comment
Share on other sites

6 hours ago, FilthyNoob said:

Thank you for the reply.

I've tried that approach, but since I don't know how to access the ChunkGeneratorOverworld settings object, the lakes I generate will be in a different place than in vanilla. The fields lavaLakeChance and useLavaLakes are of particular interest. If I could figure out how to respect vanilla settings this approach would work fine.

 

Check if the event's IChunkGenerator is an instance of ChunkGeneratorOverworld, then use reflection to access the ChunkGeneratorOverworld#settings field.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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

    • 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;     }  
    • It is an issue with quark - update it to this build: https://www.curseforge.com/minecraft/mc-mods/quark/files/3642325
    • Remove Instant Massive Structures Mod from your server     Add new crash-reports with sites like https://paste.ee/  
    • Update your drivers: https://www.amd.com/en/support/graphics/amd-radeon-r9-series/amd-radeon-r9-200-series/amd-radeon-r9-280x
  • Topics

×
×
  • Create New...

Important Information

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