Skip to content

Commit

Permalink
Merge pull request #440 from WaitingIdly/more-chat-lines
Browse files Browse the repository at this point in the history
Add more Chat-related options
  • Loading branch information
ACGaming authored Apr 14, 2024
2 parents 55dfe46 + f8da661 commit 1d28de2
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 10 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,14 @@ All changes are toggleable via config files.
* **Breakable Bedrock:** Allows customizable mining of bedrock
* **Burning Baby Zombies:** Lets baby zombies burn in daylight as in Minecraft 1.13+
* **Charged Creeper Spawning:** Sets the chance for creepers to spawn charged
* **Chat:**
* **Chat Lines:** Sets the maximum number of chat lines to display
* **Compact Messages:** Removes duplicate messages and instead put a number behind the message how often it was repeated
* **Keep Sent Messages:** Don't clear sent message history on leaving the world
* **Check Animated Models:** Improves model load times by checking if an animated model exists before trying to load it
* **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
* **Compact Messages:** Removes duplicate messages and instead put a number behind the message how often it was repeated
* **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 @@ -1218,6 +1218,10 @@ public static class MiscCategory
@Config.Name("Armor Curve")
public final ArmorCurveCategory ARMOR_CURVE = new ArmorCurveCategory();

@Config.LangKey("cfg.universaltweaks.tweaks.misc.chat")
@Config.Name("Chat")
public final ChatCategory CHAT = new ChatCategory();

@Config.LangKey("cfg.universaltweaks.tweaks.misc.incurablepotions")
@Config.Name("Incurable Potions")
public final IncurablePotionsCategory INCURABLE_POTIONS = new IncurablePotionsCategory();
Expand Down Expand Up @@ -1293,11 +1297,6 @@ public static class MiscCategory
@Config.Comment("Always indent keybind entries from the screen edge, preventing them from overflowing off the left side when particularly long keybind names are present")
public boolean utPreventKeybindingEntryOverflow = true;

@Config.RequiresMcRestart
@Config.Name("Compact Messages")
@Config.Comment("Removes duplicate messages and instead put a number behind the message how often it was repeated")
public boolean utCompactMessagesToggle = false;

@Config.RequiresMcRestart
@Config.Name("Linear XP Amount")
@Config.Comment
Expand Down Expand Up @@ -1457,6 +1456,30 @@ public static class ArmorCurveCategory
public boolean utArmorCurveLogging = false;
}

public static class ChatCategory
{
@Config.RequiresMcRestart
@Config.Name("[1] Chat Lines")
@Config.Comment
({
"Sets the maximum number of chat lines to display",
"100 is the vanilla default",
"0 or less functionally disables the chat"
})
public int utChatLines = 100;

@Config.RequiresMcRestart
@Config.Name("[2] Keep Sent Messages")
@Config.Comment("Don't clear sent message history on leaving the world")
public boolean utKeepSentMessageHistory = false;

@Config.RequiresMcRestart
@Config.Name("[3] Compact Messages")
@Config.Comment("Removes duplicate messages and instead put a number behind the message how often it was repeated")
public boolean utCompactMessagesToggle = false;
}


