Merge pull request #381 from MrGazdag/patch-7

Add 'addFlag' and 'removeFlag' to PlayerAbilitiesPacket
This commit is contained in:
TheMode 2021-07-27 12:25:19 +02:00 committed by GitHub
commit 2e406e5c46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -1787,13 +1787,13 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
protected void refreshAbilities() {
byte flags = 0;
if (invulnerable)
flags |= 0x01;
flags |= PlayerAbilitiesPacket.FLAG_INVULNERABLE;
if (flying)
flags |= 0x02;
flags |= PlayerAbilitiesPacket.FLAG_FLYING;
if (allowFlying)
flags |= 0x04;
flags |= PlayerAbilitiesPacket.FLAG_ALLOW_FLYING;
if (instantBreak)
flags |= 0x08;
flags |= PlayerAbilitiesPacket.FLAG_INSTANT_BREAK;
playerConnection.sendPacket(new PlayerAbilitiesPacket(flags, flyingSpeed, fieldViewModifier));
}

View File

@ -7,6 +7,10 @@ import net.minestom.server.utils.binary.BinaryWriter;
import org.jetbrains.annotations.NotNull;
public class PlayerAbilitiesPacket implements ServerPacket {
public static final byte FLAG_INVULNERABLE = 0x01;
public static final byte FLAG_FLYING = 0x02;
public static final byte FLAG_ALLOW_FLYING = 0x04;
public static final byte FLAG_INSTANT_BREAK = 0x08;
public byte flags;
public float flyingSpeed;