mirror of
https://github.com/GTNewHorizons/Applied-Energistics-2-Unofficial.git
synced 2026-11-25 14:34:34 +00:00
Resolve interface name suffixes as chat components (#1545)
Co-authored-by: Martin Robertz <[email protected]> Co-authored-by: Kogepan229 <[email protected]>
This commit is contained in:
7 files changed
+61
-17
No files matched your search
@@ -1,5 +1,7 @@
|
||||
package appeng.api.interfaces;
|
||||
|
||||
import net.minecraft.util.IChatComponent;
|
||||
|
||||
/**
|
||||
* Implement this on a TileEntity (or IMetaTileEntity, wrapped via the hosting TileEntity) to provide a dynamic suffix
|
||||
* for the AE2 interface name shown in the terminal.
|
||||
@@ -10,12 +12,26 @@ package appeng.api.interfaces;
|
||||
public interface IInterfaceNameProvider {
|
||||
|
||||
/**
|
||||
* Returns a suffix string to append to the ME Interface's display name, or {@code null} if no suffix should be
|
||||
* shown.
|
||||
* Returns a suffix to append to the ME Interface's display name, or {@code null} if no suffix should be shown.
|
||||
*
|
||||
* The returned string will be appended as-is (e.g. {@code " [24]"}).
|
||||
* The suffix is built on the server, where client language files are not loaded, so it is returned as a component
|
||||
* and only turned into text on the client:
|
||||
*
|
||||
* @return suffix string or {@code null}
|
||||
* <pre>
|
||||
* IChatComponent suffix = new ChatComponentText(" (");
|
||||
* suffix.appendSibling(new ChatComponentItemDisplayName(stack));
|
||||
* suffix.appendText(")");
|
||||
* return suffix;
|
||||
* </pre>
|
||||
*
|
||||
* Any component works, including the custom ones GTNHLib registers. AE2 serializes it when sending the terminal
|
||||
* update and appends {@code getUnformattedText()} on the client, so formatting is dropped and only the text is
|
||||
* used. A component the client cannot deserialize is shown as raw text rather than dropping the whole entry.
|
||||
*
|
||||
* The serialized form travels as a single string field in the terminal update packet, which caps it at 16383 bytes
|
||||
* of UTF-8. Providers are responsible for keeping the suffix reasonably short.
|
||||
*
|
||||
* @return suffix component or {@code null}
|
||||
*/
|
||||
String getInterfaceNameSuffix();
|
||||
IChatComponent getInterfaceNameSuffix();
|
||||
}
|
||||
Reference in new issue
Block a user