diff --git a/README.md b/README.md index 019ed4c5..6dab3d98 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java index 6e380ad9..92615b44 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java @@ -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(); @@ -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 diff --git a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java index fb3a9170..db00ab71 100644 --- a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java +++ b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java @@ -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); diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/world/cavegen/mixin/UTCaveGenMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/world/cavegen/mixin/UTCaveGenMixin.java new file mode 100644 index 00000000..71dacf1c --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/world/cavegen/mixin/UTCaveGenMixin.java @@ -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; + } +} \ No newline at end of file diff --git a/src/main/resources/assets/universaltweaks/lang/en_us.lang b/src/main/resources/assets/universaltweaks/lang/en_us.lang index c7d70cc6..f247db62 100644 --- a/src/main/resources/assets/universaltweaks/lang/en_us.lang +++ b/src/main/resources/assets/universaltweaks/lang/en_us.lang @@ -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 diff --git a/src/main/resources/mixins.tweaks.world.cavegen.json b/src/main/resources/mixins.tweaks.world.cavegen.json new file mode 100644 index 00000000..8a0a68c4 --- /dev/null +++ b/src/main/resources/mixins.tweaks.world.cavegen.json @@ -0,0 +1,7 @@ +{ + "package": "mod.acgaming.universaltweaks.tweaks.world.cavegen.mixin", + "refmap": "universaltweaks.refmap.json", + "minVersion": "0.8", + "compatibilityLevel": "JAVA_8", + "mixins": ["UTCaveGenMixin"] +} \ No newline at end of file