Skip to content

Commit

Permalink
misc: 构建实体生成包时也发送其实体属性
Browse files Browse the repository at this point in the history
  • Loading branch information
MATRIX-feather committed Jan 14, 2024
1 parent 62394b0 commit 2ef2f82
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
import com.comphenix.protocol.wrappers.WrappedDataValue;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.game.*;
import net.minecraft.world.entity.Attackable;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.level.GameType;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity;
import org.bukkit.entity.EntityType;
Expand Down Expand Up @@ -140,7 +143,12 @@ public List<PacketContainer> buildSpawnPackets(Player player, DisplayParameters
}

if (!player.getPassengers().isEmpty())
packets.add(PacketContainer.fromPacket(new ClientboundSetPassengersPacket(NmsRecord.ofPlayer(player))));
packets.add(PacketContainer.fromPacket(new ClientboundSetPassengersPacket(nmsPlayer)));

var attributes = nmsPlayer.getAttributes().getSyncableAttributes();

var attributePacket = new ClientboundUpdateAttributesPacket(player.getEntityId(), attributes);
packets.add(PacketContainer.fromPacket(attributePacket));

for (PacketContainer packet : packets)
packet.setMeta(MORPH_PACKET_METAKEY, true);
Expand Down

0 comments on commit 2ef2f82

Please sign in to comment.