3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-24 23:30:17 +01:00

Update TranslatableRewriter

Dieser Commit ist enthalten in:
Nassim Jahnke 2023-10-18 14:56:44 +10:00
Ursprung e419831e8a
Commit 719bb11938
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
23 geänderte Dateien mit 418 neuen und 107 gelöschten Zeilen

Datei anzeigen

@ -177,4 +177,48 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
} }
}); });
} }
@Override
public void registerAdvancements1_20_3(final C packetType) {
// Insert translatable rewriter
protocol.registerClientbound(packetType, wrapper -> {
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
final int size = wrapper.passthrough(Type.VAR_INT); // Mapping size
for (int i = 0; i < size; i++) {
wrapper.passthrough(Type.STRING); // Identifier
// Parent
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.STRING);
}
// Display data
if (wrapper.passthrough(Type.BOOLEAN)) {
final Tag title = wrapper.passthrough(Type.TAG);
final Tag description = wrapper.passthrough(Type.TAG);
final TranslatableRewriter<C> translatableRewriter = protocol.getTranslatableRewriter();
if (translatableRewriter != null) {
translatableRewriter.processTag(title);
translatableRewriter.processTag(description);
}
handleItemToClient(wrapper.passthrough(Type.ITEM1_20_2)); // Icon
wrapper.passthrough(Type.VAR_INT); // Frame type
final int flags = wrapper.passthrough(Type.INT);
if ((flags & 1) != 0) {
wrapper.passthrough(Type.STRING); // Background texture
}
wrapper.passthrough(Type.FLOAT); // X
wrapper.passthrough(Type.FLOAT); // Y
}
final int requirements = wrapper.passthrough(Type.VAR_INT);
for (int array = 0; array < requirements; array++) {
wrapper.passthrough(Type.STRING_ARRAY);
}
wrapper.passthrough(Type.BOOLEAN); // Send telemetry
}
});
}
} }

Datei anzeigen

