I hope this works well- I have tested it and it seems to work lovely on MCDerp. Here is the code if you're interested. It should be placed in the "HandleInput" void, as shown below.
- Code: Select all
void HandleInput( object m ) {
if ( !loggedIn || trainGrab || following != "" || frozen )
return;
byte[] message = (byte[])m;
byte thisid = message[0];
ushort x = NTHO( message, 1 );
ushort y = NTHO( message, 3 );
ushort z = NTHO( message, 5 );
byte rotx = message[7];
byte roty = message[8];
// Check for flying
ushort xx = (ushort)( x / 32 );
ushort yy = (ushort)( y / 32 );
ushort zz = (ushort)( z / 32 );
if ( y == oldpos[1] || y > oldpos[1] ) {
byte currBlock = level.GetTile( xx, (ushort)( yy - 1 ), zz );
byte belowBlock = level.GetTile( xx, (ushort)( yy - 2 ), zz );
if ( currBlock != Block.waterstill
&& currBlock != Block.water
&& currBlock != Block.water_portal
&& currBlock != Block.lavastill
&& currBlock != Block.lava
&& currBlock != Block.lava_portal ) {
if ( belowBlock == Block.air ) {
flyingTickCount++;
} else {
flyingTickCount = 0;
}
} else {
flyingTickCount = 0;
}
}
if ( flyingTickCount >= 30 ) {
ushort Y = 0;
for ( ushort YY = 0; YY <= yy; YY++ ) {
if ( level.GetTile( xx, YY, zz ) != Block.air ) {
Y = YY;
}
}
unchecked {
SendMessage( this, "&cFlying is not permitted on this server!" );
SendPos( (byte)-1, x, (ushort)( ( ( Y + 2 ) * 32 ) ), z, rot[0], rot[1] );
}
}
pos = new ushort[3] { x, y, z };
rot = new byte[2] { rotx, roty };
}
If you implement this- I hope I get credit Naa, only kidding. Have fun with it, hope it helps.