当前位置: 首页>>代码示例>>Java>>正文


Java Block.isSolid方法代码示例

本文整理汇总了Java中cn.nukkit.block.Block.isSolid方法的典型用法代码示例。如果您正苦于以下问题:Java Block.isSolid方法的具体用法?Java Block.isSolid怎么用?Java Block.isSolid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cn.nukkit.block.Block的用法示例。


在下文中一共展示了Block.isSolid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isInsideOfSolid

import cn.nukkit.block.Block; //导入方法依赖的package包/类
public boolean isInsideOfSolid() {
    double y = this.y + this.getEyeHeight();
    Block block = this.level.getBlock(
            this.temporalVector.setComponents(
                    NukkitMath.floorDouble(this.x),
                    NukkitMath.floorDouble(y),
                    NukkitMath.floorDouble(this.z))
    );

    AxisAlignedBB bb = block.getBoundingBox();

    return bb != null && block.isSolid() && !block.isTransparent() && bb.intersectsWith(this.getBoundingBox());

}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:15,代码来源:Entity.java

示例2: populate

import cn.nukkit.block.Block; //导入方法依赖的package包/类
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    FullChunk chunk = level.getChunk(chunkX, chunkZ);
    for (int x = 0; x < 16; ++x) {
        for (int z = 0; z < 16; ++z) {
            Biome biome = Biome.getBiome(chunk.getBiomeId(x, z));
            Block[] cover = biome.getGroundCover();
            if (cover != null && cover.length > 0) {
                int diffY = 0;
                if (!cover[0].isSolid()) {
                    diffY = 1;
                }

                byte[] column = chunk.getBlockIdColumn(x, z);
                int y;
                for (y = 127; y > 0; --y) {
                    if (column[y] != 0x00 && !Block.get(column[y] & 0xff).isTransparent()) {
                        break;
                    }
                }
                int startY = Math.min(127, y + diffY);
                int endY = startY - cover.length;
                for (y = startY; y > endY && y >= 0; --y) {
                    Block b = cover[startY - y];
                    if (column[y] == 0x00 && b.isSolid()) {
                        break;
                    }
                    if (b.getDamage() == 0) {
                        chunk.setBlockId(x, y, z, b.getId());
                    } else {
                        chunk.setBlock(x, y, z, b.getId(), b.getDamage());
                    }
                }
            }
        }
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:38,代码来源:PopulatorGroundCover.java

示例3: onActivate

import cn.nukkit.block.Block; //导入方法依赖的package包/类
@Override
public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) {
    FullChunk chunk = level.getChunk((int) block.getX() >> 4, (int) block.getZ() >> 4);

    if (chunk == null) {
        return false;
    }

    if (!target.isTransparent() && face.getIndex() > 1 && !block.isSolid()) {
        int[] direction = {2, 0, 1, 3};
        int[] right = {4, 5, 3, 2};

        List<EntityPainting.Motive> validMotives = new ArrayList<>();
        for (EntityPainting.Motive motive : EntityPainting.motives) {
            boolean valid = true;
            for (int x = 0; x < motive.width && valid; x++) {
                for (int z = 0; z < motive.height && valid; z++) {
                    if (target.getSide(BlockFace.fromIndex(right[face.getIndex() - 2]), x).isTransparent() ||
                            target.up(z).isTransparent() ||
                            block.getSide(BlockFace.fromIndex(right[face.getIndex() - 2]), x).isSolid() ||
                            block.up(z).isSolid()) {
                        valid = false;
                    }
                }
            }

            if (valid) {
                validMotives.add(motive);
            }
        }

        CompoundTag nbt = new CompoundTag()
                .putByte("Direction", direction[face.getIndex() - 2])
                .putString("Motive", validMotives.get(ThreadLocalRandom.current().nextInt(validMotives.size())).title)
                .putList(new ListTag<DoubleTag>("Pos")
                        .add(new DoubleTag("0", target.x))
                        .add(new DoubleTag("1", target.y))
                        .add(new DoubleTag("2", target.z)))
                .putList(new ListTag<DoubleTag>("Motion")
                        .add(new DoubleTag("0", 0))
                        .add(new DoubleTag("1", 0))
                        .add(new DoubleTag("2", 0)))
                .putList(new ListTag<FloatTag>("Rotation")
                        .add(new FloatTag("0", direction[face.getIndex() - 2] * 90))
                        .add(new FloatTag("1", 0)));

        EntityPainting entity = new EntityPainting(chunk, nbt);

        if (player.isSurvival()) {
            Item item = player.getInventory().getItemInHand();
            item.setCount(item.getCount() - 1);
            player.getInventory().setItemInHand(item);
        }
        entity.spawnToAll();

        return true;
    }

    return false;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:61,代码来源:ItemPainting.java

示例4: onUpdate

import cn.nukkit.block.Block; //导入方法依赖的package包/类
@Override
public boolean onUpdate() {
    if (this.closed) {
        return false;
    }

    this.timing.startTiming();

    if (!(this.chunk instanceof Chunk)) {
        return false;
    }

    if (!(this.canUpdate())) {
        return false;
    }

    if (this.namedTag.getInt("Delay") <= 0) {
        int success = 0;
        NukkitRandom random = new NukkitRandom();
        for (int i = 0; i < this.namedTag.getInt("SpawnCount"); ++i) {
            Vector3 pos = this.add(
                    this.getRandomSpawn(), 
                    NukkitMath.randomRange(random, -1, 1), 
                    this.getRandomSpawn());
            Block target = this.getLevel().getBlock(pos);
            Block ground = target.down();
            if (target.getId() == Block.AIR && ground.isSolid()) {
                ++success;
                CompoundTag nbt = new CompoundTag()
                        .putList(new ListTag<DoubleTag>("Pos")
                                .add(new DoubleTag("", pos.x))
                                .add(new DoubleTag("", pos.y))
                                .add(new DoubleTag("", pos.z)))
                        .putList(new ListTag<DoubleTag>("Motion")
                                .add(new DoubleTag("", 0))
                                .add(new DoubleTag("", 0))
                                .add(new DoubleTag("", 0)))
                        .putList(new ListTag<FloatTag>("Rotation")
                                .add(new FloatTag("", (float) Math.random() * 360))
                                .add(new FloatTag("", (float) 0)));

                Entity entity = Entity.createEntity(this.getNetworkId(), this.chunk, nbt);
                entity.spawnToAll();
            }
        }

        if (success > 0) {
            this.namedTag.putInt("Delay", NukkitMath.randomRange(random, this.namedTag.getInt("MinSpawnDelay"), this.namedTag.getInt("MaxSpawnDelay")));
        }

    } else {
        this.namedTag.putInt("Delay", this.namedTag.getInt("Delay") - 1);
    }

    this.timing.stopTiming();

    return true;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:59,代码来源:BlockEntityMobSpawner.java


注:本文中的cn.nukkit.block.Block.isSolid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。