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 EntityRewriter