Skip to content

Commit

Permalink
Implement sea level tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Jul 17, 2023
1 parent e02b88f commit 13309a9
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ All changes are toggleable via the config file.
* **Remove Realms Button:** Removes the redundant Minecraft Realms button from the main menu
* **Remove Recipe Book:** Removes the recipe book button from GUIs
* **Remove Snooper:** Forcefully turns off the snooper and hides the snooper settings button from the options menu
* **Sea Level:** Sets the default height of the overworld's sea level
* **Shield Parry:** Allows parrying of projectiles with shields
* **Skip Credits:** Skips the credits screen after the player goes through the end podium portal
* **Skip Missing Registry Entries Screen:** Automatically confirms the 'Missing Registry Entries' screen on world load
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1693,6 +1693,15 @@ public static class TweaksWorldCategory
@Config.Name("Dimension Unload")
public final DimensionUnloadCategory DIMENSION_UNLOAD = new DimensionUnloadCategory();

@Config.RequiresMcRestart
@Config.Name("Sea Level")
@Config.Comment
({
"Sets the default height of the overworld's sea level",
"Vanilla default is 63"
})
public int utSeaLevel = 63;

@Config.RequiresMcRestart
@Config.Name("Stronghold Replacement")
@Config.Comment("Replaces stronghold generation with a safer variant")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ public List<String> getMixinConfigs()
"mixins.tweaks.performance.resourcemanager.json",
"mixins.tweaks.world.chunks.gen.json",
"mixins.tweaks.world.loading.client.json",
"mixins.tweaks.world.loading.server.json") :
"mixins.tweaks.world.loading.server.json",
"mixins.tweaks.world.sealevel.json") :
Arrays.asList(
"mixins.bugfixes.blocks.comparatortiming.json",
"mixins.bugfixes.blocks.fallingblockdamage.json",
Expand Down Expand Up @@ -265,7 +266,8 @@ public List<String> getMixinConfigs()
"mixins.tweaks.performance.prefixcheck.json",
"mixins.tweaks.performance.redstone.json",
"mixins.tweaks.world.chunks.gen.json",
"mixins.tweaks.world.loading.server.json"
"mixins.tweaks.world.loading.server.json",
"mixins.tweaks.world.sealevel.json"
);
}

Expand Down Expand Up @@ -478,6 +480,8 @@ public boolean shouldMixinConfigQueue(String mixinConfig)
return UTConfig.TWEAKS_WORLD.CHUNK_GEN_LIMIT.utChunkGenLimitToggle;
case "mixins.tweaks.world.loading.server.json":
return UTConfig.TWEAKS_PERFORMANCE.utWorldLoadingToggle;
case "mixins.tweaks.world.sealevel.json":
return UTConfig.TWEAKS_WORLD.utSeaLevel != 63;
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package mod.acgaming.universaltweaks.tweaks.world.sealevel.mixin;

import mod.acgaming.universaltweaks.config.UTConfig;
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(targets = "net.minecraft.world.gen.ChunkGeneratorSettings$Factory")
public class UTSeaLevelChunkGeneratorMixin
{
@Shadow
public int seaLevel;

@Inject(method = "setDefaults", at = @At(value = "TAIL"))
public void utSeaLevel(CallbackInfo ci)
{
seaLevel = UTConfig.TWEAKS_WORLD.utSeaLevel;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package mod.acgaming.universaltweaks.tweaks.world.sealevel.mixin;

import net.minecraft.profiler.Profiler;
import net.minecraft.world.World;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.storage.ISaveHandler;
import net.minecraft.world.storage.WorldInfo;

import mod.acgaming.universaltweaks.config.UTConfig;
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(World.class)
public abstract class UTSeaLevelWorldMixin
{
@Shadow
private int seaLevel;

@Inject(method = "<init>", at = @At(value = "TAIL"))
public void utSeaLevel(ISaveHandler saveHandlerIn, WorldInfo info, WorldProvider providerIn, Profiler profilerIn, boolean client, CallbackInfo ci)
{
seaLevel = UTConfig.TWEAKS_WORLD.utSeaLevel;
}
}
7 changes: 7 additions & 0 deletions src/main/resources/mixins.tweaks.world.sealevel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.tweaks.world.sealevel.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTSeaLevelChunkGeneratorMixin", "UTSeaLevelWorldMixin"]
}

0 comments on commit 13309a9

Please sign in to comment.