From 26765d586e187ebd088cdb2f7451768a637968c8 Mon Sep 17 00:00:00 2001 From: Trumeet Date: Fri, 29 Jul 2022 12:17:56 -0700 Subject: feat(mod/libacron): provide entity type to clients API:ADD --- mod/README.md | 8 ++++++++ mod/src/main/java/moe/ymc/acron/s2c/Entity.java | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/README.md b/mod/README.md index 1e23817..49a7e8e 100644 --- a/mod/README.md +++ b/mod/README.md @@ -254,6 +254,7 @@ Response: "player": { "name": "", "uuid": "", + "type": "", "pos": { "x": 0.0, "y": 0.0, @@ -269,6 +270,7 @@ Parameters: * `.player` (entity, see below, always present): The player. * `.name` (string, any valid Minecraft username, always present): Username. * `.uuid` (uuid, UUID, always present): UUID. + * `.type` (string, namespace:path, always present): Entity type. * `.pos` (vec3d, see below, always present): The position he or she joins. * `.x` (double, any within border limit, 0.0): X * `.y` (double, any within border limit, 0.0): Y @@ -286,6 +288,7 @@ Response: "player": { "name": "", "uuid": "", + "type": "", "pos": { "x": 0.0, "y": 0.0, @@ -302,6 +305,7 @@ Parameters: * `.player` (entity, see below, null only when the server cannot verify the user): The player. * `.name` (string, any valid Minecraft username, always present): Username. * `.uuid` (uuid, UUID, always present): UUID. + * `.type` (string, namespace:path, always present): Entity type. * `.pos` (vec3d, see below, always present): The position he or she leaves. * `.x` (double, any within border limit, 0.0): X * `.y` (double, any within border limit, 0.0): Y @@ -320,6 +324,7 @@ Response: "player": { "name": "", "uuid": "", + "type": "", "pos": { "x": 0.0, "y": 0.0, @@ -336,6 +341,7 @@ Parameters: * `.player` (entity, see below, always present): The player. * `.name` (string, any valid Minecraft username, always present): Username. * `.uuid` (uuid, UUID, always present): UUID. + * `.type` (string, namespace:path, always present): Entity type. * `.pos` (vec3d, see below, always present): The position he or she sends the message. * `.x` (double, any within border limit, 0.0): X * `.y` (double, any within border limit, 0.0): Y @@ -354,6 +360,7 @@ Response: "entity": { "name": "", "uuid": "", + "type": "", "pos": { "x": 0.0, "y": 0.0, @@ -370,6 +377,7 @@ Parameters: * `.entity` (entity, see below, always present): The entity. * `.name` (string, any, always present): Default name or custom name of the entity. * `.uuid` (uuid, UUID, always present): UUID. + * `.type` (string, namespace:path, always present): Entity type. * `.pos` (vec3d, see below, always present): The position of the entity when died. * `.x` (double, any within border limit, 0.0): X * `.y` (double, any within border limit, 0.0): Y diff --git a/mod/src/main/java/moe/ymc/acron/s2c/Entity.java b/mod/src/main/java/moe/ymc/acron/s2c/Entity.java index 3e0add1..b10c041 100644 --- a/mod/src/main/java/moe/ymc/acron/s2c/Entity.java +++ b/mod/src/main/java/moe/ymc/acron/s2c/Entity.java @@ -4,6 +4,7 @@ import com.google.gson.annotations.SerializedName; import com.mojang.authlib.GameProfile; import moe.ymc.acron.common.Vec3d; import moe.ymc.acron.common.WorldKey; +import net.minecraft.entity.EntityType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -11,16 +12,18 @@ import java.util.UUID; public record Entity(@SerializedName("name") @NotNull String name, @SerializedName("uuid") @NotNull UUID uuid, + @SerializedName("type") @NotNull String type, @SerializedName("pos") @Nullable Vec3d pos, @SerializedName("world") @Nullable WorldKey world) { public Entity(@NotNull net.minecraft.entity.Entity entity) { this(entity.getName().getString(), entity.getUuid(), + EntityType.getId(entity.getType()).toString(), new Vec3d(entity.getPos()), WorldKey.create(entity.world.getRegistryKey().getValue())); } public Entity(@NotNull GameProfile profile) { - this(profile.getName(), profile.getId(), null, null); + this(profile.getName(), profile.getId(), "minecraft:player", null, null); } } -- cgit v1.2.3