From 3ba86741f9df2f79a144844f62ccb21afc2548c1 Mon Sep 17 00:00:00 2001 From: EnZaXD Date: Mon, 18 Nov 2024 15:05:25 +0100 Subject: [PATCH] Send default entity data for items in 1.10->1.11 (#4265) --- .../rewriter/EntityPacketRewriter1_11.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_10to1_11/rewriter/EntityPacketRewriter1_11.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_10to1_11/rewriter/EntityPacketRewriter1_11.java index 943bc4714..9e7e8b0c9 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_10to1_11/rewriter/EntityPacketRewriter1_11.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_10to1_11/rewriter/EntityPacketRewriter1_11.java @@ -24,9 +24,9 @@ import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11.EntityType; -import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.entitydata.EntityData; import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1_9; +import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Types; @@ -37,6 +37,7 @@ import com.viaversion.viaversion.protocols.v1_10to1_11.data.EntityMappings1_11; import com.viaversion.viaversion.protocols.v1_10to1_11.storage.EntityTracker1_11; import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3; import com.viaversion.viaversion.rewriter.EntityRewriter; +import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.logging.Level; @@ -91,13 +92,27 @@ public class EntityPacketRewriter1_11 extends EntityRewriter { byte type = wrapper.get(Types.BYTE, 0); if (type == EntityTypes1_10.ObjectType.FISHIHNG_HOOK.getId()) { tryFixFishingHookVelocity(wrapper); + } else if (type == EntityTypes1_10.ObjectType.ITEM.getId()) { + // Older clients used stone as fallback as long as the entity data was not set + wrapper.send(Protocol1_10To1_11.class); + wrapper.cancel(); + + final int entityId = wrapper.get(Types.VAR_INT, 0); + + final List entityDataList = new ArrayList<>(); + entityDataList.add(new EntityData(6, EntityDataTypes1_9.ITEM, new DataItem(1, (byte) 1, null))); + + final PacketWrapper setItem = PacketWrapper.create(ClientboundPackets1_9_3.SET_ENTITY_DATA, wrapper.user()); + setItem.write(Types.VAR_INT, entityId); + setItem.write(Types1_9.ENTITY_DATA_LIST, entityDataList); + setItem.send(Protocol1_10To1_11.class); } }); - handler(objectTrackerHandler()); } });