From febf2c283de216f53b3d95211051a4f2f77a9ddb Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 28 Nov 2025 09:56:18 +0100 Subject: [PATCH] Fix REntity.bowDrawnWatcher --- .../src/de/steamwar/core/FlatteningWrapper14.java | 8 ++++---- .../src/de/steamwar/core/FlatteningWrapper21.java | 7 +++++++ .../src/de/steamwar/core/FlatteningWrapper.java | 4 +++- .../SpigotCore_Main/src/de/steamwar/entity/REntity.java | 6 ++++-- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java b/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java index 82e1c879..f751cf41 100644 --- a/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java +++ b/SpigotCore/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java @@ -300,10 +300,10 @@ public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper return head; } - private static final Class entityPose = Reflection.getClass("net.minecraft.world.entity.Pose"); - private static final Object standing = entityPose.getEnumConstants()[0]; - private static final Object swimming = entityPose.getEnumConstants()[3]; - private static final Object sneaking = entityPose.getEnumConstants()[5]; + protected static final Class entityPose = Reflection.getClass("net.minecraft.world.entity.Pose"); + protected static final Object standing = entityPose.getEnumConstants()[0]; + protected static final Object swimming = entityPose.getEnumConstants()[3]; + protected static final Object sneaking = entityPose.getEnumConstants()[5]; @Override public Object getPose(FlatteningWrapper.EntityPose pose) { switch (pose) { diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/FlatteningWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/FlatteningWrapper21.java index 35ef5ed2..1d791a90 100644 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/FlatteningWrapper21.java +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/core/FlatteningWrapper21.java @@ -43,4 +43,11 @@ public class FlatteningWrapper21 extends FlatteningWrapper14 implements Flatteni }); return head; } + + protected static final Object shooting = entityPose.getEnumConstants()[16]; + @Override + public Object getPose(FlatteningWrapper.EntityPose pose) { + if (pose == FlatteningWrapper.EntityPose.SHOOTING) return shooting; + return super.getPose(pose); + } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/FlatteningWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/FlatteningWrapper.java index 2a6d6370..f98646f5 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/FlatteningWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/FlatteningWrapper.java @@ -56,6 +56,8 @@ public class FlatteningWrapper { public enum EntityPose { NORMAL, SNEAKING, - SWIMMING; + SWIMMING, + SHOOTING, + ; } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java index 43a22af9..9962878e 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java @@ -36,7 +36,7 @@ public class REntity { private static final Object entityStatusWatcher = BountifulWrapper.impl.getDataWatcherObject(0, Byte.class); private static final Object sneakingDataWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() > 12 ? 6 : 0, FlatteningWrapper.impl.getPose(FlatteningWrapper.EntityPose.NORMAL).getClass()); - private static final Object bowDrawnWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() > 12 ? 7 : 6, Byte.class); + private static final Object bowDrawnWatcher = Core.getVersion() >= 21 ? BountifulWrapper.impl.getDataWatcherObject(6, FlatteningWrapper.impl.getPose(FlatteningWrapper.EntityPose.NORMAL).getClass()) : BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() > 12 ? 7 : 6, Byte.class); private static final Object nameWatcher = BountifulWrapper.impl.getDataWatcherObject(2, Core.getVersion() > 12 ? Optional.class : String.class); // Optional private static final Object nameVisibleWatcher = BountifulWrapper.impl.getDataWatcherObject(3, Boolean.class); @@ -219,7 +219,9 @@ public class REntity { public void setBowDrawn(boolean drawn, boolean offHand) { bowDrawn = drawn; - if(Core.getVersion() > 8){ + if (Core.getVersion() >= 21) { + server.updateEntity(this, getDataWatcherPacket(bowDrawnWatcher, FlatteningWrapper.impl.getPose(FlatteningWrapper.EntityPose.SHOOTING))); + } else if(Core.getVersion() > 8){ server.updateEntity(this, getDataWatcherPacket(bowDrawnWatcher, (byte) ((drawn ? 1 : 0) + (offHand ? 2 : 0)))); }else{ server.updateEntity(this, getDataWatcherPacket(entityStatusWatcher, getEntityStatus()));