diff --git a/docs/scarpet/Full.md b/docs/scarpet/Full.md index 98b30a33..f9aae4b8 100644 --- a/docs/scarpet/Full.md +++ b/docs/scarpet/Full.md @@ -3397,11 +3397,21 @@ Available shapes: * `height` - height of the cyllinder, defaults to `0`, so flat disk. Can be negative. * `level` - level of details, see `'sphere'`. -### `create_marker(text, pos, rotation?, block?)` +### `create_marker(text, pos, rotation?, block?, interactive?)` Spawns a (permanent) marker entity with text or block at position. Returns that entity for further manipulations. Unloading the app that spawned them will cause all the markers from the loaded portion of the world to be removed. -Also, if the game loads that marker in the future and the app is not loaded, it will be removed as well. +Also, if the game loads that marker in the future and the app is not loaded, it will be removed as well. + +If `interactive` (`true` by default) is `false`, the armorstand will be a marker and would not be interactive in any +gamemode. But blocks can be placed inside markers and will not catch any interaction events. + +Y Position of a marker text or block will be adjusted to make blocks or text appear at the specified position. +This makes so that actual armorstand position may be offset on Y axis. You would need to adjust your entity +locations if you plan to move the armorstand around after the fact. If both text and block are specified - one of them +will be aligned (armorstand type markers text shows up at their feet, while for regular armorstands - above the head, +while block on the head always render in the same position regardless if its a marker or not). + ### `remove_all_markers()` diff --git a/docs/scarpet/api/Auxiliary.md b/docs/scarpet/api/Auxiliary.md index c5566f99..d471e769 100644 --- a/docs/scarpet/api/Auxiliary.md +++ b/docs/scarpet/api/Auxiliary.md @@ -105,11 +105,21 @@ Available shapes: * `height` - height of the cyllinder, defaults to `0`, so flat disk. Can be negative. * `level` - level of details, see `'sphere'`. -### `create_marker(text, pos, rotation?, block?)` +### `create_marker(text, pos, rotation?, block?, interactive?)` Spawns a (permanent) marker entity with text or block at position. Returns that entity for further manipulations. Unloading the app that spawned them will cause all the markers from the loaded portion of the world to be removed. -Also, if the game loads that marker in the future and the app is not loaded, it will be removed as well. +Also, if the game loads that marker in the future and the app is not loaded, it will be removed as well. + +If `interactive` (`true` by default) is `false`, the armorstand will be a marker and would not be interactive in any +gamemode. But blocks can be placed inside markers and will not catch any interaction events. + +Y Position of a marker text or block will be adjusted to make blocks or text appear at the specified position. +This makes so that actual armorstand position may be offset on Y axis. You would need to adjust your entity +locations if you plan to move the armorstand around after the fact. If both text and block are specified - one of them +will be aligned (armorstand type markers text shows up at their feet, while for regular armorstands - above the head, +while block on the head always render in the same position regardless if its a marker or not). + ### `remove_all_markers()` diff --git a/src/main/java/carpet/script/CarpetExpression.java b/src/main/java/carpet/script/CarpetExpression.java index ac82285d..30045d00 100644 --- a/src/main/java/carpet/script/CarpetExpression.java +++ b/src/main/java/carpet/script/CarpetExpression.java @@ -2905,9 +2905,30 @@ public class CarpetExpression } ArmorStandEntity armorstand = new ArmorStandEntity(EntityType.ARMOR_STAND, cc.s.getWorld()); + double yoffset; + if (targetBlock == null && name.isEmpty()) + { + yoffset = 0.0; + } + else if (!interactable && targetBlock == null) + { + yoffset = -0.41; + } + else + { + if (targetBlock==null) + { + yoffset = -armorstand.getHeight()-0.41; + } + else + { + yoffset = -armorstand.getHeight()+0.3; + } + } armorstand.refreshPositionAndAngles( pointLocator.vec.x, - pointLocator.vec.y - ((targetBlock==null)?(armorstand.getHeight()+0.41):(armorstand.getHeight()-0.3)), + //pointLocator.vec.y - ((!interactable && targetBlock == null)?0.41f:((targetBlock==null)?(armorstand.getHeight()+0.41):(armorstand.getHeight()-0.3))), + pointLocator.vec.y + yoffset, pointLocator.vec.z, (float)pointLocator.yaw, (float) pointLocator.pitch