diff --git a/pom.xml b/pom.xml index 74ea188..de495ef 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.github.unldenis.corpse Corpse - 1.0.9-SNAPSHOT + 1.0.10 8 diff --git a/src/main/java/com/github/unldenis/corpse/logic/Corpse.java b/src/main/java/com/github/unldenis/corpse/logic/Corpse.java index fdb1a23..c3d5f5a 100644 --- a/src/main/java/com/github/unldenis/corpse/logic/Corpse.java +++ b/src/main/java/com/github/unldenis/corpse/logic/Corpse.java @@ -106,14 +106,18 @@ public Corpse( public void show(@NotNull Player player) { this.seeingPlayers.add(player); + // hide name tag if option disabled if (!this.pool.isShowTags()) { hideNameTag(player); } + + // spawn and set sleep sendPackets(player, this.packetLoader.getWrapperPlayerInfoAdd().get(), this.packetLoader.getWrapperNamedEntitySpawn().get(), this.packetLoader.getWrapperEntityMetadata().get()); // Set sleep + // if version below 1.12 if (VersionUtil.isBelow(VersionUtil.VersionEnum.V1_12)) { player.sendBlockChange(BedUtil.getBedLocation(location), Material.valueOf("BED_BLOCK"), (byte) BedUtil.yawToFacing(location.getYaw())); @@ -123,6 +127,7 @@ public void show(@NotNull Player player) { .get()); // Set the correct height of the player lying down } + // show armor if (armor) { sendPackets(player, this.packetLoader.getWrapperEntityEquipment().getMore()); } diff --git a/src/main/java/com/github/unldenis/corpse/logic/packet/WrapperEntityMetadata.java b/src/main/java/com/github/unldenis/corpse/logic/packet/WrapperEntityMetadata.java index 80e26d8..86c1cdf 100644 --- a/src/main/java/com/github/unldenis/corpse/logic/packet/WrapperEntityMetadata.java +++ b/src/main/java/com/github/unldenis/corpse/logic/packet/WrapperEntityMetadata.java @@ -29,6 +29,9 @@ public class WrapperEntityMetadata implements IPacket { + private static final byte FLAGS = + (byte) (0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80); + private final int id; private PacketContainer packet; @@ -40,16 +43,13 @@ public WrapperEntityMetadata(int entityID) { public void load() { packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA); packet.getIntegers().write(0, this.id); + WrappedDataWatcher watcher = new WrappedDataWatcher(); if (VersionUtil.isAbove(VersionUtil.VersionEnum.V1_13)) { - WrappedDataWatcher.WrappedDataWatcherObject visible = new WrappedDataWatcher.WrappedDataWatcherObject( - 6, WrappedDataWatcher.Registry.get(EnumWrappers.getEntityPoseClass())); - watcher.setObject(visible, EnumWrappers.EntityPose.SLEEPING.toNms()); - /* - //Works and set location a little higher - WrappedDataWatcher.WrappedDataWatcherObject bed = new WrappedDataWatcher.WrappedDataWatcherObject(14, WrappedDataWatcher.Registry.getBlockPositionSerializer(true)); - watcher.setObject(bed, Optional.of(BlockPosition.getConverter().getGeneric(new BlockPosition(corpse.location.toVector())))); - */ + WrappedDataWatcher.WrappedDataWatcherObject visible = new WrappedDataWatcher.WrappedDataWatcherObject( + 6, WrappedDataWatcher.Registry.get(EnumWrappers.getEntityPoseClass())); + watcher.setObject(visible, EnumWrappers.EntityPose.SLEEPING.toNms()); + int indexSkinLayer = VersionUtil.isAbove(VersionUtil.VersionEnum.V1_17) ? 17 : 16; WrappedDataWatcher.WrappedDataWatcherObject skinLayers = new WrappedDataWatcher.WrappedDataWatcherObject( indexSkinLayer, WrappedDataWatcher.Registry.get(Byte.class)); @@ -59,20 +59,16 @@ public void load() { final WrappedDataWatcher.WrappedDataWatcherObject dataWatcherObject = entry.getWatcherObject(); wrappedDataValueList.add(new WrappedDataValue(dataWatcherObject.getIndex(), dataWatcherObject.getSerializer(), entry.getRawValue())); }); - wrappedDataValueList.add(new WrappedDataValue(skinLayers.getIndex(), skinLayers.getSerializer(), - (byte) (0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80))); + wrappedDataValueList.add(new WrappedDataValue(skinLayers.getIndex(), skinLayers.getSerializer(), FLAGS)); packet.getDataValueCollectionModifier().write(0, wrappedDataValueList); } else { - watcher.setObject(skinLayers, (byte) (0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80)); + watcher.setObject(skinLayers, FLAGS); packet.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects()); } - - - - } else { - watcher.setObject(10, (byte) (0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80)); - packet.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects()); - } + } else { + watcher.setObject(10, FLAGS); + packet.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects()); + } }