Skip to content

Commit

Permalink
Implement Cave Generation tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Oct 28, 2024
1 parent 2462c1a commit 3b50435
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ All changes are toggleable via config files.
* **Burning Baby Zombies:** Lets baby zombies burn in daylight as in Minecraft 1.13+
* **Burning Skeletons:** Prevents skeletons burning in daylight
* **Burning Zombies:** Prevents zombies burning in daylight
* **Cave Generation:** Sets custom values for the vanilla cave generation
* **Charged Creeper Spawning:** Sets the chance for creepers to spawn charged
* **Chat:**
* **Chat Lines:** Sets the maximum number of chat lines to display
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2232,6 +2232,10 @@ public static class EntityRadiusCheckCategory

public static class WorldCategory
{
@Config.LangKey("cfg.universaltweaks.tweaks.world.cavegen")
@Config.Name("Cave Generation")
public final CaveGenCategory CAVE_GEN = new CaveGenCategory();

@Config.LangKey("cfg.universaltweaks.tweaks.world.chunkgenlimit")
@Config.Name("Chunk Gen Limit")
public final ChunkGenLimitCategory CHUNK_GEN_LIMIT = new ChunkGenLimitCategory();
Expand Down Expand Up @@ -2272,6 +2276,32 @@ public static class WorldCategory
})
public int utVillageDistance = 32;

public static class CaveGenCategory
{
@Config.RequiresMcRestart
@Config.Name("[1] Cave Generation Toggle")
@Config.Comment("Sets custom values for the vanilla cave generation")
public boolean utCaveGenToggle = false;

@Config.Name("[2] Random Iterations")
@Config.Comment
({
"Bound for the random chance to recursively generate rooms and tunnels",
"40 for pre-1.7 generation",
"15 for vanilla default"
})
public int utCaveGenIterations = 15;

@Config.Name("[3] Random Iteration Breaks")
@Config.Comment
({
"Bound for the random chance to stop recursively generate rooms and tunnels",
"15 for pre-1.7 generation",
"7 for vanilla default"
})
public int utCaveGenIterationBreaks = 7;
}

public static class ChunkGenLimitCategory
{
@Config.RequiresMcRestart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public class UTLoadingPlugin implements IFMLLoadingPlugin, IEarlyMixinLoader
put("mixins.tweaks.performance.pathfinding.json", () -> UTConfigTweaks.PERFORMANCE.utPathfindingChunkCacheFixToggle);
put("mixins.tweaks.performance.prefixcheck.json", () -> UTConfigTweaks.PERFORMANCE.utPrefixCheckToggle);
put("mixins.tweaks.performance.redstone.json", () -> UTConfigTweaks.PERFORMANCE.utRedstoneLightingToggle);
put("mixins.tweaks.world.cavegen.json", () -> UTConfigTweaks.WORLD.CAVE_GEN.utCaveGenToggle);
put("mixins.tweaks.world.chunks.gen.json", () -> UTConfigTweaks.WORLD.CHUNK_GEN_LIMIT.utChunkGenLimitToggle);
put("mixins.tweaks.world.loading.server.json", () -> UTConfigTweaks.PERFORMANCE.utWorldLoadingToggle);
put("mixins.tweaks.world.sealevel.json", () -> UTConfigTweaks.WORLD.utSeaLevel != 63);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package mod.acgaming.universaltweaks.tweaks.world.cavegen.mixin;

import net.minecraft.world.gen.MapGenCaves;

import mod.acgaming.universaltweaks.config.UTConfigTweaks;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;

// Courtesy of brunnh1lde
@Mixin(MapGenCaves.class)
public abstract class UTCaveGenMixin
{
@ModifyArg(method = "recursiveGenerate", at = @At(value = "INVOKE", target = "Ljava/util/Random;nextInt(I)I", ordinal = 2))
public int utCaveGenIterations(int bound)
{
return UTConfigTweaks.WORLD.CAVE_GEN.utCaveGenIterations;
}

@ModifyArg(method = "recursiveGenerate", at = @At(value = "INVOKE", target = "Ljava/util/Random;nextInt(I)I", ordinal = 3))
public int utCaveGenIterationBreaks(int bound)
{
return UTConfigTweaks.WORLD.CAVE_GEN.utCaveGenIterationBreaks;
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/universaltweaks/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ cfg.universaltweaks.tweaks.misc.stg=Swing Through Grass
cfg.universaltweaks.tweaks.misc.timeouts=Connection Timeouts
cfg.universaltweaks.tweaks.misc.toastcontrol=Toast Control
cfg.universaltweaks.tweaks.performance.entityradiuscheck=Entity Radius Check
cfg.universaltweaks.tweaks.world.cavegen=Cave Generation
cfg.universaltweaks.tweaks.world.chunkgenlimit=Chunk Gen Limit
cfg.universaltweaks.tweaks.world.dimensionunload=Dimension Unload
cfg.universaltweaks.tweaks.world.voidfog=Void Fog
7 changes: 7 additions & 0 deletions src/main/resources/mixins.tweaks.world.cavegen.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.tweaks.world.cavegen.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTCaveGenMixin"]
}

0 comments on commit 3b50435

Please sign in to comment.