Package org.terasology.world.block

Examples of org.terasology.world.block.Block


                target.x += direction.x * j;
                target.y += direction.y * j;
                target.z += direction.z * j;
                blockPos.set((int) target.x, (int) target.y, (int) target.z);
                Block currentBlock = worldProvider.getBlock(blockPos);

                /* PHYSICS */
                if (currentBlock.isDestructible()) {
                    blockEntityRegistry.getEntityAt(blockPos).send(new DoDamageEvent(1000, EngineDamageTypes.EXPLOSIVE.get()));
                }
            }
        }
    }
View Full Code Here


                    target.y += direction.y * j;
                    target.z += direction.z * j;

                    blockPos.set((int) target.x, (int) target.y, (int) target.z);

                    Block currentBlock = worldProvider.getBlock(blockPos);

                    if (currentBlock.isDestructible()) {
                        if (particleEffects < MAX_PARTICLE_EFFECTS) {
                            EntityBuilder builder = entityManager.newBuilder("engine:smokeExplosion");
                            builder.getComponent(LocationComponent.class).setWorldPosition(target);
                            builder.build();
                            particleEffects++;
View Full Code Here

            Vector3i blockPos = cameraTargetSystem.getTargetBlockPosition();
            AABB aabb = null;
            BlockComponent blockComp = target.getComponent(BlockComponent.class);
            BlockRegionComponent blockRegion = target.getComponent(BlockRegionComponent.class);
            if (blockComp != null || blockRegion != null) {
                Block block = worldProvider.getBlock(blockPos);
                aabb = block.getBounds(blockPos);
            } else {
                MeshComponent mesh = target.getComponent(MeshComponent.class);
                LocationComponent location = target.getComponent(LocationComponent.class);
                if (mesh != null && mesh.mesh != null && location != null) {
                    aabb = mesh.mesh.getAABB();
View Full Code Here

        Client client = createClientMock(PLAYER_ID, character);

        when(networkSystem.getPlayers()).thenReturn(Arrays.asList(client));

        BlockManagerImpl blockManager = CoreRegistry.put(BlockManager.class, new BlockManagerImpl(mock(WorldAtlas.class), new DefaultBlockFamilyFactoryRegistry()));
        testBlock = new Block();
        testBlock.setId((short) 1);
        blockManager.addBlockFamily(new SymmetricFamily(new BlockUri("test:testblock"), testBlock), true);
        testBlock2 = new Block();
        testBlock2.setId((short) 2);
        blockManager.addBlockFamily(new SymmetricFamily(new BlockUri("test:testblock2"), testBlock2), true);

        esm = new StorageManagerInternal(moduleManager.getEnvironment(), entityManager, false);
        CoreRegistry.put(StorageManager.class, esm);
View Full Code Here

    public void setup() throws Exception {
        super.setup();
        BlockManagerImpl blockManager = new BlockManagerImpl(new NullWorldAtlas(), new DefaultBlockFamilyFactoryRegistry());
        CoreRegistry.put(BlockManager.class, blockManager);
        airBlock = BlockManager.getAir();
        solidBlock = new Block();
        solidBlock.setDisplayName("Stone");
        solidBlock.setUri(new BlockUri("engine:stone"));
        solidBlock.setId((short) 1);
        for (Side side : Side.values()) {
            solidBlock.setFullSide(side, true);
        }
        solidBlock.setTranslucent(false);
        blockManager.addBlockFamily(new SymmetricFamily(solidBlock.getURI(), solidBlock), true);

        fullLight = new Block();
        fullLight.setDisplayName("Torch");
        fullLight.setUri(new BlockUri("engine:torch"));
        fullLight.setId((short) 2);
        fullLight.setLuminance(ChunkConstants.MAX_LIGHT);
        blockManager.addBlockFamily(new SymmetricFamily(fullLight.getURI(), fullLight), true);
View Full Code Here

        offset.sub(targetBlockComp.getPosition().toVector3f());
        Side offsetDir = Side.inDirection(offset);

        Vector3i primePos = new Vector3i(targetBlockComp.getPosition());
        primePos.add(offsetDir.getVector3i());
        Block primeBlock = worldProvider.getBlock(primePos);
        if (!primeBlock.isReplacementAllowed()) {
            event.consume();
            return;
        }
        Block belowBlock = worldProvider.getBlock(primePos.x, primePos.y - 1, primePos.z);
        Block aboveBlock = worldProvider.getBlock(primePos.x, primePos.y + 1, primePos.z);

        // Determine top and bottom blocks
        Vector3i bottomBlockPos;
        Vector3i topBlockPos;
        if (belowBlock.isReplacementAllowed()) {
            bottomBlockPos = new Vector3i(primePos.x, primePos.y - 1, primePos.z);
            topBlockPos = primePos;
        } else if (aboveBlock.isReplacementAllowed()) {
            bottomBlockPos = primePos;
            topBlockPos = new Vector3i(primePos.x, primePos.y + 1, primePos.z);
        } else {
            event.consume();
            return;
        }

        Side attachSide = determineAttachSide(facingDir, offsetDir, bottomBlockPos, topBlockPos);
        if (attachSide == null) {
            event.consume();
            return;
        }

        Side closedSide = facingDir.reverse();
        if (closedSide == attachSide || closedSide.reverse() == attachSide) {
            closedSide = attachSide.yawClockwise(1);
        }

        Block newBottomBlock = door.bottomBlockFamily.getBlockForPlacement(worldProvider, blockEntityRegistry, bottomBlockPos, closedSide, Side.TOP);
        Block newTopBlock = door.topBlockFamily.getBlockForPlacement(worldProvider, blockEntityRegistry, bottomBlockPos, closedSide, Side.TOP);

        Map<Vector3i, Block> blockMap = new HashMap<>();
        blockMap.put(bottomBlockPos, newBottomBlock);
        blockMap.put(topBlockPos, newTopBlock);
        PlaceBlocks blockEvent = new PlaceBlocks(blockMap, event.getInstigator());
View Full Code Here

    }

    private boolean canAttachTo(Vector3i doorPos, Side side) {
        Vector3i adjacentBlockPos = new Vector3i(doorPos);
        adjacentBlockPos.add(side.getVector3i());
        Block adjacentBlock = worldProvider.getBlock(adjacentBlockPos);
        return adjacentBlock.isAttachmentAllowed();
    }
View Full Code Here

    @ReceiveEvent(components = {DoorComponent.class, BlockRegionComponent.class, LocationComponent.class})
    public void onFrob(ActivateEvent event, EntityRef entity) {
        DoorComponent door = entity.getComponent(DoorComponent.class);
        Side newSide = (door.isOpen) ? door.closedSide : door.openSide;
        BlockRegionComponent regionComp = entity.getComponent(BlockRegionComponent.class);
        Block bottomBlock = door.bottomBlockFamily.getBlockForPlacement(worldProvider, blockEntityRegistry, regionComp.region.min(), newSide, Side.TOP);
        worldProvider.setBlock(regionComp.region.min(), bottomBlock);
        Block topBlock = door.topBlockFamily.getBlockForPlacement(worldProvider, blockEntityRegistry, regionComp.region.max(), newSide, Side.TOP);
        worldProvider.setBlock(regionComp.region.max(), topBlock);
        StaticSound sound = (door.isOpen) ? door.closeSound : door.openSound;
        if (sound != null) {
            LocationComponent loc = entity.getComponent(LocationComponent.class);
            audioManager.playSound(sound, loc.getWorldPosition(), 10, 1);
View Full Code Here

            float density = solidityFacet.get(pos);
            if (density >= 32) {
                chunk.setBlock(pos, stone);
            } else if (density >= 0) {
                int depth = TeraMath.floorToInt(surfaceFacet.get(pos2d)) - pos.y - chunk.getChunkWorldOffsetY();
                Block block = getSurfaceBlock(depth, pos.y + chunk.getChunkWorldOffsetY(), biome);
                chunk.setBlock(pos, block);
            } else {
                int posY = pos.y + chunk.getChunkWorldOffsetY();

                if (posY == 32 && CoreBiome.SNOW == biomeFacet.get(pos2d)) {
View Full Code Here

    @Before
    public void setup() throws IOException {
        BlockManagerImpl blockManager = new BlockManagerImpl(new NullWorldAtlas(), new DefaultBlockFamilyFactoryRegistry());
        CoreRegistry.put(BlockManager.class, blockManager);
        airBlock = BlockManager.getAir();
        solidBlock = new Block();
        solidBlock.setDisplayName("Stone");
        solidBlock.setUri(new BlockUri("engine:stone"));
        blockManager.addBlockFamily(new SymmetricFamily(solidBlock.getURI(), solidBlock), true);
        solidBlock = blockManager.getBlock(solidBlock.getURI());
    }
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.