@ -21,9 +21,6 @@ import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.VBMappingDataLoader; import com.viaversion.viabackwards.api.data.VBMappingDataLoader;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.libs.gson.JsonObject; import com.viaversion.viaversion.libs.gson.JsonObject;
import com.viaversion.viaversion.rewriter.ComponentRewriter; import com.viaversion.viaversion.rewriter.ComponentRewriter;
@ -34,101 +31,43 @@ import org.checkerframework.checker.nullness.qual.Nullable;
public class TranslatableRewriter<C extends ClientboundPacketType> extends ComponentRewriter<C> { public class TranslatableRewriter<C extends ClientboundPacketType> extends ComponentRewriter<C> {
private static final Map<String, Map<String, String>> TRANSLATABLES = new HashMap<>(); private static final Map<String, Map<String, String>> TRANSLATABLES = new HashMap<>();
private final Map<String, String> newTranslatables; private final Map<String, String> translatables;
public static void loadTranslatables() { public static void loadTranslatables() {
JsonObject jsonObject = VBMappingDataLoader.loadFromDataDir("translation-mappings.json"); final JsonObject jsonObject = VBMappingDataLoader.loadFromDataDir("translation-mappings.json");
for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) { for (final Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
Map<String, String> versionMappings = new HashMap<>(); final Map<String, String> versionMappings = new HashMap<>();
TRANSLATABLES.put(entry.getKey(), versionMappings); TRANSLATABLES.put(entry.getKey(), versionMappings);
for (Map.Entry<String, JsonElement> translationEntry : entry.getValue().getAsJsonObject().entrySet()) { for (final Map.Entry<String, JsonElement> translationEntry : entry.getValue().getAsJsonObject().entrySet()) {
versionMappings.put(translationEntry.getKey(), translationEntry.getValue().getAsString()); versionMappings.put(translationEntry.getKey(), translationEntry.getValue().getAsString());
} }
} }
} }
public TranslatableRewriter(BackwardsProtocol<C, ?, ?, ?> protocol) { public TranslatableRewriter(final BackwardsProtocol<C, ?, ?, ?> protocol, final ReadType type) {
this(protocol, protocol.getClass().getSimpleName().split("To")[1].replace("_", ".")); this(protocol, type, protocol.getClass().getSimpleName().split("To")[1].replace("_", "."));
} }
public TranslatableRewriter(BackwardsProtocol<C, ?, ?, ?> protocol, String sectionIdentifier) { public TranslatableRewriter(final BackwardsProtocol<C, ?, ?, ?> protocol, final ReadType type, final String sectionIdentifier) {
super(protocol); super(protocol, type);
final Map<String, String> newTranslatables = TRANSLATABLES.get(sectionIdentifier); final Map<String, String> translatableMappings = TRANSLATABLES.get(sectionIdentifier);
if (newTranslatables == null) { if (translatableMappings == null) {
ViaBackwards.getPlatform().getLogger().warning("Error loading " + sectionIdentifier + " translatables!"); ViaBackwards.getPlatform().getLogger().warning("Missing " + sectionIdentifier + " translatables!");
this.newTranslatables = new HashMap<>(); this.translatables = new HashMap<>();
} else { } else {
this.newTranslatables = newTranslatables; this.translatables = translatableMappings;
} }
} }
public void registerPing() {
protocol.registerClientbound(State.LOGIN, 0x00, 0x00, wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
}
public void registerDisconnect(C packetType) {
protocol.registerClientbound(packetType, wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
}
public void registerLegacyOpenWindow(C packetType) {
protocol.registerClientbound(packetType, new PacketHandlers() {
@Override
public void register() {
map(Type.UNSIGNED_BYTE); // Id
map(Type.STRING); // Window Type
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
}
});
}
public void registerOpenWindow(C packetType) {
protocol.registerClientbound(packetType, new PacketHandlers() {
@Override
public void register() {
map(Type.VAR_INT); // Id
map(Type.VAR_INT); // Window Type
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
}
});
}
public void registerTabList(C packetType) {
protocol.registerClientbound(packetType, wrapper -> {
processText(wrapper.passthrough(Type.COMPONENT));
processText(wrapper.passthrough(Type.COMPONENT));
});
}
public void registerCombatKill(C packetType) {
protocol.registerClientbound(packetType, new PacketHandlers() {
@Override
public void register() {
map(Type.VAR_INT);
map(Type.INT);
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
}
});
}
public void registerCombatKill1_20(C packetType) {
protocol.registerClientbound(packetType, new PacketHandlers() {
@Override
public void register() {
map(Type.VAR_INT); // Duration
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
}
});
}
@Override @Override
protected void handleTranslate(JsonObject root, String translate) { protected void handleTranslate(final JsonObject root, final String translate) {
String newTranslate = mappedTranslationKey(translate); final String newTranslate = mappedTranslationKey(translate);
if (newTranslate != null) { if (newTranslate != null) {
root.addProperty("translate", newTranslate); root.addProperty("translate", newTranslate);
} }
} }
public @Nullable String mappedTranslationKey(final String translationKey) { public @Nullable String mappedTranslationKey(final String translationKey) {
return newTranslatables.get(translationKey); return translatables.get(translationKey);
} }
} }

Datei anzeigen

@ -29,7 +29,7 @@ import com.viaversion.viaversion.rewriter.ComponentRewriter;
public class ChatPackets1_12 extends RewriterBase<Protocol1_11_1To1_12> { public class ChatPackets1_12 extends RewriterBase<Protocol1_11_1To1_12> {
public static final ComponentRewriter<ClientboundPackets1_12> COMPONENT_REWRITER = new ComponentRewriter<ClientboundPackets1_12>() { public static final ComponentRewriter<ClientboundPackets1_12> COMPONENT_REWRITER = new ComponentRewriter<ClientboundPackets1_12>(null, ComponentRewriter.ReadType.JSON) {
@Override @Override
public void processText(JsonElement element) { public void processText(JsonElement element) {
super.processText(element); super.processText(element);

Datei anzeigen

@ -47,6 +47,7 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPacke
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_13, ClientboundPackets1_12_1, ServerboundPackets1_13, ServerboundPackets1_12_1> { public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_13, ClientboundPackets1_12_1, ServerboundPackets1_13, ServerboundPackets1_12_1> {
@ -54,7 +55,7 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_
public static final BackwardsMappings MAPPINGS = new BackwardsMappings(); public static final BackwardsMappings MAPPINGS = new BackwardsMappings();
private final EntityPackets1_13 entityRewriter = new EntityPackets1_13(this); private final EntityPackets1_13 entityRewriter = new EntityPackets1_13(this);
private final BlockItemPackets1_13 blockItemPackets = new BlockItemPackets1_13(this); private final BlockItemPackets1_13 blockItemPackets = new BlockItemPackets1_13(this);
private final TranslatableRewriter<ClientboundPackets1_13> translatableRewriter = new TranslatableRewriter<ClientboundPackets1_13>(this) { private final TranslatableRewriter<ClientboundPackets1_13> translatableRewriter = new TranslatableRewriter<ClientboundPackets1_13>(this, ComponentRewriter.ReadType.JSON) {
@Override @Override
protected void handleTranslate(JsonObject root, String translate) { protected void handleTranslate(JsonObject root, String translate) {
String mappedKey = mappedTranslationKey(translate); String mappedKey = mappedTranslationKey(translate);
@ -63,7 +64,7 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_
} }
} }
}; };
private final TranslatableRewriter<ClientboundPackets1_13> translatableToLegacyRewriter = new TranslatableRewriter<ClientboundPackets1_13>(this) { private final TranslatableRewriter<ClientboundPackets1_13> translatableToLegacyRewriter = new TranslatableRewriter<ClientboundPackets1_13>(this, ComponentRewriter.ReadType.JSON) {
@Override @Override
protected void handleTranslate(JsonObject root, String translate) { protected void handleTranslate(JsonObject root, String translate) {
String mappedKey = mappedTranslationKey(translate); String mappedKey = mappedTranslationKey(translate);
@ -89,7 +90,7 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_
translatableRewriter.registerBossBar(ClientboundPackets1_13.BOSSBAR); translatableRewriter.registerBossBar(ClientboundPackets1_13.BOSSBAR);
translatableRewriter.registerComponentPacket(ClientboundPackets1_13.CHAT_MESSAGE); translatableRewriter.registerComponentPacket(ClientboundPackets1_13.CHAT_MESSAGE);
translatableRewriter.registerLegacyOpenWindow(ClientboundPackets1_13.OPEN_WINDOW); translatableRewriter.registerLegacyOpenWindow(ClientboundPackets1_13.OPEN_WINDOW);
translatableRewriter.registerDisconnect(ClientboundPackets1_13.DISCONNECT); translatableRewriter.registerComponentPacket(ClientboundPackets1_13.DISCONNECT);
translatableRewriter.registerCombatEvent(ClientboundPackets1_13.COMBAT_EVENT); translatableRewriter.registerCombatEvent(ClientboundPackets1_13.COMBAT_EVENT);
translatableRewriter.registerTitle(ClientboundPackets1_13.TITLE); translatableRewriter.registerTitle(ClientboundPackets1_13.TITLE);
translatableRewriter.registerTabList(ClientboundPackets1_13.TAB_LIST); translatableRewriter.registerTabList(ClientboundPackets1_13.TAB_LIST);

Datei anzeigen

@ -37,6 +37,7 @@ import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPacke
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter;
public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_14, ClientboundPackets1_13, ServerboundPackets1_14, ServerboundPackets1_13> { public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_14, ClientboundPackets1_13, ServerboundPackets1_14, ServerboundPackets1_13> {
@ -44,7 +45,7 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.14", "1.13.2", Protocol1_14To1_13_2.class); public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.14", "1.13.2", Protocol1_14To1_13_2.class);
private final EntityPackets1_14 entityRewriter = new EntityPackets1_14(this); private final EntityPackets1_14 entityRewriter = new EntityPackets1_14(this);
private final BlockItemPackets1_14 blockItemPackets = new BlockItemPackets1_14(this); private final BlockItemPackets1_14 blockItemPackets = new BlockItemPackets1_14(this);
private final TranslatableRewriter<ClientboundPackets1_14> translatableRewriter = new TranslatableRewriter<>(this); private final TranslatableRewriter<ClientboundPackets1_14> translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON);
public Protocol1_13_2To1_14() { public Protocol1_13_2To1_14() {
super(ClientboundPackets1_14.class, ClientboundPackets1_13.class, ServerboundPackets1_14.class, ServerboundPackets1_13.class); super(ClientboundPackets1_14.class, ClientboundPackets1_13.class, ServerboundPackets1_14.class, ServerboundPackets1_13.class);
@ -57,7 +58,7 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
translatableRewriter.registerBossBar(ClientboundPackets1_14.BOSSBAR); translatableRewriter.registerBossBar(ClientboundPackets1_14.BOSSBAR);
translatableRewriter.registerComponentPacket(ClientboundPackets1_14.CHAT_MESSAGE); translatableRewriter.registerComponentPacket(ClientboundPackets1_14.CHAT_MESSAGE);
translatableRewriter.registerCombatEvent(ClientboundPackets1_14.COMBAT_EVENT); translatableRewriter.registerCombatEvent(ClientboundPackets1_14.COMBAT_EVENT);
translatableRewriter.registerDisconnect(ClientboundPackets1_14.DISCONNECT); translatableRewriter.registerComponentPacket(ClientboundPackets1_14.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_14.TAB_LIST); translatableRewriter.registerTabList(ClientboundPackets1_14.TAB_LIST);
translatableRewriter.registerTitle(ClientboundPackets1_14.TITLE); translatableRewriter.registerTitle(ClientboundPackets1_14.TITLE);
translatableRewriter.registerPing(); translatableRewriter.registerPing();

Datei anzeigen

@ -41,6 +41,7 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.rewriter.TagRewriter;
@ -49,7 +50,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.13.2", "1.13", Protocol1_13_1To1_13.class); public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.13.2", "1.13", Protocol1_13_1To1_13.class);
private final EntityPackets1_13_1 entityRewriter = new EntityPackets1_13_1(this); private final EntityPackets1_13_1 entityRewriter = new EntityPackets1_13_1(this);
private final InventoryPackets1_13_1 itemRewriter = new InventoryPackets1_13_1(this); private final InventoryPackets1_13_1 itemRewriter = new InventoryPackets1_13_1(this);
private final TranslatableRewriter<ClientboundPackets1_13> translatableRewriter = new TranslatableRewriter<>(this); private final TranslatableRewriter<ClientboundPackets1_13> translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON);
public Protocol1_13To1_13_1() { public Protocol1_13To1_13_1() {
super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class); super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class);
@ -63,7 +64,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
translatableRewriter.registerComponentPacket(ClientboundPackets1_13.CHAT_MESSAGE); translatableRewriter.registerComponentPacket(ClientboundPackets1_13.CHAT_MESSAGE);
translatableRewriter.registerCombatEvent(ClientboundPackets1_13.COMBAT_EVENT); translatableRewriter.registerCombatEvent(ClientboundPackets1_13.COMBAT_EVENT);
translatableRewriter.registerDisconnect(ClientboundPackets1_13.DISCONNECT); translatableRewriter.registerComponentPacket(ClientboundPackets1_13.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_13.TAB_LIST); translatableRewriter.registerTabList(ClientboundPackets1_13.TAB_LIST);
translatableRewriter.registerTitle(ClientboundPackets1_13.TITLE); translatableRewriter.registerTitle(ClientboundPackets1_13.TITLE);
translatableRewriter.registerPing(); translatableRewriter.registerPing();

Datei anzeigen

@ -35,6 +35,7 @@ import com.viaversion.viaversion.protocols.protocol1_14_4to1_14_3.ClientboundPac
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15; import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4; import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.rewriter.TagRewriter;
@ -43,7 +44,7 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol<ClientboundPackets1_
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.15", "1.14", Protocol1_15To1_14_4.class); public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.15", "1.14", Protocol1_15To1_14_4.class);
private final EntityPackets1_15 entityRewriter = new EntityPackets1_15(this); private final EntityPackets1_15 entityRewriter = new EntityPackets1_15(this);
private final BlockItemPackets1_15 blockItemPackets = new BlockItemPackets1_15(this); private final BlockItemPackets1_15 blockItemPackets = new BlockItemPackets1_15(this);
private final TranslatableRewriter<ClientboundPackets1_15> translatableRewriter = new TranslatableRewriter<>(this); private final TranslatableRewriter<ClientboundPackets1_15> translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON);
public Protocol1_14_4To1_15() { public Protocol1_14_4To1_15() {
super(ClientboundPackets1_15.class, ClientboundPackets1_14_4.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class); super(ClientboundPackets1_15.class, ClientboundPackets1_14_4.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
@ -56,7 +57,7 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol<ClientboundPackets1_
translatableRewriter.registerBossBar(ClientboundPackets1_15.BOSSBAR); translatableRewriter.registerBossBar(ClientboundPackets1_15.BOSSBAR);
translatableRewriter.registerComponentPacket(ClientboundPackets1_15.CHAT_MESSAGE); translatableRewriter.registerComponentPacket(ClientboundPackets1_15.CHAT_MESSAGE);
translatableRewriter.registerCombatEvent(ClientboundPackets1_15.COMBAT_EVENT); translatableRewriter.registerCombatEvent(ClientboundPackets1_15.COMBAT_EVENT);
translatableRewriter.registerDisconnect(ClientboundPackets1_15.DISCONNECT); translatableRewriter.registerComponentPacket(ClientboundPackets1_15.DISCONNECT);
translatableRewriter.registerOpenWindow(ClientboundPackets1_15.OPEN_WINDOW); translatableRewriter.registerOpenWindow(ClientboundPackets1_15.OPEN_WINDOW);
translatableRewriter.registerTabList(ClientboundPackets1_15.TAB_LIST); translatableRewriter.registerTabList(ClientboundPackets1_15.TAB_LIST);
translatableRewriter.registerTitle(ClientboundPackets1_15.TITLE); translatableRewriter.registerTitle(ClientboundPackets1_15.TITLE);

Datei anzeigen

@ -40,6 +40,7 @@ import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPacke
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.rewriter.TagRewriter;
import com.viaversion.viaversion.util.GsonUtil; import com.viaversion.viaversion.util.GsonUtil;
@ -62,7 +63,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
translatableRewriter.registerBossBar(ClientboundPackets1_16.BOSSBAR); translatableRewriter.registerBossBar(ClientboundPackets1_16.BOSSBAR);
translatableRewriter.registerCombatEvent(ClientboundPackets1_16.COMBAT_EVENT); translatableRewriter.registerCombatEvent(ClientboundPackets1_16.COMBAT_EVENT);
translatableRewriter.registerDisconnect(ClientboundPackets1_16.DISCONNECT); translatableRewriter.registerComponentPacket(ClientboundPackets1_16.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_16.TAB_LIST); translatableRewriter.registerTabList(ClientboundPackets1_16.TAB_LIST);
translatableRewriter.registerTitle(ClientboundPackets1_16.TITLE); translatableRewriter.registerTitle(ClientboundPackets1_16.TITLE);
translatableRewriter.registerPing(); translatableRewriter.registerPing();

Datei anzeigen

@ -51,7 +51,7 @@ public class TranslatableRewriter1_16 extends TranslatableRewriter<ClientboundPa
}; };
public TranslatableRewriter1_16(Protocol1_15_2To1_16 protocol) { public TranslatableRewriter1_16(Protocol1_15_2To1_16 protocol) {
super(protocol); super(protocol, ReadType.JSON);
} }
@Override @Override

Datei anzeigen

@ -37,6 +37,7 @@ import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2; import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.rewriter.TagRewriter;
@ -45,7 +46,7 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol<ClientboundPackets
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.16.2", "1.16", Protocol1_16_2To1_16_1.class); public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.16.2", "1.16", Protocol1_16_2To1_16_1.class);
private final EntityPackets1_16_2 entityRewriter = new EntityPackets1_16_2(this); private final EntityPackets1_16_2 entityRewriter = new EntityPackets1_16_2(this);
private final BlockItemPackets1_16_2 blockItemPackets = new BlockItemPackets1_16_2(this); private final BlockItemPackets1_16_2 blockItemPackets = new BlockItemPackets1_16_2(this);
private final TranslatableRewriter<ClientboundPackets1_16_2> translatableRewriter = new TranslatableRewriter<>(this); private final TranslatableRewriter<ClientboundPackets1_16_2> translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON);
public Protocol1_16_1To1_16_2() { public Protocol1_16_1To1_16_2() {
super(ClientboundPackets1_16_2.class, ClientboundPackets1_16.class, ServerboundPackets1_16_2.class, ServerboundPackets1_16.class); super(ClientboundPackets1_16_2.class, ClientboundPackets1_16.class, ServerboundPackets1_16_2.class, ServerboundPackets1_16.class);
@ -57,7 +58,7 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol<ClientboundPackets
translatableRewriter.registerBossBar(ClientboundPackets1_16_2.BOSSBAR); translatableRewriter.registerBossBar(ClientboundPackets1_16_2.BOSSBAR);
translatableRewriter.registerCombatEvent(ClientboundPackets1_16_2.COMBAT_EVENT); translatableRewriter.registerCombatEvent(ClientboundPackets1_16_2.COMBAT_EVENT);
translatableRewriter.registerDisconnect(ClientboundPackets1_16_2.DISCONNECT); translatableRewriter.registerComponentPacket(ClientboundPackets1_16_2.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_16_2.TAB_LIST); translatableRewriter.registerTabList(ClientboundPackets1_16_2.TAB_LIST);
translatableRewriter.registerTitle(ClientboundPackets1_16_2.TITLE); translatableRewriter.registerTitle(ClientboundPackets1_16_2.TITLE);
translatableRewriter.registerOpenWindow(ClientboundPackets1_16_2.OPEN_WINDOW); translatableRewriter.registerOpenWindow(ClientboundPackets1_16_2.OPEN_WINDOW);

Datei anzeigen

@ -41,6 +41,7 @@ import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPac
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ClientboundPackets1_17; import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ClientboundPackets1_17;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4; import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17; import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.rewriter.IdRewriteFunction; import com.viaversion.viaversion.rewriter.IdRewriteFunction;
import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.rewriter.TagRewriter;
@ -57,7 +58,7 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol<ClientboundPac
private static final int[] EMPTY_ARRAY = {}; private static final int[] EMPTY_ARRAY = {};
private final EntityPackets1_17 entityRewriter = new EntityPackets1_17(this); private final EntityPackets1_17 entityRewriter = new EntityPackets1_17(this);
private final BlockItemPackets1_17 blockItemPackets = new BlockItemPackets1_17(this); private final BlockItemPackets1_17 blockItemPackets = new BlockItemPackets1_17(this);
private final TranslatableRewriter<ClientboundPackets1_17> translatableRewriter = new TranslatableRewriter<>(this); private final TranslatableRewriter<ClientboundPackets1_17> translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON);
public Protocol1_16_4To1_17() { public Protocol1_16_4To1_17() {
super(ClientboundPackets1_17.class, ClientboundPackets1_16_2.class, ServerboundPackets1_17.class, ServerboundPackets1_16_2.class); super(ClientboundPackets1_17.class, ClientboundPackets1_16_2.class, ServerboundPackets1_17.class, ServerboundPackets1_16_2.class);
@ -69,7 +70,7 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol<ClientboundPac
translatableRewriter.registerComponentPacket(ClientboundPackets1_17.CHAT_MESSAGE); translatableRewriter.registerComponentPacket(ClientboundPackets1_17.CHAT_MESSAGE);
translatableRewriter.registerBossBar(ClientboundPackets1_17.BOSSBAR); translatableRewriter.registerBossBar(ClientboundPackets1_17.BOSSBAR);
translatableRewriter.registerDisconnect(ClientboundPackets1_17.DISCONNECT); translatableRewriter.registerComponentPacket(ClientboundPackets1_17.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_17.TAB_LIST); translatableRewriter.registerTabList(ClientboundPackets1_17.TAB_LIST);
translatableRewriter.registerOpenWindow(ClientboundPackets1_17.OPEN_WINDOW); translatableRewriter.registerOpenWindow(ClientboundPackets1_17.OPEN_WINDOW);
translatableRewriter.registerPing(); translatableRewriter.registerPing();

Datei anzeigen

@ -33,6 +33,7 @@ import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1; import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17; import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18; import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.rewriter.TagRewriter;
public final class Protocol1_17_1To1_18 extends BackwardsProtocol<ClientboundPackets1_18, ClientboundPackets1_17_1, ServerboundPackets1_17, ServerboundPackets1_17> { public final class Protocol1_17_1To1_18 extends BackwardsProtocol<ClientboundPackets1_18, ClientboundPackets1_17_1, ServerboundPackets1_17, ServerboundPackets1_17> {
@ -40,7 +41,7 @@ public final class Protocol1_17_1To1_18 extends BackwardsProtocol<ClientboundPac
private static final BackwardsMappings MAPPINGS = new BackwardsMappings(); private static final BackwardsMappings MAPPINGS = new BackwardsMappings();
private final EntityPackets1_18 entityRewriter = new EntityPackets1_18(this); private final EntityPackets1_18 entityRewriter = new EntityPackets1_18(this);
private final BlockItemPackets1_18 itemRewriter = new BlockItemPackets1_18(this); private final BlockItemPackets1_18 itemRewriter = new BlockItemPackets1_18(this);
private final TranslatableRewriter<ClientboundPackets1_18> translatableRewriter = new TranslatableRewriter<>(this); private final TranslatableRewriter<ClientboundPackets1_18> translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON);
public Protocol1_17_1To1_18() { public Protocol1_17_1To1_18() {
super(ClientboundPackets1_18.class, ClientboundPackets1_17_1.class, ServerboundPackets1_17.class, ServerboundPackets1_17.class); super(ClientboundPackets1_18.class, ClientboundPackets1_17_1.class, ServerboundPackets1_17.class, ServerboundPackets1_17.class);
@ -55,7 +56,7 @@ public final class Protocol1_17_1To1_18 extends BackwardsProtocol<ClientboundPac
translatableRewriter.registerComponentPacket(ClientboundPackets1_18.TITLE_TEXT); translatableRewriter.registerComponentPacket(ClientboundPackets1_18.TITLE_TEXT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_18.TITLE_SUBTITLE); translatableRewriter.registerComponentPacket(ClientboundPackets1_18.TITLE_SUBTITLE);
translatableRewriter.registerBossBar(ClientboundPackets1_18.BOSSBAR); translatableRewriter.registerBossBar(ClientboundPackets1_18.BOSSBAR);
translatableRewriter.registerDisconnect(ClientboundPackets1_18.DISCONNECT); translatableRewriter.registerComponentPacket(ClientboundPackets1_18.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_18.TAB_LIST); translatableRewriter.registerTabList(ClientboundPackets1_18.TAB_LIST);
translatableRewriter.registerOpenWindow(ClientboundPackets1_18.OPEN_WINDOW); translatableRewriter.registerOpenWindow(ClientboundPackets1_18.OPEN_WINDOW);
translatableRewriter.registerCombatKill(ClientboundPackets1_18.COMBAT_KILL); translatableRewriter.registerCombatKill(ClientboundPackets1_18.COMBAT_KILL);

Datei anzeigen

@ -45,6 +45,7 @@ import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.Protocol1_19_1To
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPackets1_19; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPackets1_19;
import com.viaversion.viaversion.rewriter.CommandRewriter; import com.viaversion.viaversion.rewriter.CommandRewriter;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.rewriter.TagRewriter;
import java.time.Instant; import java.time.Instant;
@ -57,7 +58,7 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
private static final byte[] EMPTY_BYTES = new byte[0]; private static final byte[] EMPTY_BYTES = new byte[0];
private final EntityPackets1_19 entityRewriter = new EntityPackets1_19(this); private final EntityPackets1_19 entityRewriter = new EntityPackets1_19(this);
private final BlockItemPackets1_19 blockItemPackets = new BlockItemPackets1_19(this); private final BlockItemPackets1_19 blockItemPackets = new BlockItemPackets1_19(this);
private final TranslatableRewriter<ClientboundPackets1_19> translatableRewriter = new TranslatableRewriter<>(this); private final TranslatableRewriter<ClientboundPackets1_19> translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON);
public Protocol1_18_2To1_19() { public Protocol1_18_2To1_19() {
super(ClientboundPackets1_19.class, ClientboundPackets1_18.class, ServerboundPackets1_19.class, ServerboundPackets1_17.class); super(ClientboundPackets1_19.class, ClientboundPackets1_18.class, ServerboundPackets1_19.class, ServerboundPackets1_17.class);
@ -71,7 +72,7 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
translatableRewriter.registerComponentPacket(ClientboundPackets1_19.TITLE_TEXT); translatableRewriter.registerComponentPacket(ClientboundPackets1_19.TITLE_TEXT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_19.TITLE_SUBTITLE); translatableRewriter.registerComponentPacket(ClientboundPackets1_19.TITLE_SUBTITLE);
translatableRewriter.registerBossBar(ClientboundPackets1_19.BOSSBAR); translatableRewriter.registerBossBar(ClientboundPackets1_19.BOSSBAR);
translatableRewriter.registerDisconnect(ClientboundPackets1_19.DISCONNECT); translatableRewriter.registerComponentPacket(ClientboundPackets1_19.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_19.TAB_LIST); translatableRewriter.registerTabList(ClientboundPackets1_19.TAB_LIST);
translatableRewriter.registerOpenWindow(ClientboundPackets1_19.OPEN_WINDOW); translatableRewriter.registerOpenWindow(ClientboundPackets1_19.OPEN_WINDOW);
translatableRewriter.registerCombatKill(ClientboundPackets1_19.COMBAT_KILL); translatableRewriter.registerCombatKill(ClientboundPackets1_19.COMBAT_KILL);

Datei anzeigen

@ -48,6 +48,7 @@ import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ServerboundPacke
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3; import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3;
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ServerboundPackets1_19_3; import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ServerboundPackets1_19_3;
import com.viaversion.viaversion.rewriter.CommandRewriter; import com.viaversion.viaversion.rewriter.CommandRewriter;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.rewriter.TagRewriter;
import com.viaversion.viaversion.util.CipherUtil; import com.viaversion.viaversion.util.CipherUtil;
@ -60,7 +61,7 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
public static final ByteArrayType SIGNATURE_BYTES_TYPE = new ByteArrayType(256); public static final ByteArrayType SIGNATURE_BYTES_TYPE = new ByteArrayType(256);
private final EntityPackets1_19_3 entityRewriter = new EntityPackets1_19_3(this); private final EntityPackets1_19_3 entityRewriter = new EntityPackets1_19_3(this);
private final BlockItemPackets1_19_3 itemRewriter = new BlockItemPackets1_19_3(this); private final BlockItemPackets1_19_3 itemRewriter = new BlockItemPackets1_19_3(this);
private final TranslatableRewriter<ClientboundPackets1_19_3> translatableRewriter = new TranslatableRewriter<>(this); private final TranslatableRewriter<ClientboundPackets1_19_3> translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON);
public Protocol1_19_1To1_19_3() { public Protocol1_19_1To1_19_3() {
super(ClientboundPackets1_19_3.class, ClientboundPackets1_19_1.class, ServerboundPackets1_19_3.class, ServerboundPackets1_19_1.class); super(ClientboundPackets1_19_3.class, ClientboundPackets1_19_1.class, ServerboundPackets1_19_3.class, ServerboundPackets1_19_1.class);
@ -75,7 +76,7 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_3.TITLE_TEXT); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_3.TITLE_TEXT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_3.TITLE_SUBTITLE); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_3.TITLE_SUBTITLE);
translatableRewriter.registerBossBar(ClientboundPackets1_19_3.BOSSBAR); translatableRewriter.registerBossBar(ClientboundPackets1_19_3.BOSSBAR);
translatableRewriter.registerDisconnect(ClientboundPackets1_19_3.DISCONNECT); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_3.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_19_3.TAB_LIST); translatableRewriter.registerTabList(ClientboundPackets1_19_3.TAB_LIST);
translatableRewriter.registerOpenWindow(ClientboundPackets1_19_3.OPEN_WINDOW); translatableRewriter.registerOpenWindow(ClientboundPackets1_19_3.OPEN_WINDOW);
translatableRewriter.registerCombatKill(ClientboundPackets1_19_3.COMBAT_KILL); translatableRewriter.registerCombatKill(ClientboundPackets1_19_3.COMBAT_KILL);

Datei anzeigen

@ -35,6 +35,7 @@ import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPac
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.Protocol1_19_4To1_19_3; import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.Protocol1_19_4To1_19_3;
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ServerboundPackets1_19_4; import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ServerboundPackets1_19_4;
import com.viaversion.viaversion.rewriter.CommandRewriter; import com.viaversion.viaversion.rewriter.CommandRewriter;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.rewriter.TagRewriter;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
@ -45,7 +46,7 @@ public final class Protocol1_19_3To1_19_4 extends BackwardsProtocol<ClientboundP
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.19.4", "1.19.3", Protocol1_19_4To1_19_3.class); public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.19.4", "1.19.3", Protocol1_19_4To1_19_3.class);
private final EntityPackets1_19_4 entityRewriter = new EntityPackets1_19_4(this); private final EntityPackets1_19_4 entityRewriter = new EntityPackets1_19_4(this);
private final BlockItemPackets1_19_4 itemRewriter = new BlockItemPackets1_19_4(this); private final BlockItemPackets1_19_4 itemRewriter = new BlockItemPackets1_19_4(this);
private final TranslatableRewriter<ClientboundPackets1_19_4> translatableRewriter = new TranslatableRewriter<>(this); private final TranslatableRewriter<ClientboundPackets1_19_4> translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON);
public Protocol1_19_3To1_19_4() { public Protocol1_19_3To1_19_4() {
super(ClientboundPackets1_19_4.class, ClientboundPackets1_19_3.class, ServerboundPackets1_19_4.class, ServerboundPackets1_19_3.class); super(ClientboundPackets1_19_4.class, ClientboundPackets1_19_3.class, ServerboundPackets1_19_4.class, ServerboundPackets1_19_3.class);
@ -65,7 +66,7 @@ public final class Protocol1_19_3To1_19_4 extends BackwardsProtocol<ClientboundP
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.TITLE_TEXT); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.TITLE_TEXT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.TITLE_SUBTITLE); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.TITLE_SUBTITLE);
translatableRewriter.registerBossBar(ClientboundPackets1_19_4.BOSSBAR); translatableRewriter.registerBossBar(ClientboundPackets1_19_4.BOSSBAR);
translatableRewriter.registerDisconnect(ClientboundPackets1_19_4.DISCONNECT); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_19_4.TAB_LIST); translatableRewriter.registerTabList(ClientboundPackets1_19_4.TAB_LIST);
translatableRewriter.registerCombatKill(ClientboundPackets1_19_4.COMBAT_KILL); translatableRewriter.registerCombatKill(ClientboundPackets1_19_4.COMBAT_KILL);
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.SYSTEM_CHAT); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.SYSTEM_CHAT);

Datei anzeigen

@ -30,6 +30,7 @@ import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4; import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4;
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ServerboundPackets1_19_4; import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ServerboundPackets1_19_4;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.rewriter.TagRewriter;
import java.util.Arrays; import java.util.Arrays;
@ -37,7 +38,7 @@ import java.util.Arrays;
public final class Protocol1_19_4To1_20 extends BackwardsProtocol<ClientboundPackets1_19_4, ClientboundPackets1_19_4, ServerboundPackets1_19_4, ServerboundPackets1_19_4> { public final class Protocol1_19_4To1_20 extends BackwardsProtocol<ClientboundPackets1_19_4, ClientboundPackets1_19_4, ServerboundPackets1_19_4, ServerboundPackets1_19_4> {
public static final BackwardsMappings MAPPINGS = new BackwardsMappings(); public static final BackwardsMappings MAPPINGS = new BackwardsMappings();
private final TranslatableRewriter<ClientboundPackets1_19_4> translatableRewriter = new TranslatableRewriter<>(this); private final TranslatableRewriter<ClientboundPackets1_19_4> translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON);
private final EntityPackets1_20 entityRewriter = new EntityPackets1_20(this); private final EntityPackets1_20 entityRewriter = new EntityPackets1_20(this);
private final BlockItemPackets1_20 itemRewriter = new BlockItemPackets1_20(this); private final BlockItemPackets1_20 itemRewriter = new BlockItemPackets1_20(this);
@ -65,7 +66,7 @@ public final class Protocol1_19_4To1_20 extends BackwardsProtocol<ClientboundPac
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.TITLE_TEXT); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.TITLE_TEXT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.TITLE_SUBTITLE); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.TITLE_SUBTITLE);
translatableRewriter.registerBossBar(ClientboundPackets1_19_4.BOSSBAR); translatableRewriter.registerBossBar(ClientboundPackets1_19_4.BOSSBAR);
translatableRewriter.registerDisconnect(ClientboundPackets1_19_4.DISCONNECT); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_19_4.TAB_LIST); translatableRewriter.registerTabList(ClientboundPackets1_19_4.TAB_LIST);
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.SYSTEM_CHAT); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.SYSTEM_CHAT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.DISGUISED_CHAT); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.DISGUISED_CHAT);

