@Test public void testComponentsUpdatedWhenBlockChanged() { worldProvider.setBlock(Vector3i.zero(), blockWithString); LifecycleEventChecker checker = new LifecycleEventChecker(entityManager.getEventSystem(), StringComponent.class); worldProvider.setBlock(Vector3i.zero(), blockWithDifferentString); EntityRef blockEntity = worldProvider.getBlockEntityAt(new Vector3i(0, 0, 0)); assertTrue(blockEntity.exists()); assertEquals( Lists.newArrayList(new EventInfo(OnChangedComponent.newInstance(), blockEntity)), checker.receivedEvents); }
@Test public void testChangedComponentsRevertedBeforeCleanUp() { worldStub.setBlock(Vector3i.zero(), blockWithString); EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i(0, 0, 0)); StringComponent comp = entity.getComponent(StringComponent.class); comp.value = "Moo"; entity.saveComponent(comp); LifecycleEventChecker checker = new LifecycleEventChecker(entityManager.getEventSystem(), StringComponent.class); worldProvider.update(1.0f); assertEquals( Lists.newArrayList(new EventInfo(OnChangedComponent.newInstance(), entity)), checker.receivedEvents); }