diff --git a/api/src/main/java/com/lunarclient/apollo/common/location/ApolloPlayerLocation.java b/api/src/main/java/com/lunarclient/apollo/common/location/ApolloPlayerLocation.java new file mode 100644 index 00000000..a51be26f --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/common/location/ApolloPlayerLocation.java @@ -0,0 +1,62 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 Moonsworth + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.lunarclient.apollo.common.location; + +import lombok.Builder; +import lombok.Getter; + +/** + * Represents a player location in the world. + * + * @since 1.0.0 + */ +@Getter +@Builder +public final class ApolloPlayerLocation { + + /** + * Returns the {@link ApolloLocation} for this player. + * + * @return the apollo location + * @since 1.0.0 + */ + ApolloLocation location; + + /** + * Returns the {@code float} yaw for this player location. + * + * @return the yaw + * @since 1.0.0 + */ + float yaw; + + /** + * Returns the {@code float} pitch for this player location. + * + * @return the pitch + * @since 1.0.0 + */ + float pitch; + +} diff --git a/common/src/main/java/com/lunarclient/apollo/module/anticheat/AntiCheatImpl.java b/common/src/main/java/com/lunarclient/apollo/module/anticheat/AntiCheatImpl.java index b1b8b141..40c2fec5 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/anticheat/AntiCheatImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/anticheat/AntiCheatImpl.java @@ -30,4 +30,6 @@ */ public final class AntiCheatImpl extends AntiCheatModule { + + } diff --git a/common/src/main/java/com/lunarclient/apollo/network/NetworkTypes.java b/common/src/main/java/com/lunarclient/apollo/network/NetworkTypes.java index a0e6bd7e..1f9f1244 100644 --- a/common/src/main/java/com/lunarclient/apollo/network/NetworkTypes.java +++ b/common/src/main/java/com/lunarclient/apollo/network/NetworkTypes.java @@ -33,6 +33,7 @@ import com.lunarclient.apollo.common.icon.SimpleResourceLocationIcon; import com.lunarclient.apollo.common.location.ApolloBlockLocation; import com.lunarclient.apollo.common.location.ApolloLocation; +import com.lunarclient.apollo.common.location.ApolloPlayerLocation; import com.lunarclient.apollo.common.v1.EntityId; import com.lunarclient.apollo.common.v1.Uuid; import java.awt.Color; @@ -224,6 +225,38 @@ public static ApolloBlockLocation fromProtobuf(com.lunarclient.apollo.common.v1. .build(); } + /** + * Converts an {@link ApolloPlayerLocation} object to an + * {@link com.lunarclient.apollo.common.v1.PlayerLocation} proto message. + * + * @param object the player location + * @return the proto player location message + * @since 1.0.0 + */ + public static com.lunarclient.apollo.common.v1.PlayerLocation toProtobuf(ApolloPlayerLocation object) { + return com.lunarclient.apollo.common.v1.PlayerLocation.newBuilder() + .setLocation(NetworkTypes.toProtobuf(object.getLocation())) + .setYaw(object.getYaw()) + .setPitch(object.getPitch()) + .build(); + } + + /** + * Converts an {@link com.lunarclient.apollo.common.v1.PlayerLocation} + * proto message to an {@link ApolloPlayerLocation} object. + * + * @param message the player location message + * @return the apollo player location object + * @since 1.0.0 + */ + public static ApolloPlayerLocation fromProtobuf(com.lunarclient.apollo.common.v1.PlayerLocation message) { + return ApolloPlayerLocation.builder() + .location(NetworkTypes.fromProtobuf(message.getLocation())) + .yaw(message.getYaw()) + .pitch(message.getPitch()) + .build(); + } + /** * Converts an {@link Cuboid2D} object to an * {@link com.lunarclient.apollo.common.v1.Cuboid2D} proto message.