diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 59b1c9730..fcf84f2a9 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.4.0-18w01a + 1.4.0-18w02a 4.0.0 diff --git a/bungee/pom.xml b/bungee/pom.xml index 30636ed3c..c52174bee 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.4.0-18w01a + 1.4.0-18w02a 4.0.0 @@ -37,7 +37,7 @@ us.myles viaversion-common - 1.4.0-18w01a + 1.4.0-18w02a \ No newline at end of file diff --git a/common/pom.xml b/common/pom.xml index 30167807b..61e1c9e9e 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.4.0-18w01a + 1.4.0-18w02a 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 ad5c2942e..89091969d 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(352, "18w01a")); + register(v1_13 = new ProtocolVersion(353, "18w02a")); 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 809eaf725..00a52a360 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 @@ -16,6 +16,7 @@ import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.EntityPack import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.InventoryPackets; import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.WorldPackets; import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.BlockEntityProvider; +import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.PaintingProvider; import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.BlockStorage; import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.EntityTracker; import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.TabCompleteTracker; @@ -391,5 +392,6 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol { @Override protected void register(ViaProviders providers) { providers.register(BlockEntityProvider.class, new BlockEntityProvider()); + providers.register(PaintingProvider.class, new PaintingProvider()); } } 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 9ec2d9399..34fa87f7c 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 @@ -1,6 +1,7 @@ package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets; import com.github.steveice10.opennbt.tag.builtin.CompoundTag; +import com.google.common.base.Optional; import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.data.UserConnection; @@ -17,11 +18,37 @@ import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4 import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.MappingData; import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.BlockEntityProvider; +import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.PaintingProvider; import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.BlockStorage; public class WorldPackets { public static void register(Protocol protocol) { // Outgoing packets + + // Spawn Painting + protocol.registerOutgoing(State.PLAY, 0x04, 0x04, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity ID + map(Type.UUID); // 1 - Entity UUID + + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + PaintingProvider provider = Via.getManager().getProviders().get(PaintingProvider.class); + String motive = wrapper.read(Type.STRING); + + Optional id = provider.getIntByIdentifier(motive); + + if (!id.isPresent()) + System.out.println("Could not find painting motive: " + motive + " falling back to default (0)"); + + wrapper.write(Type.VAR_INT, id.or(0)); + } + }); + } + }); + // Update Block Entity protocol.registerOutgoing(State.PLAY, 0x09, 0x09, new PacketRemapper() { @Override diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/providers/PaintingProvider.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/providers/PaintingProvider.java new file mode 100644 index 000000000..be82ae206 --- /dev/null +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/providers/PaintingProvider.java @@ -0,0 +1,55 @@ +package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers; + +import com.google.common.base.Optional; +import us.myles.ViaVersion.api.platform.providers.Provider; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class PaintingProvider implements Provider { + private Map paintings = new ConcurrentHashMap<>(); + + public PaintingProvider() { + add("kebab"); + add("aztec"); + add("alban"); + add("aztec2"); + add("bomb"); + add("plant"); + add("wasteland"); + add("pool"); + add("courbet"); + add("sea"); + add("sunset"); + add("creebet"); + add("wanderer"); + add("graham"); + add("match"); + add("bust"); + add("stage"); + add("void"); + add("skull_and_roses"); + add("wither"); + add("fighters"); + add("pointer"); + add("pigscene"); + add("burning_skull"); + add("skeleton"); + add("donkey_kong"); + } + + private void add(String motive) { + paintings.put("minecraft:" + motive, paintings.size()); + } + + public Optional getIntByIdentifier(String motive) { + // Handle older versions + if (!motive.startsWith("minecraft:")) + motive = "minecraft:" + motive.toLowerCase(); + + if (paintings.containsKey(motive)) + return Optional.of(paintings.get(motive)); + + return Optional.absent(); + } +} \ No newline at end of file diff --git a/jar/pom.xml b/jar/pom.xml index e84fcd6bb..f4a26abc8 100644 --- a/jar/pom.xml +++ b/jar/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.4.0-18w01a + 1.4.0-18w02a 4.0.0 viaversion-jar diff --git a/pom.xml b/pom.xml index 6a7327b37..846ae7da2 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ us.myles viaversion-parent - 1.4.0-18w01a + 1.4.0-18w02a pom viaversion-parent diff --git a/sponge-legacy/pom.xml b/sponge-legacy/pom.xml index 73686df90..c9ef0c968 100644 --- a/sponge-legacy/pom.xml +++ b/sponge-legacy/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.4.0-18w01a + 1.4.0-18w02a 4.0.0 diff --git a/sponge/pom.xml b/sponge/pom.xml index 9e0ce56c4..f432eddd2 100644 --- a/sponge/pom.xml +++ b/sponge/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.4.0-18w01a + 1.4.0-18w02a 4.0.0