From e41f445e92a66b19ba0410fd65e38710e5f3bf2b Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Thu, 19 Apr 2018 19:39:30 -0300 Subject: [PATCH 1/3] 18w16a --- .../data/SpawnEggRewriter.java | 6 ++ .../packets/InventoryPackets.java | 70 +++++++++++-------- 2 files changed, 48 insertions(+), 28 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/data/SpawnEggRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/data/SpawnEggRewriter.java index 1952d1157..6a1b0524e 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/data/SpawnEggRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/data/SpawnEggRewriter.java @@ -1,5 +1,6 @@ package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data; +import com.google.common.base.Optional; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; @@ -67,4 +68,9 @@ public class SpawnEggRewriter { return 25100288; return (383 << 16 | (spawnEggs.get(entityIdentifier) & 0xFFFF)); } + + public static Optional getEntityId(int spawnEggId) { + if (spawnEggId >> 16 != 383) return Optional.absent(); + return Optional.fromNullable(spawnEggs.inverse().get(spawnEggId & 0xFFFF)); + } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/packets/InventoryPackets.java index 71937421d..af854e967 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/packets/InventoryPackets.java @@ -250,8 +250,8 @@ public class InventoryPackets { } if (!MappingData.oldToNewItems.containsKey(rawId)) { - if (MappingData.oldToNewItems.containsKey(item.getId() << 4)) { - rawId = item.getId() << 4; + if (MappingData.oldToNewItems.containsKey(rawId & ~0xF)) { + rawId &= ~0xF; // Remove data } else { System.out.println("FAILED TO GET 1.13 ITEM FOR " + item.getId()); // TODO: Make this nicer etc, perhaps fix issues with mapping :T rawId = 16; // Stone @@ -286,45 +286,59 @@ public class InventoryPackets { for (Map.Entry entry : MappingData.oldToNewItems.entrySet()) { if (entry.getValue() == item.getId()) { int oldId = entry.getKey(); - rawId = (oldId >> 4) << 16 | oldId & 0xF; + // Handle spawn eggs + Optional eggEntityId = SpawnEggRewriter.getEntityId(oldId); + if (eggEntityId.isPresent()) { + rawId = 383 << 16; + if (tag == null) + item.setTag(tag = new CompoundTag("tag")); + if (!tag.contains("EntityTag")) { + CompoundTag entityTag = new CompoundTag("EntityTag"); + entityTag.put(new StringTag("id", eggEntityId.get())); + tag.put(entityTag); + } + } else { + rawId = (oldId >> 4) << 16 | oldId & 0xF; + } break; } } } - if (rawId != null) { - item.setId((short) (rawId >> 16)); - item.setData((short) (rawId & 0xFFFF)); + if (rawId == null) { + System.out.println("FAILED TO GET 1.12 ITEM FOR " + item.getId()); + rawId = 0x10000; // Stone + } - if (tag != null) { - if (isDamageable(item.getId())) { - if (tag.get("Damage") instanceof IntTag) { - if (!gotRawIdFromTag) - item.setData((short) (int) tag.get("Damage").getValue()); - tag.remove("Damage"); - } + item.setId((short) (rawId >> 16)); + item.setData((short) (rawId & 0xFFFF)); + + if (tag != null) { + if (isDamageable(item.getId())) { + if (tag.get("Damage") instanceof IntTag) { + if (!gotRawIdFromTag) + item.setData((short) (int) tag.get("Damage").getValue()); + tag.remove("Damage"); } + } - if (item.getId() == 358) { // map - if (tag.get("map") instanceof IntTag) { - if (!gotRawIdFromTag) - item.setData((short) (int) tag.get("map").getValue()); - tag.remove("map"); - } + if (item.getId() == 358) { // map + if (tag.get("map") instanceof IntTag) { + if (!gotRawIdFromTag) + item.setData((short) (int) tag.get("map").getValue()); + tag.remove("map"); } + } - if (item.getId() == 442) { // shield - if (tag.get("BlockEntityTag") instanceof CompoundTag) { - CompoundTag blockEntityTag = tag.get("BlockEntityTag"); - if (blockEntityTag.get("Base") instanceof IntTag) { - IntTag base = blockEntityTag.get("Base"); - base.setValue(15 - base.getValue()); // invert color id - } + if (item.getId() == 442) { // shield + if (tag.get("BlockEntityTag") instanceof CompoundTag) { + CompoundTag blockEntityTag = tag.get("BlockEntityTag"); + if (blockEntityTag.get("Base") instanceof IntTag) { + IntTag base = blockEntityTag.get("Base"); + base.setValue(15 - base.getValue()); // invert color id } } } - } else { - System.out.println("FAILED TO GET 1.12 ITEM FOR " + item.getId()); // TODO: Make this nicer etc, perhaps fix issues with mapping :T } } From 188cc5019f91b2805661dbd85cbc12aaa39a57b0 Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Sat, 21 Apr 2018 11:11:12 -0300 Subject: [PATCH 2/3] Maybe better performance? --- .../packets/WorldPackets.java | 21 ++++++++++--------- .../storage/BlockStorage.java | 6 +++--- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/packets/WorldPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/packets/WorldPackets.java index 1afdfc422..e75f2df0f 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/packets/WorldPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/packets/WorldPackets.java @@ -248,17 +248,18 @@ public class WorldPackets { } public static int toNewId(int oldId) { - if (MappingData.oldToNewBlocks.containsKey(oldId)) { - return MappingData.oldToNewBlocks.get(oldId); - } else { - if (MappingData.oldToNewBlocks.containsKey((oldId >> 4) << 4)) { - System.out.println("Missing block " + oldId); - return MappingData.oldToNewBlocks.get((oldId >> 4) << 4); - } - System.out.println("Missing block completely " + oldId); - // Default stone - return 1; + Integer newId = MappingData.oldToNewBlocks.get(oldId); + if (newId != null) { + return newId; } + newId = MappingData.oldToNewBlocks.get(oldId & ~0xF); // Remove data + if (newId != null) { + System.out.println("Missing block " + oldId); + return newId; + } + System.out.println("Missing block completely " + oldId); + // Default stone + return 1; } private static int checkStorage(UserConnection user, Position position, int newId) { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/storage/BlockStorage.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/storage/BlockStorage.java index 6e3f0de25..862351655 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/storage/BlockStorage.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/storage/BlockStorage.java @@ -1,19 +1,19 @@ package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage; +import com.google.common.collect.Sets; import lombok.AllArgsConstructor; import lombok.Data; import us.myles.ViaVersion.api.data.StoredObject; import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.minecraft.Position; -import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; public class BlockStorage extends StoredObject { // This BlockStorage is very exclusive (; - private static final List whitelist = new CopyOnWriteArrayList<>(); + private static final Set whitelist = Sets.newConcurrentHashSet(); static { // Flower pots From 136adaebd5841bdc43ec9c5d2dc98bb073bd1747 Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Wed, 9 May 2018 15:45:09 -0300 Subject: [PATCH 3/3] 18w19b --- bukkit/pom.xml | 2 +- bungee/pom.xml | 2 +- common/pom.xml | 2 +- .../api/protocol/ProtocolVersion.java | 2 +- .../ProtocolSnapshotTo1_12_2.java | 29 +++++++++++++++++-- .../assets/viaversion/data/mapping-1.13.json | 10 +++---- jar/pom.xml | 2 +- pom.xml | 2 +- sponge-legacy/pom.xml | 2 +- sponge/pom.xml | 2 +- 10 files changed, 39 insertions(+), 16 deletions(-) diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 56c374528..dcda53ae8 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.4.0-18w16a + 1.4.0-18w19b 4.0.0 diff --git a/bungee/pom.xml b/bungee/pom.xml index 05d8dcc40..00651e6fe 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.4.0-18w16a + 1.4.0-18w19b 4.0.0 diff --git a/common/pom.xml b/common/pom.xml index eafb69ac6..8a4124db0 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.4.0-18w16a + 1.4.0-18w19b 4.0.0 diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java index 6b719303f..c3e8f2f9a 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java @@ -62,7 +62,7 @@ public class ProtocolVersion { register(v1_12 = new ProtocolVersion(335, "1.12")); register(v1_12_1 = new ProtocolVersion(338, "1.12.1")); register(v1_12_2 = new ProtocolVersion(340, "1.12.2")); - register(v1_13 = new ProtocolVersion(372, "18w16a")); + register(v1_13 = new ProtocolVersion(374, "18w19b")); register(unknown = new ProtocolVersion(-1, "UNKNOWN")); } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/ProtocolSnapshotTo1_12_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/ProtocolSnapshotTo1_12_2.java index 741f3e8c5..ffe0ccafc 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/ProtocolSnapshotTo1_12_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/ProtocolSnapshotTo1_12_2.java @@ -165,6 +165,7 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol { public void write(PacketWrapper wrapper) throws Exception { wrapper.write(Type.VAR_INT, 0); wrapper.write(Type.VAR_INT, 0); + wrapper.write(Type.VAR_INT, 0); } }); tagsPacket.send(ProtocolSnapshotTo1_12_2.class); @@ -186,12 +187,22 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol { public void handle(PacketWrapper wrapper) throws Exception { int iconCount = wrapper.passthrough(Type.VAR_INT); for (int i = 0; i < iconCount; i++) { + byte directionAndType = wrapper.read(Type.BYTE); + int type = (directionAndType & 0xF0) >> 4; + wrapper.write(Type.VAR_INT, type); wrapper.passthrough(Type.BYTE); // Icon X - wrapper.passthrough(Type.BYTE); // Icon Y wrapper.passthrough(Type.BYTE); // Icon Z + byte direction = (byte) (directionAndType & 0x0F); + wrapper.write(Type.BYTE, direction); wrapper.write(Type.OPTIONAL_CHAT, null); // Display Name } - wrapper.passthroughAll(); + int columns = wrapper.passthrough(Type.BYTE); + if (columns > 0) { + wrapper.passthrough(Type.BYTE); // rows + wrapper.passthrough(Type.BYTE); // x + wrapper.passthrough(Type.BYTE); // z + wrapper.passthrough(Type.BYTE_ARRAY); // data + } } }); } @@ -458,8 +469,12 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol { int newId = oldID; if (oldID >= 1) newId += 6; + if (oldID >= 9) + newId += 4; if (oldID >= 10) newId += 5; + if (oldID >= 21) + newId += 5; if (oldID >= 86) newId += 1; if (oldID >= 166) @@ -470,14 +485,22 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol { newId += 9; if (oldID >= 226) newId += 1; + if (oldID >= 271) + newId += 1; + if (oldID >= 326) + newId += 1; + if (oldID >= 335) + newId += 1; if (oldID >= 352) - newId += 5; + newId += 6; if (oldID >= 373) newId += 1; if (oldID >= 380) newId += 7; if (oldID >= 385) newId += 4; + if (oldID >= 412) + newId += 5; if (oldID >= 438) newId += 1; if (oldID >= 443) diff --git a/common/src/main/resources/assets/viaversion/data/mapping-1.13.json b/common/src/main/resources/assets/viaversion/data/mapping-1.13.json index dac44d049..f5299a919 100644 --- a/common/src/main/resources/assets/viaversion/data/mapping-1.13.json +++ b/common/src/main/resources/assets/viaversion/data/mapping-1.13.json @@ -954,9 +954,9 @@ "951": "minecraft:grass", "952": "minecraft:fern", "953": "minecraft:dead_bush", - "954": "minecraft:sea_grass", - "955": "minecraft:tall_sea_grass[half=upper]", - "956": "minecraft:tall_sea_grass[half=lower]", + "954": "minecraft:seagrass", + "955": "minecraft:tall_seagrass[half=upper]", + "956": "minecraft:tall_seagrass[half=lower]", "957": "minecraft:piston[extended=true,facing=north]", "958": "minecraft:piston[extended=true,facing=east]", "959": "minecraft:piston[extended=true,facing=south]", @@ -8487,7 +8487,7 @@ "70": "minecraft:grass", "71": "minecraft:fern", "72": "minecraft:dead_bush", - "73": "minecraft:sea_grass", + "73": "minecraft:seagrass", "74": "minecraft:sea_pickle", "75": "minecraft:piston", "76": "minecraft:white_wool", @@ -9064,7 +9064,7 @@ "647": "minecraft:pig_spawn_egg", "648": "minecraft:phantom_spawn_egg", "649": "minecraft:polar_bear_spawn_egg", - "650": "minecraft:puffer_fish_spawn_egg", + "650": "minecraft:pufferfish_spawn_egg", "651": "minecraft:rabbit_spawn_egg", "652": "minecraft:salmon_mob_spawn_egg", "653": "minecraft:sheep_spawn_egg", diff --git a/jar/pom.xml b/jar/pom.xml index 26859ea98..cf29a534e 100644 --- a/jar/pom.xml +++ b/jar/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.4.0-18w16a + 1.4.0-18w19b 4.0.0 viaversion-jar diff --git a/pom.xml b/pom.xml index bea27b00b..859171c5b 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ us.myles viaversion-parent - 1.4.0-18w16a + 1.4.0-18w19b pom viaversion-parent diff --git a/sponge-legacy/pom.xml b/sponge-legacy/pom.xml index 4eff6e7de..97ac7d2f5 100644 --- a/sponge-legacy/pom.xml +++ b/sponge-legacy/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.4.0-18w16a + 1.4.0-18w19b 4.0.0 diff --git a/sponge/pom.xml b/sponge/pom.xml index ffb4af52e..fbe1d5a79 100644 --- a/sponge/pom.xml +++ b/sponge/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.4.0-18w16a + 1.4.0-18w19b 4.0.0