diff --git a/src/de/steamwar/spectatesystem/elements/REntity.java b/src/de/steamwar/spectatesystem/elements/REntity.java index ff5dedc..5356aa6 100644 --- a/src/de/steamwar/spectatesystem/elements/REntity.java +++ b/src/de/steamwar/spectatesystem/elements/REntity.java @@ -48,6 +48,7 @@ public abstract class REntity { for(Player player : Bukkit.getOnlinePlayers()){ sendToPlayer(player); } + sneak(false); } public static void playerJoins(Player player){ @@ -104,16 +105,17 @@ public abstract class REntity { } public void sneak(boolean sneaking) { - entity.setSneaking(sneaking); + DataWatcher dataWatcher = new DataWatcher(null); + + DataWatcherObject dataWatcherObject = new DataWatcherObject<>(6, DataWatcherRegistry.s); + dataWatcher.register(dataWatcherObject, sneaking?EntityPose.CROUCHING:EntityPose.STANDING); + dataWatcher.markDirty(dataWatcherObject); - /*DataWatcher dataWatcher = new DataWatcher(entity); - System.out.println("Let " + entity.getName() + " sneak " + sneaking); - dataWatcher.register(new DataWatcherObject<>(0, DataWatcherRegistry.a), sneaking ? (byte)0x02 : (byte)0x40); PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(entity.getId(), dataWatcher, false); for(Player player : Bukkit.getOnlinePlayers()){ - ((CraftPlayer)player).getHandle().playerConnection.sendPacket(packet); - }*/ + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + } } public void animation(byte animation) {