From 5bb87bc059e50f1ee9088894064dae2f5b96a5a9 Mon Sep 17 00:00:00 2001 From: ForceUpdate1 Date: Thu, 24 Oct 2019 22:31:40 +0200 Subject: [PATCH 1/3] Update README.md (#162) --- README.md | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ea324b7d..798dd4f9 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,21 @@ Allows older Minecraft versions on a newer Minecraft server - -Requires [ViaVersion](http://viaversion.com) to be installed -**Spigot page:** https://www.spigotmc.org/resources/viabackwards.27448/ - ### Supported versions: -![supported_versions](http://i.imgur.com/gXCifhK.png) \ No newline at end of file +![supported_versions](https://camo.githubusercontent.com/75fd692876cdeadbb8a84ed3175e6f0fc23a640a/68747470733a2f2f692e696d6775722e636f6d2f695741744431702e706e67) + +--- + +### Releases / Dev Builds: + +***Requires [ViaVersion](http://viaversion.com) to be installed*** + +You can find official releases here: +**Spgot page:** https://www.spigotmc.org/resources/viabackwards.27448/ **[1.9.x - 1.12.x]** + +You can find official dev builds here: +**Jenkins:** https://ci.viaversion.com/view/ViaBackwards/ **[1.9.x - 1.14.x]** + +**Maven:** https://repo.viaversion.com/ + +**Issue tracker:** https://github.com/ViaVersion/ViaBackwards/issues From 2531e9f353f2fc658227e640433c5f493a3ccd08 Mon Sep 17 00:00:00 2001 From: Jo0001 <47455182+Jo0001@users.noreply.github.com> Date: Sun, 27 Oct 2019 13:32:44 +0100 Subject: [PATCH 2/3] Fix typo in README.md (#163) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 798dd4f9..eb79e2b3 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Allows older Minecraft versions on a newer Minecraft server ***Requires [ViaVersion](http://viaversion.com) to be installed*** You can find official releases here: -**Spgot page:** https://www.spigotmc.org/resources/viabackwards.27448/ **[1.9.x - 1.12.x]** +**Spigot page:** https://www.spigotmc.org/resources/viabackwards.27448/ **[1.9.x - 1.12.x]** You can find official dev builds here: **Jenkins:** https://ci.viaversion.com/view/ViaBackwards/ **[1.9.x - 1.14.x]** From e55ff0130c1ac1a14fe888b92b539b356c0d3c06 Mon Sep 17 00:00:00 2001 From: KennyTV <28825609+KennyTV@users.noreply.github.com> Date: Sat, 7 Dec 2019 17:14:17 +0100 Subject: [PATCH 3/3] =?UTF-8?q?1.15=20(and=20a=20lot=20of=20other=20improv?= =?UTF-8?q?ements/fixes)=20=F0=9F=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 24 +- bukkit/src/main/resources/plugin.yml | 4 +- bungee/src/main/resources/bungee.yml | 2 +- .../api/ViaBackwardsPlatform.java | 40 +-- .../api/data/VBMappingDataLoader.java | 98 ++++++ .../viabackwards/api/data/VBMappings.java | 44 +++ .../api/entities/storage/EntityTracker.java | 1 + .../api/exceptions/RemovedValueException.java | 6 +- .../api/rewriters/BlockItemRewriter.java | 29 +- .../api/rewriters/EntityRewriter.java | 65 +++- .../api/rewriters/RecipeRewriter.java | 14 + .../protocol1_10to1_11/EntityTypeNames.java | 12 +- .../packets/BlockItemPackets1_11.java | 18 +- .../packets/EntityPackets1_11.java | 2 +- .../Protocol1_11_1To1_12.java | 1 - .../data/BlockColors.java | 10 +- .../data/MapColorMapping.java | 141 ++++---- .../packets/BlockItemPackets1_12.java | 17 +- .../packets/ChatPackets1_12.java | 2 +- .../packets/ItemPackets1_11_1.java | 5 +- .../Protocol1_12_2To1_13.java | 11 +- .../block_entity_handlers/PistonHandler.java | 2 +- .../data/BackwardsMappings.java | 65 ++-- .../data/EntityNameRewrites.java | 14 +- .../data/NamedSoundMapping.java | 6 +- .../data/PaintingMapping.java | 6 +- .../data/ParticleMapping.java | 7 +- .../data/SoundMapping.java | 54 ---- .../packets/BlockItemPackets1_13.java | 238 +++++++------- .../packets/EntityPackets1_13.java | 6 +- .../packets/PlayerPacket1_13.java | 2 +- .../packets/SoundPackets1_13.java | 15 +- .../packets/InventoryPackets1_13_2.java | 7 +- .../Protocol1_13_2To1_14.java | 65 ++-- .../data/BackwardsMappings.java | 96 +----- .../data/EntityPositionStorage.java | 34 ++ .../data/RecipeRewriter1_14.java | 65 ++++ .../data/SoundMapping.java | 44 --- .../packets/BlockItemPackets1_14.java | 237 ++++++-------- .../packets/EntityPackets1_14.java | 115 ++++++- .../packets/SoundPackets1_14.java | 58 +++- .../Protocol1_13To1_13_1.java | 8 +- .../packets/EntityPackets1_13_1.java | 2 +- .../packets/InventoryPackets1_13_1.java | 4 +- .../Protocol1_14_2To1_14_3.java | 10 +- .../Protocol1_14_4To1_15.java | 252 +++++++++++++++ .../data/BackwardsMappings.java | 25 ++ .../data/EntityTypeMapping.java | 12 + .../data/RecipeRewriter1_15.java | 45 +++ .../packets/BlockItemPackets1_15.java | 306 ++++++++++++++++++ .../packets/EntityPackets1_15.java | 271 ++++++++++++++++ .../packets/EntityPackets1_14_1.java | 2 +- .../packets/BlockItemPackets1_10.java | 13 +- .../data/mapping-1.12.2to1.13.json | 116 ++++++- .../data/mapping-1.13.2to1.14.json | 135 ++++++++ .../data/mapping-1.14.4to1.15.json | 62 ++++ fabric/src/main/resources/fabric.mod.json | 2 +- pom.xml | 6 +- .../nl/matsv/viabackwards/SpongePlugin.java | 2 +- .../nl/matsv/viabackwards/VelocityPlugin.java | 2 +- 60 files changed, 2210 insertions(+), 747 deletions(-) create mode 100644 core/src/main/java/nl/matsv/viabackwards/api/data/VBMappingDataLoader.java create mode 100644 core/src/main/java/nl/matsv/viabackwards/api/data/VBMappings.java create mode 100644 core/src/main/java/nl/matsv/viabackwards/api/rewriters/RecipeRewriter.java delete mode 100644 core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/SoundMapping.java create mode 100644 core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/data/EntityPositionStorage.java create mode 100644 core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/data/RecipeRewriter1_14.java delete mode 100644 core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/data/SoundMapping.java create mode 100644 core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/Protocol1_14_4To1_15.java create mode 100644 core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/data/BackwardsMappings.java create mode 100644 core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/data/EntityTypeMapping.java create mode 100644 core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/data/RecipeRewriter1_15.java create mode 100644 core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/packets/BlockItemPackets1_15.java create mode 100644 core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/packets/EntityPackets1_15.java create mode 100644 core/src/main/resources/assets/viabackwards/data/mapping-1.14.4to1.15.json diff --git a/README.md b/README.md index 3a1c8996..81b61ad0 100644 --- a/README.md +++ b/README.md @@ -2,24 +2,26 @@ Allows older Minecraft versions on a newer Minecraft server - -Requires [ViaVersion](http://viaversion.com) to be installed -**Spigot page:** https://www.spigotmc.org/resources/viabackwards.27448/ - ### Supported versions: -![supported_versions](https://camo.githubusercontent.com/75fd692876cdeadbb8a84ed3175e6f0fc23a640a/68747470733a2f2f692e696d6775722e636f6d2f695741744431702e706e67) +**Orange** = Native server version\ +**Green** = ViaVersion\ +**Blue** = ViaBackwards addition + +![supported_versions](https://i.imgur.com/dlxakYT.png) --- ### Releases / Dev Builds: -***Requires [ViaVersion](http://viaversion.com) to be installed*** - -You can find official releases here: -**Spigot page:** https://www.spigotmc.org/resources/viabackwards.27448/ **[1.9.x - 1.12.x]** +**Requires [ViaVersion](http://viaversion.com) to be installed** -You can find official dev builds here: -**Jenkins:** https://ci.viaversion.com/view/ViaBackwards/ **[1.9.x - 1.14.x]** +You can find the latest builds here:\ +**Jenkins:** https://ci.viaversion.com/view/ViaBackwards/ + +Spigot page (possibly outdated):\ +**Spigot page:** https://www.spigotmc.org/resources/viabackwards.27448/ + +--- **Maven:** https://repo.viaversion.com/ diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index 20c3585f..610e0be8 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -3,8 +3,8 @@ version: ${project.version} description: Allow older Minecraft versions to connect to a newer server version. main: nl.matsv.viabackwards.BukkitPlugin -authors: [Matsv] -website: https://matsv.nl +authors: [Matsv, KennyTV, Gerrygames, creeper123123321, ForceUpdate1] +website: ${project.url} load: STARTUP depend: [ViaVersion] diff --git a/bungee/src/main/resources/bungee.yml b/bungee/src/main/resources/bungee.yml index ddb7f3c1..abc6be73 100644 --- a/bungee/src/main/resources/bungee.yml +++ b/bungee/src/main/resources/bungee.yml @@ -1,5 +1,5 @@ name: ViaBackwards main: nl.matsv.viabackwards.BungeePlugin -author: Matsv +author: "Matsv, KennyTV, Gerrygames, creeper123123321, ForceUpdate1" version: ${project.version} depends: [ViaVersion] \ No newline at end of file diff --git a/core/src/main/java/nl/matsv/viabackwards/api/ViaBackwardsPlatform.java b/core/src/main/java/nl/matsv/viabackwards/api/ViaBackwardsPlatform.java index e831b469..9ff67c77 100644 --- a/core/src/main/java/nl/matsv/viabackwards/api/ViaBackwardsPlatform.java +++ b/core/src/main/java/nl/matsv/viabackwards/api/ViaBackwardsPlatform.java @@ -24,20 +24,21 @@ import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1; import nl.matsv.viabackwards.protocol.protocol1_14_1to1_14_2.Protocol1_14_1To1_14_2; import nl.matsv.viabackwards.protocol.protocol1_14_2to1_14_3.Protocol1_14_2To1_14_3; import nl.matsv.viabackwards.protocol.protocol1_14_3to1_14_4.Protocol1_14_3To1_14_4; +import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.Protocol1_14_4To1_15; import nl.matsv.viabackwards.protocol.protocol1_14to1_14_1.Protocol1_14To1_14_1; import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10; -import us.myles.ViaVersion.api.protocol.ProtocolRegistry; import us.myles.ViaVersion.api.protocol.ProtocolVersion; import us.myles.ViaVersion.update.Version; import java.io.File; -import java.util.Collections; import java.util.logging.Logger; +import static us.myles.ViaVersion.api.protocol.ProtocolRegistry.registerProtocol; + public interface ViaBackwardsPlatform { /** - * Initialize ViaBackwards + * Initialize ViaBackwards. */ default void init(File dataFolder) { ViaBackwardsConfig config = new ViaBackwardsConfig(new File(dataFolder, "config.yml")); @@ -47,20 +48,21 @@ public interface ViaBackwardsPlatform { if (isOutdated()) return; - ProtocolRegistry.registerProtocol(new Protocol1_9_4To1_10(), Collections.singletonList(ProtocolVersion.v1_9_3.getId()), ProtocolVersion.v1_10.getId()); - ProtocolRegistry.registerProtocol(new Protocol1_10To1_11(), Collections.singletonList(ProtocolVersion.v1_10.getId()), ProtocolVersion.v1_11.getId()); - ProtocolRegistry.registerProtocol(new Protocol1_11To1_11_1(), Collections.singletonList(ProtocolVersion.v1_11.getId()), ProtocolVersion.v1_11_1.getId()); - ProtocolRegistry.registerProtocol(new Protocol1_11_1To1_12(), Collections.singletonList(ProtocolVersion.v1_11_1.getId()), ProtocolVersion.v1_12.getId()); - ProtocolRegistry.registerProtocol(new Protocol1_12To1_12_1(), Collections.singletonList(ProtocolVersion.v1_12.getId()), ProtocolVersion.v1_12_1.getId()); - ProtocolRegistry.registerProtocol(new Protocol1_12_1To1_12_2(), Collections.singletonList(ProtocolVersion.v1_12_1.getId()), ProtocolVersion.v1_12_2.getId()); - ProtocolRegistry.registerProtocol(new Protocol1_12_2To1_13(), Collections.singletonList(ProtocolVersion.v1_12_2.getId()), ProtocolVersion.v1_13.getId()); - ProtocolRegistry.registerProtocol(new Protocol1_13To1_13_1(), Collections.singletonList(ProtocolVersion.v1_13.getId()), ProtocolVersion.v1_13_1.getId()); - ProtocolRegistry.registerProtocol(new Protocol1_13_1To1_13_2(), Collections.singletonList(ProtocolVersion.v1_13_1.getId()), ProtocolVersion.v1_13_2.getId()); - ProtocolRegistry.registerProtocol(new Protocol1_13_2To1_14(), Collections.singletonList(ProtocolVersion.v1_13_2.getId()), ProtocolVersion.v1_14.getId()); - ProtocolRegistry.registerProtocol(new Protocol1_14To1_14_1(), Collections.singletonList(ProtocolVersion.v1_14.getId()), ProtocolVersion.v1_14_1.getId()); - ProtocolRegistry.registerProtocol(new Protocol1_14_1To1_14_2(), Collections.singletonList(ProtocolVersion.v1_14_1.getId()), ProtocolVersion.v1_14_2.getId()); - ProtocolRegistry.registerProtocol(new Protocol1_14_2To1_14_3(), Collections.singletonList(ProtocolVersion.v1_14_2.getId()), ProtocolVersion.v1_14_3.getId()); - ProtocolRegistry.registerProtocol(new Protocol1_14_3To1_14_4(), Collections.singletonList(ProtocolVersion.v1_14_3.getId()), ProtocolVersion.v1_14_4.getId()); + 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); + registerProtocol(new Protocol1_11_1To1_12(), ProtocolVersion.v1_11_1, ProtocolVersion.v1_12); + registerProtocol(new Protocol1_12To1_12_1(), ProtocolVersion.v1_12, ProtocolVersion.v1_12_1); + registerProtocol(new Protocol1_12_1To1_12_2(), ProtocolVersion.v1_12_1, ProtocolVersion.v1_12_2); + registerProtocol(new Protocol1_12_2To1_13(), ProtocolVersion.v1_12_2, ProtocolVersion.v1_13); + registerProtocol(new Protocol1_13To1_13_1(), ProtocolVersion.v1_13, ProtocolVersion.v1_13_1); + registerProtocol(new Protocol1_13_1To1_13_2(), ProtocolVersion.v1_13_1, ProtocolVersion.v1_13_2); + registerProtocol(new Protocol1_13_2To1_14(), ProtocolVersion.v1_13_2, ProtocolVersion.v1_14); + registerProtocol(new Protocol1_14To1_14_1(), ProtocolVersion.v1_14, ProtocolVersion.v1_14_1); + registerProtocol(new Protocol1_14_1To1_14_2(), ProtocolVersion.v1_14_1, ProtocolVersion.v1_14_2); + registerProtocol(new Protocol1_14_2To1_14_3(), ProtocolVersion.v1_14_2, ProtocolVersion.v1_14_3); + registerProtocol(new Protocol1_14_3To1_14_4(), ProtocolVersion.v1_14_3, ProtocolVersion.v1_14_4); + registerProtocol(new Protocol1_14_4To1_15(), ProtocolVersion.v1_14_4, ProtocolVersion.v1_15); } /** @@ -71,7 +73,7 @@ public interface ViaBackwardsPlatform { Logger getLogger(); default boolean isOutdated() { - String minimumVVVersion = "2.0.0"; + String minimumVVVersion = "3.0.0"; boolean upToDate = false; try { Class vvVersionInfo = Class.forName("us.myles.ViaVersion.sponge.VersionInfo"); @@ -98,7 +100,7 @@ public interface ViaBackwardsPlatform { } /** - * Disable the plugin + * Disable the plugin. */ void disable(); } diff --git a/core/src/main/java/nl/matsv/viabackwards/api/data/VBMappingDataLoader.java b/core/src/main/java/nl/matsv/viabackwards/api/data/VBMappingDataLoader.java new file mode 100644 index 00000000..c08bb741 --- /dev/null +++ b/core/src/main/java/nl/matsv/viabackwards/api/data/VBMappingDataLoader.java @@ -0,0 +1,98 @@ +package nl.matsv.viabackwards.api.data; + +import nl.matsv.viabackwards.ViaBackwards; +import us.myles.ViaVersion.api.Via; +import us.myles.ViaVersion.api.data.MappingDataLoader; +import us.myles.ViaVersion.util.GsonUtil; +import us.myles.viaversion.libs.gson.JsonArray; +import us.myles.viaversion.libs.gson.JsonElement; +import us.myles.viaversion.libs.gson.JsonObject; +import us.myles.viaversion.libs.gson.JsonPrimitive; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Map; + +public class VBMappingDataLoader { + + public static JsonObject loadData(String name) { + InputStream stream = VBMappingDataLoader.class.getClassLoader().getResourceAsStream("assets/viabackwards/data/" + name); + InputStreamReader reader = new InputStreamReader(stream); + try { + return GsonUtil.getGson().fromJson(reader, JsonObject.class); + } finally { + try { + reader.close(); + } catch (IOException ignored) { + // Ignored + } + } + } + + public static void mapIdentifiers(short[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers) { + mapIdentifiers(output, oldIdentifiers, newIdentifiers, diffIdentifiers, true); + } + + public static void mapIdentifiers(short[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers, boolean warnOnMissing) { + for (Map.Entry entry : oldIdentifiers.entrySet()) { + String key = entry.getValue().getAsString(); + Map.Entry value = MappingDataLoader.findValue(newIdentifiers, key); + if (value == null) { + // Search in diff mappings + if (diffIdentifiers != null) { + JsonPrimitive diffValue = diffIdentifiers.getAsJsonPrimitive(key); + if (diffValue == null && key.contains("[")) { + diffValue = diffIdentifiers.getAsJsonPrimitive(key.substring(0, key.indexOf('['))); + } + if (diffValue == null) { + if (warnOnMissing && !Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) { + ViaBackwards.getPlatform().getLogger().warning("No diff key for " + entry.getValue() + " :( "); + } + continue; + } + value = MappingDataLoader.findValue(newIdentifiers, diffValue.getAsString()); + } + if (value == null) { + if (warnOnMissing && !Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) { + ViaBackwards.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( "); + } + continue; + } + } + output[Integer.parseInt(entry.getKey())] = Short.parseShort(value.getKey()); + } + } + + public static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers, JsonObject diffIdentifiers, boolean warnOnMissing) { + int i = -1; + for (JsonElement oldIdentifier : oldIdentifiers) { + i++; + String key = oldIdentifier.getAsString(); + Integer index = MappingDataLoader.findIndex(newIdentifiers, key); + if (index == null) { + // Search in diff mappings + if (diffIdentifiers != null) { + JsonPrimitive diffValue = diffIdentifiers.getAsJsonPrimitive(key); + if (diffValue == null) { + if (warnOnMissing && !Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) { + ViaBackwards.getPlatform().getLogger().warning("No diff key for " + key + " :( "); + } + continue; + } + String mappedName = diffValue.getAsString(); + if (mappedName.isEmpty()) continue; // "empty" remaps + + index = MappingDataLoader.findIndex(newIdentifiers, mappedName); + } + if (index == null) { + if (warnOnMissing && !Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) { + ViaBackwards.getPlatform().getLogger().warning("No key for " + key + " :( "); + } + continue; + } + } + output[i] = index.shortValue(); + } + } +} diff --git a/core/src/main/java/nl/matsv/viabackwards/api/data/VBMappings.java b/core/src/main/java/nl/matsv/viabackwards/api/data/VBMappings.java new file mode 100644 index 00000000..964b8106 --- /dev/null +++ b/core/src/main/java/nl/matsv/viabackwards/api/data/VBMappings.java @@ -0,0 +1,44 @@ +package nl.matsv.viabackwards.api.data; + +import us.myles.ViaVersion.api.data.Mappings; +import us.myles.viaversion.libs.gson.JsonArray; +import us.myles.viaversion.libs.gson.JsonObject; + +import java.util.Arrays; + +public class VBMappings extends Mappings { + + public VBMappings(int size, JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping) { + this(size, oldMapping, newMapping, diffMapping, true); + } + + public VBMappings(JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping) { + this(oldMapping, newMapping, diffMapping, true); + } + + public VBMappings(int size, JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping, boolean warnOnMissing) { + super(create(size, oldMapping, newMapping, diffMapping, warnOnMissing)); + } + + public VBMappings(JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping, boolean warnOnMissing) { + super(create(oldMapping.entrySet().size(), oldMapping, newMapping, diffMapping, warnOnMissing)); + } + + public VBMappings(JsonArray oldMapping, JsonArray newMapping, JsonObject diffMapping) { + super(create(oldMapping, newMapping, diffMapping, true)); + } + + private static short[] create(int size, JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping, boolean warnOnMissing) { + short[] oldToNew = new short[size]; + Arrays.fill(oldToNew, (short) -1); + VBMappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, diffMapping, warnOnMissing); + return oldToNew; + } + + private static short[] create(JsonArray oldMapping, JsonArray newMapping, JsonObject diffMapping, boolean warnOnMissing) { + short[] oldToNew = new short[oldMapping.size()]; + Arrays.fill(oldToNew, (short) -1); + VBMappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, diffMapping, warnOnMissing); + return oldToNew; + } +} diff --git a/core/src/main/java/nl/matsv/viabackwards/api/entities/storage/EntityTracker.java b/core/src/main/java/nl/matsv/viabackwards/api/entities/storage/EntityTracker.java index 71fd923f..0c3f9611 100644 --- a/core/src/main/java/nl/matsv/viabackwards/api/entities/storage/EntityTracker.java +++ b/core/src/main/java/nl/matsv/viabackwards/api/entities/storage/EntityTracker.java @@ -12,6 +12,7 @@ package nl.matsv.viabackwards.api.entities.storage; import lombok.Getter; import lombok.RequiredArgsConstructor; +import lombok.Setter; import lombok.ToString; import nl.matsv.viabackwards.api.BackwardsProtocol; import us.myles.ViaVersion.api.data.StoredObject; diff --git a/core/src/main/java/nl/matsv/viabackwards/api/exceptions/RemovedValueException.java b/core/src/main/java/nl/matsv/viabackwards/api/exceptions/RemovedValueException.java index ccf82672..d7a978a5 100644 --- a/core/src/main/java/nl/matsv/viabackwards/api/exceptions/RemovedValueException.java +++ b/core/src/main/java/nl/matsv/viabackwards/api/exceptions/RemovedValueException.java @@ -17,5 +17,9 @@ public class RemovedValueException extends IOException { /** * May be cached since it is never actually printed, only checked. */ - public static final RemovedValueException EX = new RemovedValueException(); + public static final RemovedValueException EX = new RemovedValueException() { + public synchronized Throwable fillInStackTrace() { + return this; + } + }; } diff --git a/core/src/main/java/nl/matsv/viabackwards/api/rewriters/BlockItemRewriter.java b/core/src/main/java/nl/matsv/viabackwards/api/rewriters/BlockItemRewriter.java index bdcb1d71..b9f28980 100644 --- a/core/src/main/java/nl/matsv/viabackwards/api/rewriters/BlockItemRewriter.java +++ b/core/src/main/java/nl/matsv/viabackwards/api/rewriters/BlockItemRewriter.java @@ -23,6 +23,7 @@ import nl.matsv.viabackwards.utils.ItemUtil; import us.myles.ViaVersion.api.minecraft.chunks.Chunk; import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection; import us.myles.ViaVersion.api.minecraft.item.Item; +import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter; import us.myles.viaversion.libs.opennbt.conversion.builtin.CompoundTagConverter; import us.myles.viaversion.libs.opennbt.tag.builtin.*; @@ -35,6 +36,7 @@ public abstract class BlockItemRewriter extends Rew private static final CompoundTagConverter converter = new CompoundTagConverter(); private final Map replacementData = new ConcurrentHashMap<>(); protected String nbtTagName; + protected boolean jsonNameFormat = true; @Override public void register(T protocol) { @@ -48,7 +50,7 @@ public abstract class BlockItemRewriter extends Rew return settings; } - protected Item handleItemToClient(Item i) { + public Item handleItemToClient(Item i) { if (i == null) return null; BlockItemSettings data = replacementData.get(i.getIdentifier()); @@ -57,14 +59,14 @@ public abstract class BlockItemRewriter extends Rew Item original = ItemUtil.copyItem(i); if (data.hasRepItem()) { ItemUtil.copyItem(i, data.getRepItem()); - - if (i.getTag() == null) + if (i.getTag() == null) { i.setTag(new CompoundTag("")); + } // Backup data for toServer i.getTag().put(createViaNBT(original)); - // Keep original data + // Keep original data (aisde from the name) if (original.getTag() != null) { for (Tag ai : original.getTag()) { i.getTag().put(ai); @@ -76,7 +78,6 @@ public abstract class BlockItemRewriter extends Rew CompoundTag tag = i.getTag().get("display"); if (tag.contains("Name")) { String value = (String) tag.get("Name").getValue(); - tag.put(new StringTag("Name", value.replaceAll("%viabackwards_color%", BlockColors.get((int) original.getData())))); } @@ -84,19 +85,21 @@ public abstract class BlockItemRewriter extends Rew i.setAmount(original.getAmount()); // Keep original data when -1 - if (i.getData() == -1) + if (i.getData() == -1) { i.setData(original.getData()); + } } if (data.hasItemTagHandler()) { - if (!i.getTag().contains(nbtTagName)) + if (!i.getTag().contains(nbtTagName)) { i.getTag().put(createViaNBT(original)); + } data.getItemHandler().handle(i); } return i; } - protected Item handleItemToServer(Item item) { + public Item handleItemToServer(Item item) { if (item == null) return null; if (item.getTag() == null) return item; @@ -242,7 +245,15 @@ public abstract class BlockItemRewriter extends Rew protected CompoundTag getNamedTag(String text) { CompoundTag tag = new CompoundTag(""); tag.put(new CompoundTag("display")); - ((CompoundTag) tag.get("display")).put(new StringTag("Name", ChatColor.RESET + text)); + text = ChatColor.RESET + text; + ((CompoundTag) tag.get("display")).put(new StringTag("Name", jsonNameFormat ? ChatRewriter.legacyTextToJson(text) : text)); + return tag; + } + + protected CompoundTag getNamedJsonTag(String text) { + CompoundTag tag = new CompoundTag(""); + tag.put(new CompoundTag("display")); + return tag; } diff --git a/core/src/main/java/nl/matsv/viabackwards/api/rewriters/EntityRewriter.java b/core/src/main/java/nl/matsv/viabackwards/api/rewriters/EntityRewriter.java index 841048a2..35147fc5 100644 --- a/core/src/main/java/nl/matsv/viabackwards/api/rewriters/EntityRewriter.java +++ b/core/src/main/java/nl/matsv/viabackwards/api/rewriters/EntityRewriter.java @@ -56,8 +56,8 @@ public abstract class EntityRewriter extends Rewrit return getEntityTracker(connection).getEntityType(id); } - protected void addTrackedEntity(UserConnection connection, int entityId, EntityType type) { - getEntityTracker(connection).trackEntityType(entityId, type); + protected void addTrackedEntity(PacketWrapper wrapper, int entityId, EntityType type) throws Exception { + getEntityTracker(wrapper.user()).trackEntityType(entityId, type); } protected boolean hasData(EntityType type) { @@ -101,9 +101,10 @@ public abstract class EntityRewriter extends Rewrit protected MetaStorage handleMeta(UserConnection user, int entityId, MetaStorage storage) throws Exception { Optional optEntity = getEntityTracker(user).getEntity(entityId); if (!optEntity.isPresent()) { - if (!Via.getConfig().isSuppressMetadataErrors()) + if (!Via.getConfig().isSuppressMetadataErrors()) { ViaBackwards.getPlatform().getLogger().warning("Metadata for entity id: " + entityId + " not sent because the entity doesn't exist. " + storage); - throw new CancelException(); + } + throw CancelException.CACHED; } EntityTracker.StoredEntity entity = optEntity.get(); @@ -171,7 +172,6 @@ public abstract class EntityRewriter extends Rewrit data.setValue(mobName); } } - } return storage; @@ -202,6 +202,47 @@ public abstract class EntityRewriter extends Rewrit }); } + protected void register1_15MetadataRewriter(int oldPacketId, int newPacketId, Type> metaType) { + register1_15MetadataRewriter(oldPacketId, newPacketId, null, metaType); + } + + /** + * Helper method to handle a metadata list packet and its full initial meta rewrite. + */ + protected void register1_15MetadataRewriter(int oldPacketId, int newPacketId, Type> oldMetaType, Type> newMetaType) { + getProtocol().registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity ID + if (oldMetaType != null) { + map(oldMetaType, newMetaType); + } else { + map(newMetaType); + } + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int entityId = wrapper.get(Type.VAR_INT, 0); + EntityType type = getEntityType(wrapper.user(), entityId); + + MetaStorage storage = new MetaStorage(wrapper.get(newMetaType, 0)); + handleMeta(wrapper.user(), entityId, storage); + + Optional optEntDat = getEntityData(type); + if (optEntDat.isPresent()) { + EntityData data = optEntDat.get(); + if (data.hasBaseMeta()) { + data.getDefaultMeta().handle(storage); + } + } + + wrapper.set(newMetaType, 0, storage.getMetaDataList()); + } + }); + } + }); + } + protected void registerMetadataRewriter(int oldPacketId, int newPacketId, Type> metaType) { registerMetadataRewriter(oldPacketId, newPacketId, null, metaType); } @@ -217,7 +258,7 @@ public abstract class EntityRewriter extends Rewrit handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { - addTrackedEntity(wrapper.user(), (int) wrapper.get(intType, 0), entityType); + addTrackedEntity(wrapper, (int) wrapper.get(intType, 0), entityType); } }); } @@ -235,12 +276,12 @@ public abstract class EntityRewriter extends Rewrit getProtocol().registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { @Override public void registerMap() { - map(Type.VAR_INT_ARRAY); // 0 - Entity ids + map(Type.VAR_INT_ARRAY_PRIMITIVE); // 0 - Entity ids handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { EntityTracker.ProtocolEntityTracker tracker = getEntityTracker(wrapper.user()); - for (int entity : wrapper.get(Type.VAR_INT_ARRAY, 0)) { + for (int entity : wrapper.get(Type.VAR_INT_ARRAY_PRIMITIVE, 0)) { tracker.removeEntity(entity); } } @@ -257,7 +298,7 @@ public abstract class EntityRewriter extends Rewrit return new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { - addTrackedEntity(wrapper.user(), wrapper.get(Type.VAR_INT, 0), getObjectTypeFromId(wrapper.get(Type.BYTE, 0))); + addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), getObjectTypeFromId(wrapper.get(Type.BYTE, 0))); } }; } @@ -267,7 +308,7 @@ public abstract class EntityRewriter extends Rewrit @Override public void handle(PacketWrapper wrapper) throws Exception { Number id = (Number) wrapper.get(intType, typeIndex); - addTrackedEntity(wrapper.user(), wrapper.get(Type.VAR_INT, 0), getTypeFromId(id.intValue())); + addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), getTypeFromId(id.intValue())); } }; } @@ -280,7 +321,7 @@ public abstract class EntityRewriter extends Rewrit return new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { - addTrackedEntity(wrapper.user(), (int) wrapper.get(intType, 0), entityType); + addTrackedEntity(wrapper, (int) wrapper.get(intType, 0), entityType); } }; } @@ -316,7 +357,7 @@ public abstract class EntityRewriter extends Rewrit return new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { - addTrackedEntity(wrapper.user(), wrapper.get(Type.VAR_INT, 0), entityType); + addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), entityType); List metaDataList = handleMeta(wrapper.user(), wrapper.get(Type.VAR_INT, 0), new MetaStorage(wrapper.get(metaType, 0))).getMetaDataList(); diff --git a/core/src/main/java/nl/matsv/viabackwards/api/rewriters/RecipeRewriter.java b/core/src/main/java/nl/matsv/viabackwards/api/rewriters/RecipeRewriter.java new file mode 100644 index 00000000..f25be98a --- /dev/null +++ b/core/src/main/java/nl/matsv/viabackwards/api/rewriters/RecipeRewriter.java @@ -0,0 +1,14 @@ +package nl.matsv.viabackwards.api.rewriters; + +import us.myles.ViaVersion.api.PacketWrapper; + +public abstract class RecipeRewriter { + + protected final BlockItemRewriter rewriter; + + protected RecipeRewriter(final BlockItemRewriter rewriter) { + this.rewriter = rewriter; + } + + public abstract void handle(PacketWrapper wrapper, String type) throws Exception; +} diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/EntityTypeNames.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/EntityTypeNames.java index 13f556f6..d4cf3dee 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/EntityTypeNames.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/EntityTypeNames.java @@ -17,10 +17,10 @@ import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag; import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag; /* - Copied from ViaVersion //TODO implement in EntityTypes? + Copied from ViaVersion */ public class EntityTypeNames { - private static BiMap newToOldNames = HashBiMap.create(); + private static final BiMap NEW_TO_OLD_NAMES = HashBiMap.create(); static { add("AreaEffectCloud", "minecraft:area_effect_cloud"); @@ -102,14 +102,14 @@ public class EntityTypeNames { // Other way around (-: private static void add(String oldName, String newName) { - newToOldNames.put(newName, oldName); + NEW_TO_OLD_NAMES.put(newName, oldName); } public static void toClient(CompoundTag tag) { if (tag.get("id") instanceof StringTag) { StringTag id = tag.get("id"); - if (newToOldNames.containsKey(id.getValue())) { - id.setValue(newToOldNames.get(id.getValue())); + if (NEW_TO_OLD_NAMES.containsKey(id.getValue())) { + id.setValue(NEW_TO_OLD_NAMES.get(id.getValue())); } } } @@ -130,7 +130,7 @@ public class EntityTypeNames { } private static boolean hasEntityTag(Item item) { - if (item != null && item.getId() == 383) { // Monster Egg + if (item != null && item.getIdentifier() == 383) { // Monster Egg CompoundTag tag = item.getTag(); if (tag != null && tag.contains("EntityTag") && tag.get("EntityTag") instanceof CompoundTag) { if (((CompoundTag) tag.get("EntityTag")).get("id") instanceof StringTag) { diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/packets/BlockItemPackets1_11.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/packets/BlockItemPackets1_11.java index 0d5f4078..4c72d4b3 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/packets/BlockItemPackets1_11.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/packets/BlockItemPackets1_11.java @@ -47,6 +47,7 @@ public class BlockItemPackets1_11 extends BlockItemRewriter @Override protected void registerPackets(Protocol1_10To1_11 protocol) { + jsonNameFormat = false; ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer); // Set slot packet @@ -351,8 +352,8 @@ public class BlockItemPackets1_11 extends BlockItemRewriter // ShulkerBoxes to EnderChest for (int i = 219; i < 235; i++) rewrite(i) - .repItem(new Item((short) 130, (byte) 1, (short) 0, getNamedTag("1.11 " + BlockColors.get(i - 219) + " Shulker Box"))) - .repBlock(new Block(130, 4)) // TODO investigate this + .repItem(new Item(130, (byte) 1, (short) 0, getNamedTag("1.11 " + BlockColors.get(i - 219) + " Shulker Box"))) + .repBlock(new Block(130, 4)) .blockEntityHandler((block, tag) -> { tag.remove("id"); tag.put(new StringTag("id", "minecraft:chest")); @@ -360,7 +361,7 @@ public class BlockItemPackets1_11 extends BlockItemRewriter }); // Observer to Dispenser - rewrite(218).repItem(new Item((short) 23, (byte) 1, (short) 0, getNamedTag("1.11 Observer"))).repBlock(new Block(23, -1)); + rewrite(218).repItem(new Item(23, (byte) 1, (short) 0, getNamedTag("1.11 Observer"))).repBlock(new Block(23, -1)); // Handle spawner block entity rewrite(52).blockEntityHandler((b, tag) -> { @@ -375,10 +376,10 @@ public class BlockItemPackets1_11 extends BlockItemRewriter }); // Totem of Undying to Dead Bush - rewrite(449).repItem(new Item((short) 32, (byte) 1, (short) 0, getNamedTag("1.11 Totem of Undying"))); + rewrite(449).repItem(new Item(32, (byte) 1, (short) 0, getNamedTag("1.11 Totem of Undying"))); // Shulker shell to Popped Chorus Fruit - rewrite(450).repItem(new Item((short) 433, (byte) 1, (short) 0, getNamedTag("1.11 Shulker Shell"))); + rewrite(450).repItem(new Item(433, (byte) 1, (short) 0, getNamedTag("1.11 Shulker Shell"))); enchantmentRewriter = new LegacyEnchantmentRewriter(nbtTagName); enchantmentRewriter.registerEnchantment(71, "§cCurse of Vanishing"); @@ -388,7 +389,7 @@ public class BlockItemPackets1_11 extends BlockItemRewriter } @Override - protected Item handleItemToClient(final Item item) { + public Item handleItemToClient(final Item item) { if (item == null) return null; super.handleItemToClient(item); @@ -405,7 +406,7 @@ public class BlockItemPackets1_11 extends BlockItemRewriter } @Override - protected Item handleItemToServer(final Item item) { + public Item handleItemToServer(final Item item) { if (item == null) return null; super.handleItemToServer(item); @@ -442,7 +443,6 @@ public class BlockItemPackets1_11 extends BlockItemRewriter return Optional.empty(); } - // TODO improve the llama inventory part private int getNewSlotId(ChestedHorseStorage storage, int slotId) { int totalSlots = !storage.isChested() ? 38 : 53; int strength = storage.isChested() ? storage.getLiamaStrength() : 0; @@ -477,7 +477,7 @@ public class BlockItemPackets1_11 extends BlockItemRewriter int endNonExistingFormula = 2 + 3 * (storage.isChested() ? 5 : 0); if (slotId >= startNonExistingFormula && slotId < endNonExistingFormula) - return new Item((short) 166, (byte) 1, (short) 0, getNamedTag(ChatColor.RED + "SLOT DISABLED")); + return new Item(166, (byte) 1, (short) 0, getNamedTag(ChatColor.RED + "SLOT DISABLED")); if (slotId == 1) return null; return current; diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/packets/EntityPackets1_11.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/packets/EntityPackets1_11.java index 6d4a0530..67b04b65 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/packets/EntityPackets1_11.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_10to1_11/packets/EntityPackets1_11.java @@ -344,7 +344,7 @@ public class EntityPackets1_11 extends EntityRewriter { return data; }); - // Create chested horse storage TODO create on mob spawn? + // Create chested horse storage registerMetaHandler().filter(Entity1_11Types.EntityType.CHESTED_HORSE, true).handle(e -> { if (!e.getEntity().has(ChestedHorseStorage.class)) e.getEntity().put(new ChestedHorseStorage()); diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/Protocol1_11_1To1_12.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/Protocol1_11_1To1_12.java index 2578a490..ca45588b 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/Protocol1_11_1To1_12.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/Protocol1_11_1To1_12.java @@ -20,7 +20,6 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; @Getter public class Protocol1_11_1To1_12 extends BackwardsProtocol { - // TODO checkAndStore all rewriters and make them easy accessible? private EntityPackets1_12 entityPackets; private BlockItemPackets1_12 blockItemPackets; diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/data/BlockColors.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/data/BlockColors.java index b40950dc..a8b182b0 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/data/BlockColors.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/data/BlockColors.java @@ -10,11 +10,11 @@ package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data; +import java.util.HashMap; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; public class BlockColors { - private static Map colors = new ConcurrentHashMap<>(); + private static final Map COLORS = new HashMap<>(); private static int count = 0; static { @@ -37,14 +37,14 @@ public class BlockColors { } private static void add(String value) { - colors.put(count++, value); + COLORS.put(count++, value); } public static boolean has(Integer key) { - return colors.containsKey(key); + return COLORS.containsKey(key); } public static String get(Integer key) { - return colors.getOrDefault(key, "Unknown color"); + return COLORS.getOrDefault(key, "Unknown color"); } } diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/data/MapColorMapping.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/data/MapColorMapping.java index 1cff310c..fad1554d 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/data/MapColorMapping.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/data/MapColorMapping.java @@ -4,75 +4,76 @@ import java.util.HashMap; import java.util.Map; public class MapColorMapping { - private static Map mapping = new HashMap<>(); - static { - mapping.put(144, 59); // (148, 124, 114) -> (148, 124, 114) - mapping.put(145, 56); // (180, 153, 139) -> (180, 153, 139) - mapping.put(146, 56); // (209, 177, 161) -> (209, 177, 161) - mapping.put(147, 45); // (111, 94, 85) -> (111, 94, 85) - mapping.put(148, 63); // (112, 58, 25) -> (112, 58, 25) - mapping.put(149, 60); // (137, 71, 31) -> (137, 71, 31) - mapping.put(150, 60); // (159, 82, 36) -> (159, 82, 36) - mapping.put(151, 136); // (84, 43, 19) -> (84, 43, 19) - mapping.put(152, 83); // (105, 61, 76) -> (105, 61, 76) - mapping.put(153, 83); // (129, 75, 93) -> (129, 75, 93) - mapping.put(154, 80); // (149, 87, 108) -> (149, 87, 108) - mapping.put(155, 115); // (79, 46, 57) -> (79, 46, 57) - mapping.put(156, 39); // (79, 76, 97) -> (79, 76, 97) - mapping.put(157, 39); // (97, 93, 119) -> (97, 93, 119) - mapping.put(158, 36); // (112, 108, 138) -> (112, 108, 138) - mapping.put(159, 47); // (59, 57, 73) -> (59, 57, 73) - mapping.put(160, 60); // (131, 94, 25) -> (131, 94, 25) - mapping.put(161, 61); // (160, 115, 31) -> (160, 115, 31) - mapping.put(162, 62); // (186, 133, 36) -> (186, 133, 36) - mapping.put(163, 137); // (98, 70, 19) -> (98, 70, 19) - mapping.put(164, 108); // (73, 83, 37) -> (73, 83, 37) - mapping.put(165, 108); // (89, 101, 46) -> (89, 101, 46) - mapping.put(166, 109); // (103, 117, 53) -> (103, 117, 53) - mapping.put(167, 111); // (55, 62, 28) -> (55, 62, 28) - mapping.put(168, 112); // (113, 54, 55) -> (113, 54, 55) - mapping.put(169, 113); // (138, 66, 67) -> (138, 66, 67) - mapping.put(170, 114); // (160, 77, 78) -> (160, 77, 78) - mapping.put(171, 115); // (85, 41, 41) -> (85, 41, 41) - mapping.put(172, 118); // (40, 29, 25) -> (40, 29, 25) - mapping.put(173, 107); // (49, 35, 30) -> (49, 35, 30) - mapping.put(174, 107); // (57, 41, 35) -> (57, 41, 35) - mapping.put(175, 118); // (30, 22, 19) -> (30, 22, 19) - mapping.put(176, 91); // (95, 76, 69) -> (95, 76, 69) - mapping.put(177, 45); // (116, 92, 85) -> (116, 92, 85) - mapping.put(178, 46); // (135, 107, 98) -> (135, 107, 98) - mapping.put(179, 47); // (71, 57, 52) -> (71, 57, 52) - mapping.put(180, 85); // (61, 65, 65) -> (61, 65, 65) - mapping.put(181, 44); // (75, 79, 79) -> (75, 79, 79) - mapping.put(182, 27); // (87, 92, 92) -> (87, 92, 92) - mapping.put(183, 84); // (46, 49, 49) -> (46, 49, 49) - mapping.put(184, 83); // (86, 52, 62) -> (86, 52, 62) - mapping.put(185, 83); // (105, 63, 76) -> (105, 63, 76) - mapping.put(186, 83); // (122, 73, 88) -> (122, 73, 88) - mapping.put(187, 84); // (65, 39, 47) -> (65, 39, 47) - mapping.put(188, 84); // (54, 44, 65) -> (54, 44, 65) - mapping.put(189, 71); // (66, 53, 79) -> (66, 53, 79) - mapping.put(190, 71); // (76, 62, 92) -> (76, 62, 92) - mapping.put(191, 87); // (40, 33, 49) -> (40, 33, 49) - mapping.put(192, 107); // (54, 35, 25) -> (54, 35, 25) - mapping.put(193, 139); // (66, 43, 30) -> (66, 43, 30) - mapping.put(194, 43); // (76, 50, 35) -> (76, 50, 35) - mapping.put(195, 107); // (40, 26, 19) -> (40, 26, 19) - mapping.put(196, 111); // (54, 58, 30) -> (54, 58, 30) - mapping.put(197, 111); // (66, 71, 36) -> (66, 71, 36) - mapping.put(198, 111); // (76, 82, 42) -> (76, 82, 42) - mapping.put(199, 107); // (40, 43, 22) -> (40, 43, 22) - mapping.put(200, 112); // (100, 42, 32) -> (100, 42, 32) - mapping.put(201, 113); // (123, 52, 40) -> (123, 52, 40) - mapping.put(202, 113); // (142, 60, 46) -> (142, 60, 46) - mapping.put(203, 115); // (75, 32, 24) -> (75, 32, 24) - mapping.put(204, 116); // (26, 16, 11) -> (26, 16, 11) - mapping.put(205, 117); // (32, 19, 14) -> (32, 19, 14) - mapping.put(206, 107); // (37, 22, 16) -> (37, 22, 16) - mapping.put(207, 119); // (20, 12, 8) -> (20, 12, 8) - } + private static final Map MAPPING = new HashMap<>(); - public static int getNearestOldColor(int color) { - return mapping.getOrDefault(color, color); - } + static { + MAPPING.put(144, 59); // (148, 124, 114) -> (148, 124, 114) + MAPPING.put(145, 56); // (180, 153, 139) -> (180, 153, 139) + MAPPING.put(146, 56); // (209, 177, 161) -> (209, 177, 161) + MAPPING.put(147, 45); // (111, 94, 85) -> (111, 94, 85) + MAPPING.put(148, 63); // (112, 58, 25) -> (112, 58, 25) + MAPPING.put(149, 60); // (137, 71, 31) -> (137, 71, 31) + MAPPING.put(150, 60); // (159, 82, 36) -> (159, 82, 36) + MAPPING.put(151, 136); // (84, 43, 19) -> (84, 43, 19) + MAPPING.put(152, 83); // (105, 61, 76) -> (105, 61, 76) + MAPPING.put(153, 83); // (129, 75, 93) -> (129, 75, 93) + MAPPING.put(154, 80); // (149, 87, 108) -> (149, 87, 108) + MAPPING.put(155, 115); // (79, 46, 57) -> (79, 46, 57) + MAPPING.put(156, 39); // (79, 76, 97) -> (79, 76, 97) + MAPPING.put(157, 39); // (97, 93, 119) -> (97, 93, 119) + MAPPING.put(158, 36); // (112, 108, 138) -> (112, 108, 138) + MAPPING.put(159, 47); // (59, 57, 73) -> (59, 57, 73) + MAPPING.put(160, 60); // (131, 94, 25) -> (131, 94, 25) + MAPPING.put(161, 61); // (160, 115, 31) -> (160, 115, 31) + MAPPING.put(162, 62); // (186, 133, 36) -> (186, 133, 36) + MAPPING.put(163, 137); // (98, 70, 19) -> (98, 70, 19) + MAPPING.put(164, 108); // (73, 83, 37) -> (73, 83, 37) + MAPPING.put(165, 108); // (89, 101, 46) -> (89, 101, 46) + MAPPING.put(166, 109); // (103, 117, 53) -> (103, 117, 53) + MAPPING.put(167, 111); // (55, 62, 28) -> (55, 62, 28) + MAPPING.put(168, 112); // (113, 54, 55) -> (113, 54, 55) + MAPPING.put(169, 113); // (138, 66, 67) -> (138, 66, 67) + MAPPING.put(170, 114); // (160, 77, 78) -> (160, 77, 78) + MAPPING.put(171, 115); // (85, 41, 41) -> (85, 41, 41) + MAPPING.put(172, 118); // (40, 29, 25) -> (40, 29, 25) + MAPPING.put(173, 107); // (49, 35, 30) -> (49, 35, 30) + MAPPING.put(174, 107); // (57, 41, 35) -> (57, 41, 35) + MAPPING.put(175, 118); // (30, 22, 19) -> (30, 22, 19) + MAPPING.put(176, 91); // (95, 76, 69) -> (95, 76, 69) + MAPPING.put(177, 45); // (116, 92, 85) -> (116, 92, 85) + MAPPING.put(178, 46); // (135, 107, 98) -> (135, 107, 98) + MAPPING.put(179, 47); // (71, 57, 52) -> (71, 57, 52) + MAPPING.put(180, 85); // (61, 65, 65) -> (61, 65, 65) + MAPPING.put(181, 44); // (75, 79, 79) -> (75, 79, 79) + MAPPING.put(182, 27); // (87, 92, 92) -> (87, 92, 92) + MAPPING.put(183, 84); // (46, 49, 49) -> (46, 49, 49) + MAPPING.put(184, 83); // (86, 52, 62) -> (86, 52, 62) + MAPPING.put(185, 83); // (105, 63, 76) -> (105, 63, 76) + MAPPING.put(186, 83); // (122, 73, 88) -> (122, 73, 88) + MAPPING.put(187, 84); // (65, 39, 47) -> (65, 39, 47) + MAPPING.put(188, 84); // (54, 44, 65) -> (54, 44, 65) + MAPPING.put(189, 71); // (66, 53, 79) -> (66, 53, 79) + MAPPING.put(190, 71); // (76, 62, 92) -> (76, 62, 92) + MAPPING.put(191, 87); // (40, 33, 49) -> (40, 33, 49) + MAPPING.put(192, 107); // (54, 35, 25) -> (54, 35, 25) + MAPPING.put(193, 139); // (66, 43, 30) -> (66, 43, 30) + MAPPING.put(194, 43); // (76, 50, 35) -> (76, 50, 35) + MAPPING.put(195, 107); // (40, 26, 19) -> (40, 26, 19) + MAPPING.put(196, 111); // (54, 58, 30) -> (54, 58, 30) + MAPPING.put(197, 111); // (66, 71, 36) -> (66, 71, 36) + MAPPING.put(198, 111); // (76, 82, 42) -> (76, 82, 42) + MAPPING.put(199, 107); // (40, 43, 22) -> (40, 43, 22) + MAPPING.put(200, 112); // (100, 42, 32) -> (100, 42, 32) + MAPPING.put(201, 113); // (123, 52, 40) -> (123, 52, 40) + MAPPING.put(202, 113); // (142, 60, 46) -> (142, 60, 46) + MAPPING.put(203, 115); // (75, 32, 24) -> (75, 32, 24) + MAPPING.put(204, 116); // (26, 16, 11) -> (26, 16, 11) + MAPPING.put(205, 117); // (32, 19, 14) -> (32, 19, 14) + MAPPING.put(206, 107); // (37, 22, 16) -> (37, 22, 16) + MAPPING.put(207, 119); // (20, 12, 8) -> (20, 12, 8) + } + + public static int getNearestOldColor(int color) { + return MAPPING.getOrDefault(color, color); + } } diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/packets/BlockItemPackets1_12.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/packets/BlockItemPackets1_12.java index 87ead1c8..0a80ed7c 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/packets/BlockItemPackets1_12.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/packets/BlockItemPackets1_12.java @@ -33,9 +33,10 @@ import us.myles.viaversion.libs.opennbt.tag.builtin.ListTag; import java.util.Collections; public class BlockItemPackets1_12 extends BlockItemRewriter { + @Override protected void registerPackets(Protocol1_11_1To1_12 protocol) { - + jsonNameFormat = false; protocol.registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() { @Override public void registerMap() { @@ -59,7 +60,7 @@ public class BlockItemPackets1_12 extends BlockItemRewriter 143) { @@ -67,7 +68,7 @@ public class BlockItemPackets1_12 extends BlockItemRewriter Stained clay? (Also got a new name Terracota?) rewrite(251) - .repItem(new Item((short) 159, (byte) 1, (short) -1, getNamedTag("1.12 %viabackwards_color% Concrete"))) + .repItem(new Item(159, (byte) 1, (short) -1, getNamedTag("1.12 %viabackwards_color% Concrete"))) .repBlock(new Block(159, -1)); // Concrete Powder -> Wool rewrite(252) - .repItem(new Item((short) 35, (byte) 1, (short) -1, getNamedTag("1.12 %viabackwards_color% Concrete Powder"))) + .repItem(new Item(35, (byte) 1, (short) -1, getNamedTag("1.12 %viabackwards_color% Concrete Powder"))) .repBlock(new Block(35, -1)); // Knowledge book -> book rewrite(453) - .repItem(new Item((short) 340, (byte) 1, (short) 0, getNamedTag("1.12 Knowledge Book"))) + .repItem(new Item(340, (byte) 1, (short) 0, getNamedTag("1.12 Knowledge Book"))) .itemHandler(i -> { CompoundTag tag = i.getTag(); @@ -286,11 +287,11 @@ public class BlockItemPackets1_12 extends BlockItemRewriter Stained Clay for (int i = 235; i < 251; i++) { - rewrite(i).repItem(new Item((short) 159, (byte) 1, (short) (i - 235), getNamedTag("1.12 " + BlockColors.get(i - 235) + " Glazed Terracotta"))) + rewrite(i).repItem(new Item(159, (byte) 1, (short) (i - 235), getNamedTag("1.12 " + BlockColors.get(i - 235) + " Glazed Terracotta"))) .repBlock(new Block(159, (i - 235))); } // Handle beds - rewrite(355).repItem(new Item((short) 355, (byte) 1, (short) 0, getNamedTag("1.12 %viabackwards_color% Bed"))); + rewrite(355).repItem(new Item(355, (byte) 1, (short) 0, getNamedTag("1.12 %viabackwards_color% Bed"))); } } diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/packets/ChatPackets1_12.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/packets/ChatPackets1_12.java index 4aa69b64..94f54e5c 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/packets/ChatPackets1_12.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11_1to1_12/packets/ChatPackets1_12.java @@ -63,7 +63,7 @@ public class ChatPackets1_12 extends Rewriter { } - // TODO improve this, not copying will cause ConcurrentModificationException + // improve this, not copying will cause ConcurrentModificationException public void handleTranslations(JsonObject object) { JsonObject copiedObj = copy(object); diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11to1_11_1/packets/ItemPackets1_11_1.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11to1_11_1/packets/ItemPackets1_11_1.java index bd6904ce..c42384b9 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11to1_11_1/packets/ItemPackets1_11_1.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_11to1_11_1/packets/ItemPackets1_11_1.java @@ -30,6 +30,7 @@ public class ItemPackets1_11_1 extends BlockItemRewriter { @Override protected void registerPackets(Protocol1_11To1_11_1 protocol) { + jsonNameFormat = false; ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer); // Set slot packet @@ -98,7 +99,7 @@ public class ItemPackets1_11_1 extends BlockItemRewriter { } @Override - protected Item handleItemToClient(final Item item) { + public Item handleItemToClient(final Item item) { if (item == null) return null; super.handleItemToClient(item); @@ -115,7 +116,7 @@ public class ItemPackets1_11_1 extends BlockItemRewriter { } @Override - protected Item handleItemToServer(final Item item) { + public Item handleItemToServer(final Item item) { if (item == null) return null; super.handleItemToServer(item); diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java index d552243a..acba53b6 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java @@ -15,7 +15,6 @@ import nl.matsv.viabackwards.api.BackwardsProtocol; import nl.matsv.viabackwards.api.entities.storage.EntityTracker; 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.data.SoundMapping; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.EntityPackets1_13; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.PlayerPacket1_13; @@ -39,7 +38,6 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol { static { BackwardsMappings.init(); PaintingMapping.init(); - SoundMapping.init(); } @Override @@ -59,7 +57,6 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol { out(State.PLAY, 0x13, 0x12); // Close Window (clientbound) out(State.PLAY, 0x14, 0x13); // Open Window out(State.PLAY, 0x16, 0x15); // Window Property - out(State.PLAY, 0x18, 0x17); // Set Cooldown out(State.PLAY, 0x1B, 0x1A); // Disconnect (play) out(State.PLAY, 0x1C, 0x1B); // Entity Status out(State.PLAY, 0x1D, -1, cancel()); // NBT Query Response (client won't send a request, so the server should not answer) @@ -166,14 +163,8 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol { return new PacketRemapper() { @Override public void registerMap() { - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper packetWrapper) throws Exception { - packetWrapper.cancel(); - } - }); + handler(PacketWrapper::cancel); } }; } - } diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/block_entity_handlers/PistonHandler.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/block_entity_handlers/PistonHandler.java index b32ca7bc..b86360b1 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/block_entity_handlers/PistonHandler.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/block_entity_handlers/PistonHandler.java @@ -53,7 +53,7 @@ public class PistonHandler implements BackwardsBlockEntityProvider.BackwardsBloc // There doesn't seem to be a nicer way around it :( private void addEntries(String data, int id) { - id = BackwardsMappings.blockMappings.getNewBlock(id); + id = BackwardsMappings.blockMappings.getNewId(id); pistonIds.put(data, id); String substring = data.substring(10); diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/BackwardsMappings.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/BackwardsMappings.java index e47081b8..bb9b5b99 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/BackwardsMappings.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/BackwardsMappings.java @@ -11,35 +11,50 @@ package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data; import nl.matsv.viabackwards.ViaBackwards; +import nl.matsv.viabackwards.api.data.VBMappingDataLoader; +import nl.matsv.viabackwards.api.data.VBMappings; import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.data.MappingDataLoader; -import us.myles.ViaVersion.util.GsonUtil; +import us.myles.ViaVersion.api.data.Mappings; import us.myles.viaversion.libs.gson.JsonElement; import us.myles.viaversion.libs.gson.JsonObject; import us.myles.viaversion.libs.gson.JsonPrimitive; -import java.io.IOException; -import java.io.InputStreamReader; import java.util.Arrays; import java.util.Map; public class BackwardsMappings { - public static BlockMappings blockMappings; + public static BlockMappingsShortArray blockMappings; + public static Mappings soundMappings; public static void init() { JsonObject mapping1_12 = MappingDataLoader.loadData("mapping-1.12.json"); JsonObject mapping1_13 = MappingDataLoader.loadData("mapping-1.13.json"); - JsonObject mapping1_12_2to1_13 = loadData("mapping-1.12.2to1.13.json"); + JsonObject mapping1_12_2to1_13 = VBMappingDataLoader.loadData("mapping-1.12.2to1.13.json"); ViaBackwards.getPlatform().getLogger().info("Loading 1.13 -> 1.12.2 block mapping..."); blockMappings = new BlockMappingsShortArray(mapping1_13.getAsJsonObject("blocks"), mapping1_12.getAsJsonObject("blocks"), mapping1_12_2to1_13.getAsJsonObject("blockstates")); + ViaBackwards.getPlatform().getLogger().info("Loading 1.13 -> 1.12.2 sound mapping..."); + soundMappings = new VBMappings(mapping1_13.getAsJsonArray("sounds"), mapping1_12.getAsJsonArray("sounds"), mapping1_12_2to1_13.getAsJsonObject("sounds")); + + /* + // Simulate some trident sounds + SOUNDS[628] = 138; // throw -> shoot + SOUNDS[629] = 137; // hit -> hit_player + SOUNDS[630] = 137; // hit_ground -> hit + SOUNDS[631] = 139; // riptide_1 -> shoot + SOUNDS[632] = 139; // riptide_2 + SOUNDS[633] = 139; // riptide_3 + SOUNDS[634] = 139; // throw -> shoot + // no fitting thunder remap + */ } - + // Has lots of compat layers, so we can't use the default Via method private static void mapIdentifiers(short[] output, JsonObject newIdentifiers, JsonObject oldIdentifiers, JsonObject mapping) { for (Map.Entry entry : newIdentifiers.entrySet()) { String key = entry.getValue().getAsString(); - Map.Entry value = findValue(oldIdentifiers, key); + Map.Entry value = MappingDataLoader.findValue(oldIdentifiers, key); if (value == null) { JsonPrimitive replacement = mapping.getAsJsonPrimitive(key); if (replacement == null && key.contains("[")) { @@ -48,9 +63,9 @@ public class BackwardsMappings { if (replacement != null) { if (replacement.getAsString().startsWith("id:")) { String id = replacement.getAsString().replace("id:", ""); - value = findValue(oldIdentifiers, oldIdentifiers.getAsJsonPrimitive(id).getAsString()); + value = MappingDataLoader.findValue(oldIdentifiers, oldIdentifiers.getAsJsonPrimitive(id).getAsString()); } else { - value = findValue(oldIdentifiers, replacement.getAsString()); + value = MappingDataLoader.findValue(oldIdentifiers, replacement.getAsString()); } } if (value == null) { @@ -68,41 +83,15 @@ public class BackwardsMappings { } } - - private static Map.Entry findValue(JsonObject object, String needle) { - for (Map.Entry entry : object.entrySet()) { - String value = entry.getValue().getAsString(); - if (value.equals(needle)) { - return entry; - } - } - return null; - } - - public static JsonObject loadData(String name) { - try (InputStreamReader reader = new InputStreamReader(BackwardsMappings.class.getClassLoader().getResourceAsStream("assets/viabackwards/data/" + name))) { - return GsonUtil.getGson().fromJson(reader, JsonObject.class); - } catch (IOException ex) { - ex.printStackTrace(); - } - - return null; - } - - public interface BlockMappings { - int getNewBlock(int old); - } - - private static class BlockMappingsShortArray implements BlockMappings { - private short[] oldToNew = new short[8582]; + public static class BlockMappingsShortArray { + private final short[] oldToNew = new short[8582]; private BlockMappingsShortArray(JsonObject newIdentifiers, JsonObject oldIdentifiers, JsonObject mapping) { Arrays.fill(oldToNew, (short) -1); mapIdentifiers(oldToNew, newIdentifiers, oldIdentifiers, mapping); } - @Override - public int getNewBlock(int old) { + public int getNewId(int old) { return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1; } } diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/EntityNameRewrites.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/EntityNameRewrites.java index decda120..9fab4cc9 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/EntityNameRewrites.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/EntityNameRewrites.java @@ -10,16 +10,14 @@ package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data; +import java.util.HashMap; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; public class EntityNameRewrites { - private static Map entityNames = new ConcurrentHashMap<>(); + private static final Map ENTITY_NAMES = new HashMap<>(); static { - /* - CHANGED NAMES IN 1.13 - */ + // CHANGED NAMES IN 1.13 reg("commandblock_minecart", "command_block_minecart"); reg("ender_crystal", "end_crystal"); reg("evocation_fangs", "evoker_fangs"); @@ -36,15 +34,15 @@ public class EntityNameRewrites { private static void reg(String past, String future) { - entityNames.put("minecraft:" + future, "minecraft:" + past); + ENTITY_NAMES.put("minecraft:" + future, "minecraft:" + past); } public static String rewrite(String entName) { - String entityName = entityNames.get(entName); + String entityName = ENTITY_NAMES.get(entName); if (entityName != null) { return entityName; } - entityName = entityNames.get("minecraft:" + entName); + entityName = ENTITY_NAMES.get("minecraft:" + entName); if (entityName != null) { return entityName; } else diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/NamedSoundMapping.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/NamedSoundMapping.java index 5788fee2..3483ac58 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/NamedSoundMapping.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/NamedSoundMapping.java @@ -7,20 +7,20 @@ import java.util.HashMap; import java.util.Map; public class NamedSoundMapping { - private static Map sounds = new HashMap<>(); + private static final Map SOUNDS = new HashMap<>(); static { try { Field field = NamedSoundRewriter.class.getDeclaredField("oldToNew"); field.setAccessible(true); Map sounds = (Map) field.get(null); - sounds.forEach((sound1_12, sound1_13) -> NamedSoundMapping.sounds.put(sound1_13, sound1_12)); + sounds.forEach((sound1_12, sound1_13) -> NamedSoundMapping.SOUNDS.put(sound1_13, sound1_12)); } catch (NoSuchFieldException | IllegalAccessException ex) { ex.printStackTrace(); } } public static String getOldId(String sound1_13) { - return sounds.get(sound1_13); + return SOUNDS.get(sound1_13); } } diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/PaintingMapping.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/PaintingMapping.java index 0a591996..1dcc44ef 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/PaintingMapping.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/PaintingMapping.java @@ -4,7 +4,7 @@ import java.util.HashMap; import java.util.Map; public class PaintingMapping { - private static Map paintings = new HashMap<>(); + private static final Map PAINTINGS = new HashMap<>(); public static void init() { add("Kebab"); @@ -36,10 +36,10 @@ public class PaintingMapping { } private static void add(String motive) { - paintings.put(paintings.size(), motive); + PAINTINGS.put(PAINTINGS.size(), motive); } public static String getStringId(int id) { - return paintings.getOrDefault(id, "kebab"); + return PAINTINGS.getOrDefault(id, "kebab"); } } diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/ParticleMapping.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/ParticleMapping.java index 1ceb1861..a08d5514 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/ParticleMapping.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/ParticleMapping.java @@ -70,8 +70,7 @@ public class ParticleMapping { Item item = protocol.getBlockItemPackets().handleItemToClient( wrapper.read(Type.FLAT_ITEM) ); - - return new Integer[]{Integer.valueOf(item.getId()), Integer.valueOf(item.getData())}; + return new Integer[]{item.getIdentifier(), (int) item.getData()}; }), // (27->36) minecraft:item -> iconcrack rewrite(33), // (28->33) minecraft:item_slime -> slime rewrite(31), // (29->31) minecraft:item_snowball -> snowballpoof @@ -127,12 +126,12 @@ public class ParticleMapping { @AllArgsConstructor @RequiredArgsConstructor public static class ParticleData { + private static final Integer[] A = new Integer[0]; private final int historyId; private ParticleHandler handler; public Integer[] rewriteData(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception { - if (handler == null) - return new Integer[0]; + if (handler == null) return A; return handler.rewrite(protocol, wrapper); } } diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/SoundMapping.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/SoundMapping.java deleted file mode 100644 index 89f2e169..00000000 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/SoundMapping.java +++ /dev/null @@ -1,54 +0,0 @@ -package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data; - -import us.myles.viaversion.libs.gson.JsonArray; -import us.myles.viaversion.libs.gson.JsonElement; -import us.myles.viaversion.libs.gson.JsonObject; - -import java.util.Arrays; - -import static us.myles.ViaVersion.api.data.MappingDataLoader.loadData; - -public class SoundMapping { - private static short[] sounds = new short[662]; - - public static void init() { - JsonObject mapping1_12 = loadData("mapping-1.12.json"); - JsonObject mapping1_13 = loadData("mapping-1.13.json"); - - Arrays.fill(sounds, (short) -1); - mapIdentifiers(sounds, mapping1_13.getAsJsonArray("sounds"), mapping1_12.getAsJsonArray("sounds")); - - // Simulate some trident sounds - sounds[628] = 138; // throw -> shoot - sounds[629] = 137; // hit -> hit_player - sounds[630] = 137; // hit_ground -> hit - sounds[631] = 139; // riptide_1 -> shoot - sounds[632] = 139; // riptide_2 - sounds[633] = 139; // riptide_3 - sounds[634] = 139; // throw -> shoot - // no fitting thunder remap - } - - private static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers) { - for (int i = 0; i < oldIdentifiers.size(); i++) { - JsonElement v = oldIdentifiers.get(i); - Integer index = findIndex(newIdentifiers, v.getAsString()); - if (index == null) continue; //There will be missing sounds, since we are goind backwards - output[i] = index.shortValue(); - } - } - - private static Integer findIndex(JsonArray array, String value) { - for (int i = 0; i < array.size(); i++) { - JsonElement v = array.get(i); - if (v.getAsString().equals(value)) { - return i; - } - } - return null; - } - - public static int getOldSound(int newSound) { - return newSound < 0 || newSound >= sounds.length ? -1 : sounds[newSound]; - } -} diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java index fbbe2e07..47158701 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java @@ -52,7 +52,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter eggEntityId = SpawnEggRewriter.getEntityId(oldId); + if (eggEntityId.isPresent()) { + itemId = 383 << 16; + } else { + itemId = (oldId >> 4) << 16 | oldId & 0xF; + } + } + wrapper.write(Type.VAR_INT, itemId); + } + }); + } + }); + // Block Action protocol.out(State.PLAY, 0x0A, 0x0A, new PacketRemapper() { @Override @@ -451,130 +475,130 @@ public class BlockItemPackets1_13 extends BlockItemRewriter { public void handle(PacketWrapper wrapper) throws Exception { int type = wrapper.get(Type.VAR_INT, 1); EntityType entityType = Entity1_13Types.getTypeFromId(type, false); - addTrackedEntity(wrapper.user(), wrapper.get(Type.VAR_INT, 0), entityType); + addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), entityType); Optional oldId = EntityTypeMapping.getOldId(type); if (!oldId.isPresent()) { @@ -313,8 +313,6 @@ public class EntityPackets1_13 extends EntityRewriter { throw RemovedValueException.EX; }); - - // TODO REWRITE BLOCKS IN MINECART } @Override diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java index f58cda88..66d0ad59 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java @@ -15,9 +15,9 @@ import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.ValueCreator; import us.myles.ViaVersion.api.type.Type; +import us.myles.ViaVersion.api.type.types.Particle; import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter; -import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets; import java.nio.charset.StandardCharsets; diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/SoundPackets1_13.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/SoundPackets1_13.java index acc31982..df31b642 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/SoundPackets1_13.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/SoundPackets1_13.java @@ -1,10 +1,12 @@ package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets; +import nl.matsv.viabackwards.ViaBackwards; import nl.matsv.viabackwards.api.rewriters.Rewriter; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13; +import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.NamedSoundMapping; -import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.SoundMapping; import us.myles.ViaVersion.api.PacketWrapper; +import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.type.Type; @@ -16,7 +18,7 @@ public class SoundPackets1_13 extends Rewriter { @Override protected void registerPackets(Protocol1_12_2To1_13 protocol) { - //Named Sound Event + // Named Sound Event protocol.out(State.PLAY, 0x1A, 0x19, new PacketRemapper() { @Override public void registerMap() { @@ -28,13 +30,15 @@ public class SoundPackets1_13 extends Rewriter { String oldSound = NamedSoundMapping.getOldId(newSound); if (oldSound != null) { wrapper.set(Type.STRING, 0, oldSound); + } else if (!Via.getConfig().isSuppress1_13ConversionErrors()) { + ViaBackwards.getPlatform().getLogger().warning("Unknown named sound in 1.13->1.12 protocol: " + newSound); } } }); } }); - //Stop Sound + // Stop Sound protocol.out(State.PLAY, 0x4C, 0x18, new PacketRemapper() { @Override public void registerMap() { @@ -58,7 +62,7 @@ public class SoundPackets1_13 extends Rewriter { } }); - //Sound Effect + // Sound Effect protocol.out(State.PLAY, 0x4D, 0x49, new PacketRemapper() { @Override public void registerMap() { @@ -67,7 +71,7 @@ public class SoundPackets1_13 extends Rewriter { @Override public void handle(PacketWrapper wrapper) throws Exception { int newSound = wrapper.get(Type.VAR_INT, 0); - int oldSound = SoundMapping.getOldSound(newSound); + int oldSound = BackwardsMappings.soundMappings.getNewId(newSound); if (oldSound == -1) { wrapper.cancel(); } else { @@ -81,6 +85,5 @@ public class SoundPackets1_13 extends Rewriter { @Override protected void registerRewrites() { - } } diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_1to1_13_2/packets/InventoryPackets1_13_2.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_1to1_13_2/packets/InventoryPackets1_13_2.java index 44a44b48..0c2b6370 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_1to1_13_2/packets/InventoryPackets1_13_2.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_1to1_13_2/packets/InventoryPackets1_13_2.java @@ -10,8 +10,7 @@ import us.myles.ViaVersion.packets.State; public class InventoryPackets1_13_2 { public static void register(Protocol protocol) { - - /* + /* Outgoing packets */ @@ -118,10 +117,9 @@ public class InventoryPackets1_13_2 { } }); - /* Incoming packets - */ + */ // Click window packet protocol.registerIncoming(State.PLAY, 0x08, 0x08, new PacketRemapper() { @@ -147,5 +145,4 @@ public class InventoryPackets1_13_2 { } ); } - } diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/Protocol1_13_2To1_14.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/Protocol1_13_2To1_14.java index 9e3d0666..80652073 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/Protocol1_13_2To1_14.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/Protocol1_13_2To1_14.java @@ -5,7 +5,6 @@ import nl.matsv.viabackwards.ViaBackwards; import nl.matsv.viabackwards.api.BackwardsProtocol; import nl.matsv.viabackwards.api.entities.storage.EntityTracker; import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.BackwardsMappings; -import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.SoundMapping; import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.BlockItemPackets1_14; import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.EntityPackets1_14; import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.PlayerPackets1_14; @@ -17,16 +16,18 @@ import us.myles.ViaVersion.api.remapper.PacketHandler; 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_14to1_13_2.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; @Getter public class Protocol1_13_2To1_14 extends BackwardsProtocol { + + private static final Integer[] A = new Integer[0]; private BlockItemPackets1_14 blockItemPackets; private EntityPackets1_14 entityPackets; static { BackwardsMappings.init(); - SoundMapping.init(); } @Override @@ -40,8 +41,6 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol { registerOutgoing(State.PLAY, 0x15, 0x16); - registerOutgoing(State.PLAY, 0x17, 0x18); - registerOutgoing(State.PLAY, 0x18, 0x19); registerOutgoing(State.PLAY, 0x19, 0x1A); @@ -91,7 +90,6 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol { registerOutgoing(State.PLAY, 0x53, 0x4E); // c registerOutgoing(State.PLAY, 0x55, 0x4F); // c - registerOutgoing(State.PLAY, 0x56, 0x50); // c // Update View Position cancelOutgoing(State.PLAY, 0x40); @@ -143,41 +141,48 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol { registerOutgoing(State.PLAY, 0x58, 0x52); // c registerOutgoing(State.PLAY, 0x59, 0x53); // c - // tags + // Tags registerOutgoing(State.PLAY, 0x5B, 0x55, new PacketRemapper() { @Override public void registerMap() { // c handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { - int blockTagsSize = wrapper.read(Type.VAR_INT); - wrapper.write(Type.VAR_INT, blockTagsSize); // block tags + int blockTagsSize = wrapper.passthrough(Type.VAR_INT); for (int i = 0; i < blockTagsSize; i++) { wrapper.passthrough(Type.STRING); - Integer[] blockIds = wrapper.passthrough(Type.VAR_INT_ARRAY); + int[] blockIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); for (int j = 0; j < blockIds.length; j++) { - blockIds[j] = getNewBlockStateId(blockIds[j]); + int id = blockIds[j]; + // Ignore new blocktags + int blockId = BackwardsMappings.blockMappings.getNewId(id); + blockIds[j] = blockId; } } - int itemTagsSize = wrapper.read(Type.VAR_INT); - wrapper.write(Type.VAR_INT, itemTagsSize); // item tags + + int itemTagsSize = wrapper.passthrough(Type.VAR_INT); for (int i = 0; i < itemTagsSize; i++) { wrapper.passthrough(Type.STRING); - Integer[] itemIds = wrapper.passthrough(Type.VAR_INT_ARRAY); + int[] itemIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); for (int j = 0; j < itemIds.length; j++) { - itemIds[j] = /*BlockItemPackets1_14.getNewItemId TODO BLOCK IDS*/(itemIds[j]); + int itemId = itemIds[j]; + // Ignore new itemtags + Integer oldId = MappingData.oldToNewItems.inverse().get(itemId); + itemIds[j] = oldId != null ? oldId : -1; } } + int fluidTagsSize = wrapper.passthrough(Type.VAR_INT); // fluid tags for (int i = 0; i < fluidTagsSize; i++) { wrapper.passthrough(Type.STRING); - wrapper.passthrough(Type.VAR_INT_ARRAY); + wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); } + // Eat entity tags int entityTagsSize = wrapper.read(Type.VAR_INT); for (int i = 0; i < entityTagsSize; i++) { wrapper.read(Type.STRING); - wrapper.read(Type.VAR_INT_ARRAY); + wrapper.read(Type.VAR_INT_ARRAY_PRIMITIVE); } } }); @@ -202,40 +207,32 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol { byte[][] skyLight = new byte[16][]; // we don't need void and +256 light if (isSet(skyLightMask, 0)) { - wrapper.read(Type.BYTE_ARRAY); + wrapper.read(Type.BYTE_ARRAY_PRIMITIVE); } for (int i = 0; i < 16; i++) { if (isSet(skyLightMask, i + 1)) { - Byte[] array = wrapper.read(Type.BYTE_ARRAY); - skyLight[i] = new byte[array.length]; - for (int j = 0; j < array.length; j++) { - skyLight[i][j] = array[j]; - } + skyLight[i] = wrapper.read(Type.BYTE_ARRAY_PRIMITIVE); } else if (isSet(emptySkyLightMask, i + 1)) { skyLight[i] = ChunkLightStorage.EMPTY_LIGHT; } } if (isSet(skyLightMask, 17)) { - wrapper.read(Type.BYTE_ARRAY); + wrapper.read(Type.BYTE_ARRAY_PRIMITIVE); } byte[][] blockLight = new byte[16][]; if (isSet(blockLightMask, 0)) { - wrapper.read(Type.BYTE_ARRAY); + wrapper.read(Type.BYTE_ARRAY_PRIMITIVE); } for (int i = 0; i < 16; i++) { if (isSet(blockLightMask, i + 1)) { - Byte[] array = wrapper.read(Type.BYTE_ARRAY); - blockLight[i] = new byte[array.length]; - for (int j = 0; j < array.length; j++) { - blockLight[i][j] = array[j]; - } + blockLight[i] = wrapper.read(Type.BYTE_ARRAY_PRIMITIVE); } else if (isSet(emptyBlockLightMask, i + 1)) { blockLight[i] = ChunkLightStorage.EMPTY_LIGHT; } } if (isSet(blockLightMask, 17)) { - wrapper.read(Type.BYTE_ARRAY); + wrapper.read(Type.BYTE_ARRAY_PRIMITIVE); } wrapper.user().get(ChunkLightStorage.class).setStoredLight(skyLight, blockLight, x, z); @@ -296,9 +293,9 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol { } public static int getNewBlockStateId(int id) { - int newId = BackwardsMappings.blockStateMappings.getNewBlock(id); + int newId = BackwardsMappings.blockStateMappings.getNewId(id); if (newId == -1) { - ViaBackwards.getPlatform().getLogger().warning("Missing 1.14 blockstate id for 1.13.2 block " + id); + ViaBackwards.getPlatform().getLogger().warning("Missing 1.13.2 blockstate id for 1.14 block " + id); return 0; } return newId; @@ -306,9 +303,9 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol { public static int getNewBlockId(int id) { - int newId = BackwardsMappings.blockMappings.getNewBlock(id); + int newId = BackwardsMappings.blockMappings.getNewId(id); if (newId == -1) { - ViaBackwards.getPlatform().getLogger().warning("Missing 1.14 block id for 1.13.2 block " + id); + ViaBackwards.getPlatform().getLogger().warning("Missing 1.13.2 block id for 1.14 block " + id); return id; } return newId; diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/data/BackwardsMappings.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/data/BackwardsMappings.java index 0f97aaba..5e2e3a88 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/data/BackwardsMappings.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/data/BackwardsMappings.java @@ -1,101 +1,25 @@ package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data; import nl.matsv.viabackwards.ViaBackwards; -import us.myles.ViaVersion.api.Via; +import nl.matsv.viabackwards.api.data.VBMappingDataLoader; +import nl.matsv.viabackwards.api.data.VBMappings; import us.myles.ViaVersion.api.data.MappingDataLoader; -import us.myles.ViaVersion.util.GsonUtil; -import us.myles.viaversion.libs.gson.JsonElement; +import us.myles.ViaVersion.api.data.Mappings; import us.myles.viaversion.libs.gson.JsonObject; -import us.myles.viaversion.libs.gson.JsonPrimitive; - -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.Arrays; -import java.util.Map; public class BackwardsMappings { - public static BlockMappings blockStateMappings; - public static BlockMappings blockMappings; + public static Mappings blockStateMappings; + public static Mappings blockMappings; + public static Mappings soundMappings; public static void init() { JsonObject mapping1_13_2 = MappingDataLoader.loadData("mapping-1.13.2.json"); JsonObject mapping1_14 = MappingDataLoader.loadData("mapping-1.14.json"); - JsonObject mapping1_13_2to1_14 = loadData("mapping-1.13.2to1.14.json"); + JsonObject mapping1_13_2to1_14 = VBMappingDataLoader.loadData("mapping-1.13.2to1.14.json"); ViaBackwards.getPlatform().getLogger().info("Loading 1.14 -> 1.13.2 block mapping..."); - blockStateMappings = new BlockMappingsShortArray(mapping1_14.getAsJsonObject("blockstates"), mapping1_13_2.getAsJsonObject("blockstates"), mapping1_13_2to1_14.getAsJsonObject("blockstates")); - //blockMappings = new BlockMappingsShortArray(mapping1_14.getAsJsonObject("blocks"), mapping1_13_2.getAsJsonObject("blocks"), mapping1_13_2to1_14.getAsJsonObject("blocks")); - } - - - private static void mapIdentifiers(short[] output, JsonObject newIdentifiers, JsonObject oldIdentifiers, JsonObject mapping) { - for (Map.Entry entry : newIdentifiers.entrySet()) { - String key = entry.getValue().getAsString(); - Map.Entry value = findValue(oldIdentifiers, key); - if (value == null) { - JsonPrimitive replacement = mapping.getAsJsonPrimitive(key); - if (replacement == null && key.contains("[")) { - replacement = mapping.getAsJsonPrimitive(key.substring(0, key.indexOf('['))); - } - if (replacement != null) { - if (replacement.getAsString().startsWith("id:")) { - String id = replacement.getAsString().replace("id:", ""); - value = findValue(oldIdentifiers, oldIdentifiers.getAsJsonPrimitive(id).getAsString()); - } else { - value = findValue(oldIdentifiers, replacement.getAsString()); - } - } - if (value == null) { - if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) { - if (replacement != null) { - ViaBackwards.getPlatform().getLogger().warning("No key for " + entry.getValue() + "/" + replacement.getAsString() + " :( "); - } else { - ViaBackwards.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( "); - } - } - continue; - } - } - output[Integer.parseInt(entry.getKey())] = Short.parseShort(value.getKey()); - } - } - - - private static Map.Entry findValue(JsonObject object, String needle) { - for (Map.Entry entry : object.entrySet()) { - String value = entry.getValue().getAsString(); - if (value.equals(needle)) { - return entry; - } - } - return null; - } - - public static JsonObject loadData(String name) { - try (InputStreamReader reader = new InputStreamReader(BackwardsMappings.class.getClassLoader().getResourceAsStream("assets/viabackwards/data/" + name))) { - return GsonUtil.getGson().fromJson(reader, JsonObject.class); - } catch (IOException ex) { - ex.printStackTrace(); - } - - return null; - } - - public interface BlockMappings { - int getNewBlock(int old); - } - - private static class BlockMappingsShortArray implements BlockMappings { - private short[] oldToNew = new short[11270 + 1]; - - private BlockMappingsShortArray(JsonObject newIdentifiers, JsonObject oldIdentifiers, JsonObject mapping) { - Arrays.fill(oldToNew, (short) -1); - mapIdentifiers(oldToNew, newIdentifiers, oldIdentifiers, mapping); - } - - @Override - public int getNewBlock(int old) { - return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1; - } + blockStateMappings = new VBMappings(mapping1_14.getAsJsonObject("blockstates"), mapping1_13_2.getAsJsonObject("blockstates"), mapping1_13_2to1_14.getAsJsonObject("blockstates")); + blockMappings = new VBMappings(mapping1_14.getAsJsonObject("blocks"), mapping1_13_2.getAsJsonObject("blocks"), mapping1_13_2to1_14.getAsJsonObject("blocks"), false); + soundMappings = new VBMappings(mapping1_14.getAsJsonArray("sounds"), mapping1_13_2.getAsJsonArray("sounds"), mapping1_13_2to1_14.getAsJsonObject("sounds")); } } diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/data/EntityPositionStorage.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/data/EntityPositionStorage.java new file mode 100644 index 00000000..ed89f881 --- /dev/null +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/data/EntityPositionStorage.java @@ -0,0 +1,34 @@ +package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data; + +import nl.matsv.viabackwards.api.entities.storage.EntityStorage; + +public class EntityPositionStorage extends EntityStorage { + + private double x; + private double y; + private double z; + + public double getX() { + return x; + } + + public double getY() { + return y; + } + + public double getZ() { + return z; + } + + public void setCoordinates(double x, double y, double z, boolean relative) { + if (relative) { + this.x += x; + this.y += y; + this.z += z; + } else { + this.x = x; + this.y = y; + this.z = z; + } + } +} diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/data/RecipeRewriter1_14.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/data/RecipeRewriter1_14.java new file mode 100644 index 00000000..6628e0e4 --- /dev/null +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/data/RecipeRewriter1_14.java @@ -0,0 +1,65 @@ +package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data; + +import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter; +import nl.matsv.viabackwards.api.rewriters.RecipeRewriter; +import us.myles.ViaVersion.api.PacketWrapper; +import us.myles.ViaVersion.api.minecraft.item.Item; +import us.myles.ViaVersion.api.type.Type; + +public class RecipeRewriter1_14 extends RecipeRewriter { + + public RecipeRewriter1_14(final BlockItemRewriter rewriter) { + super(rewriter); + } + + public void handle(PacketWrapper wrapper, String type) throws Exception { + switch (type) { + case "crafting_shapeless": + handleCraftingShapeless(wrapper); + break; + case "crafting_shaped": + handleCraftingShaped(wrapper); + break; + case "smelting": + handleSmelting(wrapper); + break; + } + } + + public void handleSmelting(PacketWrapper wrapper) throws Exception { + wrapper.passthrough(Type.STRING); // Group + Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients + for (Item item : items) { + rewriter.handleItemToClient(item); + } + + rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result + + wrapper.passthrough(Type.FLOAT); // EXP + wrapper.passthrough(Type.VAR_INT); // Cooking time + } + + public void handleCraftingShaped(PacketWrapper wrapper) throws Exception { + int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Type.STRING); // Group + for (int j = 0; j < ingredientsNo; j++) { + Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients + for (Item item : items) { + rewriter.handleItemToClient(item); + } + } + rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result + } + + public void handleCraftingShapeless(PacketWrapper wrapper) throws Exception { + wrapper.passthrough(Type.STRING); // Group + int ingredientsNo = wrapper.passthrough(Type.VAR_INT); + for (int j = 0; j < ingredientsNo; j++) { + Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients + for (Item item : items) { + rewriter.handleItemToClient(item); + } + } + rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result + } +} diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/data/SoundMapping.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/data/SoundMapping.java deleted file mode 100644 index 0ae881e3..00000000 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/data/SoundMapping.java +++ /dev/null @@ -1,44 +0,0 @@ -package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data; - -import us.myles.viaversion.libs.gson.JsonArray; -import us.myles.viaversion.libs.gson.JsonElement; -import us.myles.viaversion.libs.gson.JsonObject; - -import java.util.Arrays; - -import static us.myles.ViaVersion.api.data.MappingDataLoader.loadData; - -public class SoundMapping { - private static final short[] sounds = new short[795]; - - public static void init() { - JsonObject mapping1_13_2 = loadData("mapping-1.13.2.json"); - JsonObject mapping1_14 = loadData("mapping-1.14.json"); - - Arrays.fill(sounds, (short) -1); - mapIdentifiers(sounds, mapping1_14.getAsJsonArray("sounds"), mapping1_13_2.getAsJsonArray("sounds")); - } - - private static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers) { - for (int i = 0; i < oldIdentifiers.size(); i++) { - JsonElement v = oldIdentifiers.get(i); - Integer index = findIndex(newIdentifiers, v.getAsString()); - if (index == null) continue; //There will be missing sounds, since we are goind backwards - output[i] = index.shortValue(); - } - } - - private static Integer findIndex(JsonArray array, String value) { - for (int i = 0; i < array.size(); i++) { - JsonElement v = array.get(i); - if (v.getAsString().equals(value)) { - return i; - } - } - return null; - } - - public static int getOldSound(int newSound) { - return newSound >= sounds.length ? -1 : sounds[newSound]; - } -} diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java index e5174ec8..3eba4989 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java @@ -5,7 +5,9 @@ import nl.matsv.viabackwards.ViaBackwards; import nl.matsv.viabackwards.api.entities.storage.EntityTracker; import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter; import nl.matsv.viabackwards.api.rewriters.EnchantmentRewriter; +import nl.matsv.viabackwards.api.rewriters.RecipeRewriter; import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14; +import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.RecipeRewriter1_14; import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage; import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.Via; @@ -145,6 +147,9 @@ public class BlockItemPackets1_14 extends BlockItemRewriter removedTypes = ImmutableSet.of("crafting_special_suspiciousstew", "blasting", "smoking", "campfire_cooking", "stonecutting"); + private final RecipeRewriter recipeHandler = new RecipeRewriter1_14(BlockItemPackets1_14.this); @Override public void handle(PacketWrapper wrapper) throws Exception { @@ -291,44 +296,8 @@ public class BlockItemPackets1_14 extends BlockItemRewriter { + private static final double RELATIVE_MOVE_FACTOR = 32 * 128; + + @Override + protected void addTrackedEntity(PacketWrapper wrapper, int entityId, EntityType type) throws Exception { + super.addTrackedEntity(wrapper, entityId, type); + + // Cache the position for every newly tracked entity + if (type == Entity1_14Types.EntityType.PAINTING) { + final Position position = wrapper.get(Type.POSITION, 0); + cacheEntityPosition(wrapper, position.getX(), position.getY(), position.getZ(), true, false); + } else if (wrapper.getId() != 0x25) { // ignore join game + cacheEntityPosition(wrapper, true, false); + } + } + @Override protected void registerPackets(Protocol1_13_2To1_14 protocol) { + // Entity teleport + protocol.registerOutgoing(State.PLAY, 0x56, 0x50, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); + map(Type.DOUBLE); + map(Type.DOUBLE); + map(Type.DOUBLE); + handler(wrapper -> cacheEntityPosition(wrapper, false, false)); + } + }); + + // Entity relative move + Entity look and relative move + PacketRemapper relativeMoveHandler = new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); + map(Type.SHORT); + map(Type.SHORT); + map(Type.SHORT); + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + double x = wrapper.get(Type.SHORT, 0) / RELATIVE_MOVE_FACTOR; + double y = wrapper.get(Type.SHORT, 1) / RELATIVE_MOVE_FACTOR; + double z = wrapper.get(Type.SHORT, 2) / RELATIVE_MOVE_FACTOR; + cacheEntityPosition(wrapper, x, y, z, false, true); + } + }); + } + }; + protocol.registerOutgoing(State.PLAY, 0x28, 0x28, relativeMoveHandler); + protocol.registerOutgoing(State.PLAY, 0x29, 0x29, relativeMoveHandler); + // Spawn Object protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() { @Override @@ -128,7 +178,7 @@ public class EntityPackets1_14 extends EntityRewriter { public void handle(PacketWrapper wrapper) throws Exception { int type = wrapper.get(Type.VAR_INT, 1); Entity1_14Types.EntityType entityType = Entity1_14Types.getTypeFromId(type); - addTrackedEntity(wrapper.user(), wrapper.get(Type.VAR_INT, 0), entityType); + addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), entityType); Optional oldId = EntityTypeMapping.getOldId(type); if (!oldId.isPresent()) { @@ -151,10 +201,38 @@ public class EntityPackets1_14 extends EntityRewriter { }); // Spawn Experience Orb - registerExtraTracker(0x01, Entity1_14Types.EntityType.XP_ORB); + getProtocol().registerOutgoing(State.PLAY, 0x01, 0x01, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity id + map(Type.DOUBLE); // Needs to be mapped for the position cache + map(Type.DOUBLE); + map(Type.DOUBLE); + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), Entity1_14Types.EntityType.XP_ORB); + } + }); + } + }); // Spawn Global Object - registerExtraTracker(0x02, Entity1_14Types.EntityType.LIGHTNING_BOLT); + getProtocol().registerOutgoing(State.PLAY, 0x02, 0x02, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity id + map(Type.DOUBLE); // Needs to be mapped for the position cache + map(Type.DOUBLE); + map(Type.DOUBLE); + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), Entity1_14Types.EntityType.LIGHTNING_BOLT); + } + }); + } + }); // Spawn painting protocol.registerOutgoing(State.PLAY, 0x04, 0x04, new PacketRemapper() { @@ -170,7 +248,7 @@ public class EntityPackets1_14 extends EntityRewriter { handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { - addTrackedEntity(wrapper.user(), wrapper.get(Type.VAR_INT, 0), Entity1_14Types.EntityType.PAINTING); + addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), Entity1_14Types.EntityType.PAINTING); } }); } @@ -190,6 +268,7 @@ public class EntityPackets1_14 extends EntityRewriter { map(Types1_14.METADATA_LIST, Types1_13_2.METADATA_LIST); // 7 - Metadata handler(getTrackerAndMetaHandler(Types1_13_2.METADATA_LIST, Entity1_14Types.EntityType.PLAYER)); + handler(wrapper -> cacheEntityPosition(wrapper, true, false)); } }); @@ -426,6 +505,30 @@ public class EntityPackets1_14 extends EntityRewriter { }); } + private void cacheEntityPosition(PacketWrapper wrapper, boolean create, boolean relative) throws Exception { + cacheEntityPosition(wrapper, + wrapper.get(Type.DOUBLE, 0), wrapper.get(Type.DOUBLE, 1), wrapper.get(Type.DOUBLE, 2), create, relative); + } + + private void cacheEntityPosition(PacketWrapper wrapper, double x, double y, double z, boolean create, boolean relative) throws Exception { + int entityId = wrapper.get(Type.VAR_INT, 0); + Optional optStoredEntity = getEntityTracker(wrapper.user()).getEntity(entityId); + if (!optStoredEntity.isPresent()) { + ViaBackwards.getPlatform().getLogger().warning("Stored entity with id " + entityId + " not found!"); + return; + } + + EntityTracker.StoredEntity storedEntity = optStoredEntity.get(); + EntityPositionStorage positionStorage = create ? new EntityPositionStorage() : storedEntity.get(EntityPositionStorage.class); + if (positionStorage == null) { + ViaBackwards.getPlatform().getLogger().warning("Stored entity with id " + entityId + " missing entitypositionstorage!"); + return; + } + + positionStorage.setCoordinates(x, y, z, relative); + storedEntity.put(positionStorage); + } + public int villagerDataToProfession(VillagerData data) { switch (data.getProfession()) { case 1: // Armorer diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/SoundPackets1_14.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/SoundPackets1_14.java index ff20187e..355b0395 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/SoundPackets1_14.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/SoundPackets1_14.java @@ -1,14 +1,19 @@ package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets; +import nl.matsv.viabackwards.ViaBackwards; +import nl.matsv.viabackwards.api.entities.storage.EntityTracker; import nl.matsv.viabackwards.api.rewriters.Rewriter; import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14; -import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.SoundMapping; +import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.BackwardsMappings; +import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.EntityPositionStorage; import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.packets.State; +import java.util.Optional; + public class SoundPackets1_14 extends Rewriter { @Override protected void registerPackets(Protocol1_13_2To1_14 protocol) { @@ -20,7 +25,55 @@ public class SoundPackets1_14 extends Rewriter { handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { - wrapper.set(Type.VAR_INT, 0, SoundMapping.getOldSound(wrapper.get(Type.VAR_INT, 0))); + int newId = BackwardsMappings.soundMappings.getNewId(wrapper.get(Type.VAR_INT, 0)); + if (newId == -1) { + wrapper.cancel(); + } else { + wrapper.set(Type.VAR_INT, 0, newId); + } + } + }); + } + }); + + // Entity Sound Effect + protocol.registerOutgoing(State.PLAY, 0x50, -1, new PacketRemapper() { + @Override + public void registerMap() { + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + wrapper.cancel(); + + int soundId = wrapper.read(Type.VAR_INT); + int newId = BackwardsMappings.soundMappings.getNewId(soundId); + if (newId == -1) return; + + int category = wrapper.read(Type.VAR_INT); + int entityId = wrapper.read(Type.VAR_INT); + + Optional optEntity = wrapper.user().get(EntityTracker.class).get(protocol).getEntity(entityId); + EntityPositionStorage storedEntity; + if (!optEntity.isPresent() || (storedEntity = optEntity.get().get(EntityPositionStorage.class)) == null) { + ViaBackwards.getPlatform().getLogger().warning("Untracked entity with id " + entityId); + return; + } + + float volume = wrapper.read(Type.FLOAT); + float pitch = wrapper.read(Type.FLOAT); + int x = (int) (storedEntity.getX() * 8D); + int y = (int) (storedEntity.getY() * 8D); + int z = (int) (storedEntity.getZ() * 8D); + + PacketWrapper soundPacket = wrapper.create(0x4D); + soundPacket.write(Type.VAR_INT, newId); + soundPacket.write(Type.VAR_INT, category); + soundPacket.write(Type.INT, x); + soundPacket.write(Type.INT, y); + soundPacket.write(Type.INT, z); + soundPacket.write(Type.FLOAT, volume); + soundPacket.write(Type.FLOAT, pitch); + soundPacket.send(Protocol1_13_2To1_14.class); } }); } @@ -29,6 +82,5 @@ public class SoundPackets1_14 extends Rewriter { @Override protected void registerRewrites() { - } } diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java index 1704d890..be1a301b 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java @@ -149,7 +149,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol { } }); - //Tags + // Tags registerOutgoing(State.PLAY, 0x55, 0x55, new PacketRemapper() { @Override public void registerMap() { @@ -159,7 +159,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol { int blockTagsSize = wrapper.passthrough(Type.VAR_INT); // block tags for (int i = 0; i < blockTagsSize; i++) { wrapper.passthrough(Type.STRING); - Integer[] blocks = wrapper.passthrough(Type.VAR_INT_ARRAY); + int[] blocks = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); for (int j = 0; j < blocks.length; j++) { blocks[j] = getNewBlockId(blocks[j]); } @@ -167,7 +167,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol { int itemTagsSize = wrapper.passthrough(Type.VAR_INT); // item tags for (int i = 0; i < itemTagsSize; i++) { wrapper.passthrough(Type.STRING); - Integer[] items = wrapper.passthrough(Type.VAR_INT_ARRAY); + int[] items = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); for (int j = 0; j < items.length; j++) { items[j] = InventoryPackets1_13_1.getOldItemId(items[j]); } @@ -207,7 +207,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol { if (blockId > 565) { blockId -= 5; } else if (blockId > 561) { - blockId = 0; //TODO replace new blocks + blockId = 0; // Replacements not needed } return blockId; diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13to1_13_1/packets/EntityPackets1_13_1.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13to1_13_1/packets/EntityPackets1_13_1.java index 1a1d2268..08cb3825 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13to1_13_1/packets/EntityPackets1_13_1.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13to1_13_1/packets/EntityPackets1_13_1.java @@ -53,7 +53,7 @@ public class EntityPackets1_13_1 extends EntityRewriter { } // Track Entity - addTrackedEntity(wrapper.user(), entityId, entType); + addTrackedEntity(wrapper, entityId, entType); } }); } diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13to1_13_1/packets/InventoryPackets1_13_1.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13to1_13_1/packets/InventoryPackets1_13_1.java index 8aa15bc2..a90bd437 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13to1_13_1/packets/InventoryPackets1_13_1.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13to1_13_1/packets/InventoryPackets1_13_1.java @@ -14,6 +14,9 @@ public class InventoryPackets1_13_1 { public static void register(Protocol protocol) { ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets1_13_1::toClient, InventoryPackets1_13_1::toServer); + // Set cooldown + itemRewriter.registerSetCooldown(0x18, 0x18, InventoryPackets1_13_1::getOldItemId); + // Window items packet itemRewriter.registerWindowItems(Type.FLAT_ITEM_ARRAY, 0x15, 0x15); @@ -60,7 +63,6 @@ public class InventoryPackets1_13_1 { // Entity Equipment Packet itemRewriter.registerEntityEquipment(Type.FLAT_ITEM, 0x42, 0x42); - // Click window packet itemRewriter.registerClickWindow(Type.FLAT_ITEM, 0x08, 0x08); diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_2to1_14_3/Protocol1_14_2To1_14_3.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_2to1_14_3/Protocol1_14_2To1_14_3.java index 99cebe50..e442d84b 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_2to1_14_3/Protocol1_14_2To1_14_3.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_2to1_14_3/Protocol1_14_2To1_14_3.java @@ -80,19 +80,11 @@ public class Protocol1_14_2To1_14_3 extends BackwardsProtocol { wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients } wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);// Result - } else if (type.equals("smelting")) { - wrapper.passthrough(Type.STRING); // Group - wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients - - wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);// Result - - wrapper.passthrough(Type.FLOAT); // EXP - wrapper.passthrough(Type.VAR_INT); // Cooking time } else if (type.equals("stonecutting")) { wrapper.passthrough(Type.STRING); // Group? wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients wrapper.passthrough(Type.FLAT_VAR_INT_ITEM); // Result - } else if (type.equals("blasting") || type.equals("campfire_cooking") || type.equals("smoking")) { + } else if (type.equals("smelting") || type.equals("blasting") || type.equals("campfire_cooking") || type.equals("smoking")) { wrapper.passthrough(Type.STRING); // Group wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients wrapper.passthrough(Type.FLAT_VAR_INT_ITEM); diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/Protocol1_14_4To1_15.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/Protocol1_14_4To1_15.java new file mode 100644 index 00000000..43c95b38 --- /dev/null +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/Protocol1_14_4To1_15.java @@ -0,0 +1,252 @@ +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.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.packets.BlockItemPackets1_15; +import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.packets.EntityPackets1_15; +import us.myles.ViaVersion.api.PacketWrapper; +import us.myles.ViaVersion.api.data.UserConnection; +import us.myles.ViaVersion.api.remapper.PacketHandler; +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_15to1_14_4.data.MappingData; +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 + protected void registerPackets() { + BackwardsMappings.init(); + blockItemPackets = new BlockItemPackets1_15(); + blockItemPackets.register(this); + new EntityPackets1_15().register(this); + + // Entity Sound Effect + registerOutgoing(State.PLAY, 0x51, 0x50, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // Sound Id + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int newId = BackwardsMappings.soundMappings.getNewId(wrapper.get(Type.VAR_INT, 0)); + if (newId == -1) { + wrapper.cancel(); + } else { + wrapper.set(Type.VAR_INT, 0, newId); + } + } + }); + } + }); + + // Sound Effect + registerOutgoing(State.PLAY, 0x52, 0x51, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // Sound Id + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int newId = BackwardsMappings.soundMappings.getNewId(wrapper.get(Type.VAR_INT, 0)); + if (newId == -1) { + wrapper.cancel(); + } else { + wrapper.set(Type.VAR_INT, 0, newId); + } + } + }); + } + }); + + // Advancements + registerOutgoing(State.PLAY, 0x58, 0x57, new PacketRemapper() { + @Override + public void registerMap() { + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + wrapper.passthrough(Type.BOOLEAN); // Reset/clear + int size = wrapper.passthrough(Type.VAR_INT); + 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)) { + wrapper.passthrough(Type.STRING); // Title + wrapper.passthrough(Type.STRING); // Description + blockItemPackets.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Icon + wrapper.passthrough(Type.VAR_INT); // Frame type + int flags = wrapper.passthrough(Type.INT); // Flags + if ((flags & 1) != 0) { + wrapper.passthrough(Type.STRING); // Background texture + } + wrapper.passthrough(Type.FLOAT); // X + wrapper.passthrough(Type.FLOAT); // Y + } + + wrapper.passthrough(Type.STRING_ARRAY); // Criteria + int arrayLength = wrapper.passthrough(Type.VAR_INT); + for (int array = 0; array < arrayLength; array++) { + wrapper.passthrough(Type.STRING_ARRAY); // String array + } + } + } + }); + } + }); + + // Tags + registerOutgoing(State.PLAY, 0x5C, 0x5B, new PacketRemapper() { + @Override + public void registerMap() { + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int blockTagsSize = wrapper.passthrough(Type.VAR_INT); + for (int i = 0; i < blockTagsSize; i++) { + wrapper.passthrough(Type.STRING); + int[] blockIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); + for (int j = 0; j < blockIds.length; j++) { + int id = blockIds[j]; + blockIds[j] = BackwardsMappings.blockMappings.getNewId(id); + } + } + + int itemTagsSize = wrapper.passthrough(Type.VAR_INT); + for (int i = 0; i < itemTagsSize; i++) { + wrapper.passthrough(Type.STRING); + int[] itemIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); + for (int j = 0; j < itemIds.length; j++) { + Integer oldId = MappingData.oldToNewItems.inverse().get(itemIds[j]); + itemIds[j] = oldId != null ? oldId : -1; + } + } + + int fluidTagsSize = wrapper.passthrough(Type.VAR_INT); // fluid tags + for (int i = 0; i < fluidTagsSize; i++) { + wrapper.passthrough(Type.STRING); + wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); + } + + int entityTagsSize = wrapper.passthrough(Type.VAR_INT); + for (int i = 0; i < entityTagsSize; i++) { + wrapper.passthrough(Type.STRING); + int[] entityIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); + for (int j = 0; j < entityIds.length; j++) { + entityIds[j] = EntityTypeMapping.getOldEntityId(entityIds[j]); + } + } + } + }); + } + }); + + 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); + registerOutgoing(State.PLAY, 0x14, 0x13); + 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); + registerOutgoing(State.PLAY, 0x1F, 0x1E); + registerOutgoing(State.PLAY, 0x20, 0x1F); + registerOutgoing(State.PLAY, 0x21, 0x20); + registerOutgoing(State.PLAY, 0x25, 0x24); + registerOutgoing(State.PLAY, 0x27, 0x26); + registerOutgoing(State.PLAY, 0x29, 0x28); + registerOutgoing(State.PLAY, 0x2A, 0x29); + registerOutgoing(State.PLAY, 0x2B, 0x2A); + 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); + registerOutgoing(State.PLAY, 0x37, 0x36); + registerOutgoing(State.PLAY, 0x39, 0x38); + registerOutgoing(State.PLAY, 0x3A, 0x39); + registerOutgoing(State.PLAY, 0x3C, 0x3B); + registerOutgoing(State.PLAY, 0x3D, 0x3C); + registerOutgoing(State.PLAY, 0x3E, 0x3D); + registerOutgoing(State.PLAY, 0x3F, 0x3E); + registerOutgoing(State.PLAY, 0x40, 0x3F); + registerOutgoing(State.PLAY, 0x41, 0x40); + registerOutgoing(State.PLAY, 0x42, 0x41); + registerOutgoing(State.PLAY, 0x43, 0x42); + registerOutgoing(State.PLAY, 0x45, 0x44); + registerOutgoing(State.PLAY, 0x46, 0x45); + registerOutgoing(State.PLAY, 0x48, 0x47); + registerOutgoing(State.PLAY, 0x49, 0x48); + registerOutgoing(State.PLAY, 0x4A, 0x49); + registerOutgoing(State.PLAY, 0x4B, 0x4A); + registerOutgoing(State.PLAY, 0x4C, 0x4B); + 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); + registerOutgoing(State.PLAY, 0x5A, 0x59); + registerOutgoing(State.PLAY, 0x08, 0x5C); + } + + public static int getNewBlockStateId(int id) { + int newId = BackwardsMappings.blockStateMappings.getNewId(id); + if (newId == -1) { + ViaBackwards.getPlatform().getLogger().warning("Missing 1.15 blockstate id for 1.14.4 block " + id); + return 0; + } + return newId; + } + + + public static int getNewBlockId(int id) { + int newId = BackwardsMappings.blockMappings.getNewId(id); + if (newId == -1) { + ViaBackwards.getPlatform().getLogger().warning("Missing 1.15 block id for 1.14.4 block " + id); + return id; + } + return newId; + } + + @Override + public void init(UserConnection user) { + if (!user.has(ClientWorld.class)) + user.put(new ClientWorld(user)); + if (!user.has(EntityTracker.class)) + user.put(new EntityTracker(user)); + user.get(EntityTracker.class).initProtocol(this); + } + + public BlockItemPackets1_15 getBlockItemPackets() { + return blockItemPackets; + } +} diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/data/BackwardsMappings.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/data/BackwardsMappings.java new file mode 100644 index 00000000..c7c05af0 --- /dev/null +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/data/BackwardsMappings.java @@ -0,0 +1,25 @@ +package nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data; + +import nl.matsv.viabackwards.ViaBackwards; +import nl.matsv.viabackwards.api.data.VBMappingDataLoader; +import nl.matsv.viabackwards.api.data.VBMappings; +import us.myles.ViaVersion.api.data.MappingDataLoader; +import us.myles.ViaVersion.api.data.Mappings; +import us.myles.viaversion.libs.gson.JsonObject; + +public class BackwardsMappings { + public static Mappings blockStateMappings; + public static Mappings blockMappings; + public static Mappings soundMappings; + + public static void init() { + JsonObject mapping1_14 = MappingDataLoader.loadData("mapping-1.14.json"); + JsonObject mapping1_15 = MappingDataLoader.loadData("mapping-1.15.json"); + JsonObject mapping1_14to1_15 = VBMappingDataLoader.loadData("mapping-1.14.4to1.15.json"); + + ViaBackwards.getPlatform().getLogger().info("Loading 1.15 -> 1.14.4 mappings..."); + blockStateMappings = new VBMappings(mapping1_15.getAsJsonObject("blockstates"), mapping1_14.getAsJsonObject("blockstates"), mapping1_14to1_15.getAsJsonObject("blockstates")); + blockMappings = new VBMappings(mapping1_15.getAsJsonObject("blocks"), mapping1_14.getAsJsonObject("blocks"), mapping1_14to1_15.getAsJsonObject("blocks"), false); + soundMappings = new VBMappings(mapping1_15.getAsJsonArray("sounds"), mapping1_14.getAsJsonArray("sounds"), mapping1_14to1_15.getAsJsonObject("sounds")); + } +} \ No newline at end of file diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/data/EntityTypeMapping.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/data/EntityTypeMapping.java new file mode 100644 index 00000000..8ed90d35 --- /dev/null +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/data/EntityTypeMapping.java @@ -0,0 +1,12 @@ +package nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data; + +import us.myles.ViaVersion.api.entities.Entity1_14Types; + +public class EntityTypeMapping { + + // There's only the bee, so not much to do here + public static int getOldEntityId(int entityId) { + if (entityId == 4) return Entity1_14Types.EntityType.PUFFER_FISH.getId(); // Flying pufferfish! + return entityId >= 5 ? entityId - 1 : entityId; + } +} diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/data/RecipeRewriter1_15.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/data/RecipeRewriter1_15.java new file mode 100644 index 00000000..3ddffc50 --- /dev/null +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/data/RecipeRewriter1_15.java @@ -0,0 +1,45 @@ +package nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data; + +import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter; +import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.RecipeRewriter1_14; +import us.myles.ViaVersion.api.PacketWrapper; +import us.myles.ViaVersion.api.minecraft.item.Item; +import us.myles.ViaVersion.api.type.Type; + +public class RecipeRewriter1_15 extends RecipeRewriter1_14 { + + public RecipeRewriter1_15(final BlockItemRewriter rewriter) { + super(rewriter); + } + + @Override + public void handle(PacketWrapper wrapper, String type) throws Exception { + switch (type) { + case "crafting_shapeless": + handleCraftingShapeless(wrapper); + break; + case "crafting_shaped": + handleCraftingShaped(wrapper); + break; + case "blasting": // new + case "smoking": // new + case "campfire_cooking": // new + case "smelting": + handleSmelting(wrapper); + break; + case "stonecutting": // new + handleStonecutting(wrapper); + break; + } + } + + public void handleStonecutting(PacketWrapper wrapper) throws Exception { + wrapper.passthrough(Type.STRING); + Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients + for (Item item : items) { + rewriter.handleItemToClient(item); + } + + rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result + } +} diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/packets/BlockItemPackets1_15.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/packets/BlockItemPackets1_15.java new file mode 100644 index 00000000..df31cb65 --- /dev/null +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/packets/BlockItemPackets1_15.java @@ -0,0 +1,306 @@ +package nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.packets; + +import nl.matsv.viabackwards.ViaBackwards; +import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter; +import nl.matsv.viabackwards.api.rewriters.RecipeRewriter; +import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.Protocol1_14_4To1_15; +import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.RecipeRewriter1_15; +import us.myles.ViaVersion.api.PacketWrapper; +import us.myles.ViaVersion.api.minecraft.BlockChangeRecord; +import us.myles.ViaVersion.api.minecraft.chunks.Chunk; +import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection; +import us.myles.ViaVersion.api.minecraft.item.Item; +import us.myles.ViaVersion.api.remapper.PacketHandler; +import us.myles.ViaVersion.api.remapper.PacketRemapper; +import us.myles.ViaVersion.api.rewriters.ItemRewriter; +import us.myles.ViaVersion.api.type.Type; +import us.myles.ViaVersion.packets.State; +import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type; +import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.MappingData; +import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type; +import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; + +public class BlockItemPackets1_15 extends BlockItemRewriter { + + @Override + protected void registerPackets(Protocol1_14_4To1_15 protocol) { + ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer); + + // Set cooldown + itemRewriter.registerSetCooldown(0x18, 0x17, BlockItemPackets1_15::getOldItemId); + + // Window items packet + itemRewriter.registerWindowItems(Type.FLAT_VAR_INT_ITEM_ARRAY, 0x15, 0x14); + + // Set slot packet + itemRewriter.registerSetSlot(Type.FLAT_VAR_INT_ITEM, 0x17, 0x16); + + // Trade list + protocol.out(State.PLAY, 0x28, 0x27, new PacketRemapper() { + @Override + public void registerMap() { + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + wrapper.passthrough(Type.VAR_INT); + int size = wrapper.passthrough(Type.UNSIGNED_BYTE); + for (int i = 0; i < size; i++) { + Item input = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM); + handleItemToClient(input); + + Item output = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM); + handleItemToClient(output); + + if (wrapper.passthrough(Type.BOOLEAN)) { // Has second item + // Second Item + Item second = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM); + handleItemToClient(second); + } + + wrapper.passthrough(Type.BOOLEAN); + wrapper.passthrough(Type.INT); + wrapper.passthrough(Type.INT); + + wrapper.passthrough(Type.INT); + wrapper.passthrough(Type.INT); + wrapper.passthrough(Type.FLOAT); + } + + wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Type.BOOLEAN); + } + }); + } + }); + + // Entity Equipment Packet + itemRewriter.registerEntityEquipment(Type.FLAT_VAR_INT_ITEM, 0x47, 0x46); + + // Declare Recipes + protocol.registerOutgoing(State.PLAY, 0x5B, 0x5A, new PacketRemapper() { + @Override + public void registerMap() { + handler(new PacketHandler() { + private final RecipeRewriter recipeHandler = new RecipeRewriter1_15(BlockItemPackets1_15.this); + + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int size = wrapper.passthrough(Type.VAR_INT); + for (int i = 0; i < size; i++) { + String type = wrapper.passthrough(Type.STRING).replace("minecraft:", ""); + String id = wrapper.passthrough(Type.STRING); // Recipe Identifier + recipeHandler.handle(wrapper, type); + } + } + }); + } + }); + + // Incoming packets + + // Click window packet + itemRewriter.registerClickWindow(Type.FLAT_VAR_INT_ITEM, 0x09, 0x09); + + // Creative Inventory Action + itemRewriter.registerCreativeInvAction(Type.FLAT_VAR_INT_ITEM, 0x26, 0x26); + + // Block Action + protocol.registerOutgoing(State.PLAY, 0x0B, 0x0A, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.POSITION1_14); // Location + map(Type.UNSIGNED_BYTE); // Action id + map(Type.UNSIGNED_BYTE); // Action param + map(Type.VAR_INT); // Block id - /!\ NOT BLOCK STATE + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + wrapper.set(Type.VAR_INT, 0, Protocol1_14_4To1_15.getNewBlockId(wrapper.get(Type.VAR_INT, 0))); + } + }); + } + }); + + // Block Change + protocol.registerOutgoing(State.PLAY, 0x0C, 0x0B, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.POSITION1_14); + map(Type.VAR_INT); + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int id = wrapper.get(Type.VAR_INT, 0); + wrapper.set(Type.VAR_INT, 0, Protocol1_14_4To1_15.getNewBlockStateId(id)); + } + }); + } + }); + + // Multi Block Change + protocol.registerOutgoing(State.PLAY, 0x10, 0x0F, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.INT); // 0 - Chunk X + map(Type.INT); // 1 - Chunk Z + map(Type.BLOCK_CHANGE_RECORD_ARRAY); // 2 - Records + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) { + int id = record.getBlockId(); + record.setBlockId(Protocol1_14_4To1_15.getNewBlockStateId(id)); + } + } + }); + } + }); + + // Chunk + protocol.registerOutgoing(State.PLAY, 0x22, 0x21, new PacketRemapper() { + @Override + public void registerMap() { + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); + Chunk chunk = wrapper.read(new Chunk1_15Type(clientWorld)); + wrapper.write(new Chunk1_14Type(clientWorld), chunk); + + if (chunk.isGroundUp()) { + int[] biomeData = chunk.getBiomeData(); + int[] newBiomeData = new int[256]; + for (int i = 0; i < 4; ++i) { + for (int j = 0; j < 4; ++j) { + int x = j << 2; + int z = i << 2; + int newIndex = z << 4 | x; + int oldIndex = i << 2 | j; + + int biome = biomeData[oldIndex]; + for (int k = 0; k < 4; k++) { + int offX = newIndex + (k << 4); + for (int l = 0; l < 4; l++) { + newBiomeData[offX + l] = biome; + } + } + } + } + + chunk.setBiomeData(newBiomeData); + } + + for (int i = 0; i < chunk.getSections().length; i++) { + ChunkSection section = chunk.getSections()[i]; + if (section == null) continue; + for (int j = 0; j < section.getPaletteSize(); j++) { + int old = section.getPaletteEntry(j); + int newId = Protocol1_14_4To1_15.getNewBlockStateId(old); + section.setPaletteEntry(j, newId); + } + } + } + }); + } + }); + + // Effect packet + protocol.registerOutgoing(State.PLAY, 0x23, 0x22, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.INT); // Effect Id + map(Type.POSITION1_14); // Location + map(Type.INT); // Data + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int id = wrapper.get(Type.INT, 0); + int data = wrapper.get(Type.INT, 1); + if (id == 1010) { // Play record + wrapper.set(Type.INT, 1, BlockItemPackets1_15.getOldItemId(data)); + } else if (id == 2001) { // Block break + block break sound + wrapper.set(Type.INT, 1, Protocol1_14_4To1_15.getNewBlockStateId(data)); + } + } + }); + } + }); + + // Spawn particle + protocol.registerOutgoing(State.PLAY, 0x24, 0x23, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.INT); // 0 - Particle ID + map(Type.BOOLEAN); // 1 - Long Distance + map(Type.DOUBLE, Type.FLOAT); // 2 - X + map(Type.DOUBLE, Type.FLOAT); // 3 - Y + map(Type.DOUBLE, Type.FLOAT); // 4 - Z + map(Type.FLOAT); // 5 - Offset X + map(Type.FLOAT); // 6 - Offset Y + map(Type.FLOAT); // 7 - Offset Z + map(Type.FLOAT); // 8 - Particle Data + map(Type.INT); // 9 - Particle Count + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int id = wrapper.get(Type.INT, 0); + if (id == 3 || id == 23) { + int data = wrapper.passthrough(Type.VAR_INT); + wrapper.set(Type.VAR_INT, 0, Protocol1_14_4To1_15.getNewBlockStateId(data)); + } else if (id == 32) { + Item item = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM)); + wrapper.write(Type.FLAT_VAR_INT_ITEM, item); + } + } + }); + } + }); + } + + @Override + protected void registerRewrites() { + rewrite(881).repItem(new Item(824, (byte) 1, (short) -1, getNamedTag("1.15 Honey Bottle"))); + rewrite(878).repItem(new Item(323, (byte) 1, (short) -1, getNamedTag("1.15 Honeycomb"))); + rewrite(883).repItem(new Item(455, (byte) 1, (short) -1, getNamedTag("1.15 Honeycomb Block"))); + rewrite(879).repItem(new Item(385, (byte) 1, (short) -1, getNamedTag("1.15 Bee Nest"))); + rewrite(880).repItem(new Item(865, (byte) 1, (short) -1, getNamedTag("1.15 Beehive"))); + rewrite(882).repItem(new Item(321, (byte) 1, (short) -1, getNamedTag("1.15 Honey Block"))); + rewrite(698).repItem(new Item(722, (byte) 1, (short) -1, getNamedTag("1.15 Bee Spawn Egg"))); + } + + @Override + public Item handleItemToClient(Item i) { + Item item = super.handleItemToClient(i); + if (item == null) return null; + item.setIdentifier(getOldItemId(item.getIdentifier())); + return item; + } + + @Override + public Item handleItemToServer(Item item) { + if (item == null) return null; + item.setIdentifier(getNewItemId(item.getIdentifier())); + return super.handleItemToServer(item); + } + + + public static int getNewItemId(int id) { + Integer newId = MappingData.oldToNewItems.get(id); + if (newId == null) { + ViaBackwards.getPlatform().getLogger().warning("Missing 1.15 item for 1.14.4 item " + id); + return 1; + } + return newId; + } + + + public static int getOldItemId(int id) { + Integer oldId = MappingData.oldToNewItems.inverse().get(id); + if (oldId == null) { + ViaBackwards.getPlatform().getLogger().warning("Missing 1.14.4 item for 1.15 item " + id); + return 1; + } + return oldId; + } +} diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/packets/EntityPackets1_15.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/packets/EntityPackets1_15.java new file mode 100644 index 00000000..0d1ecfa2 --- /dev/null +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14_4to1_15/packets/EntityPackets1_15.java @@ -0,0 +1,271 @@ +package nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.packets; + +import nl.matsv.viabackwards.api.exceptions.RemovedValueException; +import nl.matsv.viabackwards.api.rewriters.EntityRewriter; +import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.Protocol1_14_4To1_15; +import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.EntityTypeMapping; +import us.myles.ViaVersion.api.PacketWrapper; +import us.myles.ViaVersion.api.entities.Entity1_14Types; +import us.myles.ViaVersion.api.entities.Entity1_15Types; +import us.myles.ViaVersion.api.entities.EntityType; +import us.myles.ViaVersion.api.minecraft.item.Item; +import us.myles.ViaVersion.api.minecraft.metadata.MetaType; +import us.myles.ViaVersion.api.minecraft.metadata.Metadata; +import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14; +import us.myles.ViaVersion.api.remapper.PacketHandler; +import us.myles.ViaVersion.api.remapper.PacketRemapper; +import us.myles.ViaVersion.api.type.Type; +import us.myles.ViaVersion.api.type.types.version.Types1_14; +import us.myles.ViaVersion.packets.State; +import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; + +public class EntityPackets1_15 extends EntityRewriter { + + @Override + protected void registerPackets(Protocol1_14_4To1_15 protocol) { + // Spawn Object + protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity id + map(Type.UUID); // 1 - UUID + map(Type.VAR_INT); // 2 - Type + map(Type.DOUBLE); // 3 - X + map(Type.DOUBLE); // 4 - Y + map(Type.DOUBLE); // 5 - Z + map(Type.BYTE); // 6 - Pitch + map(Type.BYTE); // 7 - Yaw + map(Type.INT); // 8 - Data + + handler(getTrackerHandler()); + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int typeId = wrapper.get(Type.VAR_INT, 1); + Entity1_14Types.EntityType entityType = Entity1_14Types.getTypeFromId(getOldEntityId(typeId)); + wrapper.set(Type.VAR_INT, 1, entityType.getId()); + + if (entityType == Entity1_14Types.EntityType.FALLING_BLOCK) { + int blockState = wrapper.get(Type.INT, 0); + int combined = Protocol1_14_4To1_15.getNewBlockStateId(blockState); + wrapper.set(Type.INT, 0, combined); + } + } + }); + } + }); + + // Spawn mob packet + protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity ID + map(Type.UUID); // 1 - Entity UUID + map(Type.VAR_INT); // 2 - Entity Type + map(Type.DOUBLE); // 3 - X + map(Type.DOUBLE); // 4 - Y + map(Type.DOUBLE); // 5 - Z + map(Type.BYTE); // 6 - Yaw + map(Type.BYTE); // 7 - Pitch + map(Type.BYTE); // 8 - Head Pitch + map(Type.SHORT); // 9 - Velocity X + map(Type.SHORT); // 10 - Velocity Y + map(Type.SHORT); // 11 - Velocity Z + create(wrapper -> wrapper.write(Type.UNSIGNED_BYTE, (short) 0xff)); // Metadata is no longer sent in 1.15, so we have to send an empty one + + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int type = wrapper.get(Type.VAR_INT, 1); + Entity1_15Types.EntityType entityType = Entity1_15Types.getTypeFromId(type); + addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), entityType); + wrapper.set(Type.VAR_INT, 1, EntityTypeMapping.getOldEntityId(type)); + } + }); + } + }); + + // Respawn + protocol.registerOutgoing(State.PLAY, 0x3B, 0x3A, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.INT); + map(Type.LONG, Type.NOTHING); // Seed + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); + clientWorld.setEnvironment(wrapper.get(Type.INT, 0)); + } + }); + } + }); + + // Join Game + protocol.registerOutgoing(State.PLAY, 0x26, 0x25, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.INT); // 0 - Entity ID + map(Type.UNSIGNED_BYTE); // 1 - Gamemode + map(Type.INT); // 2 - Dimension + + map(Type.LONG, Type.NOTHING); // Seed + + map(Type.UNSIGNED_BYTE); // 3 - Max Players + map(Type.STRING); // 4 - Level Type + map(Type.VAR_INT); // 5 - View Distance + map(Type.BOOLEAN); // 6 - Reduce Debug Info + + map(Type.BOOLEAN, Type.NOTHING); // Show death screen + + handler(getTrackerHandler(Entity1_15Types.EntityType.PLAYER, Type.INT)); + handler(getDimensionHandler(1)); + } + }); + + // Edit Book + protocol.registerIncoming(State.PLAY, 0x0D, 0x0C, new PacketRemapper() { + @Override + public void registerMap() { + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + getProtocol().getBlockItemPackets().handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); + } + }); + } + }); + + // Spawn Experience Orb + registerExtraTracker(0x01, Entity1_15Types.EntityType.XP_ORB); + + // Spawn Global Object + registerExtraTracker(0x02, Entity1_15Types.EntityType.LIGHTNING_BOLT); + + // Spawn painting + registerExtraTracker(0x04, Entity1_15Types.EntityType.PAINTING); + + // Spawn player packet + protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity ID + map(Type.UUID); // 1 - Player UUID + map(Type.DOUBLE); // 2 - X + map(Type.DOUBLE); // 3 - Y + map(Type.DOUBLE); // 4 - Z + map(Type.BYTE); // 5 - Yaw + map(Type.BYTE); // 6 - Pitch + create(wrapper -> wrapper.write(Type.UNSIGNED_BYTE, (short) 0xff)); // Metadata is no longer sent in 1.15, so we have to send an empty one + + handler(getTrackerHandler(Entity1_15Types.EntityType.PLAYER, Type.VAR_INT)); + } + }); + + // Destroy entities + registerEntityDestroy(0x38, 0x37); + + // Entity Metadata packet + register1_15MetadataRewriter(0x44, 0x43, Types1_14.METADATA_LIST); + + // Attributes (get rid of generic.flyingSpeed for the Bee remap) + protocol.registerOutgoing(State.PLAY, 0x59, 0x58, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); + map(Type.INT); + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int entityId = wrapper.get(Type.VAR_INT, 0); + EntityType entityType = getEntityType(wrapper.user(), entityId); + if (entityType != Entity1_15Types.EntityType.BEE) return; + + int size = wrapper.get(Type.INT, 0); + for (int i = 0; i < size; i++) { + String key = wrapper.read(Type.STRING); + if (key.equals("generic.flyingSpeed")) { + size--; + wrapper.read(Type.DOUBLE); + int modSize = wrapper.read(Type.VAR_INT); + for (int j = 0; j < modSize; j++) { + wrapper.read(Type.UUID); + wrapper.read(Type.DOUBLE); + wrapper.read(Type.BYTE); + } + } else { + wrapper.write(Type.STRING, key); + wrapper.passthrough(Type.DOUBLE); + int modSize = wrapper.passthrough(Type.VAR_INT); + for (int j = 0; j < modSize; j++) { + wrapper.passthrough(Type.UUID); + wrapper.passthrough(Type.DOUBLE); + wrapper.passthrough(Type.BYTE); + } + } + } + wrapper.set(Type.INT, 0, size); + } + }); + } + }); + } + + @Override + protected void registerRewrites() { + setDisplayNameJson(true); + setDisplayNameMetaType(MetaType1_14.OptChat); + + registerMetaHandler().handle(e -> { + Metadata meta = e.getData(); + MetaType type = meta.getMetaType(); + if (type == MetaType1_14.Slot) { + Item item = (Item) meta.getValue(); + meta.setValue(getProtocol().getBlockItemPackets().handleItemToClient(item)); + } else if (type == MetaType1_14.BlockID) { + int blockstate = (int) meta.getValue(); + meta.setValue(Protocol1_14_4To1_15.getNewBlockStateId(blockstate)); + } + return meta; + }); + + registerMetaHandler().filter(Entity1_15Types.EntityType.LIVINGENTITY, true).handle(e -> { + int index = e.getIndex(); + if (index == 12) { + throw RemovedValueException.EX; + } else if (index > 12) { + e.getData().setId(index - 1); + } + return e.getData(); + }); + + registerMetaHandler().filter(Entity1_15Types.EntityType.BEE, 15).removed(); + registerMetaHandler().filter(Entity1_15Types.EntityType.BEE, 16).removed(); + + regEntType(Entity1_15Types.EntityType.BEE, Entity1_15Types.EntityType.PUFFER_FISH).mobName("Bee").spawnMetadata(storage -> { + storage.add(new Metadata(14, MetaType1_14.Boolean, false)); + storage.add(new Metadata(15, MetaType1_14.VarInt, 2)); + }); + + registerMetaHandler().filter(Entity1_15Types.EntityType.ENDERMAN, 16).removed(); + registerMetaHandler().filter(Entity1_15Types.EntityType.TRIDENT, 10).removed(); + + registerMetaHandler().filter(Entity1_15Types.EntityType.WOLF).handle(e -> { + int index = e.getIndex(); + if (index >= 17) { + e.getData().setId(index + 1); // redundant health removed in 1.15 + } + return e.getData(); + }); + } + + @Override + protected EntityType getTypeFromId(int typeId) { + return Entity1_15Types.getTypeFromId(typeId); + } + + @Override + protected int getOldEntityId(final int newId) { + return EntityTypeMapping.getOldEntityId(newId); + } +} diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14to1_14_1/packets/EntityPackets1_14_1.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14to1_14_1/packets/EntityPackets1_14_1.java index e22dada8..33d57530 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14to1_14_1/packets/EntityPackets1_14_1.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_14to1_14_1/packets/EntityPackets1_14_1.java @@ -60,7 +60,7 @@ public class EntityPackets1_14_1 extends EntityRewriter { int type = wrapper.get(Type.VAR_INT, 1); // Register Type ID - addTrackedEntity(wrapper.user(), entityId, Entity1_14Types.getTypeFromId(type)); + addTrackedEntity(wrapper, entityId, Entity1_14Types.getTypeFromId(type)); MetaStorage storage = new MetaStorage(wrapper.get(Types1_14.METADATA_LIST, 0)); handleMeta(wrapper.user(), entityId, storage); diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_9_4to1_10/packets/BlockItemPackets1_10.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_9_4to1_10/packets/BlockItemPackets1_10.java index 49e8ac17..79e20b06 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_9_4to1_10/packets/BlockItemPackets1_10.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_9_4to1_10/packets/BlockItemPackets1_10.java @@ -29,6 +29,7 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; public class BlockItemPackets1_10 extends BlockItemRewriter { protected void registerPackets(Protocol1_9_4To1_10 protocol) { + jsonNameFormat = false; ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer); // Set slot packet @@ -176,11 +177,11 @@ public class BlockItemPackets1_10 extends BlockItemRewriter @Override protected void registerRewrites() { - rewrite(255).repItem(new Item((short) 166, (byte) 1, (short) 0, getNamedTag("1.10 Structure Block"))); // Structure block only item since the structure block is in 1.9 - rewrite(217).repItem(new Item((short) 287, (byte) 1, (short) 0, getNamedTag("1.10 Structure Void"))).repBlock(new Block(287, 0)); // Structure void to string - rewrite(213).repItem(new Item((short) 159, (byte) 1, (short) 1, getNamedTag("1.10 Magma Block"))).repBlock(new Block(159, 1)); // Magma block to orange clay - rewrite(214).repItem(new Item((short) 159, (byte) 1, (short) 14, getNamedTag("1.10 Nether Wart Block"))).repBlock(new Block(159, 14)); // Nether wart block to red clay - rewrite(215).repItem(new Item((short) 112, (byte) 1, (short) 0, getNamedTag("1.10 Red Nether Bricks"))).repBlock(new Block(112, 0)); // Red nether brick to nether brick - rewrite(216).repItem(new Item((short) 155, (byte) 1, (short) 0, getNamedTag("1.10 Bone Block"))).repBlock(new Block(155, 0)); // Bone block to quartz + rewrite(255).repItem(new Item(166, (byte) 1, (short) 0, getNamedTag("1.10 Structure Block"))); // Structure block only item since the structure block is in 1.9 + rewrite(217).repItem(new Item(287, (byte) 1, (short) 0, getNamedTag("1.10 Structure Void"))).repBlock(new Block(287, 0)); // Structure void to string + rewrite(213).repItem(new Item(159, (byte) 1, (short) 1, getNamedTag("1.10 Magma Block"))).repBlock(new Block(159, 1)); // Magma block to orange clay + rewrite(214).repItem(new Item(159, (byte) 1, (short) 14, getNamedTag("1.10 Nether Wart Block"))).repBlock(new Block(159, 14)); // Nether wart block to red clay + rewrite(215).repItem(new Item(112, (byte) 1, (short) 0, getNamedTag("1.10 Red Nether Bricks"))).repBlock(new Block(112, 0)); // Red nether brick to nether brick + rewrite(216).repItem(new Item(155, (byte) 1, (short) 0, getNamedTag("1.10 Bone Block"))).repBlock(new Block(155, 0)); // Bone block to quartz } } diff --git a/core/src/main/resources/assets/viabackwards/data/mapping-1.12.2to1.13.json b/core/src/main/resources/assets/viabackwards/data/mapping-1.12.2to1.13.json index 65946408..ada90f15 100644 --- a/core/src/main/resources/assets/viabackwards/data/mapping-1.12.2to1.13.json +++ b/core/src/main/resources/assets/viabackwards/data/mapping-1.12.2to1.13.json @@ -343,7 +343,6 @@ "minecraft:black_bed[facing=east,occupied=false,part=foot]": "minecraft:red_bed[facing=east,occupied=false,part=foot]", "minecraft:seagrass": "minecraft:grass", "minecraft:tall_seagrass[half=upper]": "id:2809", - //2809 / 175:9 is the upper half of every flower in 1.12.2, the lower half determines the type "minecraft:tall_seagrass[half=lower]": "minecraft:tall_grass[half=lower]", "minecraft:sunflower[half=upper]": "id:2809", "minecraft:lilac[half=upper]": "id:2809", @@ -5436,5 +5435,120 @@ "minecraft:dragon_head[rotation=13]": "id:2305", "minecraft:dragon_head[rotation=14]": "id:2305", "minecraft:dragon_head[rotation=15]": "id:2305" + }, + "sounds": { + "ambient.underwater.enter": "block.water.ambient", + "ambient.underwater.exit": "block.water.ambient", + "ambient.underwater.loop": "entity.boat.paddle_water", + "ambient.underwater.loop.additions": "block.water.ambient", + "ambient.underwater.loop.additions.rare": "entity.elder_guardian.death", + "ambient.underwater.loop.additions.ultra_rare": "entity.elder_guardian.death", + "block.beacon.activate": "entity.elder_guardian.curse", + "block.beacon.ambient": "entity.elder_guardian.ambient", + "block.beacon.deactivate": "entity.elder_guardian.death", + "block.beacon.power_select": "entity.elder_guardian.hurt_land", + "block.bubble_column.bubble_pop": "block.lava.pop", + "block.bubble_column.upwards_ambient": "block.water.ambient", + "block.bubble_column.upwards_inside": "block.water.ambient", + "block.bubble_column.whirlpool_ambient": "block.water.ambient", + "block.bubble_column.whirlpool_inside": "block.water.ambient", + "block.conduit.activate": "block.chorus_flower.grow", + "block.conduit.ambient": "block.enchantment_table.use", + "block.conduit.ambient.short": "block.enchantment_table.use", + "block.conduit.attack.target": "block.shulker_box.open", + "block.conduit.deactivate": "enchant.thorns.hit", + "block.wet_grass.break": "block.grass.break", + "block.wet_grass.fall": "block.grass.fall", + "block.wet_grass.hit": "block.grass.hit", + "block.wet_grass.place": "block.grass.place", + "block.wet_grass.step": "block.grass.step", + "block.coral_block.break": "block.metal.break", + "block.coral_block.fall": "block.metal.fall", + "block.coral_block.hit": "block.metal.hit", + "block.coral_block.place": "block.metal.place", + "block.coral_block.step": "block.metal.step", + "block.pumpkin.carve": "block.gravel.break", + "entity.cod.ambient": "entity.elder_guardian.flop", + "entity.cod.death": "entity.elder_guardian.flop", + "entity.cod.flop": "entity.elder_guardian.flop", + "entity.cod.hurt": "entity.elder_guardian.hurt_land", + "entity.dolphin.ambient": "entity.bat.ambient", + "entity.dolphin.ambient_water": "entity.fishing_bobber.splash", + "entity.dolphin.attack": "entity.bat.hurt", + "entity.dolphin.death": "entity.bat.death", + "entity.dolphin.eat": "entity.parrot.eat", + "entity.dolphin.hurt": "entity.bat.hurt", + "entity.dolphin.jump": "entity.fishing_bobber.splash", + "entity.dolphin.play": "entity.fishing_bobber.splash", + "entity.dolphin.splash": "entity.fishing_bobber.splash", + "entity.dolphin.swim": "entity.boat.paddle_water", + "entity.drowned.ambient": "entity.zombie.ambient", + "entity.drowned.ambient_water": "entity.zombie.ambient", + "entity.drowned.death": "entity.zombie.death", + "entity.drowned.death_water": "entity.zombie.death", + "entity.drowned.hurt": "entity.zombie.hurt", + "entity.drowned.hurt_water": "entity.zombie.hurt", + "entity.drowned.shoot": "entity.ender_eye.launch", + "entity.drowned.step": "entity.zombie.step", + "entity.drowned.swim": "entity.boat.paddle_water", + "entity.fish.swim": "entity.boat.paddle_water", + "entity.husk.converted_to_zombie": "entity.zombie_villager.cure", + "entity.parrot.imitate.drowned": "entity.zombie.ambient", + "entity.parrot.imitate.phantom": "entity.blaze.ambient", + "entity.phantom.ambient": "entity.blaze.ambient", + "entity.phantom.bite": "entity.blaze.shoot", + "entity.phantom.death": "entity.blaze.death", + "entity.phantom.flap": "entity.bat.loop", + "entity.phantom.hurt": "entity.blaze.hurt", + "entity.phantom.swoop": "entity.blaze.ambient", + "entity.player.splash.high_speed": "entity.fishing_bobber.splash", + "entity.puffer_fish.ambient": "entity.guardian.flop", + "entity.puffer_fish.blow_out": "block.redstone_torch.burnout", + "entity.puffer_fish.blow_up": "block.lava.extinguish", + "entity.puffer_fish.death": "enchant.thorns.hit", + "entity.puffer_fish.flop": "entity.guardian.flop", + "entity.puffer_fish.hurt": "entity.guardian.hurt_land", + "entity.puffer_fish.sting": "entity.blaze.hurt", + "entity.salmon.ambient": "entity.guardian.flop", + "entity.salmon.death": "entity.guardian.hurt_land", + "entity.salmon.flop": "entity.guardian.flop", + "entity.salmon.hurt": "entity.guardian.flop", + "entity.skeleton_horse.swim": "entity.generic.swim", + "entity.skeleton_horse.ambient_water": "entity.horse.ambient", + "entity.skeleton_horse.gallop_water": "entity.horse.gallop", + "entity.skeleton_horse.jump_water": "entity.horse.jump", + "entity.skeleton_horse.step_water": "entity.horse.step", + "entity.squid.squirt": "entity.squid.ambient", + "entity.tropical_fish.ambient": "entity.guardian.flop", + "entity.tropical_fish.death": "entity.slime.death", + "entity.tropical_fish.flop": "entity.guardian.flop", + "entity.tropical_fish.hurt": "entity.slime.hurt", + "entity.turtle.ambient_land": "block.sand.hit", + "entity.turtle.death": "entity.endermite.death", + "entity.turtle.death_baby": "entity.endermite.death", + "entity.turtle.egg_break": "entity.chicken.egg", + "entity.turtle.egg_crack": "entity.chicken.egg", + "entity.turtle.egg_hatch": "entity.chicken.egg", + "entity.turtle.hurt": "entity.chicken.egg", + "entity.turtle.hurt_baby": "entity.endermite.hurt", + "entity.turtle.lay_egg": "entity.chicken.egg", + "entity.turtle.shamble": "block.sand.step", + "entity.turtle.shamble_baby": "block.sand.step", + "entity.turtle.swim": "item.bucket.empty", + "entity.zombie.converted_to_drowned": "item.bucket.empty", + "entity.zombie.destroy_egg": "entity.chicken.egg", + "item.armor.equip_turtle": "item.armor.equip_generic", + "item.axe.strip": "block.wood.break", + "item.bucket.empty_fish": "item.bucket.empty", + "item.bucket.fill_fish": "item.bottle.fill", + "item.trident.hit": "entity.stray.step", + "item.trident.hit_ground": "entity.arrow.hit", + "item.trident.return": "item.armor.equip_diamond", + "item.trident.riptide_1": "entity.arrow.shoot", + "item.trident.riptide_2": "entity.arrow.shoot", + "item.trident.riptide_3": "entity.arrow.shoot", + "item.trident.throw": "entity.skeleton.shoot", + "item.trident.thunder": "entity.lightning_bolt.thunder", + "music.under_water": "music.creative" } } \ No newline at end of file diff --git a/core/src/main/resources/assets/viabackwards/data/mapping-1.13.2to1.14.json b/core/src/main/resources/assets/viabackwards/data/mapping-1.13.2to1.14.json index e2c9e891..beaf3c41 100644 --- a/core/src/main/resources/assets/viabackwards/data/mapping-1.13.2to1.14.json +++ b/core/src/main/resources/assets/viabackwards/data/mapping-1.13.2to1.14.json @@ -2658,5 +2658,140 @@ "minecraft:jigsaw[facing=west]": "minecraft:structure_block[mode=corner]", "minecraft:jigsaw[facing=up]": "minecraft:structure_block[mode=corner]", "minecraft:jigsaw[facing=down]": "minecraft:structure_block[mode=corner]" + }, + "sounds": { + "block.bamboo.break": "block.grass.break", + "block.bamboo.fall": "block.grass.fall", + "block.bamboo.hit": "block.grass.hit", + "block.bamboo.place": "block.grass.place", + "block.bamboo.step": "block.grass.step", + "block.bamboo_sapling.break": "block.grass.break", + "block.bamboo_sapling.hit": "block.sand.break", + "block.bamboo_sapling.place": "block.gravel.place", + "block.barrel.close": "block.wooden_trapdoor.close", + "block.barrel.open": "block.wooden_trapdoor.open", + "block.bell.use": "block.anvil.land", + "block.bell.resonate": "block.enchantment_table.use", + "item.book.page_turn": "", + "item.book.put": "block.wood.step", + "block.blastfurnace.fire_crackle": "block.furnace.fire_crackle", + "block.campfire.crackle": "block.fire.ambient", + "entity.cat.stray_ambient": "entity.cat.ambient", + "entity.cat.eat": "entity.cod.flop", + "entity.cat.beg_for_food": "entity.cat.ambient", + "block.composter.empty": "block.grass.break", + "block.composter.fill": "block.gravel.break", + "block.composter.fill_success": "block.gravel.break", + "block.composter.ready": "block.gravel.break", + "block.crop.break": "block.grass.break", + "item.crop.plant": "block.grass.place", + "item.crossbow.hit": "entity.arrow.hit", + "item.crossbow.loading_end": "block.tripwire.detach", + "item.crossbow.loading_middle": "block.comparator.click", + "item.crossbow.loading_start": "block.comparator.click", + "item.crossbow.quick_charge_1": "block.comparator.click", + "item.crossbow.quick_charge_2": "block.comparator.click", + "item.crossbow.quick_charge_3": "block.comparator.click", + "item.crossbow.shoot": "entity.arrow.shoot", + "entity.evoker.celebrate": "entity.villager.yes", + "entity.fox.aggro": "entity.wolf.growl", + "entity.fox.ambient": "entity.wolf.ambient", + "entity.fox.bite": "entity.dolphin.hurt", + "entity.fox.death": "entity.wolf.death", + "entity.fox.eat": "entity.dolphin.eat", + "entity.fox.hurt": "entity.wolf.hurt", + "entity.fox.screech": "entity.wolf.ambient", + "entity.fox.sleep": "entity.wolf.growl", + "entity.fox.sniff": "entity.wolf.pant", + "entity.fox.spit": "entity.llama.spit", + "block.grindstone.use": "block.iron_door.open", + "entity.ravager.ambient": "entity.polar_bear.ambient", + "entity.ravager.attack": "entity.polar_bear.warning", + "entity.ravager.celebrate": "entity.enderman.ambient", + "entity.ravager.death": "entity.polar_bear.death", + "entity.ravager.hurt": "entity.polar_bear.hurt", + "entity.ravager.step": "entity.polar_bear.step", + "entity.ravager.stunned": "entity.polar_bear.ambient", + "entity.ravager.roar": "entity.polar_bear.warning", + "block.lantern.break": "block.glass.break", + "block.lantern.fall": "block.glass.fall", + "block.lantern.hit": "block.glass.hit", + "block.lantern.place": "block.glass.place", + "block.lantern.step": "block.glass.step", + "entity.mooshroom.convert": "entity.zombie_villager.converted", + "entity.mooshroom.eat": "entity.boat.paddle_land", + "entity.mooshroom.milk": "entity.cow.milk", + "entity.mooshroom.suspicious_milk": "entity.cow.milk", + "block.nether_wart.break": "block.wet_grass.break", + "item.nether_wart.plant": "block.wet_grass.place", + "block.note_block.iron_xylophone": "block.note_block.xylophone", + "block.note_block.cow_bell": "block.note_block.bell", + "block.note_block.didgeridoo": "block.note_block.bass", + "block.note_block.bit": "block.note_block.pling", + "block.note_block.banjo": "block.note_block.chime", + "entity.ocelot.hurt": "entity.cat.hurt", + "entity.ocelot.ambient": "entity.cat.purreow", + "entity.ocelot.death": "entity.cat.death", + "entity.panda.pre_sneeze": "entity.turtle.hurt_baby", + "entity.panda.sneeze": "entity.bat.ambient", + "entity.panda.ambient": "entity.turtle.hurt_baby", + "entity.panda.death": "entity.turtle.death_baby", + "entity.panda.eat": "entity.turtle.egg_crack", + "entity.panda.step": "entity.turtle.shamble", + "entity.panda.cant_breed": "entity.polar_bear.ambient_baby", + "entity.panda.aggressive_ambient": "entity.polar_bear.warning", + "entity.panda.worried_ambient": "entity.polar_bear.ambient_baby", + "entity.panda.hurt": "entity.polar_bear.hurt", + "entity.panda.bite": "entity.polar_bear.step", + "entity.pillager.ambient": "entity.villager.ambient", + "entity.pillager.celebrate": "entity.vindicator.ambient", + "entity.pillager.death": "entity.vindicator.death", + "entity.pillager.hurt": "entity.vindicator.hurt", + "entity.player.hurt_sweet_berry_bush": "block.grass.step", + "event.raid.horn": "entity.wither.death", + "block.scaffolding.break": "block.wood.break", + "block.scaffolding.fall": "block.wood.fall", + "block.scaffolding.hit": "block.wood.hit", + "block.scaffolding.place": "block.wood.place", + "block.scaffolding.step": "block.wood.step", + "block.smoker.smoke": "block.fire.ambient", + "block.sweet_berry_bush.break": "block.gravel.break", + "block.sweet_berry_bush.place": "block.gravel.place", + "item.sweet_berries.pick_from_bush": "block.grass.hit", + "ui.loom.select_pattern": "item.flintandsteel.use", + "ui.loom.take_result": "block.wooden_door.close", + "ui.cartography_table.take_result": "block.enchantment_table.use", + "ui.stonecutter.take_result": "entity.horse.breathe", + "ui.stonecutter.select_recipe": "ui.button.click", + "entity.villager.celebrate": "entity.villager.ambient", + "entity.villager.work_armorer": "entity.villager.ambient", + "entity.villager.work_butcher": "entity.villager.ambient", + "entity.villager.work_cartographer": "entity.villager.ambient", + "entity.villager.work_cleric": "entity.villager.ambient", + "entity.villager.work_farmer": "entity.villager.ambient", + "entity.villager.work_fisherman": "entity.villager.ambient", + "entity.villager.work_fletcher": "entity.villager.ambient", + "entity.villager.work_leatherworker": "entity.villager.ambient", + "entity.villager.work_librarian": "entity.villager.ambient", + "entity.villager.work_mason": "entity.villager.ambient", + "entity.villager.work_shepherd": "entity.villager.ambient", + "entity.villager.work_toolsmith": "entity.villager.ambient", + "entity.villager.work_weaponsmith": "entity.villager.ambient", + "entity.vindicator.celebrate": "entity.villager.no", + "entity.wandering_trader.ambient": "entity.villager.ambient", + "entity.wandering_trader.death": "entity.villager.death", + "entity.wandering_trader.disappeared": "entity.enderman.teleport", + "entity.wandering_trader.drink_milk": "entity.witch.drink", + "entity.wandering_trader.drink_potion": "entity.generic.drink", + "entity.wandering_trader.hurt": "entity.villager.hurt", + "entity.wandering_trader.no": "entity.villager.no", + "entity.wandering_trader.reappeared": "entity.villager.yes", + "entity.wandering_trader.trade": "entity.villager.trade", + "entity.wandering_trader.yes": "entity.villager.yes", + "entity.witch.celebrate": "entity.witch.ambient", + "entity.parrot.imitate.guardian": "", + "entity.parrot.imitate.panda": "", + "entity.parrot.imitate.pillager": "", + "entity.parrot.imitate.ravager": "" } } \ No newline at end of file diff --git a/core/src/main/resources/assets/viabackwards/data/mapping-1.14.4to1.15.json b/core/src/main/resources/assets/viabackwards/data/mapping-1.14.4to1.15.json new file mode 100644 index 00000000..d01cf0b9 --- /dev/null +++ b/core/src/main/resources/assets/viabackwards/data/mapping-1.14.4to1.15.json @@ -0,0 +1,62 @@ +{ + "blockstates": { + "minecraft:bell[attachment=floor,facing=north,powered=true]": "minecraft:bell[attachment=floor,facing=north]", + "minecraft:bell[attachment=floor,facing=north,powered=false]": "minecraft:bell[attachment=floor,facing=north]", + "minecraft:bell[attachment=floor,facing=south,powered=true]": "minecraft:bell[attachment=floor,facing=south]", + "minecraft:bell[attachment=floor,facing=south,powered=false]": "minecraft:bell[attachment=floor,facing=south]", + "minecraft:bell[attachment=floor,facing=west,powered=true]": "minecraft:bell[attachment=floor,facing=west]", + "minecraft:bell[attachment=floor,facing=west,powered=false]": "minecraft:bell[attachment=floor,facing=west]", + "minecraft:bell[attachment=floor,facing=east,powered=true]": "minecraft:bell[attachment=floor,facing=east]", + "minecraft:bell[attachment=floor,facing=east,powered=false]": "minecraft:bell[attachment=floor,facing=east]", + "minecraft:bell[attachment=ceiling,facing=north,powered=true]": "minecraft:bell[attachment=ceiling,facing=north]", + "minecraft:bell[attachment=ceiling,facing=north,powered=false]": "minecraft:bell[attachment=ceiling,facing=north]", + "minecraft:bell[attachment=ceiling,facing=south,powered=true]": "minecraft:bell[attachment=ceiling,facing=south]", + "minecraft:bell[attachment=ceiling,facing=south,powered=false]": "minecraft:bell[attachment=ceiling,facing=south]", + "minecraft:bell[attachment=ceiling,facing=west,powered=true]": "minecraft:bell[attachment=ceiling,facing=west]", + "minecraft:bell[attachment=ceiling,facing=west,powered=false]": "minecraft:bell[attachment=ceiling,facing=west]", + "minecraft:bell[attachment=ceiling,facing=east,powered=true]": "minecraft:bell[attachment=ceiling,facing=east]", + "minecraft:bell[attachment=ceiling,facing=east,powered=false]": "minecraft:bell[attachment=ceiling,facing=east]", + "minecraft:bell[attachment=single_wall,facing=north,powered=true]": "minecraft:bell[attachment=single_wall,facing=north]", + "minecraft:bell[attachment=single_wall,facing=north,powered=false]": "minecraft:bell[attachment=single_wall,facing=north]", + "minecraft:bell[attachment=single_wall,facing=south,powered=true]": "minecraft:bell[attachment=single_wall,facing=south]", + "minecraft:bell[attachment=single_wall,facing=south,powered=false]": "minecraft:bell[attachment=single_wall,facing=south]", + "minecraft:bell[attachment=single_wall,facing=west,powered=true]": "minecraft:bell[attachment=single_wall,facing=west]", + "minecraft:bell[attachment=single_wall,facing=west,powered=false]": "minecraft:bell[attachment=single_wall,facing=west]", + "minecraft:bell[attachment=single_wall,facing=east,powered=true]": "minecraft:bell[attachment=single_wall,facing=east]", + "minecraft:bell[attachment=single_wall,facing=east,powered=false]": "minecraft:bell[attachment=single_wall,facing=east]", + "minecraft:bell[attachment=double_wall,facing=north,powered=true]": "minecraft:bell[attachment=double_wall,facing=north]", + "minecraft:bell[attachment=double_wall,facing=north,powered=false]": "minecraft:bell[attachment=double_wall,facing=north]", + "minecraft:bell[attachment=double_wall,facing=south,powered=true]": "minecraft:bell[attachment=double_wall,facing=south]", + "minecraft:bell[attachment=double_wall,facing=south,powered=false]": "minecraft:bell[attachment=double_wall,facing=south]", + "minecraft:bell[attachment=double_wall,facing=west,powered=true]": "minecraft:bell[attachment=double_wall,facing=west]", + "minecraft:bell[attachment=double_wall,facing=west,powered=false]": "minecraft:bell[attachment=double_wall,facing=west]", + "minecraft:bell[attachment=double_wall,facing=east,powered=true]": "minecraft:bell[attachment=double_wall,facing=east]", + "minecraft:bell[attachment=double_wall,facing=east,powered=false]": "minecraft:bell[attachment=double_wall,facing=east]", + "minecraft:honey_block": "minecraft:slime_block", + "minecraft:honeycomb_block": "minecraft:horn_coral_block", + "minecraft:beehive": "minecraft:barrel[facing=up,open=false]", + "minecraft:bee_nest": "minecraft:yellow_shulker_box[facing=up]" + }, + "sounds": { + "entity.bee.death": "entity.creeper.death", + "entity.bee.hurt": "entity.bat.hurt", + "entity.bee.loop_aggressive": "entity.enderman.scream", + "entity.bee.loop": "entity.parrot.fly", + "entity.bee.sting": "entity.phantom.bite", + "entity.bee.pollinate": "entity.parrot.fly", + "block.beehive.drip": "entity.slime.squish", + "block.beehive.enter": "entity.slime.death", + "block.beehive.exit": "entity.slime.death_small", + "block.beehive.shear": "block.wool.hit", + "block.beehive.work": "entity.parrot.fly", + "block.honey_block.break": "block.slime_block.break", + "block.honey_block.fall": "block.slime_block.fall", + "block.honey_block.hit": "block.slime_block.hit", + "block.honey_block.place": "block.slime_block.place", + "block.honey_block.slide": "block.slime_block.fall", + "block.honey_block.step": "block.slime_block.step", + "item.honey_bottle.drink": "entity.generic.drink", + "entity.iron_golem.damage": "entity.item.break", + "entity.iron_golem.repair": "entity.iron_golem.step" + } +} \ No newline at end of file diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index e77b486d..a92193c2 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -12,7 +12,7 @@ }, "environment": "*", "authors": [ - "Matsv" + "Matsv", "KennyTV", "Gerrygames", "creeper123123321", "ForceUpdate1" ], "entrypoints": { "viafabric:via_api_initialized": [ diff --git a/pom.xml b/pom.xml index edf8afbb..bba3735d 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ Allow newer clients to join older server versions. 2016 - https://www.spigotmc.org/resources/viaversion.19254/ + https://github.com/ViaVersion/ViaBackwards core @@ -54,14 +54,14 @@ org.projectlombok lombok - 1.16.18 + 1.18.10 provided us.myles viaversion - 2.1.4-19w39a + 3.0.0-SNAPSHOT provided diff --git a/sponge/src/main/java/nl/matsv/viabackwards/SpongePlugin.java b/sponge/src/main/java/nl/matsv/viabackwards/SpongePlugin.java index aa98d27c..2b5ba6c3 100644 --- a/sponge/src/main/java/nl/matsv/viabackwards/SpongePlugin.java +++ b/sponge/src/main/java/nl/matsv/viabackwards/SpongePlugin.java @@ -28,7 +28,7 @@ import java.util.logging.Logger; @Plugin(id = "viabackwards", name = "ViaBackwards", version = VersionInfo.VERSION, - authors = {"Matsv"}, + authors = {"Matsv", "KennyTV", "Gerrygames", "creeper123123321", "ForceUpdate1"}, description = "Allow older Minecraft versions to connect to a newer server version.", dependencies = {@Dependency(id = "viaversion")} ) diff --git a/velocity/src/main/java/nl/matsv/viabackwards/VelocityPlugin.java b/velocity/src/main/java/nl/matsv/viabackwards/VelocityPlugin.java index 4099522a..c48decb8 100644 --- a/velocity/src/main/java/nl/matsv/viabackwards/VelocityPlugin.java +++ b/velocity/src/main/java/nl/matsv/viabackwards/VelocityPlugin.java @@ -28,7 +28,7 @@ import java.util.logging.Logger; @Plugin(id = "viabackwards", name = "ViaBackwards", version = VersionInfo.VERSION, - authors = {"Matsv"}, + authors = {"Matsv", "KennyTV", "Gerrygames", "creeper123123321", "ForceUpdate1"}, description = "Allow older Minecraft versions to connect to a newer server version.", dependencies = {@Dependency(id = "viaversion")} )