Search in sources :

Example 6 with BlockRegion

use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.

the class StandardBatchPropagator method propagateBetween.

@Override
public void propagateBetween(Chunk chunk, Chunk adjChunk, Side side, boolean propagateExternal) {
    Function<Vector3ic, Integer> indexProvider = createIndexProvider(side);
    BlockRegion edgeRegion = new BlockRegion(0, 0, 0).setSize(Chunks.SIZE_X, Chunks.SIZE_Y, Chunks.SIZE_Z);
    edgeRegion.face(side, edgeRegion);
    int[] depth = new int[edgeRegion.volume()];
    propagateSide(chunk, adjChunk, side, indexProvider, edgeRegion, depth);
    propagateDepth(adjChunk, side, propagateExternal, indexProvider, edgeRegion, depth);
}
Also used : Vector3ic(org.joml.Vector3ic) BlockRegion(org.terasology.engine.world.block.BlockRegion)

Example 7 with BlockRegion

use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.

the class BlockSelectionComponent method copyFrom.

@Override
public void copyFrom(BlockSelectionComponent other) {
    this.startPosition = new Vector3i(other.startPosition);
    this.currentSelection = new BlockRegion(other.currentSelection);
    this.shouldRender = other.shouldRender;
    this.texture = other.texture;
    this.isMovable = other.isMovable;
}
Also used : Vector3i(org.joml.Vector3i) BlockRegion(org.terasology.engine.world.block.BlockRegion)

Example 8 with BlockRegion

use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.

the class ChunkViewCoreImpl method setDirtyAround.

@Override
public void setDirtyAround(BlockRegionc region) {
    BlockRegion tmp = new BlockRegion(region).expand(1, 1, 1);
    for (Vector3ic pos : Chunks.toChunkRegion(tmp, tmp)) {
        int px = pos.x() + offset.x;
        int py = pos.y() + offset.y;
        int pz = pos.z() + offset.z;
        Chunk chunk = chunks[px + chunkRegion.getSizeX() * (pz + chunkRegion.getSizeZ() * py)];
        if (chunk != null) {
            chunk.setDirty(true);
        }
    }
}
Also used : Vector3ic(org.joml.Vector3ic) BlockRegion(org.terasology.engine.world.block.BlockRegion) Chunk(org.terasology.engine.world.chunks.Chunk)

Example 9 with BlockRegion

use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.

the class LayeredZoneRegionFunctionTest method setup.

@BeforeEach
public void setup() {
    parent.addZone(new Zone("Medium sky", new LayeredZoneRegionFunction(new MinMaxLayerThickness(100, 100), MEDIUM_SKY))).addZone(new Zone("Low sky", new LayeredZoneRegionFunction(new MinMaxLayerThickness(100, 100), LOW_SKY))).addZone(new Zone("Above ground", new LayeredZoneRegionFunction(new MinMaxLayerThickness(100, 100), ABOVE_GROUND))).addZone(new Zone("Ground", new LayeredZoneRegionFunction(new MinMaxLayerThickness(100, 100), GROUND))).addZone(new Zone("Shallow underground", new LayeredZoneRegionFunction(new MinMaxLayerThickness(100, 100), SHALLOW_UNDERGROUND))).addZone(new Zone("Medium underground", new LayeredZoneRegionFunction(new MinMaxLayerThickness(100, 100), MEDIUM_UNDERGROUND)));
    parent.setSeed(12345);
    parent.initialize();
    ListMultimap<Class<? extends WorldFacet>, FacetProvider> facetProviderChains = ArrayListMultimap.create();
    facetProviderChains.put(ElevationFacet.class, (generatingRegion) -> {
        ElevationFacet facet = new ElevationFacet(generatingRegion.getRegion(), generatingRegion.getBorderForFacet(ElevationFacet.class));
        for (Vector2ic pos : facet.getRelativeArea()) {
            facet.set(pos, 100);
        }
        generatingRegion.setRegionFacet(ElevationFacet.class, facet);
    });
    Map<Class<? extends WorldFacet>, Border3D> borders = new HashMap<>();
    borders.put(ElevationFacet.class, new Border3D(0, 0, 0));
    region = new RegionImpl(new BlockRegion(0, 0, 0).expand(4, 4, 4), facetProviderChains, borders, 1);
}
Also used : HashMap(java.util.HashMap) Zone(org.terasology.engine.world.zones.Zone) FacetProvider(org.terasology.engine.world.generation.FacetProvider) Border3D(org.terasology.engine.world.generation.Border3D) MinMaxLayerThickness(org.terasology.engine.world.zones.MinMaxLayerThickness) LayeredZoneRegionFunction(org.terasology.engine.world.zones.LayeredZoneRegionFunction) ElevationFacet(org.terasology.engine.world.generation.facets.ElevationFacet) WorldFacet(org.terasology.engine.world.generation.WorldFacet) Vector2ic(org.joml.Vector2ic) BlockRegion(org.terasology.engine.world.block.BlockRegion) RegionImpl(org.terasology.engine.world.generation.RegionImpl) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 10 with BlockRegion

use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.

the class LocalChunkProviderTest method requestCreatingOrLoadingArea.

private Future<Chunk> requestCreatingOrLoadingArea(Vector3ic chunkPosition, int radius) {
    Future<Chunk> chunkFuture = chunkProvider.createOrLoadChunk(chunkPosition);
    BlockRegion extentsRegion = new BlockRegion(chunkPosition.x() - radius, chunkPosition.y() - radius, chunkPosition.z() - radius, chunkPosition.x() + radius, chunkPosition.y() + radius, chunkPosition.z() + radius);
    extentsRegion.iterator().forEachRemaining(pos -> {
        if (!pos.equals(chunkPosition)) {
            // remove center. we takes future for it already.
            chunkProvider.createOrLoadChunk(pos);
        }
    });
    return chunkFuture;
}
Also used : BlockRegion(org.terasology.engine.world.block.BlockRegion) Chunk(org.terasology.engine.world.chunks.Chunk)

Aggregations

BlockRegion (org.terasology.engine.world.block.BlockRegion)52 Vector3i (org.joml.Vector3i)29 Vector3ic (org.joml.Vector3ic)26 Test (org.junit.jupiter.api.Test)26 Chunk (org.terasology.engine.world.chunks.Chunk)23 ChunkImpl (org.terasology.engine.world.chunks.internal.ChunkImpl)11 ChunkViewCoreImpl (org.terasology.engine.world.internal.ChunkViewCoreImpl)7 ChunkViewCore (org.terasology.engine.world.internal.ChunkViewCore)5 Vector3f (org.joml.Vector3f)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 ReceiveEvent (org.terasology.engine.entitySystem.event.ReceiveEvent)4 Border3D (org.terasology.engine.world.generation.Border3D)4 WorldGeneratorPluginLibrary (org.terasology.engine.world.generator.plugin.WorldGeneratorPluginLibrary)4 ElevationFacet (org.terasology.engine.world.generation.facets.ElevationFacet)3 Vector2ic (org.joml.Vector2ic)2 RenderableChunk (org.terasology.engine.world.chunks.RenderableChunk)2 PreLodChunk (org.terasology.engine.world.chunks.internal.PreLodChunk)2 Region (org.terasology.engine.world.generation.Region)2 World (org.terasology.engine.world.generation.World)2 JsonElement (com.google.gson.JsonElement)1