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


Java Block类代码示例

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


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

示例1: populate

import cn.nukkit.block.Block; //导入依赖的package包/类
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    BaseFullChunk chunk = level.getChunk(chunkX, chunkZ);
    int bx = chunkX << 4;
    int bz = chunkZ << 4;
    int tx = bx + 15;
    int tz = bz + 15;
    int amount = random.nextRange(0, this.randomAmount + 1) + this.baseAmount;
    for (int i = 0; i < amount; ++i) {
        int x = random.nextRange(0, 15);
        int z = random.nextRange(0, 15);
        int y = this.getHighestWorkableBlock(chunk, x, z);
        if (y != -1 && this.canGroundFireStay(chunk, x, y, z)) {
            chunk.setBlock(x, y, z, Block.FIRE);
            chunk.setBlockLight(x, y, z, Block.light[Block.FIRE]);
        }
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:20,代码来源:PopulatorGroundFire.java

示例2: populate

import cn.nukkit.block.Block; //导入依赖的package包/类
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
    for (int i = 0; i < amount; ++i) {
        int x = NukkitMath.randomRange(random, chunkX * 16, chunkX * 16 + 15);
        int z = NukkitMath.randomRange(random, chunkZ * 16, chunkZ * 16 + 15);
        int y = this.getHighestWorkableBlock(x, z);

        if (y != -1 && this.canTallGrassStay(x, y, z)) {
            this.level.setBlockIdAt(x, y, z, Block.DOUBLE_PLANT);
            this.level.setBlockDataAt(x, y, z, 2);
            this.level.setBlockIdAt(x, y + 1, z, Block.DOUBLE_PLANT);
            this.level.setBlockDataAt(x, y + 1, z, 10);
        }
    }
}
 
开发者ID:CoreXDevelopment,项目名称:CoreX,代码行数:18,代码来源:PopulatorTallGrass.java

示例3: get

import cn.nukkit.block.Block; //导入依赖的package包/类
public static Item get(int id, Integer meta, int count, byte[] tags) {
    try {
        Class c = list[id];
        Item item;

        if (c == null) {
            item = new Item(id, meta, count);
        } else if (id < 256) {
            item = new ItemBlock((Block) c.getConstructor(int.class).newInstance(meta), meta, count);
        } else {
            item = ((Item) c.getConstructor(Integer.class, int.class).newInstance(meta, count));
        }

        if (tags.length != 0) {
            item.setCompoundTag(tags);
        }

        return item;
    } catch (Exception e) {
        return new Item(id, meta, count).setCompoundTag(tags);
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:23,代码来源:Item.java

示例4: growGrass

import cn.nukkit.block.Block; //导入依赖的package包/类
public static void growGrass(ChunkManager level, Vector3 pos, NukkitRandom random, int count, int radius) {
    int[][] arr = {
            {Block.DANDELION, 0},
            {Block.POPPY, 0},
            {Block.TALL_GRASS, 1},
            {Block.TALL_GRASS, 1},
            {Block.TALL_GRASS, 1},
            {Block.TALL_GRASS, 1}
    };
    int arrC = arr.length - 1;
    for (int c = 0; c < count; c++) {
        int x = random.nextRange((int) (pos.x - radius), (int) (pos.x + radius));
        int z = random.nextRange((int) (pos.z) - radius, (int) (pos.z + radius));

        if (level.getBlockIdAt(x, (int) (pos.y + 1), z) == Block.AIR && level.getBlockIdAt(x, (int) (pos.y), z) == Block.GRASS) {
            int[] t = arr[random.nextRange(0, arrC)];
            level.setBlockIdAt(x, (int) (pos.y + 1), z, t[0]);
            level.setBlockDataAt(x, (int) (pos.y + 1), z, t[1]);
        }
    }
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:22,代码来源:ObjectTallGrass.java

示例5: updateBlock

import cn.nukkit.block.Block; //导入依赖的package包/类
public void updateBlock() {
    Block block = this.getLevelBlock();

    if (!(block instanceof BlockBrewingStand)) {
        return;
    }

    int meta = 0;

    for (int i = 1; i <= 3; ++i) {
        Item potion = this.inventory.getItem(i);

        if (potion.getId() == Item.POTION && potion.getCount() > 0) {
            meta |= 1 << i;
        }
    }

    block.setDamage(meta);
    this.level.setBlock(block, block, false, false);
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:21,代码来源:BlockEntityBrewingStand.java

示例6: onCustomName

import cn.nukkit.block.Block; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL,ignoreCancelled = true)
public void onCustomName(PlayerInteractEvent event){
    if(event.getBlock().getId() == Block.CHEST) {
        if (ChestLocker.getInstance().getCustomName().containsKey(event.getPlayer().getName())) {
            Block block = event.getBlock();
            BlockEntity chestP = event.getBlock().getLevel().getBlockEntity(block);
            if(chestP instanceof BlockEntityChest){
                BlockEntityChest chest = (BlockEntityChest)chestP;
                if(EconomyAPI.getInstance().myMoney(event.getPlayer()) >= 500) {
                    chest.setName(ChestLocker.getInstance().getCustomName().get(event.getPlayer().getName()));
                    event.getPlayer().sendMessage("设置成功");
                    ChestLocker.getInstance().getCustomName().remove(event.getPlayer().getName());
                    EconomyAPI.getInstance().reduceMoney(event.getPlayer(),500);
                }else{
                    event.getPlayer().sendMessage("你没有足够的金钱");
                    ChestLocker.getInstance().getCustomName().remove(event.getPlayer().getName());
                }
            }
        }
    }
}
 
开发者ID:zzz1999,项目名称:ChestLocker,代码行数:22,代码来源:EventListener.java

示例7: 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) {
    if (face != BlockFace.UP) return false;
    EntityBoat boat = new EntityBoat(
            level.getChunk(block.getFloorX() >> 4, block.getFloorZ() >> 4), new CompoundTag("")
            .putList(new ListTag<DoubleTag>("Pos")
                    .add(new DoubleTag("", block.getX() + 0.5))
                    .add(new DoubleTag("", block.getY() - 0.0625))
                    .add(new DoubleTag("", block.getZ() + 0.5)))
            .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) ((player.yaw + 90f) % 360)))
                    .add(new FloatTag("", 0)))
            .putByte("woodID", this.getDamage())
    );

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

    boat.spawnToAll();
    return true;
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:29,代码来源:ItemBoat.java

