use of org.dragonet.net.packet.minecraft.MoveEntitiesPacket 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.MoveEntitiesPacket 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 };
}
}
Aggregations