use of org.joml.Vector3i in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method testComponentsAddedAndActivatedWhenBlockChanged.
@Disabled("Failing due to #2625. TODO: fix to match new behaviour")
@Test
public void testComponentsAddedAndActivatedWhenBlockChanged() {
LifecycleEventChecker checker = new LifecycleEventChecker(entityManager.getEventSystem(), StringComponent.class);
worldProvider.setBlock(new Vector3i(), blockWithString);
EntityRef blockEntity = worldProvider.getBlockEntityAt(new Vector3i());
assertTrue(blockEntity.exists());
assertEquals(Lists.newArrayList(new EventInfo(OnAddedComponent.newInstance(), blockEntity), new EventInfo(OnActivatedComponent.newInstance(), blockEntity)), checker.receivedEvents);
}
use of org.joml.Vector3i in project Terasology by MovingBlocks.
the class MapWorldProvider method getBlock.
@Override
public Block getBlock(int x, int y, int z) {
Vector3i pos = new Vector3i(x, y, z);
Block block = blocks.get(pos);
if (block != null) {
return block;
}
// TODO block manager
Vector3i chunkPos = Chunks.toChunkPos(pos, new Vector3i());
Chunk chunk = chunks.get(chunkPos);
if (chunk == null && worldGenerator != null) {
chunk = new ChunkImpl(chunkPos, blockManager, extraDataManager);
worldGenerator.createChunk(chunk, entityBuffer);
chunks.put(chunkPos, chunk);
}
if (chunk != null) {
return chunk.getBlock(Chunks.toRelative(pos, pos));
}
return null;
}
use of org.joml.Vector3i in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method testComponentsAlteredIfBlockInSameFamilyWhenForced.
@Test
public void testComponentsAlteredIfBlockInSameFamilyWhenForced() {
worldProvider.setBlock(new Vector3i(), blockInFamilyOne);
EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i());
entity.addComponent(new IntegerComponent());
worldProvider.setBlockForceUpdateEntity(new Vector3i(), blockInFamilyTwo);
assertNull(entity.getComponent(IntegerComponent.class));
}
use of org.joml.Vector3i in project Terasology by MovingBlocks.
the class Diamond3iIteratorTest method testTwoDistanceIteration.
@Test
public void testTwoDistanceIteration() {
int cc = 0;
for (Vector3ic next : Diamond3iIterable.region(new Vector3i(), 2).build()) {
assertTrue(next.gridDistance(new Vector3i()) <= 2);
cc++;
}
assertEquals(25, cc);
}
use of org.joml.Vector3i in project Terasology by MovingBlocks.
the class Diamond3iIteratorTest method testOneDistanceIteration.
@Test
public void testOneDistanceIteration() {
Iterator<Vector3ic> iter = Diamond3iIterable.region(new Vector3i(), 1).build().iterator();
Set<Vector3i> expected = Sets.newHashSet(new Vector3i(), new Vector3i(1, 0, 0), new Vector3i(-1, 0, 0), new Vector3i(0, 1, 0), new Vector3i(0, -1, 0), new Vector3i(0, 0, 1), new Vector3i(0, 0, -1));
while (iter.hasNext()) {
Vector3i next = new Vector3i(iter.next());
assertTrue(expected.remove(next), () -> "Received Unexpected: " + next);
}
assertTrue(expected.isEmpty(), () -> "Missing: " + expected);
}
Aggregations