specified interactive option for markers, fixes #372

This commit is contained in:
gnembon committed 2020-07-13 00:22:15 -03:00
1 parent 5f34b5c96c
commit d90b4a306a
3 files changed
+44 -3

No files matched your search

+11 -1
View File
@@ -3397,12 +3397,22 @@ 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.
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()`
Removes all scarpet markers from the loaded portion of the world created by this app, in case you didn't want to do
+11 -1
View File
@@ -105,12 +105,22 @@ 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.
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()`
Removes all scarpet markers from the loaded portion of the world created by this app, in case you didn't want to do
@@ -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