161 lines
4 KiB
Java
161 lines
4 KiB
Java
/**
|
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
|
* Copyright (C) Kristian S. Strangeland
|
|
* <p>
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
* <p>
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
* <p>
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
package fr.leomelki.com.comphenix.packetwrapper;
|
|
|
|
import com.comphenix.protocol.PacketType;
|
|
import com.comphenix.protocol.events.PacketContainer;
|
|
import com.comphenix.protocol.reflect.StructureModifier;
|
|
import com.comphenix.protocol.utility.MinecraftReflection;
|
|
import com.comphenix.protocol.wrappers.EnumWrappers;
|
|
|
|
import java.util.Set;
|
|
|
|
public class WrapperPlayServerPosition extends AbstractPacket {
|
|
public static final PacketType TYPE = PacketType.Play.Server.POSITION;
|
|
private static final Class<?> FLAGS_CLASS = MinecraftReflection
|
|
.getMinecraftClass("EnumPlayerTeleportFlags",
|
|
"PacketPlayOutPosition$EnumPlayerTeleportFlags");
|
|
|
|
public WrapperPlayServerPosition() {
|
|
super(new PacketContainer(TYPE), TYPE);
|
|
handle.getModifier().writeDefaults();
|
|
}
|
|
|
|
public WrapperPlayServerPosition(PacketContainer packet) {
|
|
super(packet, TYPE);
|
|
}
|
|
|
|
/**
|
|
* Retrieve X.
|
|
* <p>
|
|
* Notes: absolute/Relative position
|
|
*
|
|
* @return The current X
|
|
*/
|
|
public double getX() {
|
|
return handle.getDoubles().read(0);
|
|
}
|
|
|
|
/**
|
|
* Set X.
|
|
*
|
|
* @param value - new value.
|
|
*/
|
|
public void setX(double value) {
|
|
handle.getDoubles().write(0, value);
|
|
}
|
|
|
|
/**
|
|
* Retrieve Y.
|
|
* <p>
|
|
* Notes: absolute/Relative position
|
|
*
|
|
* @return The current Y
|
|
*/
|
|
public double getY() {
|
|
return handle.getDoubles().read(1);
|
|
}
|
|
|
|
/**
|
|
* Set Y.
|
|
*
|
|
* @param value - new value.
|
|
*/
|
|
public void setY(double value) {
|
|
handle.getDoubles().write(1, value);
|
|
}
|
|
|
|
/**
|
|
* Retrieve Z.
|
|
* <p>
|
|
* Notes: absolute/Relative position
|
|
*
|
|
* @return The current Z
|
|
*/
|
|
public double getZ() {
|
|
return handle.getDoubles().read(2);
|
|
}
|
|
|
|
/**
|
|
* Set Z.
|
|
*
|
|
* @param value - new value.
|
|
*/
|
|
public void setZ(double value) {
|
|
handle.getDoubles().write(2, value);
|
|
}
|
|
|
|
/**
|
|
* Retrieve Yaw.
|
|
* <p>
|
|
* Notes: absolute/Relative rotation on the X Axis, in degrees
|
|
*
|
|
* @return The current Yaw
|
|
*/
|
|
public float getYaw() {
|
|
return handle.getFloat().read(0);
|
|
}
|
|
|
|
/**
|
|
* Set Yaw.
|
|
*
|
|
* @param value - new value.
|
|
*/
|
|
public void setYaw(float value) {
|
|
handle.getFloat().write(0, value);
|
|
}
|
|
|
|
/**
|
|
* Retrieve Pitch.
|
|
* <p>
|
|
* Notes: absolute/Relative rotation on the Y Axis, in degrees
|
|
*
|
|
* @return The current Pitch
|
|
*/
|
|
public float getPitch() {
|
|
return handle.getFloat().read(1);
|
|
}
|
|
|
|
/**
|
|
* Set Pitch.
|
|
*
|
|
* @param value - new value.
|
|
*/
|
|
public void setPitch(float value) {
|
|
handle.getFloat().write(1, value);
|
|
}
|
|
|
|
private StructureModifier<Set<PlayerTeleportFlag>> getFlagsModifier() {
|
|
return handle.getSets(
|
|
EnumWrappers.getGenericConverter(FLAGS_CLASS, PlayerTeleportFlag.class));
|
|
}
|
|
|
|
public Set<PlayerTeleportFlag> getFlags() {
|
|
return getFlagsModifier().read(0);
|
|
}
|
|
|
|
public void setFlags(Set<PlayerTeleportFlag> value) {
|
|
getFlagsModifier().write(0, value);
|
|
}
|
|
|
|
public enum PlayerTeleportFlag {
|
|
X, Y, Z, Y_ROT, X_ROT
|
|
}
|
|
}
|