Jump to content

(1.18) Equivalent to onBlockAdded


Rai-The-Jultak

Recommended Posts

Hello, I'm currently updating an older geology-themed mod of mine which had a workaround of several "base" ores that, upon world generation, they would change into their final state according to y-level.

Specifically I am looking for a method called when the block is naturally generated in the world. Since its looking like onBlockAdded is gone, are loot tables + blockstate jsons the proper way to do this? 

Edited by Rai-The-Jultak
Link to comment
Share on other sites

You are correct there is no direct equivalent in 1.18

There is the BlockEvent.EntityPlaceEvent, but this is for players, dispensers, endermen, etc. placing blocks. It does not get used for worldgen.

 

If you just want to change the drops of a block, you can use a GlobalLootModifier. https://forge.gemwire.uk/wiki/Dynamic_Loot_Modification/1.18

You would need to write your own LootItemCondition to do your y position check. One example that changes loot conditions using a BlockPos is the vanilla LocationCheck

 

If you want to change the world gen blocks, then you are going to need to understand how modern worldgen works.

For ores this is OreFeaure/OreConfiguration/OrePlacement

To override vanilla configuration you can use the vanilla datapacks mechanism (every mod is a datapack)

 

But personally I think mods overriding vanilla configurations by default is a bad idea, because it leads to conflicts when other  mods try to do the same thing.

You would probably be better off adding new ore definitions for your blocks and then using the BiomeLoadingEvent to add them to the relevant biomes.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

  • 3 weeks later...
On 8/9/2022 at 2:28 AM, warjort said:

You are correct there is no direct equivalent in 1.18

There is the BlockEvent.EntityPlaceEvent, but this is for players, dispensers, endermen, etc. placing blocks. It does not get used for worldgen.

 

If you just want to change the drops of a block, you can use a GlobalLootModifier. https://forge.gemwire.uk/wiki/Dynamic_Loot_Modification/1.18

You would need to write your own LootItemCondition to do your y position check. One example that changes loot conditions using a BlockPos is the vanilla LocationCheck

 

If you want to change the world gen blocks, then you are going to need to understand how modern worldgen works.

For ores this is OreFeaure/OreConfiguration/OrePlacement

To override vanilla configuration you can use the vanilla datapacks mechanism (every mod is a datapack)

 

But personally I think mods overriding vanilla configurations by default is a bad idea, because it leads to conflicts when other  mods try to do the same thing.

You would probably be better off adding new ore definitions for your blocks and then using the BiomeLoadingEvent to add them to the relevant biomes.

That’s a great overview, 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.



×
×
  • Create New...

Important Information

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