From 015b73276c698d383547a3909feeda83db6c83d3 Mon Sep 17 00:00:00 2001 From: ACGaming <4818419+ACGaming@users.noreply.github.com> Date: Thu, 15 Feb 2024 22:43:27 +0100 Subject: [PATCH] Implement village distance tweak --- README.md | 1 + .../config/UTConfigTweaks.java | 9 ++++++++ .../universaltweaks/core/UTLoadingPlugin.java | 8 +++---- .../village/mixin/UTVillageDistanceMixin.java | 23 +++++++++++++++++++ .../mixins.tweaks.world.village.json | 7 ++++++ 5 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 src/main/java/mod/acgaming/universaltweaks/tweaks/world/village/mixin/UTVillageDistanceMixin.java create mode 100644 src/main/resources/mixins.tweaks.world.village.json diff --git a/README.md b/README.md index 904d51f4..53c6012e 100644 --- a/README.md +++ b/README.md @@ -201,6 +201,7 @@ All changes are toggleable via config files. * **Undead Horses** * **Burning:** Lets untamed undead horses burn in daylight * **Taming:** Allows taming of undead horses +* **Village Distance:** Sets the village generation distance in chunks * **Water Fall Damage:** Re-implements an improved version of pre-1.4 fall damage in water * **XP Bottle Amount:** Sets the amount of experience spawned by bottles o' enchanting * **XP Level Cap:** Sets the maximum experience level players can reach diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java index de5cade6..eea03a25 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java @@ -1697,6 +1697,15 @@ public static class WorldCategory @Config.Comment("Tidies newly generated chunks by removing scattered item entities") public boolean utTidyChunkToggle = false; + @Config.RequiresMcRestart + @Config.Name("Village Distance") + @Config.Comment + ({ + "Sets the village generation distance in chunks", + "Vanilla default is 32" + }) + public int utVillageDistance = 32; + 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 aadf2111..4e45c991 100644 --- a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java +++ b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java @@ -246,6 +246,7 @@ public List getMixinConfigs() configs.add("mixins.tweaks.world.chunks.gen.json"); configs.add("mixins.tweaks.world.loading.server.json"); configs.add("mixins.tweaks.world.sealevel.json"); + configs.add("mixins.tweaks.world.village.json"); return configs; } @@ -255,10 +256,7 @@ public boolean shouldMixinConfigQueue(String mixinConfig) if (isDev) { // Causes crashes in dev env only - if (mixinConfig.equals("mixins.tweaks.misc.armorcurve.json")) - { - return false; - } + if (mixinConfig.equals("mixins.tweaks.misc.armorcurve.json")) return false; return true; } if (isClient) @@ -530,6 +528,8 @@ public boolean shouldMixinConfigQueue(String mixinConfig) return UTConfigTweaks.PERFORMANCE.utWorldLoadingToggle; case "mixins.tweaks.world.sealevel.json": return UTConfigTweaks.WORLD.utSeaLevel != 63; + case "mixins.tweaks.world.village.json": + return UTConfigTweaks.WORLD.utVillageDistance != 32; } return true; } diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/world/village/mixin/UTVillageDistanceMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/world/village/mixin/UTVillageDistanceMixin.java new file mode 100644 index 00000000..2551ebca --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/world/village/mixin/UTVillageDistanceMixin.java @@ -0,0 +1,23 @@ +package mod.acgaming.universaltweaks.tweaks.world.village.mixin; + +import net.minecraft.world.gen.structure.MapGenVillage; + +import mod.acgaming.universaltweaks.config.UTConfigTweaks; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(MapGenVillage.class) +public class UTVillageDistanceMixin +{ + @Shadow + private int distance; + + @Inject(method = "()V", at = @At("TAIL")) + public void utVillageDistance(CallbackInfo ci) + { + this.distance = UTConfigTweaks.WORLD.utVillageDistance; + } +} \ No newline at end of file diff --git a/src/main/resources/mixins.tweaks.world.village.json b/src/main/resources/mixins.tweaks.world.village.json new file mode 100644 index 00000000..5ffcf88d --- /dev/null +++ b/src/main/resources/mixins.tweaks.world.village.json @@ -0,0 +1,7 @@ +{ + "package": "mod.acgaming.universaltweaks.tweaks.world.village.mixin", + "refmap": "universaltweaks.refmap.json", + "minVersion": "0.8", + "compatibilityLevel": "JAVA_8", + "mixins": ["UTVillageDistanceMixin"] +} \ No newline at end of file