Mods / Sticky Dirt

Category: #QoL #Tweak
Author: Cirne
Side: Both
Created: Apr 29th at 7:55 PM
Last modified: Apr 29th at 9:58 PM
Downloads: 190
Follow Unfollow 22

Latest file for v1.19.7: 1-click install

Do you ever just want to carve yourself a little nook out of a hillside, but you can't because a whole mountain of dirt will come crashing down on you? This is the mod for you! It changes the rules for when a soil block is considered "unsupported", when world gravity is set to "Sand, gravel, and soil with sideways instability", so that they won't necessarily fall even when there is no block underneath them. In specific:

Whenever a block made of the "Soil" material is disturbed (i.e. when any of the six "blocks" around it change), the mod will calculate how much "support" is being applied to each of its six faces. If the block has at least 7 points of support in total, it will not be subject to falling, either straight down or sideways. The following are the ways a block face can be supported:

  • Another block is pressing a solid face against it. 2 points of support for up to each of the six different faces.
  • A support beam is pressing directly against it: the beam must be touching that specific face of that specific block, and it must have no more than a 45° angle off the normal. 6 points of support for the bottom face, 3 for the horizontal faces. Support beams cannot provide support to the top face.
  • A plant (grass, flower, reed, etc, but not a full-size tree) growing out of the top face provides 3 support for the top face because of all the tiny roots that hold the block together.

In the screenshot, the block above the door is supported as there are blocks pressing against its left, right, back, and top for 2 points each, or 8 total.

This mod also contains a fix for a bug in VS 1.19.7 which makes support beam data for a given chunk unable to be changed after you save and reload the world. If not for that, this would be a server-side-only mod.

Known issues:

  • This mod is in alpha status! The numbers above are subject to tweaking. If you have a structure that you need to stay uncollapsed in survival mode, line the underside with something more stable (like packed dirt) after hollowing out your cave or tunnel.
  • There is currently no way to configure any of these values (other than recompiling the code).
  • There may be blocks that act like dirt blocks which shouldn't, or blocks that don't act as plants which should. See the modding info below for the exact code criteria.
  • As mentioned above, there is a bug in VS 1.19.7 that prevents the internal data for a given set of support beams from being changed after you save and reload the world. While this mod includes a fix for the bug for ongoing play, it doesn't attempt to fix save files where the support beam data already doesn't match the visible support beams. TL;DR: unless you've had this mod enabled for your world since it was created, there may be invisible support beams providing support, and some visible support beams may be nonfunctional (for both cave-in purposes and Sticky Dirt purposes). If you want to be sure a given support beam is working, remove and re-place it while this mod is loaded.

For modders:

Sticky Dirt will only affect the gravity behavior of blocks for which all of the following are true:

  • The block has an UnstableFalling behavior attached to it. (In other words, it must be a block that can fall.)
  • The BlockMaterial of the block is set to Soil.
  • The block can fall sideways, but it has less than a 50% chance to do so. (So, not gravel or sand, even if they have the "Soil" material type like Muddy Gravel.)
  • There is at least one fall path open to the block, as determined by BehaviorUnstableFalling. This means that either:
    • The block underneath is air or another "replaceable" block (Replaceable > 6000).
    • One of the four blocks cardinally adjacent to this one, along with the block below it, are both replaceable blocks (Replaceable ≥ 6000). Yes, this implies that blocks with Replaceable=6000 will block a direct fall but not an adjacency fall. Shrug, it's in the VS code.

Sticky Dirt will count the block above as a "plant" block, providing 3 support rather than 2, if its implementation class derives from the BlockPlant class.

Sticky Dirt will count a neighboring block as "supporting" a given face of a dirt block if all of the following are true:

  • The block isn't a plant block, as above (in which case it has already provided its support).
  • The block is not replaceable (Replaceable ≤ 6000).
  • The face of the block facing the dirt block is "solid", according to neighborBlock.SideIsSolid().
  • The dirt block can be "attached" to the neighbor block on the appropriate face, according to neighborBlock.CanAttachBlockAt(). Basically, it needs to be a block you could stick a torch on (if there weren't a dirt block in the way).

Sticky Dirt will count a support beam as "supporting" a given face of a dirt block if all of the following are true:

  • That face of the dirt block is not supported by a neighboring block.
  • One end of the beam falls "within" that face of the block (defined as: endpoint no more than 0.25m above or below the surface of the plane, and no more than 0.6m away from the centerpoint of the face in either of the other two coordinates) and the other end of the beam does not.
  • The vector pointing along the beam towards the endpoint that sits within the face of the block must be no more than a 45° angle from the vector pointing directly into that face (the anti-normal). This is a true 3d angle check, not a piecewise coordinate check.


Version For Game version Downloads Release date Changelog Download 1-click mod install*
v0.1.0 190 Apr 29th at 9:58 PM Show Install now

3 Comments (oldest first | newest first)

💬 Maamessu, May 15th at 5:59 AM

I love soil instability and am also a burrower.  Going to give this a go, as often I find soil wants to act more like sand than dirt.

💬 Marlim, May 9th at 8:42 PM

Very interesting!

💬 Vinter_Nacht, Apr 30th at 2:38 PM

I like what you're doing here!

(edit comment delete)