3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-07-05 23:28:03 +02:00

Fix 1.13.1->1.13 inventory title regression

Fixes #375
Dieser Commit ist enthalten in:
Nassim Jahnke 2021-10-26 11:09:42 +02:00
Ursprung 169650f17c
Commit db345577a2
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
5 geänderte Dateien mit 27 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -31,6 +31,7 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback
private boolean addTeamColorToPrefix;
private boolean fix1_13FacePlayer;
private boolean alwaysShowOriginalMobName;
private boolean fix1_13FormattedInventoryTitles;
private boolean handlePingsAsInvAcknowledgements;
public ViaBackwardsConfig(File configFile) {
@ -47,6 +48,7 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback
addCustomEnchantsToLore = getBoolean("add-custom-enchants-into-lore", true);
addTeamColorToPrefix = getBoolean("add-teamcolor-to-prefix", true);
fix1_13FacePlayer = getBoolean("fix-1_13-face-player", false);
fix1_13FormattedInventoryTitles = getBoolean("fix-formatted-inventory-titles", true);
alwaysShowOriginalMobName = getBoolean("always-show-original-mob-name", true);
handlePingsAsInvAcknowledgements = getBoolean("handle-pings-as-inv-acknowledgements", false);
}
@ -66,6 +68,11 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback
return fix1_13FacePlayer;
}
@Override
public boolean fix1_13FormattedInventoryTitle() {
return fix1_13FormattedInventoryTitles;
}
@Override
public boolean alwaysShowOriginalMobName() {
return alwaysShowOriginalMobName;

Datei anzeigen

@ -40,6 +40,8 @@ public interface ViaBackwardsConfig {
*/
boolean isFix1_13FacePlayer();
boolean fix1_13FormattedInventoryTitle();
/**
* Always shows the original mob's name instead of only when hovering over them with the cursor.
*

Datei anzeigen

@ -60,7 +60,7 @@ public class BackwardsMappings extends com.viaversion.viabackwards.api.data.Back
// Has lots of compat layers, so we can't use the default Via method
private static void mapIdentifiers(int[] output, JsonObject newIdentifiers, JsonObject oldIdentifiers, JsonObject mapping) {
Object2IntMap newIdentifierMap = MappingDataLoader.indexedObjectToMap(oldIdentifiers);
Object2IntMap<String> newIdentifierMap = MappingDataLoader.indexedObjectToMap(oldIdentifiers);
for (Map.Entry<String, JsonElement> entry : newIdentifiers.entrySet()) {
String key = entry.getValue().getAsString();
int value = newIdentifierMap.getInt(key);

Datei anzeigen

@ -17,6 +17,7 @@
*/
package com.viaversion.viabackwards.protocol.protocol1_13to1_13_1;
import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.BackwardsMappings;
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
@ -109,14 +110,21 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
map(Type.UNSIGNED_BYTE); // Id
map(Type.STRING); // Window Type
handler(wrapper -> {
JsonElement title = wrapper.read(Type.COMPONENT);
JsonElement title = wrapper.passthrough(Type.COMPONENT);
translatableRewriter.processText(title);
// https://bugs.mojang.com/browse/MC-124543
JsonObject legacyComponent = new JsonObject();
legacyComponent.addProperty("text", ChatRewriter.jsonToLegacyText(title.toString()));
if (ViaBackwards.getConfig().fix1_13FormattedInventoryTitle()) {
if (title.isJsonObject() && title.getAsJsonObject().size() == 1
&& title.getAsJsonObject().has("translate")) {
// Hotfix simple translatable components from being converted to legacy text
return;
}
wrapper.write(Type.COMPONENT, legacyComponent);
// https://bugs.mojang.com/browse/MC-124543
JsonObject legacyComponent = new JsonObject();
legacyComponent.addProperty("text", ChatRewriter.jsonToLegacyText(title.toString()));
wrapper.set(Type.COMPONENT, 0, legacyComponent);
}
});
}
});

Datei anzeigen

@ -13,6 +13,10 @@ add-teamcolor-to-prefix: true
# Converts the 1.13 face look-at packet for 1.12- players. Requires a bit of extra caching.
fix-1_13-face-player: false
#
# Fixes 1.13 clients and lower not seeing color or formatting in inventory titles by converting them to legacy text.
# If you have issues with translatable text being displayed wrongly, disable this.
fix-formatted-inventory-titles: true
#
# Sends inventory acknowledgement packets to act as a replacement for ping packets for sub 1.17 clients.
# This only takes effect for ids in the short range. Useful for anticheat compatibility.
handle-pings-as-inv-acknowledgements: false