Datei anzeigen

@ -55,6 +55,7 @@ import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ServerboundPacke
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPackets1_19; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPackets1_19;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.packets.EntityPackets; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.packets.EntityPackets;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.util.CipherUtil; import com.viaversion.viaversion.util.CipherUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -68,7 +69,7 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol<ClientboundPac
private static final UUID ZERO_UUID = new UUID(0, 0); private static final UUID ZERO_UUID = new UUID(0, 0);
private static final byte[] EMPTY_BYTES = new byte[0]; private static final byte[] EMPTY_BYTES = new byte[0];
private final EntityPackets1_19_1 entityRewriter = new EntityPackets1_19_1(this); private final EntityPackets1_19_1 entityRewriter = new EntityPackets1_19_1(this);
private final TranslatableRewriter<ClientboundPackets1_19_1> translatableRewriter = new TranslatableRewriter<>(this); private final TranslatableRewriter<ClientboundPackets1_19_1> translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON);
public Protocol1_19To1_19_1() { public Protocol1_19To1_19_1() {
super(ClientboundPackets1_19_1.class, ClientboundPackets1_19.class, ServerboundPackets1_19_1.class, ServerboundPackets1_19.class); super(ClientboundPackets1_19_1.class, ClientboundPackets1_19.class, ServerboundPackets1_19_1.class, ServerboundPackets1_19.class);
@ -80,7 +81,7 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol<ClientboundPac
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_1.TITLE_TEXT); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_1.TITLE_TEXT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_1.TITLE_SUBTITLE); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_1.TITLE_SUBTITLE);
translatableRewriter.registerBossBar(ClientboundPackets1_19_1.BOSSBAR); translatableRewriter.registerBossBar(ClientboundPackets1_19_1.BOSSBAR);
translatableRewriter.registerDisconnect(ClientboundPackets1_19_1.DISCONNECT); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_1.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_19_1.TAB_LIST); translatableRewriter.registerTabList(ClientboundPackets1_19_1.TAB_LIST);
translatableRewriter.registerOpenWindow(ClientboundPackets1_19_1.OPEN_WINDOW); translatableRewriter.registerOpenWindow(ClientboundPackets1_19_1.OPEN_WINDOW);
translatableRewriter.registerCombatKill(ClientboundPackets1_19_1.COMBAT_KILL); translatableRewriter.registerCombatKill(ClientboundPackets1_19_1.COMBAT_KILL);

