Skip to content

Commit

Permalink
Add config/readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jchung01 committed Sep 25, 2024
1 parent 5a6977e commit ad99178
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ All changes are toggleable via config files.
* **Chicken Shedding:** Allows chickens to have a chance to shed feathers (similarly to laying eggs)
* **Chunk Gen Limit:** Limits maximum chunk generation per tick for improved server performance
* **Cobweb Slowness:** Modifies the applied slowness factor when entities are moving in cobwebs
* **Connection Timeouts:** Allows configuring read/login timeouts
* Helps slow clients log into a server of a large modpack
* **Copy World Seed:** Enables clicking of `/seed` world seed in chat to copy to clipboard
* **Crafting Cache:** Adds an IRecipe cache to improve recipe performance in large modpacks
* **Creeper Confetti:** Replaces deadly creeper explosions with delightful confetti (with a configurable chance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import mod.acgaming.universaltweaks.tweaks.misc.incurablepotions.UTIncurablePotions;
import mod.acgaming.universaltweaks.tweaks.misc.loadsound.UTLoadSound;
import mod.acgaming.universaltweaks.tweaks.misc.swingthroughgrass.UTSwingThroughGrassLists;
import mod.acgaming.universaltweaks.tweaks.misc.timeouts.UTTimeoutManager;
import mod.acgaming.universaltweaks.tweaks.performance.autosave.UTAutoSaveOFCompat;
import mod.acgaming.universaltweaks.tweaks.performance.entityradiuscheck.UTEntityRadiusCheck;

Expand Down Expand Up @@ -1374,6 +1375,10 @@ public static class MiscCategory
@Config.Name("Chat")
public final ChatCategory CHAT = new ChatCategory();

@Config.LangKey("cfg.universaltweaks.tweaks.misc.timeouts")
@Config.Name("Connection Timeouts")
public final TimeoutsCategory TIMEOUTS = new TimeoutsCategory();

@Config.LangKey("cfg.universaltweaks.tweaks.misc.incurablepotions")
@Config.Name("Incurable Potions")
public final IncurablePotionsCategory INCURABLE_POTIONS = new IncurablePotionsCategory();
Expand Down Expand Up @@ -1948,6 +1953,34 @@ public static class SwingThroughGrassCategory
public String[] utSwingThroughGrassWhitelist = new String[] {};
}

public static class TimeoutsCategory
{
@Config.Name("[1] Connection Timeouts Toggle")
@Config.Comment
({
"Allows configuring read/login timeouts.",
"If you are having trouble logging into a server of a large modpack, try changing the timeouts below."
})
public boolean utTimeoutsToggle = true;

@Config.Name("[2] Read Timeout")
@Config.Comment
({
"The connection read timeout in seconds.",
"This value is used on both client and server.",
"On the server, also extends the time allowed to respond to a KeepAlive packet."
})
public int utReadTimeout = 90;

@Config.Name("[3] Login Timeout")
@Config.Comment
({
"The login timeout in seconds. (Vanilla default: 600 ticks, or 30 secs)",
"Only used on the server.",
})
public int utLoginTimeout = 90;
}

