Package org.terasology.math

Examples of org.terasology.math.Vector3i


    }

    @Test
    public void removeSolidAndLight() {
        StubPropagatorWorldView worldView = new StubPropagatorWorldView(testingRegion);
        for (Vector3i pos : Region3i.createFromCenterExtents(new Vector3i(1, 0, 0), new Vector3i(0, 30, 30))) {
            worldView.setBlockAt(pos, solid);
        }
        worldView.setBlockAt(new Vector3i(0, 0, 0), fullLight);
        BatchPropagator propagator = new StandardBatchPropagator(lightRules, worldView);
        propagator.process(new BlockChange(new Vector3i(0, 0, 0), air, fullLight));

        assertEquals(0, worldView.getValueAt(new Vector3i(1, 0, 0)));

        worldView.setBlockAt(new Vector3i(1, 0, 0), air);
        worldView.setBlockAt(new Vector3i(0, 0, 0), air);
        propagator.process(new BlockChange(new Vector3i(1, 0, 0), solid, air), new BlockChange(new Vector3i(0, 0, 0), fullLight, air));

        for (int i = 0; i < fullLight.getLuminance() + 1; ++i) {
            byte expectedLuminance = (byte) 0;
            for (Vector3i pos : Diamond3iIterator.iterateAtDistance(Vector3i.zero(), i)) {
                assertEquals(expectedLuminance, worldView.getValueAt(pos));
View Full Code Here


        return null//To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public Block getBlock(int x, int y, int z) {
        Block result = blocks.get(new Vector3i(x, y, z));
        if (result == null) {
            return air;
        }
        return result;
    }
View Full Code Here

    }


    @Test
    public void betweenChunksSimple() {
        Chunk topChunk = new ChunkImpl(new Vector3i(0, 1, 0));
        Chunk bottomChunk = new ChunkImpl(new Vector3i(0, 0, 0));

        provider.addChunk(topChunk);
        provider.addChunk(bottomChunk);

        for (Vector3i pos : Region3i.createFromMinAndSize(new Vector3i(0, 0, 0), new Vector3i(ChunkConstants.SIZE_X, 1, ChunkConstants.SIZE_Z))) {
            topChunk.setSunlight(pos, ChunkConstants.MAX_SUNLIGHT);
            topChunk.setSunlightRegen(pos, ChunkConstants.MAX_SUNLIGHT_REGEN);
        }
        InternalLightProcessor.generateInternalLighting(bottomChunk);
        propagator.propagateBetween(topChunk, bottomChunk, Side.BOTTOM, true);
View Full Code Here

        }
    }

    @Test
    public void betweenChunksSimpleSunlightRegenOnly() {
        Chunk topChunk = new ChunkImpl(new Vector3i(0, 1, 0));
        Chunk bottomChunk = new ChunkImpl(new Vector3i(0, 0, 0));

        provider.addChunk(topChunk);
        provider.addChunk(bottomChunk);

        for (Vector3i pos : Region3i.createFromMinAndSize(new Vector3i(0, 0, 0), new Vector3i(ChunkConstants.SIZE_X, 1, ChunkConstants.SIZE_Z))) {
            topChunk.setSunlight(pos, ChunkConstants.MAX_SUNLIGHT);
            topChunk.setSunlightRegen(pos, ChunkConstants.MAX_SUNLIGHT_REGEN);
        }
        InternalLightProcessor.generateInternalLighting(bottomChunk);
        propagator.propagateBetween(topChunk, bottomChunk, Side.BOTTOM, true);
View Full Code Here

        }
    }

    @Test
    public void betweenChunksWithOverhang() {
        Chunk topChunk = new ChunkImpl(new Vector3i(0, 1, 0));
        Chunk bottomChunk = new ChunkImpl(new Vector3i(0, 0, 0));

        provider.addChunk(topChunk);
        provider.addChunk(bottomChunk);

        for (Vector3i pos : Region3i.createFromMinAndSize(new Vector3i(0, 0, 0), new Vector3i(ChunkConstants.SIZE_X, 1, ChunkConstants.SIZE_Z))) {
            topChunk.setSunlight(pos, ChunkConstants.MAX_SUNLIGHT);
            topChunk.setSunlightRegen(pos, ChunkConstants.MAX_SUNLIGHT_REGEN);
        }
        for (Vector3i pos : Region3i.createFromMinMax(new Vector3i(16, 48, 0), new Vector3i(31, 48, 31))) {
            bottomChunk.setBlock(pos, solid);
        }
        InternalLightProcessor.generateInternalLighting(bottomChunk);

        propagator.propagateBetween(topChunk, bottomChunk, Side.BOTTOM, false);
View Full Code Here

        }
    }

    @Test
    public void propagateSunlightAppearingMidChunk() {
        Chunk topChunk = new ChunkImpl(new Vector3i(0, 1, 0));
        Chunk bottomChunk = new ChunkImpl(new Vector3i(0, 0, 0));

        provider.addChunk(topChunk);
        provider.addChunk(bottomChunk);

        for (Vector3i pos : Region3i.createFromMinAndSize(new Vector3i(0, 0, 0), new Vector3i(ChunkConstants.SIZE_X, 1, ChunkConstants.SIZE_Z))) {
            topChunk.setSunlight(pos, (byte) 0);
            topChunk.setSunlightRegen(pos, (byte) 0);
        }
        for (Vector3i pos : Region3i.createFromMinAndSize(new Vector3i(8, 0, 8), new Vector3i(ChunkConstants.SIZE_X - 16, 1, ChunkConstants.SIZE_Z - 16))) {
            topChunk.setSunlight(pos, (byte) 0);
            topChunk.setSunlightRegen(pos, (byte) 32);
        }
        InternalLightProcessor.generateInternalLighting(bottomChunk);
View Full Code Here

    @Override
    public PersistedData serialize(EntityRef value, SerializationContext context) {
        BlockComponent blockComponent = value.getComponent(BlockComponent.class);
        if (blockComponent != null) {
            Vector3i pos = blockComponent.getPosition();
            return context.create(pos.x, pos.y, pos.z);
        }
        NetworkComponent netComponent = value.getComponent(NetworkComponent.class);
        if (netComponent != null) {
            return context.create(netComponent.getNetworkId());
View Full Code Here

    public EntityRef deserialize(PersistedData data, DeserializationContext context) {
        if (data.isArray()) {
            PersistedDataArray array = data.getAsArray();
            if (array.isNumberArray() && array.size() == 3) {
                TIntList items = data.getAsArray().getAsIntegerArray();
                Vector3i pos = new Vector3i(items.get(0), items.get(1), items.get(2));
                return blockEntityRegistry.getBlockEntityAt(pos);
            }
        }
        if (data.isNumber()) {
            return networkSystem.getEntity(data.getAsInteger());
View Full Code Here

    public PersistedData serializeCollection(Collection<EntityRef> value, SerializationContext context) {
        List<PersistedData> items = Lists.newArrayList();
        for (EntityRef ref : value) {
            BlockComponent blockComponent = ref.getComponent(BlockComponent.class);
            if (blockComponent != null) {
                Vector3i blockPos = blockComponent.getPosition();
                items.add(context.create(blockPos.x, blockPos.y, blockPos.z));
            } else {
                NetworkComponent netComponent = ref.getComponent(NetworkComponent.class);
                if (netComponent != null) {
                    items.add(context.create(netComponent.getNetworkId()));
View Full Code Here

    }

    @Override
    public Region3i deserialize(PersistedData data, DeserializationContext context) {
        PersistedDataMap map = data.getAsValueMap();
        Vector3i min = context.deserializeAs(map.get(MIN_FIELD), Vector3i.class);
        Vector3i size = context.deserializeAs(map.get(SIZE_FIELD), Vector3i.class);
        return Region3i.createFromMinAndSize(min, size);
    }
View Full Code Here

TOP

Related Classes of org.terasology.math.Vector3i

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.