Merge remote-tracking branch 'origin/master' into dev

This commit is contained in:
Nassim Jahnke 2021-10-26 11:09:59 +02:00
commit 74aa5f4598
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
5 changed files with 27 additions and 6 deletions

View File

@ -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;

View File

@ -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.
*

View File

@ -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);

View File

@ -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);
}
});
}
});

View File

@ -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