public static class ToastControlCategory
{
@Config.RequiresMcRestart
Expand Down Expand Up @@ -2303,6 +2336,7 @@ public static class VoidFogCategory
static
{
ConfigAnytime.register(UTConfigTweaks.class);
UTTimeoutManager.init();
}

@Mod.EventBusSubscriber(modid = UniversalTweaks.MODID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ public class UTLoadingPlugin implements IFMLLoadingPlugin, IEarlyMixinLoader
put("mixins.tweaks.misc.lightning.damage.json", () -> UTConfigTweaks.MISC.LIGHTNING.utLightningDamage != 5.0D || UTConfigTweaks.MISC.LIGHTNING.utLightningFireTicks != 8);
put("mixins.tweaks.misc.lightning.fire.json", () -> UTConfigTweaks.MISC.LIGHTNING.utLightningFireToggle);
put("mixins.tweaks.misc.recipebook.server.json", () -> UTConfigTweaks.MISC.utRecipeBookToggle);
// TODO: add config
put("mixins.tweaks.misc.timeouts.json", () -> true);
put("mixins.tweaks.misc.timeouts.json", () -> UTConfigTweaks.MISC.TIMEOUTS.utTimeoutsToggle);
put("mixins.tweaks.misc.xp.cap.json", () -> UTConfigTweaks.MISC.utXPLevelCap > -1);
put("mixins.tweaks.misc.xp.linear.json", () -> UTConfigTweaks.MISC.utLinearXP > 0);
put("mixins.tweaks.misc.xp.smelting.json", () -> UTConfigTweaks.MISC.utSmeltingXPToggle);
Expand Down Expand Up @@ -219,8 +218,7 @@ public class UTLoadingPlugin implements IFMLLoadingPlugin, IEarlyMixinLoader
put("mixins.tweaks.misc.personalpotionparticles.json", () -> UTConfigTweaks.MISC.utPoVEffectParticles);
put("mixins.tweaks.misc.recipebook.client.json", () -> UTConfigTweaks.MISC.utRecipeBookToggle);
put("mixins.tweaks.misc.smoothscrolling.json", () -> UTConfigTweaks.MISC.SMOOTH_SCROLLING.utSmoothScrollingToggle);
// TODO: add config
put("mixins.tweaks.misc.timeouts.client.json", () -> true);
put("mixins.tweaks.misc.timeouts.client.json", () -> UTConfigTweaks.MISC.TIMEOUTS.utTimeoutsToggle);
put("mixins.tweaks.misc.toastcontrol.json", () -> UTConfigTweaks.MISC.TOAST_CONTROL.utToastControlToggle);
put("mixins.tweaks.performance.audioreload.json", () -> UTConfigTweaks.PERFORMANCE.utDisableAudioDebugToggle && !surgeLoaded);
put("mixins.tweaks.performance.connectionspeed.json", () -> UTConfigTweaks.PERFORMANCE.utImproveLanguageSwitchingSpeed);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package mod.acgaming.universaltweaks.tweaks.misc.timeouts;

import org.apache.commons.lang3.math.NumberUtils;

import mod.acgaming.universaltweaks.config.UTConfigTweaks;

public class UTTimeoutManager
{
public static long readTimeoutMillis;
public static int loginTimeoutTicks;

public static void init()
{
if (!UTConfigTweaks.MISC.TIMEOUTS.utTimeoutsToggle) return;
int readTimeout = NumberUtils.toInt(System.getProperty("fml.readTimeout"), UTConfigTweaks.MISC.TIMEOUTS.utReadTimeout);
// Don't overwrite read timeout that was specified by command line.
if (readTimeout == UTConfigTweaks.MISC.TIMEOUTS.utReadTimeout)
{
System.setProperty("fml.readTimeout", String.valueOf(UTConfigTweaks.MISC.TIMEOUTS.utReadTimeout));
}
readTimeoutMillis = UTConfigTweaks.MISC.TIMEOUTS.utReadTimeout * 1000L;
loginTimeoutTicks = UTConfigTweaks.MISC.TIMEOUTS.utLoginTimeout * 20;
// fml.loginTimeout is unused
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package mod.acgaming.universaltweaks.tweaks.misc.timeouts.mixin;

import mod.acgaming.universaltweaks.config.UTConfigTweaks;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
Expand All @@ -12,6 +13,6 @@ public class UTClientReadTimeoutMixin
@ModifyConstant(method = "initChannel", constant = @Constant(intValue = 30))
private int utModifyReadTimeout(int original)
{
return 90;
return UTConfigTweaks.MISC.TIMEOUTS.utReadTimeout;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.server.network.NetHandlerLoginServer;

import mod.acgaming.universaltweaks.tweaks.misc.timeouts.UTTimeoutManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
Expand All @@ -13,6 +14,6 @@ public class UTLoginTimeoutMixin
@ModifyConstant(method = "update", constant = @Constant(intValue = 600))
private int utModifyLoginTimeout(int original)
{
return 1800;
return UTTimeoutManager.loginTimeoutTicks;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import mod.acgaming.universaltweaks.tweaks.misc.timeouts.UTTimeoutManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -25,7 +26,7 @@ public class UTServerReadTimeoutMixin
at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetHandlerPlayServer;disconnect(Lnet/minecraft/util/text/ITextComponent;)V"))
private void utKeepAliveUntilReadTimeout(NetHandlerPlayServer instance, ITextComponent textComponent, Operation<Void> original, @Local long currentTimeMillis)
{
if (currentTimeMillis - field_194402_f >= 90)
if (currentTimeMillis - field_194402_f >= UTTimeoutManager.readTimeoutMillis)
{
original.call(instance, textComponent);
}
Expand Down
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 @@ -152,6 +152,7 @@ cfg.universaltweaks.tweaks.misc.loadsounds=Load Sounds
cfg.universaltweaks.tweaks.misc.pickupnotification=Pickup Notification
cfg.universaltweaks.tweaks.misc.smoothscrolling=Smooth Scrolling
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.chunkgenlimit=Chunk Gen Limit
Expand Down

0 comments on commit ad99178

Please sign in to comment.