Datei anzeigen

@ -3,7 +3,7 @@ metadata.format.version = "1.1"
[versions] [versions]
# ViaVersion # ViaVersion
viaver = "4.9.0-23w40a-SNAPSHOT" viaver = "4.9.0-23w41a-SNAPSHOT"
# Common provided # Common provided
netty = "4.0.20.Final" netty = "4.0.20.Final"

Datei anzeigen

@ -30,6 +30,7 @@ setupViaSubproject("bungee")
setupViaSubproject("velocity") setupViaSubproject("velocity")
setupViaSubproject("sponge") setupViaSubproject("sponge")
setupViaSubproject("fabric") setupViaSubproject("fabric")
setupViaSubproject("template")
setupSubproject("viabackwards") { setupSubproject("viabackwards") {
projectDir = file("universal") projectDir = file("universal")

3
template/build.gradle.kts Normale Datei
Datei anzeigen

@ -0,0 +1,3 @@
dependencies {
implementation(projects.viabackwardsCommon)
}

Datei anzeigen

@ -0,0 +1,124 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2023 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.template.protocol;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.BackwardsMappings;
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
import com.viaversion.viabackwards.template.protocol.rewriter.BlockItemPacketRewriter1_99;
import com.viaversion.viabackwards.template.protocol.rewriter.EntityPacketRewriter1_99;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundConfigurationPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundConfigurationPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.Protocol1_20_3To1_20_2;
import com.viaversion.viaversion.rewriter.ComponentRewriter.ReadType;
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter;
import org.checkerframework.checker.nullness.qual.Nullable;
// Placeholders to replace (in the entire package):
// Protocol1_98To_99, EntityPacketRewriter1_99, BlockItemPacketRewriter1_99
// Protocol1_20_3To1_20_2 (the ViaVersion protocol class the mappings depend on)
// ClientboundPackets1_20_2
// ServerboundPackets1_20_2
// ClientboundConfigurationPackets1_20_2
// ServerboundConfigurationPackets1_20_2
// Entity1_19_4Types (UNMAPPED type)
// 1.99, 1.98
public final class Protocol1_98To_99 extends BackwardsProtocol<ClientboundPackets1_20_2, ClientboundPackets1_20_2, ServerboundPackets1_20_2, ServerboundPackets1_20_2> {
// ViaBackwards uses its own mappings and also needs a translatablerewriter for translation mappings
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.99", "1.98", Protocol1_20_3To1_20_2.class);
private final EntityPacketRewriter1_99 entityRewriter = new EntityPacketRewriter1_99(this);
private final BlockItemPacketRewriter1_99 itemRewriter = new BlockItemPacketRewriter1_99(this);
private final TranslatableRewriter<ClientboundPackets1_20_2> translatableRewriter = new TranslatableRewriter<>(this, ReadType.NBT);
public Protocol1_98To_99() {
super(ClientboundPackets1_20_2.class, ClientboundPackets1_20_2.class, ServerboundPackets1_20_2.class, ServerboundPackets1_20_2.class);
}
@Override
protected void registerPackets() {
super.registerPackets();
final TagRewriter<ClientboundPackets1_20_2> tagRewriter = new TagRewriter<>(this);
tagRewriter.registerGeneric(ClientboundPackets1_20_2.TAGS);
final SoundRewriter<ClientboundPackets1_20_2> soundRewriter = new SoundRewriter<>(this);
soundRewriter.register1_19_3Sound(ClientboundPackets1_20_2.SOUND);
soundRewriter.registerSound(ClientboundPackets1_20_2.ENTITY_SOUND);
soundRewriter.registerStopSound(ClientboundPackets1_20_2.STOP_SOUND);
new StatisticsRewriter<>(this).register(ClientboundPackets1_20_2.STATISTICS);
// Registers translatable mappings (missing a whole bunch still)
//translatableRewriter.registerOpenWindow(ClientboundPackets1_20_2.OPEN_WINDOW); // Handled by registerOpenWindow in item rewriters
translatableRewriter.registerComponentPacket(ClientboundPackets1_20_2.ACTIONBAR);
translatableRewriter.registerComponentPacket(ClientboundPackets1_20_2.TITLE_TEXT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_20_2.TITLE_SUBTITLE);
translatableRewriter.registerBossBar(ClientboundPackets1_20_2.BOSSBAR);
translatableRewriter.registerComponentPacket(ClientboundPackets1_20_2.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_20_2.TAB_LIST);
translatableRewriter.registerCombatKill1_20(ClientboundPackets1_20_2.COMBAT_KILL);
translatableRewriter.registerComponentPacket(ClientboundPackets1_20_2.SYSTEM_CHAT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_20_2.DISGUISED_CHAT);
translatableRewriter.registerPing();
}
@Override
public void init(final UserConnection user) {
addEntityTracker(user, new EntityTrackerBase(user, Entity1_19_4Types.PLAYER));
}
@Override
public BackwardsMappings getMappingData() {
return MAPPINGS;
}
@Override
public EntityPacketRewriter1_99 getEntityRewriter() {
return entityRewriter;
}
@Override
public BlockItemPacketRewriter1_99 getItemRewriter() {
return itemRewriter;
}
@Nullable
public TranslatableRewriter<ClientboundPackets1_20_2> getTranslatableRewriter() {
return translatableRewriter;
}
@Override
protected ClientboundPacketType clientboundFinishConfigurationPacket() {
return ClientboundConfigurationPackets1_20_2.FINISH_CONFIGURATION;
}
@Override
protected ServerboundPacketType serverboundFinishConfigurationPacket() {
return ServerboundConfigurationPackets1_20_2.FINISH_CONFIGURATION;
}
}

Datei anzeigen

@ -0,0 +1,61 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2023 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.template.protocol.rewriter;
import com.viaversion.viabackwards.api.rewriters.ItemRewriter;
import com.viaversion.viabackwards.template.protocol.Protocol1_98To_99;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.rewriter.RecipeRewriter1_20_2;
import com.viaversion.viaversion.rewriter.BlockRewriter;
// To replace if needed:
// Chunk1_18Type
// RecipeRewriter1_20_2
public final class BlockItemPacketRewriter1_99 extends ItemRewriter<ClientboundPackets1_20_2, ServerboundPackets1_20_2, Protocol1_98To_99> {
public BlockItemPacketRewriter1_99(final Protocol1_98To_99 protocol) {
super(protocol, Type.ITEM1_20_2, Type.ITEM1_20_2_VAR_INT_ARRAY);
}
@Override
public void registerPackets() {
final BlockRewriter<ClientboundPackets1_20_2> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14);
blockRewriter.registerBlockAction(ClientboundPackets1_20_2.BLOCK_ACTION);
blockRewriter.registerBlockChange(ClientboundPackets1_20_2.BLOCK_CHANGE);
blockRewriter.registerVarLongMultiBlockChange1_20(ClientboundPackets1_20_2.MULTI_BLOCK_CHANGE);
blockRewriter.registerEffect(ClientboundPackets1_20_2.EFFECT, 1010, 2001);
blockRewriter.registerChunkData1_19(ClientboundPackets1_20_2.CHUNK_DATA, Chunk1_18Type::new);
blockRewriter.registerBlockEntityData(ClientboundPackets1_20_2.BLOCK_ENTITY_DATA);
registerSetCooldown(ClientboundPackets1_20_2.COOLDOWN);
registerWindowItems1_17_1(ClientboundPackets1_20_2.WINDOW_ITEMS);
registerSetSlot1_17_1(ClientboundPackets1_20_2.SET_SLOT);
registerAdvancements1_20_3(ClientboundPackets1_20_2.ADVANCEMENTS);
registerEntityEquipmentArray(ClientboundPackets1_20_2.ENTITY_EQUIPMENT);
registerClickWindow1_17_1(ServerboundPackets1_20_2.CLICK_WINDOW);
registerTradeList1_19(ClientboundPackets1_20_2.TRADE_LIST);
registerCreativeInvAction(ServerboundPackets1_20_2.CREATIVE_INVENTORY_ACTION, Type.ITEM1_20_2);
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_20_2.WINDOW_PROPERTY);
registerSpawnParticle1_19(ClientboundPackets1_20_2.SPAWN_PARTICLE);
new RecipeRewriter1_20_2<>(protocol).register(ClientboundPackets1_20_2.DECLARE_RECIPES);
}
}

