Verify entity removal from instance entity list

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2022-01-31 12:54:48 +01:00
parent 6f099a4036
commit b5cc2c4126

View File

@ -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();