Search in sources :

Example 51 with Vector3i

use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.

the class SparseFieldFacet3D method getWorldEntries.

/**
 * @return a <b>new</b> map with world-based position entries
 */
public Map<Vector3i, Number> getWorldEntries() {
    Map<Vector3i, Number> result = Maps.newLinkedHashMap();
    for (Entry<Vector3i, Number> entry : relData.entrySet()) {
        Vector3i relPos = entry.getKey();
        Vector3i worldPos = relativeToWorld(relPos.x, relPos.y, relPos.z);
        result.put(worldPos, entry.getValue());
    }
    return result;
}
Also used : Vector3i(org.terasology.math.geom.Vector3i)

Example 52 with Vector3i

use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.

the class SparseObjectFacet3D method getWorld.

@Override
public T getWorld(int x, int y, int z) {
    checkWorldCoords(x, y, z);
    Vector3i index = worldToRelative(x, y, z);
    return relData.get(index);
}
Also used : BaseVector3i(org.terasology.math.geom.BaseVector3i) Vector3i(org.terasology.math.geom.Vector3i)

Example 53 with Vector3i

use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.

the class ChunkViewCoreImpl method getBiome.

@Override
public Biome getBiome(int blockX, int blockY, int blockZ) {
    if (!blockRegion.encompasses(blockX, blockY, blockZ)) {
        return BiomeManager.getUnknownBiome();
    }
    int chunkIndex = relChunkIndex(blockX, blockY, blockZ);
    Vector3i blockPos = ChunkMath.calcBlockPos(blockX, blockY, blockZ, chunkFilterSize);
    return chunks[chunkIndex].getBiome(blockPos.x, blockPos.y, blockPos.z);
}
Also used : Vector3i(org.terasology.math.geom.Vector3i)

Example 54 with Vector3i

use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.

the class ChunkViewCoreImpl method setBiome.

@Override
public void setBiome(int blockX, int blockY, int blockZ, Biome biome) {
    if (blockRegion.encompasses(blockX, blockY, blockZ)) {
        int chunkIndex = relChunkIndex(blockX, blockY, blockZ);
        Vector3i pos = ChunkMath.calcBlockPos(blockX, blockY, blockZ, chunkFilterSize);
        chunks[chunkIndex].setBiome(pos.x, pos.y, pos.z, biome);
    } else {
        logger.warn("Attempt to modify biome outside of the view");
    }
}
Also used : Vector3i(org.terasology.math.geom.Vector3i)

Example 55 with Vector3i

use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.

the class EntityAwareWorldProvider method updateBlockEntity.

private void updateBlockEntity(EntityRef blockEntity, Vector3i pos, Block oldType, Block type, boolean forceEntityUpdate, Set<Class<? extends Component>> retainComponents) {
    if (type.isKeepActive()) {
        temporaryBlockEntities.remove(blockEntity);
    } else if (oldType.isKeepActive() && isTemporaryBlock(blockEntity, type)) {
        temporaryBlockEntities.add(blockEntity);
    }
    if (forceEntityUpdate || !(Objects.equal(oldType.getBlockFamily(), type.getBlockFamily()) && Objects.equal(oldType.getPrefab(), type.getPrefab()))) {
        updateBlockEntityComponents(blockEntity, oldType, type, retainComponents);
    }
    EntityRef regionEntity = blockRegionLookup.get(pos);
    if (regionEntity != null) {
        regionEntity.send(new OnChangedBlock(pos, type, oldType));
    }
    blockEntity.send(new OnChangedBlock(new Vector3i(pos), type, oldType));
}
Also used : OnChangedBlock(org.terasology.world.OnChangedBlock) Vector3i(org.terasology.math.geom.Vector3i) EntityRef(org.terasology.entitySystem.entity.EntityRef)

Aggregations

Vector3i (org.terasology.math.geom.Vector3i)246 Test (org.junit.Test)91 EntityRef (org.terasology.entitySystem.entity.EntityRef)34 Block (org.terasology.world.block.Block)32 Chunk (org.terasology.world.chunks.Chunk)30 Vector3f (org.terasology.math.geom.Vector3f)21 ReceiveEvent (org.terasology.entitySystem.event.ReceiveEvent)17 ChunkImpl (org.terasology.world.chunks.internal.ChunkImpl)17 Region3i (org.terasology.math.Region3i)15 BaseVector3i (org.terasology.math.geom.BaseVector3i)15 LocationComponent (org.terasology.logic.location.LocationComponent)14 BlockComponent (org.terasology.world.block.BlockComponent)10 Side (org.terasology.math.Side)9 ChunkViewCoreImpl (org.terasology.world.internal.ChunkViewCoreImpl)8 Before (org.junit.Before)7 Biome (org.terasology.world.biomes.Biome)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 CoreChunk (org.terasology.world.chunks.CoreChunk)6 RenderableChunk (org.terasology.world.chunks.RenderableChunk)6