-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
None
-
None
-
Java 16.0.1
Windows 10 Pro
-
This server is running CraftBukkit version 3133-Spigot-66f9d3c-3fa79d3 (MC: 1.17) (Implementing API version 1.17-R0.1-SNAPSHOT)
-
Yes
I recently found out that there is Entity#playEffect(EntityEffect.GUARDIAN_TARGET) to show Guardian's laser when the Guardian has a target.
However, it turns out that when the awareness is disabled with Guardian#setAware(false), then it's not possible to set target for the guradian with Guardian#setTarget(livingEntity) for some reason. This is true for Spigot 1.16.x also.
To work around this issue, I am able to set the target by using DataWatcher:
DataWatcher dataWatcher = ((CraftLivingEntity) guardian).getHandle().getDataWatcher(); dataWatcher.set(new DataWatcherObject<>(16, DataWatcherRegistry.b), targetEntityId); // https://wiki.vg/Entity_metadata#Guardian -> Target EID -> 16 guardian.playEffect(EntityEffect.GUARDIAN_TARGET);
This forces me to use a version-dependant solution... Is it an oversight or is it intended that the target cannot be manually set while the awareness is disabled and/or I could approach it differently?