Formations (Structure Library)

Formations (Structure Library)

10M Downloads

[Feature] Backport of 1.21's `liquid_settings` to 1.20 and older versions

Zortexxx619 opened this issue ยท 6 comments

commented

In versions of Minecraft before 1.21, any waterloggable block generated onto an existing water source block as part of a structure would be waterlogged, with no option to change the behavior. This works fine for underwater structures (eg. shipwrecks) but is horrible for something like an underwater dome, unless the structure foregoes using any waterloggable blocks.

1.21 fixed this by adding a liquid_settings option to structure definitions, but it would be nice to have an equivalent feature for older MC versions.

commented

Please, I need this. I'm struggling so hard with waterlogged blocks

commented

Please, I need this. I'm struggling so hard with waterlogged blocks

The workaround I found in the meantime: some of YUNG's mods in 1.20 implement a waterlogged_processor, which does exactly this. it's not part of YUNG's API, so you have to have a mod like Better Strongholds installed to use it, which wasn't an issue for me as I was already using them. But if you don't want the YUNG structures to generate, you'll have to adjust that in a datapack.

commented

Looking into it, I have 2 options:

  1. Add a liquid_settings option to the formations:single_pool_element pool element.
  2. Add a waterlogging structure processor

Adding a liquid_settings option to the actual structures would require me copying a bunch of vanilla code, so I'd rather not do that for just this feature.
My preference would go to option 2 as it doesn't interfere with vanilla's format if they ever change how the liquid_settings option works. Would option 2 work for your use case?

commented

Would option 2 work for your use case?

For me personally, option 2 would work perfectly.

commented

I added a formations:waterlogging structure processor for it. It has one additional field handling with 6 options for how to determine whether a waterloggable block should be waterlogged: dry, wet, take_world, take_structure, world_or_structure_wet, world_or_structure_dry. If handling is omitted, it will use take_structure.

public enum WaterHandling implements StringRepresentable {
/**
* Any waterloggable blocks will not be waterlogged.
*/
DRY,
/**
* Any waterloggable blocks will be waterlogged.
*/
WET,
/**
* Any waterloggable blocks will be waterlogged only if the block's position contained water before the structure was placed.
*/
TAKE_WORLD,
/**
* Any waterloggable blocks will be waterlogged only if the block is waterlogged in the structure.
*/
TAKE_STRUCTURE,
/**
* Any waterloggable blocks will be waterlogged only if either the block's position contained water before the structure was placed, or the block is waterlogged in the structure.
*/
WORLD_OR_STRUCTURE_WET,
/**
* Any waterloggable blocks will be waterlogged only if both the block's position contained water before the structure was placed, and the block is waterlogged in the structure.
*/
WORLD_OR_STRUCTURE_DRY;

I haven't tested it as I don't really have an easy way to do so, so let me know if it works as expected.

commented

I likely wont do an exhaustive test (my return to modded minecraft arc ended last month), but I did try the thing I originally made this feature suggestion for. The Underground Bunkers mod adds a single underground structure that uses many waterloggable blocks. The mod itself doesn't do any special handling in 1.20, which leads to flooding in almost every generated structure due to underwater caves, and kinda ruins the mod.

I made a datapack which copied UB's internal data pack and simply added the following entry to the top of the structure's processor list:

    {
          "processor_type": "formations:waterlogging",
	  "handling": "take_structure"
    },

I then generated the same seed, before and after adding this datapack, and located the same bunker struture. But it didn't actually change anything. So either I did something wrong, or there's a bug in the code

mods/loaders used:

Minecraft 1.20.1
NeoForge 47.1.106
Formations 1.0.3
Underground Bunkers 1.0.5
OpenLoader 19.0.4
MixinExtras 0.3.5 (not sure where this came from, as I didn't install it myself)
//the rest are generic optimization mods I always use
Embeddium 0.7.1
Ferrite Core 6.0.1
ModernFix 5.19.5
EntityCulling 1.7.1
Yeetus Experimentus 2.3.1-build6