Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-09-07 21:32:52 +02:00
Handle translatable messages (1.15->...->1.12)
Dieser Commit ist enthalten in:
Ursprung
80ef8a401d
Commit
e809c117c4
@ -12,6 +12,7 @@ package nl.matsv.viabackwards.api;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.ViaBackwardsConfig;
|
||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1;
|
||||
@ -52,6 +53,9 @@ public interface ViaBackwardsPlatform {
|
||||
|
||||
if (isOutdated()) return;
|
||||
|
||||
getLogger().info("Loading all translations...");
|
||||
TranslatableRewriter.loadTranslatables();
|
||||
|
||||
registerProtocol(new Protocol1_9_4To1_10(), ProtocolVersion.v1_9_3, ProtocolVersion.v1_10);
|
||||
registerProtocol(new Protocol1_10To1_11(), ProtocolVersion.v1_10, ProtocolVersion.v1_11);
|
||||
registerProtocol(new Protocol1_11To1_11_1(), ProtocolVersion.v1_11, ProtocolVersion.v1_11_1);
|
||||
|
@ -0,0 +1,189 @@
|
||||
package nl.matsv.viabackwards.api.rewriters;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TranslatableComponent;
|
||||
import net.md_5.bungee.chat.ComponentSerializer;
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.data.VBMappingDataLoader;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TranslatableRewriter {
|
||||
|
||||
private static final Map<String, Map<String, String>> TRANSLATABLES = new HashMap<>();
|
||||
private final BackwardsProtocol protocol;
|
||||
protected final Map<String, String> newTranslatables;
|
||||
|
||||
public static void loadTranslatables() {
|
||||
JsonObject jsonObject = VBMappingDataLoader.loadData("translation-mappings.json");
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
|
||||
Map<String, String> versionMappings = new HashMap<>();
|
||||
TRANSLATABLES.put(entry.getKey(), versionMappings);
|
||||
for (Map.Entry<String, JsonElement> translationEntry : entry.getValue().getAsJsonObject().entrySet()) {
|
||||
versionMappings.put(translationEntry.getKey(), translationEntry.getValue().getAsString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TranslatableRewriter(BackwardsProtocol protocol) {
|
||||
this(protocol, protocol.getClass().getSimpleName().split("To")[1].replace("_", "."));
|
||||
}
|
||||
|
||||
public TranslatableRewriter(BackwardsProtocol protocol, String sectionIdentifier) {
|
||||
this.protocol = protocol;
|
||||
final Map<String, String> newTranslatables = TRANSLATABLES.get(sectionIdentifier);
|
||||
if (newTranslatables == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Error loading " + sectionIdentifier + " translatables!");
|
||||
this.newTranslatables = new HashMap<>();
|
||||
} else
|
||||
this.newTranslatables = newTranslatables;
|
||||
}
|
||||
|
||||
public void registerPing() {
|
||||
protocol.out(State.LOGIN, 0x00, 0x00, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> wrapper.write(Type.STRING, processTranslate(wrapper.read(Type.STRING))));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerDisconnect(int oldId, int newId) {
|
||||
protocol.out(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> wrapper.write(Type.STRING, processTranslate(wrapper.read(Type.STRING))));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerChatMessage(int oldId, int newId) {
|
||||
protocol.out(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> wrapper.write(Type.STRING, processTranslate(wrapper.read(Type.STRING))));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerBossBar(int oldId, int newId) {
|
||||
protocol.out(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UUID);
|
||||
map(Type.VAR_INT);
|
||||
handler(wrapper -> {
|
||||
int action = wrapper.get(Type.VAR_INT, 0);
|
||||
if (action == 0 || action == 3) {
|
||||
wrapper.write(Type.STRING, processTranslate(wrapper.read(Type.STRING)));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerLegacyOpenWindow(int oldId, int newId) {
|
||||
protocol.out(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // Id
|
||||
map(Type.STRING); // Window Type
|
||||
handler(wrapper -> wrapper.write(Type.STRING, processTranslate(wrapper.read(Type.STRING))));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerOpenWindow(int oldId, int newId) {
|
||||
protocol.out(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // Id
|
||||
map(Type.VAR_INT); // Window Type
|
||||
handler(wrapper -> wrapper.write(Type.STRING, processTranslate(wrapper.read(Type.STRING))));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerCombatEvent(int oldId, int newId) {
|
||||
protocol.out(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
if (wrapper.passthrough(Type.VAR_INT) == 2) {
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.write(Type.STRING, processTranslate(wrapper.read(Type.STRING)));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerTitle(int oldId, int newId) {
|
||||
protocol.out(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
int action = wrapper.passthrough(Type.VAR_INT);
|
||||
if (action >= 0 && action <= 2) {
|
||||
wrapper.write(Type.STRING, processTranslate(wrapper.read(Type.STRING)));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerPlayerList(int oldId, int newId) {
|
||||
protocol.out(State.PLAY, oldId, newId, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.write(Type.STRING, processTranslate(wrapper.read(Type.STRING)));
|
||||
wrapper.write(Type.STRING, processTranslate(wrapper.read(Type.STRING)));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public String processTranslate(String value) {
|
||||
BaseComponent[] components = ComponentSerializer.parse(value);
|
||||
for (BaseComponent component : components) {
|
||||
processTranslate(component);
|
||||
}
|
||||
return components.length == 1 ? ComponentSerializer.toString(components[0]) : ComponentSerializer.toString(components);
|
||||
}
|
||||
|
||||
protected void processTranslate(BaseComponent component) {
|
||||
if (component == null) return;
|
||||
if (component instanceof TranslatableComponent) {
|
||||
TranslatableComponent translatableComponent = (TranslatableComponent) component;
|
||||
String oldTranslate = translatableComponent.getTranslate();
|
||||
String newTranslate = newTranslatables.get(oldTranslate);
|
||||
if (newTranslate != null) {
|
||||
translatableComponent.setTranslate(newTranslate);
|
||||
}
|
||||
if (translatableComponent.getWith() != null) {
|
||||
for (BaseComponent baseComponent : translatableComponent.getWith()) {
|
||||
processTranslate(baseComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (component.getHoverEvent() != null) {
|
||||
for (BaseComponent baseComponent : component.getHoverEvent().getValue()) {
|
||||
processTranslate(baseComponent);
|
||||
}
|
||||
}
|
||||
if (component.getExtra() != null) {
|
||||
for (BaseComponent baseComponent : component.getExtra()) {
|
||||
processTranslate(baseComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -11,9 +11,12 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TranslatableComponent;
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.PaintingMapping;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13;
|
||||
@ -28,7 +31,6 @@ import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.platform.providers.ViaProviders;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
@ -49,6 +51,44 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
|
||||
new PlayerPacket1_13(this).register();
|
||||
new SoundPackets1_13(this).register();
|
||||
|
||||
TranslatableRewriter translatableRewriter = new TranslatableRewriter(this) {
|
||||
@Override
|
||||
protected void processTranslate(BaseComponent component) {
|
||||
if (component == null) return;
|
||||
if (component instanceof TranslatableComponent) {
|
||||
TranslatableComponent translatableComponent = (TranslatableComponent) component;
|
||||
String oldTranslate = translatableComponent.getTranslate();
|
||||
String newTranslate = newTranslatables.get(oldTranslate);
|
||||
if (newTranslate != null || (newTranslate = BackwardsMappings.translateMappings.get(oldTranslate)) != null) {
|
||||
translatableComponent.setTranslate(newTranslate);
|
||||
}
|
||||
if (translatableComponent.getWith() != null) {
|
||||
for (BaseComponent baseComponent : translatableComponent.getWith()) {
|
||||
processTranslate(baseComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (component.getHoverEvent() != null) {
|
||||
for (BaseComponent baseComponent : component.getHoverEvent().getValue()) {
|
||||
processTranslate(baseComponent);
|
||||
}
|
||||
}
|
||||
if (component.getExtra() != null) {
|
||||
for (BaseComponent baseComponent : component.getExtra()) {
|
||||
processTranslate(baseComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
translatableRewriter.registerPing();
|
||||
translatableRewriter.registerBossBar(0x0C, 0x0C);
|
||||
translatableRewriter.registerChatMessage(0x0E, 0x0F);
|
||||
translatableRewriter.registerLegacyOpenWindow(0x14, 0x13);
|
||||
translatableRewriter.registerDisconnect(0x1B, 0x1A);
|
||||
translatableRewriter.registerCombatEvent(0x2F, 0x2D);
|
||||
translatableRewriter.registerTitle(0x4B, 0x48);
|
||||
translatableRewriter.registerPlayerList(0x4E, 0x4A);
|
||||
|
||||
// Thanks to https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14150
|
||||
|
||||
out(State.PLAY, 0x11, -1, cancel()); // Declare Commands TODO NEW
|
||||
@ -119,94 +159,6 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
|
||||
in(State.PLAY, 0x28, 0x1E); // Spectate
|
||||
in(State.PLAY, 0x29, 0x1F); // Player Block Placement
|
||||
in(State.PLAY, 0x2A, 0x20); // Use Item
|
||||
|
||||
// Handle translation key changes
|
||||
|
||||
out(State.LOGIN, 0x00, 0x00, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> wrapper.write(Type.STRING, TranslationRewriter.processTranslate(wrapper.read(Type.STRING))));
|
||||
}
|
||||
});
|
||||
|
||||
// Bossbar
|
||||
out(State.LOGIN, 0x0C, 0x0C, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UUID);
|
||||
map(Type.VAR_INT);
|
||||
handler(wrapper -> {
|
||||
int action = wrapper.get(Type.VAR_INT, 0);
|
||||
if (action == 0 || action == 3) {
|
||||
wrapper.write(Type.STRING, TranslationRewriter.processTranslate(wrapper.read(Type.STRING)));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Chat Message
|
||||
out(State.PLAY, 0x0E, 0x0F, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> wrapper.write(Type.STRING, TranslationRewriter.processTranslate(wrapper.read(Type.STRING))));
|
||||
}
|
||||
});
|
||||
|
||||
// Open Window
|
||||
out(State.PLAY, 0x14, 0x13, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // Id
|
||||
map(Type.STRING); // Window Type
|
||||
handler(wrapper -> wrapper.write(Type.STRING, TranslationRewriter.processTranslate(wrapper.read(Type.STRING))));
|
||||
}
|
||||
});
|
||||
|
||||
// Disconnect
|
||||
out(State.PLAY, 0x1B, 0x1A, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> wrapper.write(Type.STRING, TranslationRewriter.processTranslate(wrapper.read(Type.STRING))));
|
||||
}
|
||||
});
|
||||
|
||||
// Combat Event
|
||||
out(State.PLAY, 0x2F, 0x2D, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
if (wrapper.passthrough(Type.VAR_INT) == 2) {
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.write(Type.STRING, TranslationRewriter.processTranslate(wrapper.read(Type.STRING)));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Title
|
||||
out(State.PLAY, 0x4B, 0x48, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
int action = wrapper.passthrough(Type.VAR_INT);
|
||||
if (action >= 0 && action <= 2) {
|
||||
wrapper.write(Type.STRING, TranslationRewriter.processTranslate(wrapper.read(Type.STRING)));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Player List Header And Footer
|
||||
out(State.PLAY, 0x4E, 0x4A, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.write(Type.STRING, TranslationRewriter.processTranslate(wrapper.read(Type.STRING)));
|
||||
wrapper.write(Type.STRING, TranslationRewriter.processTranslate(wrapper.read(Type.STRING)));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,45 +0,0 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TranslatableComponent;
|
||||
import net.md_5.bungee.chat.ComponentSerializer;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings;
|
||||
|
||||
// Slightly changed methods of the ChatRewriter
|
||||
public class TranslationRewriter {
|
||||
|
||||
public static String processTranslate(String value) {
|
||||
BaseComponent[] components = ComponentSerializer.parse(value);
|
||||
for (BaseComponent component : components) {
|
||||
processTranslate(component);
|
||||
}
|
||||
return components.length == 1 ? ComponentSerializer.toString(components[0]) : ComponentSerializer.toString(components);
|
||||
}
|
||||
|
||||
private static void processTranslate(BaseComponent component) {
|
||||
if (component == null) return;
|
||||
if (component instanceof TranslatableComponent) {
|
||||
TranslatableComponent translatableComponent = (TranslatableComponent) component;
|
||||
String oldTranslate = translatableComponent.getTranslate();
|
||||
String newTranslate = BackwardsMappings.translateMappings.get(oldTranslate);
|
||||
if (newTranslate != null) {
|
||||
translatableComponent.setTranslate(newTranslate);
|
||||
}
|
||||
if (translatableComponent.getWith() != null) {
|
||||
for (BaseComponent baseComponent : translatableComponent.getWith()) {
|
||||
processTranslate(baseComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (component.getHoverEvent() != null) {
|
||||
for (BaseComponent baseComponent : component.getHoverEvent().getValue()) {
|
||||
processTranslate(baseComponent);
|
||||
}
|
||||
}
|
||||
if (component.getExtra() != null) {
|
||||
for (BaseComponent baseComponent : component.getExtra()) {
|
||||
processTranslate(baseComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import lombok.Getter;
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.BlockItemPackets1_14;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.EntityPackets1_14;
|
||||
@ -39,57 +40,49 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol {
|
||||
new PlayerPackets1_14(this).register();
|
||||
new SoundPackets1_14(this).register();
|
||||
|
||||
TranslatableRewriter translatableRewriter = new TranslatableRewriter(this);
|
||||
translatableRewriter.registerBossBar(0x0C, 0x0C);
|
||||
translatableRewriter.registerChatMessage(0x0E, 0x0E);
|
||||
translatableRewriter.registerCombatEvent(0x32, 0x2F);
|
||||
translatableRewriter.registerDisconnect(0x1A, 0x1B);
|
||||
translatableRewriter.registerPlayerList(0x53, 0x4E);
|
||||
translatableRewriter.registerTitle(0x4F, 0x4B);
|
||||
translatableRewriter.registerPing();
|
||||
|
||||
registerOutgoing(State.PLAY, 0x15, 0x16);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x18, 0x19);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x19, 0x1A);
|
||||
registerOutgoing(State.PLAY, 0x1A, 0x1B);
|
||||
registerOutgoing(State.PLAY, 0x1B, 0x1C);
|
||||
registerOutgoing(State.PLAY, 0x54, 0x1D);
|
||||
registerOutgoing(State.PLAY, 0x1E, 0x20);
|
||||
registerOutgoing(State.PLAY, 0x20, 0x21);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x2B, 0x27);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x2C, 0x2B);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x30, 0x2D);
|
||||
registerOutgoing(State.PLAY, 0x31, 0x2E);
|
||||
registerOutgoing(State.PLAY, 0x32, 0x2F);
|
||||
registerOutgoing(State.PLAY, 0x33, 0x30);
|
||||
registerOutgoing(State.PLAY, 0x34, 0x31);
|
||||
// Position and look
|
||||
registerOutgoing(State.PLAY, 0x35, 0x32);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x36, 0x34);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x38, 0x36);
|
||||
registerOutgoing(State.PLAY, 0x39, 0x37);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x3B, 0x39);
|
||||
registerOutgoing(State.PLAY, 0x3C, 0x3A);
|
||||
registerOutgoing(State.PLAY, 0x3D, 0x3B);
|
||||
registerOutgoing(State.PLAY, 0x3E, 0x3C);
|
||||
registerOutgoing(State.PLAY, 0x3F, 0x3D);
|
||||
registerOutgoing(State.PLAY, 0x42, 0x3E);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x44, 0x40);
|
||||
registerOutgoing(State.PLAY, 0x45, 0x41);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x47, 0x43);
|
||||
registerOutgoing(State.PLAY, 0x48, 0x44);
|
||||
registerOutgoing(State.PLAY, 0x49, 0x45);
|
||||
registerOutgoing(State.PLAY, 0x4A, 0x46);
|
||||
registerOutgoing(State.PLAY, 0x4B, 0x47);
|
||||
registerOutgoing(State.PLAY, 0x4C, 0x48);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x4E, 0x4A);
|
||||
registerOutgoing(State.PLAY, 0x4F, 0x4B);
|
||||
registerOutgoing(State.PLAY, 0x52, 0x4C);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x53, 0x4E); // c
|
||||
registerOutgoing(State.PLAY, 0x55, 0x4F); // c
|
||||
registerOutgoing(State.PLAY, 0x55, 0x4F);
|
||||
|
||||
// Update View Position
|
||||
cancelOutgoing(State.PLAY, 0x40);
|
||||
|
@ -2,6 +2,7 @@ package nl.matsv.viabackwards.protocol.protocol1_13to1_13_1;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.EntityPackets1_13_1;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.InventoryPackets1_13_1;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.WorldPackets1_13_1;
|
||||
@ -23,6 +24,15 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
InventoryPackets1_13_1.register(this);
|
||||
WorldPackets1_13_1.register(this);
|
||||
|
||||
TranslatableRewriter translatableRewriter = new TranslatableRewriter(this);
|
||||
translatableRewriter.registerChatMessage(0x0E, 0x0E);
|
||||
translatableRewriter.registerLegacyOpenWindow(0x14, 0x14);
|
||||
translatableRewriter.registerCombatEvent(0x2F, 0x2F);
|
||||
translatableRewriter.registerDisconnect(0x1B, 0x1B);
|
||||
translatableRewriter.registerPlayerList(0x4E, 0x4E);
|
||||
translatableRewriter.registerTitle(0x4B, 0x4B);
|
||||
translatableRewriter.registerPing();
|
||||
|
||||
//Tab complete
|
||||
registerIncoming(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||
@Override
|
||||
@ -81,7 +91,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
}
|
||||
});
|
||||
|
||||
//boss bar
|
||||
// Boss bar
|
||||
registerOutgoing(State.PLAY, 0x0C, 0x0C, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -91,14 +101,16 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int action = wrapper.get(Type.VAR_INT, 0);
|
||||
if (action == 0) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
wrapper.passthrough(Type.FLOAT);
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
short flags = wrapper.read(Type.UNSIGNED_BYTE);
|
||||
if ((flags & 0x04) != 0) flags |= 0x02;
|
||||
wrapper.write(Type.UNSIGNED_BYTE, flags);
|
||||
if (action == 0 || action == 3) {
|
||||
wrapper.write(Type.STRING, translatableRewriter.processTranslate(wrapper.read(Type.STRING)));
|
||||
if (action == 0) {
|
||||
wrapper.passthrough(Type.FLOAT);
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
short flags = wrapper.read(Type.UNSIGNED_BYTE);
|
||||
if ((flags & 0x04) != 0) flags |= 0x02;
|
||||
wrapper.write(Type.UNSIGNED_BYTE, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -176,7 +188,6 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static int getNewBlockStateId(int blockId) {
|
||||
|
@ -24,7 +24,6 @@ public class EntityPackets1_13_1 extends EntityRewriter<Protocol1_13To1_13_1> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
|
||||
// Spawn Object
|
||||
protocol.out(State.PLAY, 0x00, 0x00, new PacketRemapper() {
|
||||
@Override
|
||||
|
@ -3,6 +3,7 @@ package nl.matsv.viabackwards.protocol.protocol1_14_4to1_15;
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.EntityTypeMapping;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.ImmediateRespawn;
|
||||
@ -19,7 +20,6 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_14_4To1_15 extends BackwardsProtocol {
|
||||
|
||||
private static final Integer[] A = new Integer[0];
|
||||
private BlockItemPackets1_15 blockItemPackets;
|
||||
|
||||
@Override
|
||||
@ -28,6 +28,16 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol {
|
||||
(blockItemPackets = new BlockItemPackets1_15(this)).register();
|
||||
new EntityPackets1_15(this).register();
|
||||
|
||||
TranslatableRewriter translatableRewriter = new TranslatableRewriter(this);
|
||||
translatableRewriter.registerBossBar(0x0D, 0x0C);
|
||||
translatableRewriter.registerChatMessage(0x0F, 0x0E);
|
||||
translatableRewriter.registerCombatEvent(0x33, 0x32);
|
||||
translatableRewriter.registerDisconnect(0x1B, 0x1A);
|
||||
translatableRewriter.registerOpenWindow(0x2F, 0x2E);
|
||||
translatableRewriter.registerPlayerList(0x54, 0x53);
|
||||
translatableRewriter.registerTitle(0x50, 0x4F);
|
||||
translatableRewriter.registerPing();
|
||||
|
||||
// Entity Sound Effect
|
||||
registerOutgoing(State.PLAY, 0x51, 0x50, new PacketRemapper() {
|
||||
@Override
|
||||
@ -154,9 +164,7 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol {
|
||||
|
||||
registerOutgoing(State.PLAY, 0x09, 0x08);
|
||||
registerOutgoing(State.PLAY, 0x0A, 0x09);
|
||||
registerOutgoing(State.PLAY, 0x0D, 0x0C);
|
||||
registerOutgoing(State.PLAY, 0x0E, 0x0D);
|
||||
registerOutgoing(State.PLAY, 0x0F, 0x0E);
|
||||
registerOutgoing(State.PLAY, 0x11, 0x10);
|
||||
registerOutgoing(State.PLAY, 0x12, 0x11);
|
||||
registerOutgoing(State.PLAY, 0x13, 0x12);
|
||||
@ -164,7 +172,6 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol {
|
||||
registerOutgoing(State.PLAY, 0x16, 0x15);
|
||||
registerOutgoing(State.PLAY, 0x19, 0x18);
|
||||
registerOutgoing(State.PLAY, 0x1A, 0x19);
|
||||
registerOutgoing(State.PLAY, 0x1B, 0x1A);
|
||||
registerOutgoing(State.PLAY, 0x1C, 0x1B);
|
||||
registerOutgoing(State.PLAY, 0x1D, 0x1C);
|
||||
registerOutgoing(State.PLAY, 0x1E, 0x1D);
|
||||
@ -178,11 +185,9 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol {
|
||||
registerOutgoing(State.PLAY, 0x2C, 0x2B);
|
||||
registerOutgoing(State.PLAY, 0x2D, 0x2C);
|
||||
registerOutgoing(State.PLAY, 0x2E, 0x2D);
|
||||
registerOutgoing(State.PLAY, 0x2F, 0x2E);
|
||||
registerOutgoing(State.PLAY, 0x30, 0x2F);
|
||||
registerOutgoing(State.PLAY, 0x31, 0x30);
|
||||
registerOutgoing(State.PLAY, 0x32, 0x31);
|
||||
registerOutgoing(State.PLAY, 0x33, 0x32);
|
||||
registerOutgoing(State.PLAY, 0x34, 0x33);
|
||||
registerOutgoing(State.PLAY, 0x35, 0x34);
|
||||
registerOutgoing(State.PLAY, 0x36, 0x35);
|
||||
@ -206,9 +211,7 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol {
|
||||
registerOutgoing(State.PLAY, 0x4D, 0x4C);
|
||||
registerOutgoing(State.PLAY, 0x4E, 0x4D);
|
||||
registerOutgoing(State.PLAY, 0x4F, 0x4E);
|
||||
registerOutgoing(State.PLAY, 0x50, 0x4F);
|
||||
registerOutgoing(State.PLAY, 0x53, 0x52);
|
||||
registerOutgoing(State.PLAY, 0x54, 0x53);
|
||||
registerOutgoing(State.PLAY, 0x55, 0x54);
|
||||
registerOutgoing(State.PLAY, 0x56, 0x55);
|
||||
registerOutgoing(State.PLAY, 0x57, 0x56);
|
||||
|
1690
core/src/main/resources/assets/viabackwards/data/translation-mappings.json
Normale Datei
1690
core/src/main/resources/assets/viabackwards/data/translation-mappings.json
Normale Datei
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren