From a14d852df427b7383863e57065150acf6c2b8340 Mon Sep 17 00:00:00 2001 From: Alex 'mcmonkey' Goodwin Date: Fri, 16 Apr 2021 22:39:26 -0700 Subject: [PATCH] EntityTag.standing_on --- .../denizen/objects/EntityTag.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/EntityTag.java b/plugin/src/main/java/com/denizenscript/denizen/objects/EntityTag.java index 4aa0ee3edc..447e607d76 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/EntityTag.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/EntityTag.java @@ -1453,20 +1453,29 @@ else if (mtr.angle == BlockFace.EAST) { return new LocationTag(object.getTargetBlockSafe(set, range)); } - // <--[tag] - // @attribute - // @returns LocationTag - // @group location - // @description - // Returns the location of what the entity is standing on. - // --> if (attribute.startsWith("standing_on", 2)) { + Deprecations.entityStandingOn.warn(attribute.context); attribute.fulfill(1); return new LocationTag(object.entity.getLocation().clone().add(0, -0.5f, 0)); } return new LocationTag(object.entity.getLocation()); }); + // <--[tag] + // @attribute + // @returns LocationTag + // @group location + // @description + // Returns the location of the block the entity is standing on top of (if on the ground, returns null if in the air). + // --> + registerSpawnedOnlyTag("standing_on", (attribute, object) -> { + if (!object.getBukkitEntity().isOnGround()) { + return null; + } + Location loc = object.getBukkitEntity().getLocation().clone().subtract(0, 0.05f, 0); + return new LocationTag(loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); + }); + // <--[tag] // @attribute // @returns ElementTag(Decimal)