dragon-mounts icon indicating copy to clipboard operation
dragon-mounts copied to clipboard

Are Dragons Supposed To Do This?

Open MikulDev opened this issue 8 years ago • 7 comments

I've noticed that for some strange reason, dragons, tamed and untamed, will close their wings if they are underneath any blocks. No matter the size, shape, and distance of the formation from the dragon. They get stuck at walking speed horizontally, but go vertically just fine, although it looks kinda silly :P Is this something to do with how air currents work in real life, or is this a genuine glitch?

MikulDev avatar Dec 20 '16 15:12 MikulDev

Yup, pretty sure it's a bug.

JonL98 avatar Jan 03 '17 23:01 JonL98

I think I found the issue. In EntityTameableDragon, getAltitude() (line 200) returns the distance from the world surface to the dragon. If the dragon is below any blocks, than the value returned is negative. Later in the same class is a boolean (line 268) comparing getAltitude() and ALTITUDE_FLYING_THRESHOLD for deciding whether to set the dragon's state to flying. It will always return false if getAltitude is negative, therefore stopping the dragon from flying.

JonL98 avatar Jan 03 '17 23:01 JonL98

Is this workable, or a permanent issue? It is just rather annoying because I have many floating structures in the world that are constantly forcing my dragon to fold its wings...

On Tue, Jan 3, 2017 at 6:44 PM, Jon Lentz [email protected] wrote:

I think I found the issue. In EntityTameableDragon, getAltitude() (line 200) returns the distance from the world surface to the dragon. If the dragon is below any blocks, than the value returned is negative. Later in the same class is a boolean (line 268) comparing getAltitude() and ALTITUDE_FLYING_THRESHOLD for deciding whether to set the dragon's state to flying. It will always return false if getAltitude is negative, therefore stopping the dragon from flying.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ata4/dragon-mounts/issues/35#issuecomment-270257675, or mute the thread https://github.com/notifications/unsubscribe-auth/AXiZ5ovysh8RltxoLqyvkbvnpsJkZpedks5rOt1PgaJpZM4LR-La .

MikulDev avatar Jan 03 '17 23:01 MikulDev

perhaps instead of checking to see if a solid block exists above the dragon, check to see if "X-number" of air blocks exist below the dragon...(or just that there aren't any solid blocks within X-number below or above dragon)...once air blocks below dragon < 3, have dragon fold in it's wings, this can make for a more-realistic landing as well.....

usafphoenix avatar Feb 08 '17 05:02 usafphoenix

This might work. And I maybe could tweak the code to check for this. Is the source code free to access?

On Wed, Feb 8, 2017 at 12:26 AM, usafphoenix [email protected] wrote:

perhaps instead of checking to see if a solid block exists above the dragon, check to see if "X-number" of air blocks exist below the dragon...once air blocks below dragon < 3, have dragon fold in it's wings.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ata4/dragon-mounts/issues/35#issuecomment-278232730, or mute the thread https://github.com/notifications/unsubscribe-auth/AXiZ5jXSnlNcS1SNiOBBdHnF1zPGGjIcks5raVH7gaJpZM4LR-La .

MikulDev avatar Feb 15 '17 01:02 MikulDev

@ata4 @Avatair There is a method in "net.minecraft.world.World" called isAirBlock(BlockPos pos). Basically you could use this method in getAltitude() to check for the next non-air block below when getHeight() returns higher than the dragon's position.

JonL98 avatar Sep 07 '17 22:09 JonL98

So I added this method to EntityTameableDragon

public boolean willLand() {
    BlockPos pos = getPosition();
return !world.isAirBlock(pos.down()) || !world.isAirBlock(pos.down(2));
}

And I changed this line in onLivingUpdate()

boolean flying = canFly() && !willLand();

This eliminates the issue of dragons landing while under blocks, but it isn't very efficient at all and makes things laggy in-game. Any suggestions to fix this while still accomplishing the same thing?

JonL98 avatar Sep 11 '17 22:09 JonL98