[1.21.2] Rewrite of the out player position packet with new relative flags
Signed-off-by: Irmo van den Berge <irmo.vandenberge@ziggo.nl>
This commit is contained in:
1 parent
583ae5e636
commit
7429648ea2
9 files changed
+411
-231
No files matched your search
@@ -3,7 +3,7 @@ template-minecraft-version = "1.21.2"
|
||||
spigot = "1.21.2-R0.1-SNAPSHOT"
|
||||
netty = "4.1.42.Final"
|
||||
log4j = "2.17.0"
|
||||
mountiplex = "3.21"
|
||||
mountiplex = "3.22"
|
||||
regionchangetracker = "1.3"
|
||||
colorconversionhelper = "1.03"
|
||||
softdependencylib = "1.04"
|
||||
|
||||
+29
-67
@@ -1,9 +1,8 @@
|
||||
package com.bergerkiller.generated.net.minecraft.network.protocol.game;
|
||||
|
||||
import com.bergerkiller.mountiplex.reflection.declarations.Template;
|
||||
import com.bergerkiller.bukkit.common.wrappers.RelativeFlags;
|
||||
import com.bergerkiller.generated.net.minecraft.network.protocol.PacketHandle;
|
||||
import com.bergerkiller.generated.net.minecraft.world.entity.RelativeMovementHandle;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Instance wrapper handle for type <b>net.minecraft.network.protocol.game.PacketPlayOutPosition</b>.
|
||||
@@ -22,83 +21,46 @@ public abstract class PacketPlayOutPositionHandle extends PacketHandle {
|
||||
|
||||
/* ============================================================================== */
|
||||
|
||||
public static PacketPlayOutPositionHandle createNew(int teleportWaitTimer, double x, double y, double z, float yaw, float pitch, RelativeFlags relativeFlags) {
|
||||
return T.createNew.invokeVA(teleportWaitTimer, x, y, z, yaw, pitch, relativeFlags);
|
||||
}
|
||||
|
||||
public abstract double getX();
|
||||
public abstract double getY();
|
||||
public abstract double getZ();
|
||||
public abstract float getYaw();
|
||||
public abstract float getPitch();
|
||||
public abstract RelativeFlags getRelativeFlags();
|
||||
public abstract int getTeleportWaitTimer();
|
||||
public static PacketPlayOutPositionHandle createRelative(double dx, double dy, double dz, float dyaw, float dpitch) {
|
||||
return T.createRelative.invoke(dx, dy, dz, dyaw, dpitch);
|
||||
}
|
||||
|
||||
public static PacketPlayOutPositionHandle createAbsolute(double x, double y, double z, float yaw, float pitch) {
|
||||
return T.createAbsolute.invoke(x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
public int getTeleportWaitTimer() {
|
||||
if (T.teleportWaitTimer.isAvailable()) {
|
||||
return T.teleportWaitTimer.getInteger(getRaw());
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setTeleportWaitTimer(int ticks) {
|
||||
if (T.teleportWaitTimer.isAvailable()) {
|
||||
T.teleportWaitTimer.setInteger(getRaw(), ticks);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRotationRelative(boolean relative) {
|
||||
Set<RelativeMovementHandle> flags = getTeleportFlags();
|
||||
if (relative) {
|
||||
flags.add(RelativeMovementHandle.Y_ROT);
|
||||
flags.add(RelativeMovementHandle.X_ROT);
|
||||
} else {
|
||||
flags.remove(RelativeMovementHandle.Y_ROT);
|
||||
flags.remove(RelativeMovementHandle.X_ROT);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPositionRelative(boolean relative) {
|
||||
Set<RelativeMovementHandle> flags = getTeleportFlags();
|
||||
if (relative) {
|
||||
flags.add(RelativeMovementHandle.X);
|
||||
flags.add(RelativeMovementHandle.Y);
|
||||
flags.add(RelativeMovementHandle.Z);
|
||||
} else {
|
||||
flags.remove(RelativeMovementHandle.X);
|
||||
flags.remove(RelativeMovementHandle.Y);
|
||||
flags.remove(RelativeMovementHandle.Z);
|
||||
}
|
||||
return createNew(dx, dy, dz, dyaw, dpitch, RelativeFlags.RELATIVE_POSITION_ROTATION);
|
||||
}
|
||||
|
||||
public static PacketPlayOutPositionHandle createAbsolute(org.bukkit.Location location) {
|
||||
return createAbsolute(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
}
|
||||
public abstract double getX();
|
||||
public abstract void setX(double value);
|
||||
public abstract double getY();
|
||||
public abstract void setY(double value);
|
||||
public abstract double getZ();
|
||||
public abstract void setZ(double value);
|
||||
public abstract float getYaw();
|
||||
public abstract void setYaw(float value);
|
||||
public abstract float getPitch();
|
||||
public abstract void setPitch(float value);
|
||||
public abstract Set<RelativeMovementHandle> getTeleportFlags();
|
||||
public abstract void setTeleportFlags(Set<RelativeMovementHandle> value);
|
||||
|
||||
public static PacketPlayOutPositionHandle createAbsolute(double x, double y, double z, float yaw, float pitch) {
|
||||
return createNew(x, y, z, yaw, pitch, RelativeFlags.ABSOLUTE_POSITION);
|
||||
}
|
||||
|
||||
public static PacketPlayOutPositionHandle createNew(double x, double y, double z, float yaw, float pitch, RelativeFlags relativeFlags) {
|
||||
return createNew(0, x, y, z, yaw, pitch, relativeFlags);
|
||||
}
|
||||
/**
|
||||
* Stores class members for <b>net.minecraft.network.protocol.game.PacketPlayOutPosition</b>.
|
||||
* Methods, fields, and constructors can be used without using Handle Objects.
|
||||
*/
|
||||
public static final class PacketPlayOutPositionClass extends Template.Class<PacketPlayOutPositionHandle> {
|
||||
public final Template.Field.Double x = new Template.Field.Double();
|
||||
public final Template.Field.Double y = new Template.Field.Double();
|
||||
public final Template.Field.Double z = new Template.Field.Double();
|
||||
public final Template.Field.Float yaw = new Template.Field.Float();
|
||||
public final Template.Field.Float pitch = new Template.Field.Float();
|
||||
public final Template.Field.Converted<Set<RelativeMovementHandle>> teleportFlags = new Template.Field.Converted<Set<RelativeMovementHandle>>();
|
||||
@Template.Optional
|
||||
public final Template.Field.Integer teleportWaitTimer = new Template.Field.Integer();
|
||||
public final Template.StaticMethod.Converted<PacketPlayOutPositionHandle> createNew = new Template.StaticMethod.Converted<PacketPlayOutPositionHandle>();
|
||||
|
||||
public final Template.StaticMethod.Converted<PacketPlayOutPositionHandle> createRelative = new Template.StaticMethod.Converted<PacketPlayOutPositionHandle>();
|
||||
public final Template.StaticMethod.Converted<PacketPlayOutPositionHandle> createAbsolute = new Template.StaticMethod.Converted<PacketPlayOutPositionHandle>();
|
||||
public final Template.Method<Double> getX = new Template.Method<Double>();
|
||||
public final Template.Method<Double> getY = new Template.Method<Double>();
|
||||
public final Template.Method<Double> getZ = new Template.Method<Double>();
|
||||
public final Template.Method<Float> getYaw = new Template.Method<Float>();
|
||||
public final Template.Method<Float> getPitch = new Template.Method<Float>();
|
||||
public final Template.Method.Converted<RelativeFlags> getRelativeFlags = new Template.Method.Converted<RelativeFlags>();
|
||||
public final Template.Method<Integer> getTeleportWaitTimer = new Template.Method<Integer>();
|
||||
|
||||
}
|
||||
|
||||
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
package com.bergerkiller.generated.net.minecraft.world.entity;
|
||||
|
||||
import com.bergerkiller.mountiplex.reflection.declarations.Template;
|
||||
|
||||
/**
|
||||
* Instance wrapper handle for type <b>net.minecraft.world.entity.RelativeMovement</b>.
|
||||
* To access members without creating a handle type, use the static {@link #T} member.
|
||||
* New handles can be created from raw instances using {@link #createHandle(Object)}.
|
||||
*/
|
||||
@Template.InstanceType("net.minecraft.world.entity.RelativeMovement")
|
||||
public abstract class RelativeMovementHandle extends Template.Handle {
|
||||
/** @see RelativeMovementClass */
|
||||
public static final RelativeMovementClass T = Template.Class.create(RelativeMovementClass.class, com.bergerkiller.bukkit.common.Common.TEMPLATE_RESOLVER);
|
||||
public static final RelativeMovementHandle X = T.X.getSafe();
|
||||
public static final RelativeMovementHandle Y = T.Y.getSafe();
|
||||
public static final RelativeMovementHandle Z = T.Z.getSafe();
|
||||
public static final RelativeMovementHandle Y_ROT = T.Y_ROT.getSafe();
|
||||
public static final RelativeMovementHandle X_ROT = T.X_ROT.getSafe();
|
||||
/* ============================================================================== */
|
||||
|
||||
public static RelativeMovementHandle createHandle(Object handleInstance) {
|
||||
return T.createHandle(handleInstance);
|
||||
}
|
||||
|
||||
/* ============================================================================== */
|
||||
|
||||
public static java.util.Set<?> allAbsolute() {
|
||||
return java.util.EnumSet.noneOf((Class) T.getType());
|
||||
}
|
||||
|
||||
public static java.util.Set<?> allRelative() {
|
||||
return java.util.EnumSet.allOf((Class) T.getType());
|
||||
}
|
||||
/**
|
||||
* Stores class members for <b>net.minecraft.world.entity.RelativeMovement</b>.
|
||||
* Methods, fields, and constructors can be used without using Handle Objects.
|
||||
*/
|
||||
public static final class RelativeMovementClass extends Template.Class<RelativeMovementHandle> {
|
||||
public final Template.EnumConstant.Converted<RelativeMovementHandle> X = new Template.EnumConstant.Converted<RelativeMovementHandle>();
|
||||
public final Template.EnumConstant.Converted<RelativeMovementHandle> Y = new Template.EnumConstant.Converted<RelativeMovementHandle>();
|
||||
public final Template.EnumConstant.Converted<RelativeMovementHandle> Z = new Template.EnumConstant.Converted<RelativeMovementHandle>();
|
||||
public final Template.EnumConstant.Converted<RelativeMovementHandle> Y_ROT = new Template.EnumConstant.Converted<RelativeMovementHandle>();
|
||||
public final Template.EnumConstant.Converted<RelativeMovementHandle> X_ROT = new Template.EnumConstant.Converted<RelativeMovementHandle>();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.bergerkiller.bukkit.common.entity.CommonEntityType;
|
||||
import com.bergerkiller.bukkit.common.internal.logic.UnsetDataWatcherItemInit;
|
||||
import com.bergerkiller.bukkit.common.wrappers.Brightness;
|
||||
import com.bergerkiller.bukkit.common.wrappers.ItemDisplayMode;
|
||||
import com.bergerkiller.bukkit.common.wrappers.RelativeFlags;
|
||||
import com.bergerkiller.mountiplex.reflection.declarations.Template;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@@ -799,6 +800,11 @@ public class CommonBootstrap {
|
||||
remappings.put("org.bukkit.craftbukkit.inventory.SerializableMeta", "org.bukkit.craftbukkit.inventory.CraftMetaItem$SerializableMeta");
|
||||
}
|
||||
|
||||
// 1.21.2 mappings
|
||||
if (evaluateMCVersion(">=", "1.21.2")) {
|
||||
remappings.put("net.minecraft.world.entity.RelativeMovement", "net.minecraft.world.entity.Relative");
|
||||
}
|
||||
|
||||
// There have been various locations where starlight was installed
|
||||
// This was also part of tuinity at some point, but was then ported into paper
|
||||
{
|
||||
@@ -883,6 +889,7 @@ public class CommonBootstrap {
|
||||
Conversion.registerConverters(Brightness.class);
|
||||
Conversion.registerConverters(CommonEntityType.class);
|
||||
Conversion.registerConverters(MapConversion.class);
|
||||
Conversion.registerConverters(RelativeFlags.class);
|
||||
|
||||
// EquipmentSlot <> EnumItemSlot, only for later version of 1.8 builds
|
||||
{
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
package com.bergerkiller.bukkit.common.wrappers;
|
||||
|
||||
import com.bergerkiller.bukkit.common.internal.CommonBootstrap;
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.mountiplex.conversion.annotations.ConverterMethod;
|
||||
import com.bergerkiller.mountiplex.reflection.util.FastMethod;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Controls what coordinates in a position update are relative or absolute.
|
||||
* A relative flag will add the coordinate to the existing coordinate on the
|
||||
* client side, an absolute flag sets the coordinates to this new value.<br>
|
||||
* <br>
|
||||
* This is used to shift a player's position without having to know the current
|
||||
* position of the player.
|
||||
*/
|
||||
public final class RelativeFlags {
|
||||
private static final int FLAG_X = 1;
|
||||
private static final int FLAG_Y = (1 << 1);
|
||||
private static final int FLAG_Z = (1 << 2);
|
||||
private static final int FLAG_YAW = (1 << 3);
|
||||
private static final int FLAG_PITCH = (1 << 4);
|
||||
private static final int FLAG_DELTA_X = (1 << 5);
|
||||
private static final int FLAG_DELTA_Y = (1 << 6);
|
||||
private static final int FLAG_DELTA_Z = (1 << 7);
|
||||
private static final int FLAG_DELTA_ROTATION = (1 << 8);
|
||||
private static final RelativeFlags[] cache = new RelativeFlags[1 << 9];
|
||||
|
||||
// Used for converting between these RelativeFlags and internally-used Set of movement relative flags
|
||||
public static final FastMethod<Set<?>> unpackMethod = new FastMethod<>(m -> {
|
||||
Class<?> relativeMovementType = CommonUtil.getClass("net.minecraft.world.entity.RelativeMovement");
|
||||
if (CommonBootstrap.evaluateMCVersion(">=", "1.18")) {
|
||||
m.init(relativeMovementType.getDeclaredMethod("unpack", int.class));
|
||||
} else {
|
||||
m.init(relativeMovementType.getDeclaredMethod("a", int.class));
|
||||
}
|
||||
});
|
||||
public static final FastMethod<Integer> packMethod = new FastMethod<>(m -> {
|
||||
Class<?> relativeMovementType = CommonUtil.getClass("net.minecraft.world.entity.RelativeMovement");
|
||||
if (CommonBootstrap.evaluateMCVersion(">=", "1.18")) {
|
||||
m.init(relativeMovementType.getDeclaredMethod("pack", Set.class));
|
||||
} else {
|
||||
m.init(relativeMovementType.getDeclaredMethod("a", Set.class));
|
||||
}
|
||||
});
|
||||
|
||||
// Frequently used constants
|
||||
public static final RelativeFlags ABSOLUTE_POSITION = fromFlags(0);
|
||||
public static final RelativeFlags RELATIVE_ROTATION = fromFlags(FLAG_YAW | FLAG_PITCH);
|
||||
public static final RelativeFlags RELATIVE_POSITION_ROTATION = fromFlags(FLAG_X | FLAG_Y | FLAG_Z | FLAG_YAW | FLAG_PITCH);
|
||||
|
||||
private final int flags;
|
||||
private final Set<?> relativeFlags;
|
||||
|
||||
private RelativeFlags(int flags) {
|
||||
this.flags = flags;
|
||||
this.relativeFlags = Collections.unmodifiableSet(unpackMethod.invoke(flags));
|
||||
}
|
||||
|
||||
public boolean isRelativeX() {
|
||||
return (flags & FLAG_X) != 0;
|
||||
}
|
||||
|
||||
public boolean isRelativeY() {
|
||||
return (flags & FLAG_Y) != 0;
|
||||
}
|
||||
|
||||
public boolean isRelativeZ() {
|
||||
return (flags & FLAG_Z) != 0;
|
||||
}
|
||||
|
||||
public boolean isRelativeYaw() {
|
||||
return (flags & FLAG_YAW) != 0;
|
||||
}
|
||||
|
||||
public boolean isRelativePitch() {
|
||||
return (flags & FLAG_PITCH) != 0;
|
||||
}
|
||||
|
||||
public boolean isRelativeDeltaX() {
|
||||
return (flags & FLAG_DELTA_X) != 0;
|
||||
}
|
||||
|
||||
public boolean isRelativeDeltaY() {
|
||||
return (flags & FLAG_DELTA_Y) != 0;
|
||||
}
|
||||
|
||||
public boolean isRelativeDeltaZ() {
|
||||
return (flags & FLAG_DELTA_Z) != 0;
|
||||
}
|
||||
|
||||
public boolean isRelativeDeltaRotation() {
|
||||
return (flags & FLAG_DELTA_ROTATION) != 0;
|
||||
}
|
||||
|
||||
public RelativeFlags withRelativeX() {
|
||||
return fromFlags(flags | FLAG_X);
|
||||
}
|
||||
|
||||
public RelativeFlags withAbsoluteX() {
|
||||
return fromFlags(flags & ~FLAG_X);
|
||||
}
|
||||
|
||||
public RelativeFlags withRelativeY() {
|
||||
return fromFlags(flags | FLAG_Y);
|
||||
}
|
||||
|
||||
public RelativeFlags withAbsoluteY() {
|
||||
return fromFlags(flags & ~FLAG_Y);
|
||||
}
|
||||
|
||||
public RelativeFlags withRelativeZ() {
|
||||
return fromFlags(flags | FLAG_Z);
|
||||
}
|
||||
|
||||
public RelativeFlags withAbsoluteZ() {
|
||||
return fromFlags(flags & ~FLAG_Z);
|
||||
}
|
||||
|
||||
public RelativeFlags withRelativeDeltaX() {
|
||||
return fromFlags(flags | FLAG_DELTA_X);
|
||||
}
|
||||
|
||||
public RelativeFlags withAbsoluteDeltaX() {
|
||||
return fromFlags(flags & ~FLAG_DELTA_X);
|
||||
}
|
||||
|
||||
public RelativeFlags withRelativeDeltaY() {
|
||||
return fromFlags(flags | FLAG_DELTA_Y);
|
||||
}
|
||||
|
||||
public RelativeFlags withAbsoluteDeltaY() {
|
||||
return fromFlags(flags & ~FLAG_DELTA_Y);
|
||||
}
|
||||
|
||||
public RelativeFlags withRelativeDeltaZ() {
|
||||
return fromFlags(flags | FLAG_DELTA_Z);
|
||||
}
|
||||
|
||||
public RelativeFlags withAbsoluteDeltaZ() {
|
||||
return fromFlags(flags & ~FLAG_DELTA_Z);
|
||||
}
|
||||
|
||||
public RelativeFlags withRelativeDeltaRotation() {
|
||||
return fromFlags(flags | FLAG_DELTA_ROTATION);
|
||||
}
|
||||
|
||||
public RelativeFlags withAbsoluteDeltaRotation() {
|
||||
return fromFlags(flags & ~FLAG_DELTA_ROTATION);
|
||||
}
|
||||
|
||||
public RelativeFlags withRelativePosition() {
|
||||
return fromFlags(flags | (FLAG_X | FLAG_Y | FLAG_Z));
|
||||
}
|
||||
|
||||
public RelativeFlags withAbsolutePosition() {
|
||||
return fromFlags(flags & ~(FLAG_X | FLAG_Y | FLAG_Z));
|
||||
}
|
||||
|
||||
public RelativeFlags withRelativeRotation() {
|
||||
return fromFlags(flags | (FLAG_YAW | FLAG_PITCH));
|
||||
}
|
||||
|
||||
public RelativeFlags withAbsoluteRotation() {
|
||||
return fromFlags(flags & ~(FLAG_YAW | FLAG_PITCH));
|
||||
}
|
||||
|
||||
public RelativeFlags withRelativeDelta() {
|
||||
return fromFlags(flags | (FLAG_DELTA_X | FLAG_DELTA_Y | FLAG_DELTA_Z | FLAG_DELTA_ROTATION));
|
||||
}
|
||||
|
||||
public RelativeFlags withAbsoluteDelta() {
|
||||
return fromFlags(flags & ~(FLAG_DELTA_X | FLAG_DELTA_Y | FLAG_DELTA_Z | FLAG_DELTA_ROTATION));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return flags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.append("RelativeFlags{flags=").append(flags).append(", relative=[");
|
||||
if (isRelativeX())
|
||||
str.append(" X");
|
||||
if (isRelativeY())
|
||||
str.append(" Y");
|
||||
if (isRelativeZ())
|
||||
str.append(" Z");
|
||||
if (isRelativeYaw())
|
||||
str.append(" Yaw");
|
||||
if (isRelativePitch())
|
||||
str.append(" Pitch");
|
||||
if (isRelativeDeltaX())
|
||||
str.append(" Delta-X");
|
||||
if (isRelativeDeltaY())
|
||||
str.append(" Delta-Y");
|
||||
if (isRelativeDeltaZ())
|
||||
str.append(" Delta-Z");
|
||||
if (isRelativeDeltaRotation())
|
||||
str.append(" Delta-Rotation");
|
||||
str.append(" ]}");
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the Set of the flags used internally by the server into RelativeFlags.
|
||||
*
|
||||
* @param rawRelativeFlags Raw relative flags for use internally
|
||||
* @return RelativeFlags value
|
||||
*/
|
||||
@ConverterMethod(input="java.util.Set<net.minecraft.world.entity.RelativeMovement>")
|
||||
public static RelativeFlags fromRawRelativeFlags(Set<?> rawRelativeFlags) {
|
||||
return fromFlags(packMethod.invoke(rawRelativeFlags));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts relative flags to the flags as used internally by the server. This returned set
|
||||
* is read-only.
|
||||
*
|
||||
* @param flags RelativeFlags
|
||||
* @return Set of raw flags
|
||||
*/
|
||||
@ConverterMethod(output="java.util.Set<net.minecraft.world.entity.RelativeMovement>")
|
||||
public static Set<?> toRawRelativeFlags(RelativeFlags flags) {
|
||||
return flags.relativeFlags;
|
||||
}
|
||||
|
||||
private static RelativeFlags fromFlags(int flags) {
|
||||
RelativeFlags cachedFlags = cache[flags];
|
||||
if (cachedFlags == null) {
|
||||
synchronized (cache) {
|
||||
cachedFlags = cache[flags];
|
||||
if (cachedFlags == null) {
|
||||
cache[flags] = cachedFlags = new RelativeFlags(flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cachedFlags;
|
||||
}
|
||||
}
|
||||
+56
-10
@@ -1593,12 +1593,61 @@ public class NMSPacketClasses {
|
||||
|
||||
public static class NMSPacketPlayOutPosition extends NMSPacket {
|
||||
|
||||
public final FieldAccessor<Double> x = PacketPlayOutPositionHandle.T.x.toFieldAccessor();
|
||||
public final FieldAccessor<Double> y = PacketPlayOutPositionHandle.T.y.toFieldAccessor();
|
||||
public final FieldAccessor<Double> z = PacketPlayOutPositionHandle.T.z.toFieldAccessor();
|
||||
public final FieldAccessor<Float> yaw = PacketPlayOutPositionHandle.T.yaw.toFieldAccessor();
|
||||
public final FieldAccessor<Float> pitch = PacketPlayOutPositionHandle.T.pitch.toFieldAccessor();
|
||||
public final FieldAccessor<Set<?>> teleportFlags = CommonUtil.unsafeCast(PacketPlayOutPositionHandle.T.teleportFlags.raw.toFieldAccessor());
|
||||
public final FieldAccessor<Double> x = new FieldAccessor<Double>() {
|
||||
@Override
|
||||
public Double get(Object instance) {
|
||||
return PacketPlayOutPositionHandle.T.getX.invoke(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean set(Object instance, Double value) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
public final FieldAccessor<Double> y = new FieldAccessor<Double>() {
|
||||
@Override
|
||||
public Double get(Object instance) {
|
||||
return PacketPlayOutPositionHandle.T.getY.invoke(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean set(Object instance, Double value) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
public final FieldAccessor<Double> z = new FieldAccessor<Double>() {
|
||||
@Override
|
||||
public Double get(Object instance) {
|
||||
return PacketPlayOutPositionHandle.T.getZ.invoke(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean set(Object instance, Double value) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
public final FieldAccessor<Float> yaw = new FieldAccessor<Float>() {
|
||||
@Override
|
||||
public Float get(Object instance) {
|
||||
return PacketPlayOutPositionHandle.T.getYaw.invoke(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean set(Object instance, Float value) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
public final FieldAccessor<Float> pitch = new FieldAccessor<Float>() {
|
||||
@Override
|
||||
public Float get(Object instance) {
|
||||
return PacketPlayOutPositionHandle.T.getPitch.invoke(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean set(Object instance, Float value) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
public final FieldAccessor<Integer> teleportWaitTimer = new SafeDirectField<Integer>() {
|
||||
@Override
|
||||
public Integer get(Object instance) {
|
||||
@@ -1607,12 +1656,9 @@ public class NMSPacketClasses {
|
||||
|
||||
@Override
|
||||
public boolean set(Object instance, Integer value) {
|
||||
PacketPlayOutPositionHandle.createHandle(instance).setTeleportWaitTimer(value.intValue());
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@Deprecated
|
||||
public final FieldAccessor<Integer> unknown1 = teleportWaitTimer;
|
||||
}
|
||||
|
||||
public static class NMSPacketPlayOutRemoveEntityEffect extends NMSPacket {
|
||||
|
||||
@@ -58,7 +58,6 @@
|
||||
#include /net/minecraft/entity/player_inventory.txt
|
||||
#include /net/minecraft/entity/shulker.txt
|
||||
#include /net/minecraft/entity/entity_types.txt
|
||||
#include /net/minecraft/entity/relative_movement.txt
|
||||
#include /net/minecraft/entity/vehicles.txt
|
||||
#include /net/minecraft/entity/entity.txt
|
||||
#include /net/minecraft/entity/ageable.txt
|
||||
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package net.minecraft.world.entity;
|
||||
|
||||
import com.bergerkiller.generated.net.minecraft.world.entity.RelativeMovementHandle;
|
||||
|
||||
class RelativeMovement {
|
||||
enum (RelativeMovementHandle) RelativeMovement X;
|
||||
enum (RelativeMovementHandle) RelativeMovement Y;
|
||||
enum (RelativeMovementHandle) RelativeMovement Z;
|
||||
enum (RelativeMovementHandle) RelativeMovement Y_ROT;
|
||||
enum (RelativeMovementHandle) RelativeMovement X_ROT;
|
||||
|
||||
<code>
|
||||
public static java.util.Set<?> allAbsolute() {
|
||||
return java.util.EnumSet.noneOf((Class) T.getType());
|
||||
}
|
||||
|
||||
public static java.util.Set<?> allRelative() {
|
||||
return java.util.EnumSet.allOf((Class) T.getType());
|
||||
}
|
||||
</code>
|
||||
}
|
||||
+73
-83
@@ -23,6 +23,7 @@ import net.minecraft.world.EnumHand;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectList;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.PositionMoveRotation;
|
||||
import net.minecraft.world.entity.RelativeMovement;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -48,6 +49,7 @@ import com.bergerkiller.bukkit.common.wrappers.ChatText;
|
||||
import com.bergerkiller.bukkit.common.wrappers.UseAction;
|
||||
import com.bergerkiller.bukkit.common.wrappers.Holder;
|
||||
import com.bergerkiller.bukkit.common.wrappers.HumanHand;
|
||||
import com.bergerkiller.bukkit.common.wrappers.RelativeFlags;
|
||||
import com.bergerkiller.bukkit.common.resources.BlockStateType;
|
||||
import com.bergerkiller.bukkit.common.resources.DimensionType;
|
||||
import com.bergerkiller.bukkit.common.wrappers.WindowType;
|
||||
@@ -86,7 +88,6 @@ import com.bergerkiller.generated.net.minecraft.network.protocol.game.PacketPlay
|
||||
import com.bergerkiller.generated.net.minecraft.resources.MinecraftKeyHandle;
|
||||
import com.bergerkiller.generated.net.minecraft.sounds.SoundCategoryHandle;
|
||||
import com.bergerkiller.generated.net.minecraft.world.effect.MobEffectListHandle;
|
||||
import com.bergerkiller.generated.net.minecraft.world.entity.RelativeMovementHandle;
|
||||
import com.bergerkiller.generated.net.minecraft.world.entity.ai.attributes.AttributeModifiableHandle;
|
||||
|
||||
class PacketPlayOutEntityDestroy extends Packet {
|
||||
@@ -1941,99 +1942,88 @@ class PacketPlayOutStopSound extends Packet {
|
||||
}
|
||||
|
||||
class PacketPlayOutPosition extends Packet {
|
||||
#if version >= 1.17
|
||||
private double x:x;
|
||||
private double y:y;
|
||||
private double z:z;
|
||||
private float yaw:yRot;
|
||||
private float pitch:xRot;
|
||||
private (Set<RelativeMovementHandle>) Set<RelativeMovement> teleportFlags:relativeArguments;
|
||||
|
||||
// >= MC 1.9
|
||||
private optional int teleportWaitTimer:id;
|
||||
#else
|
||||
private double x:a;
|
||||
private double y:b;
|
||||
private double z:c;
|
||||
private float yaw:d;
|
||||
private float pitch:e;
|
||||
private (Set<RelativeMovementHandle>) Set<RelativeMovement> teleportFlags:f;
|
||||
|
||||
// >= MC 1.9
|
||||
private optional int teleportWaitTimer:g;
|
||||
#endif
|
||||
|
||||
<code>
|
||||
public int getTeleportWaitTimer() {
|
||||
if (T.teleportWaitTimer.isAvailable()) {
|
||||
return T.teleportWaitTimer.getInteger(getRaw());
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setTeleportWaitTimer(int ticks) {
|
||||
if (T.teleportWaitTimer.isAvailable()) {
|
||||
T.teleportWaitTimer.setInteger(getRaw(), ticks);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRotationRelative(boolean relative) {
|
||||
Set<RelativeMovementHandle> flags = getTeleportFlags();
|
||||
if (relative) {
|
||||
flags.add(RelativeMovementHandle.Y_ROT);
|
||||
flags.add(RelativeMovementHandle.X_ROT);
|
||||
} else {
|
||||
flags.remove(RelativeMovementHandle.Y_ROT);
|
||||
flags.remove(RelativeMovementHandle.X_ROT);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPositionRelative(boolean relative) {
|
||||
Set<RelativeMovementHandle> flags = getTeleportFlags();
|
||||
if (relative) {
|
||||
flags.add(RelativeMovementHandle.X);
|
||||
flags.add(RelativeMovementHandle.Y);
|
||||
flags.add(RelativeMovementHandle.Z);
|
||||
} else {
|
||||
flags.remove(RelativeMovementHandle.X);
|
||||
flags.remove(RelativeMovementHandle.Y);
|
||||
flags.remove(RelativeMovementHandle.Z);
|
||||
}
|
||||
}
|
||||
</code>
|
||||
|
||||
public static (PacketPlayOutPositionHandle) PacketPlayOutPosition createRelative(double dx, double dy, double dz, float dyaw, float dpitch) {
|
||||
java.util.Set flags = com.bergerkiller.generated.net.minecraft.world.entity.RelativeMovementHandle.allRelative();
|
||||
#if version >= 1.19.4
|
||||
return new PacketPlayOutPosition(dx, dy, dz, dyaw, dpitch, flags, 0);
|
||||
#if version >= 1.21.2
|
||||
public double getX() { return instance.change().position().x; }
|
||||
public double getY() { return instance.change().position().y; }
|
||||
public double getZ() { return instance.change().position().z; }
|
||||
public float getYaw() { return instance.change().yRot(); }
|
||||
public float getPitch() { return instance.change().xRot(); }
|
||||
public (RelativeFlags) Set<RelativeMovement> getRelativeFlags:relatives();
|
||||
public int getTeleportWaitTimer:id();
|
||||
#elseif version >= 1.18
|
||||
public double getX();
|
||||
public double getY();
|
||||
public double getZ();
|
||||
public float getYaw:getYRot();
|
||||
public float getPitch:getXRot();
|
||||
public (RelativeFlags) Set<RelativeMovement> getRelativeFlags:getRelativeArguments();
|
||||
public int getTeleportWaitTimer:getId();
|
||||
#elseif version >= 1.17
|
||||
return new PacketPlayOutPosition(dx, dy, dz, dyaw, dpitch, flags, 0, false);
|
||||
#elseif version >= 1.9
|
||||
return new PacketPlayOutPosition(dx, dy, dz, dyaw, dpitch, flags, 0);
|
||||
public double getX:b();
|
||||
public double getY:c();
|
||||
public double getZ:d();
|
||||
public float getYaw:e();
|
||||
public float getPitch:f();
|
||||
public (RelativeFlags) Set<RelativeMovement> getRelativeFlags:i();
|
||||
public int getTeleportWaitTimer:g();
|
||||
#else
|
||||
return new PacketPlayOutPosition(dx, dy, dz, dyaw, dpitch, flags);
|
||||
#require PacketPlayOutPosition private double x:a;
|
||||
#require PacketPlayOutPosition private double y:b;
|
||||
#require PacketPlayOutPosition private double z:c;
|
||||
#require PacketPlayOutPosition private float yaw:d;
|
||||
#require PacketPlayOutPosition private float pitch:e;
|
||||
#require PacketPlayOutPosition private Set<RelativeMovement> relativeArguments:f;
|
||||
|
||||
public double getX() { return instance#x; }
|
||||
public double getY() { return instance#y; }
|
||||
public double getZ() { return instance#z; }
|
||||
public float getYaw() { return instance#yaw; }
|
||||
public float getPitch() { return instance#pitch; }
|
||||
public (RelativeFlags) Set<RelativeMovement> getRelativeFlags() { return instance#relativeArguments; }
|
||||
|
||||
public int getTeleportWaitTimer() {
|
||||
#if version >= 1.9
|
||||
#require PacketPlayOutPosition private int teleportWaitTimer:g;
|
||||
return instance#teleportWaitTimer; }
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
public static (PacketPlayOutPositionHandle) PacketPlayOutPosition createNew(int teleportWaitTimer, double x, double y, double z, float yaw, float pitch, (RelativeFlags) Set<RelativeMovement> relativeFlags) {
|
||||
#if version >= 1.21.2
|
||||
return PacketPlayOutPosition.of(teleportWaitTimer, new PositionMoveRotation(
|
||||
new Vec3D(x, y, z), new Vec3D(0.0, 0.0, 0.0), yaw, pitch
|
||||
), relativeFlags);
|
||||
#elseif version >= 1.19.4
|
||||
return new PacketPlayOutPosition(x, y, z, yaw, pitch, relativeFlags, teleportWaitTimer);
|
||||
#elseif version >= 1.17
|
||||
return new PacketPlayOutPosition(x, y, z, yaw, pitch, relativeFlags, teleportWaitTimer, false);
|
||||
#elseif version >= 1.9
|
||||
return new PacketPlayOutPosition(x, y, z, yaw, pitch, relativeFlags, teleportWaitTimer);
|
||||
#else
|
||||
return new PacketPlayOutPosition(x, y, z, yaw, pitch, relativeFlags);
|
||||
#endif
|
||||
}
|
||||
|
||||
<code>
|
||||
public static PacketPlayOutPositionHandle createRelative(double dx, double dy, double dz, float dyaw, float dpitch) {
|
||||
return createNew(dx, dy, dz, dyaw, dpitch, RelativeFlags.RELATIVE_POSITION_ROTATION);
|
||||
}
|
||||
|
||||
public static PacketPlayOutPositionHandle createAbsolute(org.bukkit.Location location) {
|
||||
return createAbsolute(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
}
|
||||
</code>
|
||||
|
||||
public static (PacketPlayOutPositionHandle) PacketPlayOutPosition createAbsolute(double x, double y, double z, float yaw, float pitch) {
|
||||
java.util.Set flags = com.bergerkiller.generated.net.minecraft.world.entity.RelativeMovementHandle.allAbsolute();
|
||||
#if version >= 1.19.4
|
||||
return new PacketPlayOutPosition(x, y, z, yaw, pitch, flags, 0);
|
||||
#elseif version >= 1.17
|
||||
return new PacketPlayOutPosition(x, y, z, yaw, pitch, flags, 0, false);
|
||||
#elseif version >= 1.9
|
||||
return new PacketPlayOutPosition(x, y, z, yaw, pitch, flags, 0);
|
||||
#else
|
||||
return new PacketPlayOutPosition(x, y, z, yaw, pitch, flags);
|
||||
#endif
|
||||
public static PacketPlayOutPositionHandle createAbsolute(double x, double y, double z, float yaw, float pitch) {
|
||||
return createNew(x, y, z, yaw, pitch, RelativeFlags.ABSOLUTE_POSITION);
|
||||
}
|
||||
|
||||
public static PacketPlayOutPositionHandle createNew(double x, double y, double z, float yaw, float pitch, RelativeFlags relativeFlags) {
|
||||
return createNew(0, x, y, z, yaw, pitch, relativeFlags);
|
||||
}
|
||||
</code>
|
||||
}
|
||||
|
||||
// Available >= MC 1.9
|
||||
|
||||
Reference in new issue
Block a user