Package org.terasology.world.block

Examples of org.terasology.world.block.Block


        this.world = world;
    }

    @Override
    public VoxelInfo getCollisionShapeAt(int x, int y, int z) {
        Block block = world.getBlock(x, y, z);
        return new LiquidVoxelInfo(block, new Vector3i(x, y, z));
    }
View Full Code Here


        Vector3i chunkPos = TeraMath.calcChunkPos(worldPos);
        CoreChunk chunk = chunkProvider.getChunk(chunkPos);
        if (chunk != null) {
            Vector3i blockPos = TeraMath.calcBlockPos(worldPos);
            chunk.lock();
            Block oldBlockType = chunk.setBlock(blockPos, type);
            chunk.unlock();
            if (oldBlockType != type) {
                BlockChange oldChange = blockChanges.get(worldPos);
                if (oldChange == null) {
                    blockChanges.put(worldPos, new BlockChange(worldPos, oldBlockType, type));
View Full Code Here

    @Override
    public Block setBlock(Vector3i pos, Block type) {
        if (GameThread.isCurrentThread()) {
            EntityRef blockEntity = getBlockEntityAt(pos);
            Block oldType = super.setBlock(pos, type);
            if (oldType != null) {
                updateBlockEntity(blockEntity, pos, oldType, type, false, Collections.<Class<? extends Component>>emptySet());
            }
            return oldType;
        }
View Full Code Here

    @Override
    @SafeVarargs
    public final Block setBlockRetainComponent(Vector3i pos, Block type, Class<? extends Component>... components) {
        if (GameThread.isCurrentThread()) {
            EntityRef blockEntity = getBlockEntityAt(pos);
            Block oldType = super.setBlock(pos, type);
            if (oldType != null) {
                updateBlockEntity(blockEntity, pos, oldType, type, false, Sets.newHashSet(components));
            }
            return oldType;
        }
View Full Code Here

    @Override
    public Block setBlockForceUpdateEntity(Vector3i pos, Block type) {
        if (GameThread.isCurrentThread()) {
            EntityRef blockEntity = getBlockEntityAt(pos);
            Block oldType = super.setBlock(pos, type);
            if (oldType != null) {
                updateBlockEntity(blockEntity, pos, oldType, type, true, Collections.<Class<? extends Component>>emptySet());
            }
            return oldType;
        }
View Full Code Here

    @Override
    public EntityRef getBlockEntityAt(Vector3i blockPosition) {
        if (GameThread.isCurrentThread()) {
            EntityRef blockEntity = getExistingBlockEntityAt(blockPosition);
            if (!blockEntity.exists() && isBlockRelevant(blockPosition.x, blockPosition.y, blockPosition.z)) {
                Block block = getBlock(blockPosition.x, blockPosition.y, blockPosition.z);
                blockEntity = createBlockEntity(blockPosition, block);
            }
            return blockEntity;
        }
        logger.error("Attempted to get block entity off-thread");
View Full Code Here

    @Override
    public void onEntityComponentRemoved(EntityRef entity, Class<? extends Component> component) {
        if (entityManager.getComponentLibrary().getMetadata(component).isForceBlockActive()) {
            BlockComponent blockComp = entity.getComponent(BlockComponent.class);
            if (blockComp != null) {
                Block block = getBlock(blockComp.getPosition().x, blockComp.getPosition().y, blockComp.getPosition().z);
                if (isTemporaryBlock(entity, block, component)) {
                    temporaryBlockEntities.add(entity);
                }
            }
        }
View Full Code Here

        // Now make sure we have all combinations based on the basic set (above) and rotations
        for (byte connections = 0; connections < 64; connections++) {
            // Only the allowed connections should be created
            if ((connections & connectionSides) == connections) {
                Block block = constructBlockForConnections(connections, blockBuilder, blockDefUri, basicBlocks);
                if (block == null) {
                    throw new IllegalStateException("Unable to find correct block definition for connections: " + connections);
                }
                block.setUri(new BlockUri(blockUri, String.valueOf(connections)));
                blocksForConnections.put(connections, block);
            }
        }

        final Block archetypeBlock = blocksForConnections.get(SideBitFlag.getSides(Side.RIGHT, Side.LEFT));
        return new UpdatesWithNeighboursFamily(connectionCondition, blockUri, blockDefinition.categories,
                archetypeBlock, blocksForConnections, connectionSides);
    }
View Full Code Here

@RegisterBlockFamilyFactory("symmetric")
public class SymmetricBlockFamilyFactory implements BlockFamilyFactory {

    @Override
    public BlockFamily createBlockFamily(BlockBuilderHelper blockBuilder, AssetUri blockDefUri, BlockDefinition blockDefinition, JsonObject blockDefJson) {
        Block block = blockBuilder.constructSimpleBlock(blockDefUri, blockDefinition);
        return new SymmetricFamily(new BlockUri(blockDefUri.getModuleName(), blockDefUri.getAssetName()), block, blockDefinition.categories);
    }
View Full Code Here

            }
        }
    }

    private void purge(Vector3i pos, byte oldValue) {
        Block block = world.getBlockAt(pos);
        increaseQueues[rules.getMaxValue() - oldValue].remove(pos);
        byte fixedValue = rules.getFixedValue(block, pos);
        if (fixedValue > 0) {
            increase(pos, fixedValue);
        } else {
            world.setValueAt(pos, NO_VALUE);
        }

        for (Side side : Side.values()) {
            byte expectedValue = rules.propagateValue(oldValue, side, block);
            Vector3i adjPos = side.getAdjacentPos(pos);
            if (rules.canSpreadOutOf(block, side)) {
                byte adjValue = world.getValueAt(adjPos);
                if (adjValue == expectedValue) {
                    Block adjBlock = world.getBlockAt(adjPos);
                    if (rules.canSpreadInto(adjBlock, side.reverse())) {
                        reduce(adjPos, expectedValue);
                    }
                } else if (adjValue > 0) {
                    queueSpreadValue(adjPos, adjValue);
View Full Code Here

TOP

Related Classes of org.terasology.world.block.Block

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.