Minecraft – Elytra mechanics in Minecraft

minecraft-bukkitminecraft-commandsminecraft-java-edition

My goal is to use ArmorStands wearing elytra for ray casting. So far I figured out how to make it travel horizontally in any direction. But my problem is that the speed of the entity changes and it results in a curved path when I try to make it travel other pitches than straight horizontal. The method I use teleports the entity upwards every tick by a fixed amount as it glides.

What I can change with commands:

  • initial vertical momentum
  • entity rotation
  • upwards teleport amount

So I'd need the X and Z components of the momentum to be constant for this to be viable. Because I can counteract the Y momentum with the teleportation but not the X or Z. As long as the tp value can be calculated as some polynomial with trig-functions it's feasible to implement it.

How could I determine at what pitch does the X and Z momentum stay constant?

Here's a simplified snippet from the MCP:

Vec3d Look = getLookVec()
f = rotationPitch * 0.017453292 # pi/180
LookHorizontal = sqrt(Look.xCoord * Look.xCoord + Look.zCoord * Look.zCoord)
MotionHorizontal = sqrt(motionX * motionX + motionZ * motionZ)
LookLength = Look.lengthVector()
PitchCos = MathHelper.cos(f)
PitchCos = PitchCos * PitchCos * min(1.0, LookLength / 0.4)
motionY += -0.08 + PitchCos * 0.06

if (motionY < 0.0 and LookHorizontal > 0.0) #Moving DOWN and not looking straight up or down
{
    d2 = motionY * -0.1 * PitchCos
    motionY += d2
    motionX += Look.xCoord * d2 / LookHorizontal
    motionZ += Look.zCoord * d2 / LookHorizontal
}

if (f < 0.0) #Looking UP
{
    d9 = MotionHorizontal * -sin(f) * 0.04
    motionY += d9 * 3.2
    motionX -= Look.xCoord * d9 / LookHorizontal
    motionZ -= Look.zCoord * d9 / LookHorizontal
}

if (LookHorizontal > 0.0) #Not looking straight up or down
{
    motionX += (Look.xCoord / LookHorizontal * MotionHorizontal - motionX) * 0.1
    motionZ += (Look.zCoord / LookHorizontal * MotionHorizontal - motionZ) * 0.1
}

motionX *= 0.99
motionY *= 0.98
motionZ *= 0.99
moveEntity(motionX, motionY, motionZ)

Best Answer

Sorry to burst your bubble, but the Elytra can't be put on Armor Stands.

Also, you can't determine when X and Z postistions are constant. Remember that the Elytra don't give you the ability to actually fly (minus Creative mode), they only allow you to glide. And noting that they take up the Chestplate armor slot still makes players question why the Elytra can't be put on ArmorStands in the first place. The ability to but them on the stands may be in a future update. I tried this with my own game, and I came out with negative results. I died doing this, since Creative mode really makes the Elytra, um, unusable. Survival mode was the only way to do this.

Related Topic