use of org.dragonet.protocol.packets.MoveEntityPacket in project DragonProxy by DragonetMC.
the class PCEntityPositionRotationPacketTranslator method translate.
public PEPacket[] translate(UpstreamSession session, ServerEntityPositionRotationPacket packet) {
CachedEntity entity = session.getEntityCache().getByRemoteEID(packet.getEntityId());
if (entity == null) {
if (packet.getEntityId() == (int) session.getDataCache().get(CacheKey.PLAYER_EID)) {
entity = session.getEntityCache().getClientEntity();
} else {
return null;
}
}
entity.relativeMove(packet.getMovementX(), packet.getMovementY(), packet.getMovementZ(), packet.getYaw(), packet.getPitch());
if (entity.shouldMove) {
MoveEntityPacket pk = new MoveEntityPacket();
pk.rtid = entity.proxyEid;
pk.yaw = (byte) (entity.yaw / (360d / 256d));
pk.headYaw = (byte) (entity.headYaw / (360d / 256d));
pk.pitch = (byte) (entity.pitch / (360d / 256d));
pk.position = new Vector3F((float) entity.x, (float) entity.y + entity.peType.getOffset(), (float) entity.z);
pk.onGround = packet.isOnGround();
entity.shouldMove = false;
return new PEPacket[] { pk };
}
return null;
}
use of org.dragonet.protocol.packets.MoveEntityPacket in project DragonProxy by DragonetMC.
the class PCEntityRotationPacketTranslator method translate.
public PEPacket[] translate(UpstreamSession session, ServerEntityRotationPacket packet) {
CachedEntity entity = session.getEntityCache().getByRemoteEID(packet.getEntityId());
if (entity == null) {
if (packet.getEntityId() == (int) session.getDataCache().get(CacheKey.PLAYER_EID)) {
entity = session.getEntityCache().getClientEntity();
} else {
return null;
}
}
entity.relativeMove(packet.getMovementX(), packet.getMovementY(), packet.getMovementZ(), packet.getYaw(), packet.getPitch());
if (entity.shouldMove) {
MoveEntityPacket pk = new MoveEntityPacket();
pk.rtid = entity.proxyEid;
pk.yaw = (byte) (entity.yaw / (360d / 256d));
pk.headYaw = (byte) (entity.headYaw / (360d / 256d));
pk.pitch = (byte) (entity.pitch / (360d / 256d));
pk.position = new Vector3F((float) entity.x, (float) entity.y + entity.peType.getOffset(), (float) entity.z);
pk.onGround = packet.isOnGround();
entity.shouldMove = false;
return new PEPacket[] { pk };
}
return null;
}
use of org.dragonet.protocol.packets.MoveEntityPacket in project DragonProxy by DragonetMC.
the class PCEntityPositionPacketTranslator method translate.
public PEPacket[] translate(UpstreamSession session, ServerEntityPositionPacket packet) {
CachedEntity entity = session.getEntityCache().getByRemoteEID(packet.getEntityId());
if (entity == null) {
if (packet.getEntityId() == (int) session.getDataCache().get(CacheKey.PLAYER_EID)) {
entity = session.getEntityCache().getClientEntity();
} else {
return null;
}
}
entity.relativeMove(packet.getMovementX(), packet.getMovementY(), packet.getMovementZ(), packet.getYaw(), packet.getPitch());
if (entity.shouldMove) {
MoveEntityPacket pk = new MoveEntityPacket();
pk.rtid = entity.proxyEid;
pk.yaw = (byte) (entity.yaw / (360d / 256d));
pk.headYaw = (byte) (entity.headYaw / (360d / 256d));
pk.pitch = (byte) (entity.pitch / (360d / 256d));
pk.position = new Vector3F((float) entity.x, (float) entity.y + entity.peType.getOffset(), (float) entity.z);
pk.onGround = packet.isOnGround();
entity.shouldMove = false;
return new PEPacket[] { pk };
}
return null;
}
use of org.dragonet.protocol.packets.MoveEntityPacket in project DragonProxy by DragonetMC.
the class PCEntityTeleportPacketTranslator method translate.
public PEPacket[] translate(UpstreamSession session, ServerEntityTeleportPacket packet) {
CachedEntity entity = session.getEntityCache().getByRemoteEID(packet.getEntityId());
if (entity == null) {
if (packet.getEntityId() == (int) session.getDataCache().get(CacheKey.PLAYER_EID)) {
entity = session.getEntityCache().getClientEntity();
} else {
return null;
}
}
entity.absoluteMove(packet.getX(), packet.getY(), packet.getZ(), packet.getYaw(), packet.getPitch());
if (entity.shouldMove) {
MoveEntityPacket pk = new MoveEntityPacket();
pk.rtid = entity.proxyEid;
pk.yaw = (byte) (entity.yaw / (360d / 256d));
pk.headYaw = (byte) (entity.headYaw / (360d / 256d));
pk.pitch = (byte) (entity.pitch / (360d / 256d));
pk.position = new Vector3F((float) entity.x, (float) entity.y + entity.peType.getOffset(), (float) entity.z);
pk.onGround = packet.isOnGround();
entity.shouldMove = false;
return new PEPacket[] { pk };
}
return null;
}
use of org.dragonet.protocol.packets.MoveEntityPacket in project DragonProxy by DragonetMC.
the class PCEntityHeadLookPacketTranslator method translate.
public PEPacket[] translate(UpstreamSession session, ServerEntityHeadLookPacket packet) {
CachedEntity entity = session.getEntityCache().getByRemoteEID(packet.getEntityId());
if (entity == null) {
if (packet.getEntityId() == (int) session.getDataCache().get(CacheKey.PLAYER_EID)) {
entity = session.getEntityCache().getClientEntity();
} else {
return null;
}
}
entity.headYaw = packet.getHeadYaw();
MoveEntityPacket pk = new MoveEntityPacket();
pk.rtid = entity.proxyEid;
pk.yaw = (byte) (entity.yaw / (360d / 256d));
pk.headYaw = (byte) (entity.headYaw / (360d / 256d));
pk.pitch = (byte) (entity.pitch / (360d / 256d));
pk.position = new Vector3F((float) entity.x, (float) entity.y + entity.peType.getOffset(), (float) entity.z);
pk.onGround = true;
return new PEPacket[] { pk };
}
Aggregations