Datei anzeigen

@ -0,0 +1,126 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2023 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.template.protocol.rewriter;
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
import com.viaversion.viabackwards.template.protocol.Protocol1_98To_99;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.version.Types1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundConfigurationPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2;
// Replace if needed
// Types1_OLD
// Types1_20_3
public final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPackets1_20_2, Protocol1_98To_99> {
public EntityPacketRewriter1_99(final Protocol1_98To_99 protocol) {
super(protocol);
}
@Override
public void registerPackets() {
registerTrackerWithData1_19(ClientboundPackets1_20_2.SPAWN_ENTITY, Entity1_19_4Types.FALLING_BLOCK);
registerMetadataRewriter(ClientboundPackets1_20_2.ENTITY_METADATA, /*Types1_OLD.METADATA_LIST, */Types1_20_3.METADATA_LIST); // Specify old and new metadata list if changed
registerRemoveEntities(ClientboundPackets1_20_2.REMOVE_ENTITIES);
protocol.registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_2.REGISTRY_DATA, new PacketHandlers() {
@Override
protected void register() {
map(Type.NAMED_COMPOUND_TAG); // Registry data
handler(dimensionDataHandler()); // Caches dimensions to access data like height later
handler(biomeSizeTracker()); // Tracks the amount of biomes sent for chunk data
}
});
protocol.registerClientbound(ClientboundPackets1_20_2.JOIN_GAME, new PacketHandlers() {
@Override
public void register() {
map(Type.INT); // Entity id
map(Type.BOOLEAN); // Hardcore
map(Type.STRING_ARRAY); // World List
map(Type.VAR_INT); // Max players
map(Type.VAR_INT); // View distance
map(Type.VAR_INT); // Simulation distance
map(Type.BOOLEAN); // Reduced debug info
map(Type.BOOLEAN); // Show death screen
map(Type.BOOLEAN); // Limited crafting
map(Type.STRING); // Dimension key
map(Type.STRING); // World
handler(worldDataTrackerHandlerByKey()); // Tracks world height and name for chunk data and entity (un)tracking
}
});
protocol.registerClientbound(ClientboundPackets1_20_2.RESPAWN, new PacketHandlers() {
@Override
public void register() {
map(Type.STRING); // Dimension
map(Type.STRING); // World
handler(worldDataTrackerHandlerByKey()); // Tracks world height and name for chunk data and entity (un)tracking
}
});
}
@Override
protected void registerRewrites() {
/*filter().handler((event, meta) -> {
int id = meta.metaType().typeId();
if (id >= ac) {
return;
} else if (id >= ab) {
id--;
}
meta.setMetaType(Types1_20_3.META_TYPES.byId(id));
});*/
registerMetaTypeHandler(
Types1_20_3.META_TYPES.itemType,
Types1_20_3.META_TYPES.blockStateType,
Types1_20_3.META_TYPES.optionalBlockStateType,
Types1_20_3.META_TYPES.particleType,
Types1_20_3.META_TYPES.componentType,
Types1_20_3.META_TYPES.optionalComponentType
);
filter().filterFamily(Entity1_19_4Types.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
final int blockState = meta.value();
meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState));
});
// Remove metadata of new entity type
// filter().type(Entity1_xTypes.SNIFFER).removeIndex(newIndex);
}
@Override
public void onMappingDataLoaded() {
// If types changed, uncomment to map them
// mapTypes();
// mapEntityTypeWithData(Entity1_19_4Types.SNIFFER, Entity1_19_4Types.RAVAGER).jsonName();
}
@Override
public EntityType typeFromId(final int type) {
return Entity1_19_4Types.getTypeFromId(type);
}
}