Open MikulDev opened 7 years ago
Yup, pretty sure it's a bug.
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.
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 notifications@github.com 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 .
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.....
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 notifications@github.com 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 .
@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.
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?
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?