Search in sources :

Example 56 with Vector3ic

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)));
    }
}
Also used : Vector3ic(org.joml.Vector3ic) Vector3i(org.joml.Vector3i) BlockRegion(org.terasology.engine.world.block.BlockRegion) Test(org.junit.jupiter.api.Test)

Example 57 with Vector3ic

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));
}
Also used : Vector3ic(org.joml.Vector3ic) Vector3i(org.joml.Vector3i) Test(org.junit.jupiter.api.Test)

Example 58 with Vector3ic

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());
}
Also used : OnPlayerSpawnedEvent(org.terasology.engine.logic.players.event.OnPlayerSpawnedEvent) Vector3ic(org.joml.Vector3ic) Client(org.terasology.engine.network.Client) ClientComponent(org.terasology.engine.network.ClientComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef)

Example 59 with Vector3ic

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());
}
Also used : CharacterTeleportEvent(org.terasology.engine.logic.characters.CharacterTeleportEvent) Vector3ic(org.joml.Vector3ic) Vector3f(org.joml.Vector3f) Client(org.terasology.engine.network.Client) ClientComponent(org.terasology.engine.network.ClientComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) LocationComponent(org.terasology.engine.logic.location.LocationComponent) OnPlayerRespawnedEvent(org.terasology.engine.logic.players.event.OnPlayerRespawnedEvent) AliveCharacterComponent(org.terasology.engine.logic.characters.AliveCharacterComponent)

Example 60 with Vector3ic

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));
}
Also used : Vector3ic(org.joml.Vector3ic) Vector3i(org.joml.Vector3i) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Vector3ic (org.joml.Vector3ic)87 Vector3i (org.joml.Vector3i)52 Test (org.junit.jupiter.api.Test)35 BlockRegion (org.terasology.engine.world.block.BlockRegion)28 Chunk (org.terasology.engine.world.chunks.Chunk)28 ChunkImpl (org.terasology.engine.world.chunks.internal.ChunkImpl)16 Block (org.terasology.engine.world.block.Block)12 ReceiveEvent (org.terasology.engine.entitySystem.event.ReceiveEvent)11 Map (java.util.Map)8 Lists (com.google.common.collect.Lists)5 List (java.util.List)5 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)5 LocationComponent (org.terasology.engine.logic.location.LocationComponent)5 BlockRegionComponent (org.terasology.engine.world.block.regions.BlockRegionComponent)5 Maps (com.google.common.collect.Maps)4 Sets (com.google.common.collect.Sets)4 ArrayList (java.util.ArrayList)4 Collections (java.util.Collections)4 Set (java.util.Set)4 Vector3f (org.joml.Vector3f)4