use of org.dragonet.net.packet.minecraft.MovePlayerPacket in project Dragonet-Legacy by DragonetMC.
the class DragonetSession method sendPosition.
/**
* Send the server side position to the client, used to correct the position
*/
public void sendPosition() {
if (this.getPlayer() == null) {
return;
}
/*
MoveEntitiesPacket.MoveEntityData d = new MoveEntitiesPacket.MoveEntityData();
d.eid = this.getPlayer().getEntityId();
d.x = (float) this.getPlayer().getLocation().getX();
d.y = (float) this.getPlayer().getLocation().getY();
d.z = (float) this.getPlayer().getLocation().getZ();
d.yaw = this.getPlayer().getLocation().getYaw();
d.pitch = this.getPlayer().getLocation().getPitch();
MoveEntitiesPacket pkMovePlayer = new MoveEntitiesPacket(new MoveEntitiesPacket.MoveEntityData[]{d});
*/
MovePlayerPacket pkMovePlayer = new MovePlayerPacket();
pkMovePlayer.eid = this.getPlayer().getEntityId();
pkMovePlayer.x = (float) this.getPlayer().getLocation().getX();
pkMovePlayer.y = (float) this.getPlayer().getLocation().getY();
pkMovePlayer.z = (float) this.getPlayer().getLocation().getZ();
pkMovePlayer.yaw = this.getPlayer().getLocation().getYaw();
pkMovePlayer.bodyYaw = this.getPlayer().getLocation().getYaw();
pkMovePlayer.pitch = this.getPlayer().getLocation().getPitch();
pkMovePlayer.teleport = true;
this.send(pkMovePlayer);
}
use of org.dragonet.net.packet.minecraft.MovePlayerPacket in project Dragonet-Legacy by DragonetMC.
the class RelativeEntityPositionMessageTranslator method handleSpecific.
@Override
public PEPacket[] handleSpecific(RelativeEntityPositionMessage packet) {
Entity entity = this.getSession().getPlayer().getWorld().getEntityManager().getEntity(packet.id);
if (entity == null) {
return null;
}
if (entity instanceof GlowPlayer) {
boolean isTeleport = (packet.deltaX ^ 2 + packet.deltaY ^ 2 + packet.deltaZ ^ 2) > 4;
MovePlayerPacket pkMovePlayer = new MovePlayerPacket(packet.id, (float) entity.getLocation().getX(), (float) entity.getLocation().getY(), (float) entity.getLocation().getZ(), entity.getLocation().getYaw(), entity.getLocation().getPitch(), entity.getLocation().getYaw(), isTeleport);
return new PEPacket[] { pkMovePlayer };
} else {
MoveEntitiesPacket.MoveEntityData data = new MoveEntitiesPacket.MoveEntityData();
data.eid = packet.id;
data.x = (float) entity.getLocation().getX();
data.y = (float) entity.getLocation().getY();
data.z = (float) entity.getLocation().getZ();
data.yaw = (float) entity.getLocation().getYaw();
data.pitch = (float) entity.getLocation().getPitch();
MoveEntitiesPacket pk = new MoveEntitiesPacket(new MoveEntitiesPacket.MoveEntityData[] { data });
return new PEPacket[] { pk };
}
}
use of org.dragonet.net.packet.minecraft.MovePlayerPacket in project Dragonet-Legacy by DragonetMC.
the class RelativeEntityPositionRotationMessageTranslator method handleSpecific.
@Override
public PEPacket[] handleSpecific(RelativeEntityPositionRotationMessage packet) {
Entity entity = this.getSession().getPlayer().getWorld().getEntityManager().getEntity(packet.id);
if (entity == null) {
return null;
}
if (entity instanceof GlowPlayer) {
boolean isTeleport = (packet.deltaX ^ 2 + packet.deltaY ^ 2 + packet.deltaZ ^ 2) > 4;
MovePlayerPacket pkMovePlayer = new MovePlayerPacket(packet.id, (float) entity.getLocation().getX(), (float) entity.getLocation().getY(), (float) entity.getLocation().getZ(), (float) entity.getLocation().getYaw(), (float) entity.getLocation().getPitch(), (float) entity.getLocation().getYaw(), isTeleport);
return new PEPacket[] { pkMovePlayer };
} else {
MoveEntitiesPacket.MoveEntityData data = new MoveEntitiesPacket.MoveEntityData();
data.eid = packet.id;
data.x = (float) entity.getLocation().getX();
data.y = (float) entity.getLocation().getY();
data.z = (float) entity.getLocation().getZ();
data.yaw = (float) entity.getLocation().getYaw();
data.pitch = (float) entity.getLocation().getPitch();
MoveEntitiesPacket pk = new MoveEntitiesPacket(new MoveEntitiesPacket.MoveEntityData[] { data });
return new PEPacket[] { pk };
}
}
use of org.dragonet.net.packet.minecraft.MovePlayerPacket in project Dragonet-Legacy by DragonetMC.
the class PlayerPositionMessageTranslator method handleSpecific.
@Override
public PEPacket[] handleSpecific(PlayerPositionMessage packet) {
MovePlayerPacket pkMovePlayer = new MovePlayerPacket();
pkMovePlayer.eid = this.getSession().getPlayer().getEntityId();
pkMovePlayer.x = (float) packet.x;
pkMovePlayer.y = (float) packet.y;
pkMovePlayer.z = (float) packet.z;
pkMovePlayer.yaw = this.getSession().getPlayer().getLocation().getYaw();
pkMovePlayer.pitch = this.getSession().getPlayer().getLocation().getPitch();
pkMovePlayer.teleport = true;
return new PEPacket[] { pkMovePlayer };
}
use of org.dragonet.net.packet.minecraft.MovePlayerPacket in project Dragonet-Legacy by DragonetMC.
the class PlayerPositionLookMessageTranslator method handleSpecific.
@Override
public PEPacket[] handleSpecific(PlayerPositionLookMessage packet) {
MovePlayerPacket pkMovePlayer = new MovePlayerPacket();
pkMovePlayer.eid = this.getSession().getPlayer().getEntityId();
pkMovePlayer.x = (float) packet.x;
pkMovePlayer.y = (float) packet.y;
pkMovePlayer.z = (float) packet.z;
pkMovePlayer.yaw = packet.yaw;
pkMovePlayer.pitch = packet.pitch;
pkMovePlayer.teleport = true;
return new PEPacket[] { pkMovePlayer };
}
Aggregations