forked from neoforged/NeoForge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Have TranslatableContents throw when fed improper arguments in dev
Closes neoforged#703 Also fixed several spots in NeoForge where we were passing bad arguments as well. Note: the track command's crash from bad argument passed to Translatable will be fixed in this PR: neoforged#915
- Loading branch information
1 parent
8bdd59d
commit efc3c13
Showing
6 changed files
with
30 additions
and
16 deletions.
There are no files selected for viewing
28 changes: 21 additions & 7 deletions
28
patches/net/minecraft/network/chat/contents/TranslatableContents.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,28 @@ | ||
--- a/net/minecraft/network/chat/contents/TranslatableContents.java | ||
+++ b/net/minecraft/network/chat/contents/TranslatableContents.java | ||
@@ -140,6 +_,11 @@ | ||
j = l; | ||
} | ||
@@ -81,6 +_,13 @@ | ||
this.key = p_265775_; | ||
this.fallback = p_265204_; | ||
this.args = p_265752_; | ||
+ if (!net.neoforged.fml.loading.FMLEnvironment.production) { | ||
+ for (Object arg : this.args) { | ||
+ if (!(arg instanceof Component) && !isAllowedPrimitiveArgument(arg)) { | ||
+ throw new IllegalArgumentException("TranslatableContents's arguments must be a Component, Number, Boolean, or String. Was given " + arg + " for " + this.key); | ||
+ } | ||
+ } | ||
+ } | ||
} | ||
|
||
@Override | ||
@@ -138,6 +_,11 @@ | ||
} | ||
|
||
j = l; | ||
+ } | ||
+ | ||
+ if (j == 0) { | ||
+ // Neo has some special formatting handlers defined in I18nExtension, use those if no %s replacements present. | ||
+ j = net.neoforged.neoforge.internal.TextComponentMessageFormatHandler.handle(this, p_237517_, this.args, p_237516_); | ||
+ } | ||
+ | ||
} | ||
if (j < p_237516_.length()) { | ||
String s3 = p_237516_.substring(j); | ||
if (s3.indexOf(37) != -1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters