use of com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientVehicleMovePacket in project DragonProxy by DragonetMC.
the class PEMovePlayerPacketTranslator method translate.
public Packet[] translate(UpstreamSession session, MovePlayerPacket packet) {
CachedEntity entity = session.getEntityCache().getClientEntity();
if (entity.riding != 0 && packet.ridingRuntimeId != 0) {
// Riding case
ClientVehicleMovePacket pk = new ClientVehicleMovePacket(packet.position.x, packet.position.y - EntityType.PLAYER.getOffset(), packet.position.z, packet.yaw, packet.pitch);
session.getDownstream().send(pk);
} else {
// not riding
ClientPlayerPositionRotationPacket pk = new ClientPlayerPositionRotationPacket(packet.onGround, packet.position.x, // To simplify the movements
ceilToHalf(packet.position.y - EntityType.PLAYER.getOffset()), packet.position.z, packet.yaw, packet.pitch);
// Special blocks handling
boolean isColliding = false;
BlockPosition blockPos = new BlockPosition(NukkitMath.floorDouble(packet.position.x), NukkitMath.floorDouble(packet.position.y), NukkitMath.floorDouble(packet.position.z));
// System.out.println("block " + blockPos.toString());
try {
ItemEntry PEBlock = session.getChunkCache().translateBlock(blockPos.asPosition());
if (PEBlock != null) {
Block b = Block.get(PEBlock.getId(), PEBlock.getPEDamage(), blockPos);
if (b != null && b.collidesWithBB(session.getEntityCache().getClientEntity().boundingBox.clone())) {
DragonProxy.getInstance().getLogger().info("Player position : " + entity.x + ", " + entity.y + ", " + entity.z + " collide with " + b.getClass().getSimpleName() + " on " + blockPos.toString());
isColliding = true;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
entity.absoluteMove(pk.getX(), pk.getY(), pk.getZ(), (float) pk.getYaw(), (float) pk.getPitch());
if (!isColliding) {
session.getDownstream().send(pk);
session.getChunkCache().sendOrderedChunks();
}
}
return null;
}
Aggregations