FallenMoonNetwork / CanaryMod

Server administration mod and API for Minecraft beta multiplayer server
http://canarymod.net
GNU Lesser General Public License v3.0
20 stars 14 forks source link

request - player.setFlying(boolean b) #106

Closed ghost closed 11 years ago

ghost commented 11 years ago

So that i can set that a player can fly without creative mode.

shadow386 commented 11 years ago

If I recall correctly, the client handles the flying which requires the creative mode to be set otherwise the player is mortal and cannot fly. I may be wrong, as they may have changed it recently, but to my knowledge, this will be a no.

gregcarlin commented 11 years ago

@shadow386 I thought the same thing, but have you seen http://wiki.vg/Protocol#Player_Abilities_.280xCA.29?

shadow386 commented 11 years ago

I have, and that's only an onGround packet and is not controlled by the server to allow a player flight. It will allow the server to tell the client that the onGround is false, which the client cannot do anything as it still needs the controls set which would have to be modified via a client mod. If you wish to have this setting for your server/plugins, change the setting for onGround to false.

14mRh4X0r commented 11 years ago

I thought I added this already... Anyway, yes, all fields from that packet can be set independently. They're in the OPlayerCapabilites class.

ghost commented 11 years ago

But a b****t server can do that so we should be able to add this too or ?

ghost commented 11 years ago

@14mRh4X0r if you mean player.setFlying(boolean b) dont work

14mRh4X0r commented 11 years ago

I was right, I did add the methods. But because I misunderstood their functions, I named them something that isn't quite right. I will be adding clones with proper names, but for now, use player.setFallingDisabled(bool)

ghost commented 11 years ago

K thx

ghost commented 11 years ago

Dont work. I mean that the player can fly like creative but he is in survival

14mRh4X0r commented 11 years ago

Ah, then you'll have to send the packet as well:

player.setFallingDisabled(true);
player.getEntity().a.b(new OPacket202PlayerAbilities(player.getEntity().cd));
ghost commented 11 years ago

Works thx :+1:

14mRh4X0r commented 11 years ago

The new names are canFly() and setCanFly(boolean).

ghost commented 11 years ago

Thx but the server kicks the player if allow-flight=false can you pls fix that ?

14mRh4X0r commented 11 years ago

No. That's a feature, not a bug. I will probably make kicks cancel-able though, so that can be caught.

ghost commented 11 years ago

Cant you check if the player isAllowed to flight ?

14mRh4X0r commented 11 years ago

I could, perhaps. That's not a bad idea, even :wink: Marked as minecraft bug because it kicks players while they're allowed to fly.

ghost commented 11 years ago

Thx works fine but could you add the code to update the flymode: p.getEntity().a.b(new OPacket202PlayerAbilities(p.getEntity().cd)); in the method´s ?

14mRh4X0r commented 11 years ago

If you had taken a closer look, you would've seen there already is: Player.updateCapabilities()

ghost commented 11 years ago

Hmm But why Player.setCanFly(boolean b) dont update it automatically ?