use of org.joml.Vector3ic in project Terasology by MovingBlocks.
the class BulkSunlightPropagationTest method testAllowSunlightVertical.
@Test
public void testAllowSunlightVertical() {
for (Vector3ic pos : new BlockRegion(0, 16, 0).union(Chunks.SIZE_X - 1, Chunks.SIZE_Y - 1, Chunks.SIZE_Z - 1)) {
regenWorldView.setValueAt(pos, Chunks.MAX_SUNLIGHT_REGEN);
lightWorldView.setValueAt(pos, Chunks.MAX_SUNLIGHT);
}
for (Vector3ic pos : new BlockRegion(0, 15, 0).union(Chunks.SIZE_X - 1, 15, Chunks.SIZE_Z - 1)) {
regenWorldView.setBlockAt(new Vector3i(pos), solid);
}
for (Vector3ic pos : new BlockRegion(0, 0, 0).union(Chunks.SIZE_X - 1, 14, Chunks.SIZE_Z - 1)) {
regenWorldView.setValueAt(pos, (byte) (14 - pos.y()));
}
regenWorldView.setBlockAt(new Vector3i(16, 15, 16), air);
propagator.process(new BlockChange(new Vector3i(16, 15, 16), solid, air));
sunlightPropagator.process(new BlockChange(new Vector3i(16, 15, 16), solid, air));
for (int y = 0; y < 16; y++) {
assertEquals(Chunks.MAX_SUNLIGHT_REGEN, regenWorldView.getValueAt(new Vector3i(16, y, 16)), "Incorrect value at " + y);
assertEquals(Chunks.MAX_SUNLIGHT, lightWorldView.getValueAt(new Vector3i(16, y, 16)));
}
for (int y = 0; y < 15; y++) {
assertEquals(Chunks.MAX_SUNLIGHT - 1, lightWorldView.getValueAt(new Vector3i(15, y, 16)));
}
}
use of org.joml.Vector3ic in project Terasology by MovingBlocks.
the class Diamond3iIteratorTest method testZeroDistanceIteration.
@Test
public void testZeroDistanceIteration() {
Iterator<Vector3ic> iter = Diamond3iIterable.region(new Vector3i(), 0).build().iterator();
assertEquals(Lists.newArrayList(new Vector3i()), Lists.newArrayList(iter));
}
use of org.joml.Vector3ic in project Terasology by MovingBlocks.
the class PlayerSystem method spawnPlayer.
private void spawnPlayer(EntityRef clientEntity) {
ClientComponent client = clientEntity.getComponent(ClientComponent.class);
PlayerFactory playerFactory = new PlayerFactory(entityManager, worldProvider);
EntityRef playerCharacter = playerFactory.newInstance(clientEntity);
Client clientListener = networkSystem.getOwner(clientEntity);
Vector3ic distance = clientListener.getViewDistance().getChunkDistance();
updateRelevanceEntity(clientEntity, distance);
client.character = playerCharacter;
clientEntity.saveComponent(client);
playerCharacter.send(new OnPlayerSpawnedEvent());
}
use of org.joml.Vector3ic in project Terasology by MovingBlocks.
the class PlayerSystem method respawnPlayer.
private void respawnPlayer(EntityRef clientEntity) {
ClientComponent client = clientEntity.getComponent(ClientComponent.class);
EntityRef playerCharacter = client.character;
LocationComponent location = playerCharacter.getComponent(LocationComponent.class);
PlayerFactory playerFactory = new PlayerFactory(entityManager, worldProvider);
Vector3f spawnPosition = playerFactory.findSpawnPositionFromLocationComponent(location);
playerCharacter.addComponent(new AliveCharacterComponent());
playerCharacter.send(new CharacterTeleportEvent(spawnPosition));
logger.debug("Re-spawing player at: {}", spawnPosition);
Client clientListener = networkSystem.getOwner(clientEntity);
Vector3ic distance = clientListener.getViewDistance().getChunkDistance();
updateRelevanceEntity(clientEntity, distance);
playerCharacter.send(new OnPlayerRespawnedEvent());
}
use of org.joml.Vector3ic in project Terasology by MovingBlocks.
the class BlockRegionTest method testSingleBlockRegion.
// -- ITERABLE ---------------------------------------------------------------------------------------------------//
@Test
public void testSingleBlockRegion() {
BlockRegion region = new BlockRegion(new Vector3i(0, 0, 0), new Vector3i(0, 0, 0));
List<Vector3ic> actual = new ArrayList<>();
for (Vector3ic vector3ic : region) {
actual.add(new Vector3i(vector3ic));
}
Assertions.assertEquals(1, actual.size());
Assertions.assertEquals(new HashSet<>(expectedPositions(region)), new HashSet<>(actual));
}
Aggregations