From d8bd671f20509bbfa2e22632a280aa3ce0bb7494 Mon Sep 17 00:00:00 2001 From: Tofaa <82680183+Tofaa2@users.noreply.github.com> Date: Sun, 11 Feb 2024 23:06:17 +0400 Subject: [PATCH] add removing --- .../java/me/tofaa/entitylib/EntityLib.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/java/me/tofaa/entitylib/EntityLib.java b/src/main/java/me/tofaa/entitylib/EntityLib.java index f536679..dd2b180 100644 --- a/src/main/java/me/tofaa/entitylib/EntityLib.java +++ b/src/main/java/me/tofaa/entitylib/EntityLib.java @@ -105,6 +105,28 @@ public final class EntityLib { return entitiesById.get(entityId); } + /** + * Removes the entity completely from EntityLib and the platform. + * The viewer will no longer be able to see the entity. + */ + public static boolean removeEntity(int entityId) { + checkInit(); + WrapperEntity e = entitiesById.get(entityId); + if (e == null) return false; + entities.remove(e.getUuid()); + entitiesById.remove(entityId); + e.remove(); + return true; + } + + /** + * Removes the entity completely from EntityLib and the platform. + * The viewer will no longer be able to see the entity. + */ + public static boolean removeEntity(WrapperEntity entity) { + return removeEntity(entity.getEntityId()); + } + /** * @param uuid the entity uuid * @return the entity with the given uuid, or null if an entity with that uuid does not exist