Skip to content

Commit

Permalink
Update WrapperPlayServerPlayerPositionAndLook to 1.21.2
Browse files Browse the repository at this point in the history
  • Loading branch information
booky10 committed Oct 20, 2024
1 parent a2fcc30 commit eb68151
Show file tree
Hide file tree
Showing 2 changed files with 215 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,85 @@

package com.github.retrooper.packetevents.protocol.teleport;

// This is an immutable container for a masking byte
/**
* An immutable container for a single relative teleport flag or
* multiple relative teleport flags.
*/
public final class RelativeFlag {

public static final RelativeFlag X = new RelativeFlag(1 << 0);
public static final RelativeFlag Y = new RelativeFlag(1 << 1);
public static final RelativeFlag Z = new RelativeFlag(1 << 2);
public static final RelativeFlag YAW = new RelativeFlag(1 << 3);
public static final RelativeFlag PITCH = new RelativeFlag(1 << 4);
/**
* Added with 1.21.2
*/
public static final RelativeFlag DELTA_X = new RelativeFlag(1 << 5);
/**
* Added with 1.21.2
*/
public static final RelativeFlag DELTA_Y = new RelativeFlag(1 << 6);
/**
* Added with 1.21.2
*/
public static final RelativeFlag DELTA_Z = new RelativeFlag(1 << 7);
/**
* Added with 1.21.2
*/
public static final RelativeFlag ROTATE_DELTA = new RelativeFlag(1 << 8);

private final byte mask;
private final int mask;

public RelativeFlag(int mask) {
this.mask = (byte) mask;
this.mask = mask;
}

public RelativeFlag combine(RelativeFlag relativeFlag) { // FIXME: Should this be called append?
return new RelativeFlag(this.mask | relativeFlag.mask);
public RelativeFlag and(RelativeFlag other) {
return new RelativeFlag(this.mask & other.mask);
}

public byte getMask() {
return mask;
public RelativeFlag or(RelativeFlag other) {
return new RelativeFlag(this.mask | other.mask);
}

public boolean has(RelativeFlag flag) {
return this.has(flag.mask);
}

public boolean has(int flags) {
return (flags & this.mask) != 0;
}

public RelativeFlag set(RelativeFlag flag, boolean relative) {
return this.set(flag.mask, relative);
}

public RelativeFlag set(int flags, boolean relative) {
int ret = relative ? (byte) (flags | this.mask) : (byte) (flags & ~this.mask);
return new RelativeFlag(ret);
}

@Deprecated
public RelativeFlag combine(RelativeFlag relativeFlag) {
return this.or(relativeFlag);
}

@Deprecated
public boolean isSet(byte flags) {
return (flags & mask) != 0;
return this.has(flags);
}

@Deprecated
public byte set(byte flags, boolean relative) {
if (relative) {
return (byte) (flags | mask);
}
return (byte) (flags & ~mask);
return (byte) this.set((int) flags, relative).mask;
}

public byte getMask() {
return (byte) this.mask;
}

public int getFullMask() {
return this.mask;
}
}
}
Loading

0 comments on commit eb68151

Please sign in to comment.