示例8: BlockPlaceEvent

import cn.nukkit.block.Block; //导入依赖的package包/类
public BlockPlaceEvent(Player player, Block blockPlace, Block blockReplace, Block blockAgainst, Item item) {
    super(blockPlace);
    this.blockReplace = blockReplace;
    this.blockAgainst = blockAgainst;
    this.item = item;
    this.player = player;
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:8,代码来源:BlockPlaceEvent.java

示例9: getMetadata

import cn.nukkit.block.Block; //导入依赖的package包/类
@Override
public List<MetadataValue> getMetadata(Object block, String metadataKey) {
    if (!(block instanceof Block)) {
        throw new IllegalArgumentException("Object must be a Block");
    }
    if (((Block) block).getLevel() == this.owningLevel) {
        return super.getMetadata(block, metadataKey);
    } else {
        throw new IllegalStateException("Block does not belong to world " + this.owningLevel.getName());
    }
}
 
开发者ID:CoreXDevelopment,项目名称:CoreX,代码行数:12,代码来源:BlockMetadataStore.java

示例10: PlayerBucketEvent

import cn.nukkit.block.Block; //导入依赖的package包/类
public PlayerBucketEvent(Player who, Block blockClicked, BlockFace blockFace, Item bucket, Item itemInHand) {
    this.player = who;
    this.blockClicked = blockClicked;
    this.blockFace = blockFace;
    this.item = itemInHand;
    this.bucket = bucket;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:8,代码来源:PlayerBucketEvent.java

示例11: equals

import cn.nukkit.block.Block; //导入依赖的package包/类
@Override
public boolean equals(Object object) {
    if (!(object instanceof BlockUpdateEntry)) {
        return false;
    } else {
        BlockUpdateEntry entry = (BlockUpdateEntry) object;
        return this.pos.equals(entry.pos) && Block.equals(this.block, entry.block, false);
    }
}
 
开发者ID:CoreXDevelopment,项目名称:CoreX,代码行数:10,代码来源:BlockUpdateEntry.java

示例12: isSuitableBlock

import cn.nukkit.block.Block; //导入依赖的package包/类
protected boolean isSuitableBlock(int block, int blockAbove, Biome biome) {
    if (!(biome instanceof CaveBiome)) {
        return false;
    }

    CaveBiome caveBiome = (CaveBiome) biome;

    if (block == caveBiome.getStoneBlock()) {
        return true;
    }

    if (block == Block.SAND || block == Block.GRAVEL) {
        return !(blockAbove == Block.WATER || blockAbove == Block.STILL_WATER || blockAbove == Block.LAVA || blockAbove == Block.STILL_LAVA);
    }

    if (block == caveBiome.getGroundBlock()) {
        return true;
    }

    if (block == caveBiome.getSurfaceBlock()) {
        return true;
    }

    // Few hardcoded cases
    if (block == Block.HARDENED_CLAY) {
        return true;
    }

    if (block == Block.SANDSTONE) {
        return true;
    }

    // TODO: add red sandstone case in Minecraft 1.8
    return block == Block.SNOW;

}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:37,代码来源:PopulatorCaves.java

示例13: populate

import cn.nukkit.block.Block; //导入依赖的package包/类
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
    for (int i = 0; i < amount; ++i) {
        int x = NukkitMath.randomRange(random, chunkX * 16, chunkX * 16 + 15);
        int z = NukkitMath.randomRange(random, chunkZ * 16, chunkZ * 16 + 15);
        int y = this.getHighestWorkableBlock(x, z);

        if (y != -1 && this.canCactusStay(x, y, z)) {
            this.level.setBlockIdAt(x, y, z, Block.CACTUS);
            this.level.setBlockDataAt(x, y, z, 1);
        }
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:16,代码来源:PopulatorCactus.java

示例14: addHangingVine

import cn.nukkit.block.Block; //导入依赖的package包/类
private void addHangingVine(ChunkManager worldIn, BlockVector3 pos, int meta) {
    this.addVine(worldIn, pos, meta);
    int i = 4;

    for (pos = pos.down(); i > 0 && worldIn.getBlockIdAt(pos.x, pos.y, pos.z) == Block.AIR; --i) {
        this.addVine(worldIn, pos, meta);
        pos = pos.down();
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:10,代码来源:ObjectSwampTree.java

示例15: 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:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:15,代码来源:Entity.java


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