From b5cc2c4126064f3a3f6711c0adb96a160dff863a Mon Sep 17 00:00:00 2001 From: TheMode Date: Mon, 31 Jan 2022 12:54:48 +0100 Subject: [PATCH] Verify entity removal from instance entity list Signed-off-by: TheMode --- .../entity/EntityRemovalIntegrationTest.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/test/java/net/minestom/server/entity/EntityRemovalIntegrationTest.java b/src/test/java/net/minestom/server/entity/EntityRemovalIntegrationTest.java index 6654536d9..7dea5a2d8 100644 --- a/src/test/java/net/minestom/server/entity/EntityRemovalIntegrationTest.java +++ b/src/test/java/net/minestom/server/entity/EntityRemovalIntegrationTest.java @@ -21,7 +21,7 @@ public class EntityRemovalIntegrationTest { var connection = env.createConnection(); connection.connect(instance, new Pos(0, 40, 0)).join(); - var entity = new TestEntity(2, TimeUnit.SERVER_TICK); + var entity = new Entity(EntityType.ZOMBIE); entity.setInstance(instance, new Pos(0, 40, 0)).join(); var tracker = connection.trackIncoming(DestroyEntitiesPacket.class); @@ -29,6 +29,18 @@ public class EntityRemovalIntegrationTest { tracker.assertSingle(packet -> assertEquals(List.of(entity.getEntityId()), packet.entityIds())); } + @Test + public void instanceRemoval(Env env) { + var instance = env.createFlatInstance(); + var entity = new Entity(EntityType.ZOMBIE); + entity.setInstance(instance, new Pos(0, 40, 0)).join(); + assertFalse(entity.isRemoved()); + + entity.remove(); + assertTrue(entity.isRemoved()); + assertFalse(instance.getEntities().contains(entity), "Entity must not be in the instance anymore"); + } + @Test public void tickTimedRemoval(Env env) throws InterruptedException { var instance = env.createFlatInstance();