use of org.joml.Vector3i in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class VSIterationUtilsTest method testIterator3d.
@Test
public void testIterator3d() {
Iterator<Vector3i> iterator = new VSIterationUtils.Int3dIterator(-10, -10, -10, 10, 10, 10);
List<Vector3i> iVals = new ArrayList<>();
List<Vector3i> oVals = new ArrayList<>();
while (iterator.hasNext()) {
Vector3i vec = iterator.next();
iVals.add(vec);
}
VSIterationUtils.iterate3d(-10, -10, -10, 10, 10, 10, (x, y, z) -> oVals.add(new Vector3i(x, y, z)));
assertThat(iVals, containsInAnyOrder(oVals.toArray()));
}
use of org.joml.Vector3i in project Terasology by MovingBlocks.
the class LocalChunkProviderTest method testGenerateSingleChunkWithBlockLifeCycle.
@Test
void testGenerateSingleChunkWithBlockLifeCycle() throws InterruptedException, ExecutionException, TimeoutException {
Vector3i chunkPosition = new Vector3i(0, 0, 0);
blockAtBlockManager.setLifecycleEventsRequired(true);
blockAtBlockManager.setEntity(mock(EntityRef.class));
requestCreatingOrLoadingArea(chunkPosition).get(WAIT_CHUNK_IS_READY_IN_SECONDS, TimeUnit.SECONDS);
chunkProvider.update();
final ArgumentCaptor<Event> worldEventCaptor = ArgumentCaptor.forClass(Event.class);
verify(worldEntity, atLeast(2)).send(worldEventCaptor.capture());
Assertions.assertAll("World Events not valid", () -> {
Event mustBeOnGeneratedEvent = worldEventCaptor.getAllValues().get(0);
Assertions.assertTrue(mustBeOnGeneratedEvent instanceof OnChunkGenerated, "First world event must be OnChunkGenerated");
Assertions.assertEquals(((OnChunkGenerated) mustBeOnGeneratedEvent).getChunkPos(), chunkPosition, "Chunk position at event not expected");
}, () -> {
Event mustBeOnLoadedEvent = worldEventCaptor.getAllValues().get(1);
Assertions.assertTrue(mustBeOnLoadedEvent instanceof OnChunkLoaded, "Second world event must be OnChunkLoaded");
Assertions.assertEquals(chunkPosition, ((OnChunkLoaded) mustBeOnLoadedEvent).getChunkPos(), "Chunk position at event not expected");
});
// TODO, it is not clear if the activate/addedBlocks event logic is correct.
// See https://github.com/MovingBlocks/Terasology/issues/3244
final ArgumentCaptor<Event> blockEventCaptor = ArgumentCaptor.forClass(Event.class);
verify(blockAtBlockManager.getEntity(), atLeast(1)).send(blockEventCaptor.capture());
Event mustBeOnActivatedBlocks = blockEventCaptor.getAllValues().get(0);
Assertions.assertTrue(mustBeOnActivatedBlocks instanceof OnActivatedBlocks, "First block event must be OnActivatedBlocks");
Assertions.assertTrue(((OnActivatedBlocks) mustBeOnActivatedBlocks).blockCount() > 0, "Block count on activate must be non zero");
}
use of org.joml.Vector3i in project Terasology by MovingBlocks.
the class BooleanFacetTest method setup.
@BeforeEach
public void setup() {
Border3D border = new Border3D(0, 0, 0).extendBy(0, 15, 10);
Vector3i min = new Vector3i(10, 20, 30);
Vector3i size = new Vector3i(40, 50, 60);
BlockRegion region = new BlockRegion(min).setSize(size);
facet = createFacet(region, border);
// facet = [worldMin=(0, 5, 20), relativeMin=(-10, -15, -10), size=(60, 65, 80)]
}
use of org.joml.Vector3i in project Terasology by MovingBlocks.
the class SparseBooleanFacetTest method testGetWorldMap.
@Test
public void testGetWorldMap() {
facet.set(0, 1, 2, true);
facet.set(0, 1, 3, true);
facet.set(9, 3, 1, true);
facet.setWorld(13, 28, 34, true);
facet.setWorld(10, 21, 35, true);
Map<Vector3i, Boolean> expected = ImmutableMap.of(new Vector3i(10, 21, 32), true, new Vector3i(10, 21, 33), true, new Vector3i(13, 28, 34), true, new Vector3i(10, 21, 35), true, new Vector3i(19, 23, 31), true);
assertEquals(expected, facet.getWorldEntries());
}
use of org.joml.Vector3i in project Terasology by MovingBlocks.
the class BetweenChunkPropagationTest method testBetweenChunksSimple.
@Test
public void testBetweenChunksSimple() {
Chunk topChunk = new ChunkImpl(new Vector3i(0, 1, 0), blockManager, extraDataManager);
Chunk bottomChunk = new ChunkImpl(new Vector3i(0, 0, 0), blockManager, extraDataManager);
provider.addChunk(topChunk);
provider.addChunk(bottomChunk);
for (Vector3ic pos : new BlockRegion(0, 0, 0).setSize(Chunks.SIZE_X, 1, Chunks.SIZE_Z)) {
topChunk.setSunlight(pos, Chunks.MAX_SUNLIGHT);
topChunk.setSunlightRegen(pos, Chunks.MAX_SUNLIGHT_REGEN);
}
InternalLightProcessor.generateInternalLighting(bottomChunk);
propagator.propagateBetween(topChunk, bottomChunk, Side.BOTTOM, true);
propagator.process();
sunlightPropagator.process();
for (Vector3ic pos : Chunks.CHUNK_REGION) {
assertEquals(Chunks.MAX_SUNLIGHT, bottomChunk.getSunlight(pos), () -> "Incorrect at position " + pos);
assertEquals(Chunks.MAX_SUNLIGHT_REGEN, bottomChunk.getSunlightRegen(pos), () -> "Incorrect at position " + pos);
}
}
Aggregations