public static class IncurablePotionsCategory
{
@Config.RequiresMcRestart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public class UTLoadingPlugin implements IFMLLoadingPlugin, IEarlyMixinLoader
put("mixins.tweaks.misc.buttons.anaglyph.json", () -> UTConfigTweaks.MISC.ut3DAnaglyphButtonToggle);
put("mixins.tweaks.misc.buttons.realms.json", () -> UTConfigTweaks.MISC.utRealmsButtonToggle && !randomPatchesLoaded);
put("mixins.tweaks.misc.buttons.snooper.client.json", () -> UTConfigTweaks.MISC.utSnooperToggle);
put("mixins.tweaks.misc.chat.compactmessage.json", () -> UTConfigTweaks.MISC.CHAT.utCompactMessagesToggle);
put("mixins.tweaks.misc.chat.maximumlines.json", () -> UTConfigTweaks.MISC.CHAT.utChatLines != 100);
put("mixins.tweaks.misc.chat.keepsentmessages.json", () -> UTConfigTweaks.MISC.CHAT.utKeepSentMessageHistory);
put("mixins.tweaks.misc.commands.seed.json", () -> UTConfigTweaks.MISC.utCopyWorldSeedToggle);
put("mixins.tweaks.misc.credits.json", () -> UTConfigTweaks.MISC.utSkipCreditsToggle);
put("mixins.tweaks.misc.gui.keybindlistentry.json", () -> UTConfigTweaks.MISC.utPreventKeybindingEntryOverflow);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package mod.acgaming.universaltweaks.tweaks.misc.chat.keepsentmessages.mixin;

import mod.acgaming.universaltweaks.config.UTConfigTweaks;
import net.minecraft.client.gui.GuiNewChat;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

// Courtesy of WaitingIdly
@Mixin(value = GuiNewChat.class)
public class UTGuiNewChatMixin
{
@Inject(method = "clearChatMessages", at = @At(value = "INVOKE", target = "Ljava/util/List;clear()V", ordinal = 2), cancellable = true)
public void utKeepSentMessageHistory(boolean clearHistory, CallbackInfo ci)
{
if (!UTConfigTweaks.MISC.CHAT.utKeepSentMessageHistory) return;
ci.cancel();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package mod.acgaming.universaltweaks.tweaks.misc.chat.maximumlines.mixin;

import mod.acgaming.universaltweaks.config.UTConfigTweaks;
import net.minecraft.client.gui.GuiNewChat;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

// Courtesy of WaitingIdly
@Mixin(value = GuiNewChat.class)
public class UTGuiNewChatMixin
{
@ModifyConstant(method = "setChatLine", constant = @Constant(intValue = 100))
public int utAdvancementToast(int original)
{
// Prevents negative config numbers generating an NPE
if (UTConfigTweaks.MISC.CHAT.utChatLines < 0) return 0;
return UTConfigTweaks.MISC.CHAT.utChatLines;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public abstract class UTCompactMessageMixin
@Inject(method = "setChatLine", at = @At("HEAD"))
public void utCompactMessage(ITextComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly, CallbackInfo ci)
{
if (!UTConfigTweaks.MISC.utCompactMessagesToggle) return;
if (!UTConfigTweaks.MISC.CHAT.utCompactMessagesToggle) return;
int count = 1;
int chatSize = MathHelper.floor(this.getChatWidth() / this.getChatScale());
List<ITextComponent> splittedText = GuiUtilRenderComponents.splitText(chatComponent, chatSize, this.mc.fontRenderer, false, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class UTObsoleteModsHandler
put("bedsaynosleep", () -> UTConfigTweaks.ENTITIES.SLEEPING.utDisableSleepingToggle);
put("betterburning", () -> UTConfigTweaks.ENTITIES.BETTER_BURNING.utBBArrowsToggle || UTConfigTweaks.ENTITIES.BETTER_BURNING.utBBCookedToggle || UTConfigTweaks.ENTITIES.BETTER_BURNING.utBBExtinguishToggle || UTConfigTweaks.ENTITIES.BETTER_BURNING.utBBOverlayToggle || UTConfigTweaks.ENTITIES.BETTER_BURNING.utBBSpreadingToggle);
put("betterplacement", () -> UTConfigTweaks.BLOCKS.BETTER_PLACEMENT.utBetterPlacementToggle);
put("biggerchathistory", () -> UTConfigTweaks.MISC.CHAT.utChatLines != 100);
put("biggerpacketsplz", () -> UTConfigBugfixes.MISC.utPacketSize > 0x200000);
put("blockdispenser", () -> UTConfigTweaks.BLOCKS.BLOCK_DISPENSER.utBlockDispenserToggle);
put("blockfire", () -> UTConfigBugfixes.ENTITIES.utBlockFireToggle);
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 @@ -127,6 +127,7 @@ cfg.universaltweaks.tweaks.items.itementities=Item Entities
cfg.universaltweaks.tweaks.items.mending=Mending
cfg.universaltweaks.tweaks.items.parry=Shield Parry
cfg.universaltweaks.tweaks.misc.armorcurve=Armor Curve
cfg.universaltweaks.tweaks.misc.chat=Chat
cfg.universaltweaks.tweaks.misc.incurablepotions=Incurable Potions
cfg.universaltweaks.tweaks.misc.lightning=Lightning
cfg.universaltweaks.tweaks.misc.loadsounds=Load Sounds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"client": [
"UTCompactMessageMixin"
]
"client": ["UTCompactMessageMixin"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.tweaks.misc.chat.keepsentmessages.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"client": ["UTGuiNewChatMixin"]
}
7 changes: 7 additions & 0 deletions src/main/resources/mixins.tweaks.misc.chat.maximumlines.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.tweaks.misc.chat.maximumlines.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"client": ["UTGuiNewChatMixin"]
}

0 comments on commit 1d28de2

Please sign in to comment.