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: 850
Follow Unfollow 47

Latest file for v1.19.7:
stickydirt_0.1.0.zip 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 850 Apr 29th at 9:58 PM Show stickydirt_0.1.0.zip Install now

8 Comments (oldest first | newest first)

💬 quartzar, Dec 13th at 2:17 PM

I can confirm that this mod is working on 1.20.0-rc.1!
Cirne Marlim Crius ShanaLarisar

💬 Marlim, Dec 3rd at 7:38 PM

Hello! Do you plan on keeping this mod updated?

💬 Crius, Oct 7th at 12:43 AM

Adding myself to the "update planned for the 1.20"? :)

 

💬 ShanaLarisar, Oct 2nd at 7:45 AM

Does this mod still function/is there a planned update for the newly released 1.20 branch?

💬 Maquin, Jul 30th at 6:00 AM

I think that this is a fantastic idea, as I really like the idea of soil instability requiring me to think and plan how I'm digging but hate the current execution that treats soil like bone-dry sand.

Unfortunately I can't use this mod in its current state as it absolutely tanks performance, my FPS are permanently lowered and the game freezes for several seconds quite often. This is the exact same thing that used to happen on older versions of the game when sideways instability was turned on.

EDIT: I thought that the mod was causing performance issues but it seems like VS was running really badly at the time for some reason as I was having the same performance drops after remaking the world with soil instability turned off and the mod disabled. I'll try this mod again later.

EDIT EDIT: After playing with this mod a bit, I must say that I'm very pleased. It makes the sideways instability mechanic for soil much much more balanced. Now I can finally dig a basement without the fear of every soil block that detects a >1 block drop off to their side threatening to throw themselves screaming into the void if I even dare look at them too hard.

💬 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)