From 9fe9cd3a8a9ac775c7906e06628a88754dbef058 Mon Sep 17 00:00:00 2001 From: Lucas Date: Fri, 18 Mar 2022 05:52:37 -0400 Subject: [PATCH] Map smoke directions from 1.13.1 to 1.13 (#413) --- .../packets/WorldPackets1_13_1.java | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/WorldPackets1_13_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/WorldPackets1_13_1.java index a50ced4a..4bdaa143 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/WorldPackets1_13_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/WorldPackets1_13_1.java @@ -17,6 +17,8 @@ */ package com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.packets; +import com.viaversion.viaversion.api.minecraft.BlockFace; +import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.protocol.Protocol; @@ -58,6 +60,45 @@ public class WorldPackets1_13_1 { blockRewriter.registerBlockAction(ClientboundPackets1_13.BLOCK_ACTION); blockRewriter.registerBlockChange(ClientboundPackets1_13.BLOCK_CHANGE); blockRewriter.registerMultiBlockChange(ClientboundPackets1_13.MULTI_BLOCK_CHANGE); - blockRewriter.registerEffect(ClientboundPackets1_13.EFFECT, 1010, 2001); + protocol.registerClientbound(ClientboundPackets1_13.EFFECT, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.INT); // Effect Id + map(Type.POSITION); // Location + map(Type.INT); // Data + handler(wrapper -> { + int id = wrapper.get(Type.INT, 0); + int data = wrapper.get(Type.INT, 1); + if (id == 1010) { // Play record + wrapper.set(Type.INT, 1, protocol.getMappingData().getNewItemId(data)); + } else if (id == 2001) { // Block break + block break sound + wrapper.set(Type.INT, 1, protocol.getMappingData().getNewBlockStateId(data)); + } else if (id == 2000) { // Smoke + switch (data) { + case 0: // Down + case 1: // Up + Position pos = wrapper.get(Type.POSITION, 0); + BlockFace relative = data == 0 ? BlockFace.BOTTOM : BlockFace.TOP; + wrapper.set(Type.POSITION, 0, pos.getRelative(relative)); // Y Offset + wrapper.set(Type.INT, 1, 4); // Self + break; + case 2: // North + wrapper.set(Type.INT, 1, 1); // North + break; + case 3: // South + wrapper.set(Type.INT, 1, 7); // South + break; + case 4: // West + wrapper.set(Type.INT, 1, 3); // West + break; + case 5: // East + wrapper.set(Type.INT, 1, 5); // East + break; + } + } + }); + } + }); + } }