From 8737b2b51a2426e73f9dbbe6437b610430c09c67 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 25 Sep 2024 18:11:09 +0200 Subject: [PATCH] 24w39a --- .../v1_21_2to1_21/Protocol1_21_2To1_21.java | 15 +++ .../rewriter/EntityPacketRewriter1_21_2.java | 103 ++++++++++++++++-- .../data/mappings-1.21.2to1.21.nbt | Bin 1145 -> 1513 bytes 3 files changed, 110 insertions(+), 8 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/Protocol1_21_2To1_21.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/Protocol1_21_2To1_21.java index 92dfd66d..27285a85 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/Protocol1_21_2To1_21.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/Protocol1_21_2To1_21.java @@ -109,6 +109,21 @@ public final class Protocol1_21_2To1_21 extends BackwardsProtocol { + wrapper.passthrough(Types.LONG); // Game time + + long dayTime = wrapper.read(Types.LONG); + final boolean daylightCycle = wrapper.read(Types.BOOLEAN); + if (!daylightCycle) { + if (dayTime == 0) { + dayTime = -1; + } else { + dayTime = -dayTime; + } + } + wrapper.write(Types.LONG, dayTime); + }); } private void storeTags(final PacketWrapper wrapper) { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/EntityPacketRewriter1_21_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/EntityPacketRewriter1_21_2.java index 4994bb01..363f3bfb 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/EntityPacketRewriter1_21_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/EntityPacketRewriter1_21_2.java @@ -22,7 +22,8 @@ import com.viaversion.viabackwards.api.rewriters.EntityRewriter; import com.viaversion.viabackwards.protocol.v1_21_2to1_21.Protocol1_21_2To1_21; import com.viaversion.viaversion.api.minecraft.RegistryEntry; import com.viaversion.viaversion.api.minecraft.entities.EntityType; -import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_2; +import com.viaversion.viaversion.api.minecraft.entitydata.EntityData; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Types; @@ -30,10 +31,13 @@ import com.viaversion.viaversion.api.type.types.version.Types1_21; import com.viaversion.viaversion.api.type.types.version.Types1_21_2; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_20_5; import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfigurationPackets1_21; +import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPackets1_21; import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2; import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPackets1_21_2; import com.viaversion.viaversion.util.Key; +import java.util.ArrayList; import java.util.BitSet; +import java.util.List; import static com.viaversion.viaversion.protocols.v1_21to1_21_2.rewriter.EntityPacketRewriter1_21_2.updateEnchantmentAttributes; @@ -45,9 +49,37 @@ public final class EntityPacketRewriter1_21_2 extends EntityRewriter { + final int entityId = wrapper.passthrough(Types.VAR_INT); + wrapper.passthrough(Types.UUID); // Entity UUID + final int entityTypeId = wrapper.passthrough(Types.VAR_INT); + wrapper.passthrough(Types.DOUBLE); // X + wrapper.passthrough(Types.DOUBLE); // Y + wrapper.passthrough(Types.DOUBLE); // Z + wrapper.passthrough(Types.BYTE); // Pitch + wrapper.passthrough(Types.BYTE); // Yaw + wrapper.passthrough(Types.BYTE); // Head yaw + wrapper.passthrough(Types.VAR_INT); // Data + getSpawnTrackerWithDataHandler1_19(EntityTypes1_21_2.FALLING_BLOCK).handle(wrapper); + + final EntityType type = EntityTypes1_21_2.getTypeFromId(entityTypeId); + if (type.isOrHasParent(EntityTypes1_21_2.ABSTRACT_BOAT)) { + wrapper.send(Protocol1_21_2To1_21.class); + wrapper.cancel(); + + // Add boat type to entity data + final List data = new ArrayList<>(); + final int boatType = type.isOrHasParent(EntityTypes1_21_2.ABSTRACT_CHEST_BOAT) ? chestBoatTypeFromEntityType(type) : boatTypeFromEntityType(type); + data.add(new EntityData(11, Types1_21.ENTITY_DATA_TYPES.varIntType, boatType)); + + final PacketWrapper entityDataPacket = wrapper.create(ClientboundPackets1_21.SET_ENTITY_DATA); + entityDataPacket.write(Types.VAR_INT, entityId); + entityDataPacket.write(Types1_21.ENTITY_DATA_LIST, data); + entityDataPacket.send(Protocol1_21_2To1_21.class); + } + }); protocol.registerClientbound(ClientboundConfigurationPackets1_21.REGISTRY_DATA, wrapper -> { final String registryKey = Key.stripMinecraftNamespace(wrapper.passthrough(Types.STRING)); @@ -152,6 +184,7 @@ public final class EntityPacketRewriter1_21_2 extends EntityRewriter { final float sideways = wrapper.read(Types.FLOAT); final float forward = wrapper.read(Types.FLOAT); @@ -245,6 +278,54 @@ public final class EntityPacketRewriter1_21_2 extends EntityRewriterQve%xXlyp|2;PC7ghOxv zF2ND(_`b+SCi(2V`SUWr>~FA(RvVoKX6CH3CiPV~jg!Po2KLJ+rM|WD>_q#jkp6A_ zM9PaDCk@EZ@DQMg5G9mR!6~XZ$0e>%gY-AiLUzlijXOM`k4HS?1+N(34MU9Zjv3}i zkV1kjNa$o!UXV0rkRh|IPY$!JC3U2-|BHFU1qXFVT#0>+4sMX&=^oX+qgs;R;|Vc7 WFh<^IsKVH}Pdi>X`RD7cUV3}N>?NcC delta 12 TcmaFK{gY$EamLN&%$t}1CNu>P