cn.nukkit.block.Block Java Examples

The following examples show how to use cn.nukkit.block.Block. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Item.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
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) {
            if (meta >= 0) {
                item = new ItemBlock(Block.get(id, meta), meta, count);
            } else {
                item = new ItemBlock(Block.get(id), 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);
    }
}
 
Example #2
Source File: SwampBiome.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public SwampBiome() {
    super();

    PopulatorLilyPad lilypad = new PopulatorLilyPad();
    lilypad.setBaseAmount(4);

    SwampTreePopulator trees = new SwampTreePopulator();
    trees.setBaseAmount(2);

    PopulatorFlower flower = new PopulatorFlower();
    flower.setBaseAmount(2);
    flower.addType(Block.RED_FLOWER, BlockFlower.TYPE_BLUE_ORCHID);

    this.addPopulator(trees);
    this.addPopulator(flower);
    this.addPopulator(lilypad);

    this.setElevation(62, 63);

    this.temperature = 0.8;
    this.rainfall = 0.9;
}
 
Example #3
Source File: PopulatorGroundFire.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
@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]);
        }
    }
}
 
Example #4
Source File: SandyBiome.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
public SandyBiome() {

        PopulatorCactus cactus = new PopulatorCactus();
        cactus.setBaseAmount(2);

        PopulatorDeadBush deadbush = new PopulatorDeadBush();
        deadbush.setBaseAmount(2);

        this.addPopulator(cactus);
        this.addPopulator(deadbush);

        this.setGroundCover(new Block[]{
                new BlockSand(),
                new BlockSand(),
                new BlockSandstone(),
                new BlockSandstone(),
                new BlockSandstone()
        });
    }
 
Example #5
Source File: BlockEntityBrewingStand.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #6
Source File: HugeTreesGenerator.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
/**
 * grow leaves in a circle with the outsides being within the circle
 */
protected void growLeavesLayerStrict(ChunkManager worldIn, Vector3 layerCenter, int width) {
    int i = width * width;

    for (int j = -width; j <= width + 1; ++j) {
        for (int k = -width; k <= width + 1; ++k) {
            int l = j - 1;
            int i1 = k - 1;

            if (j * j + k * k <= i || l * l + i1 * i1 <= i || j * j + i1 * i1 <= i || l * l + k * k <= i) {
                Vector3 blockpos = layerCenter.add(j, 0, k);
                int id = worldIn.getBlockIdAt((int) blockpos.x, (int) blockpos.y, (int) blockpos.z);

                if (id == Block.AIR || id == Block.LEAVES) {
                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
                }
            }
        }
    }
}
 
Example #7
Source File: Entity.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public List<Block> getBlocksAround() {
    if (this.blocksAround == null) {
        int minX = NukkitMath.floorDouble(this.boundingBox.getMinX());
        int minY = NukkitMath.floorDouble(this.boundingBox.getMinY());
        int minZ = NukkitMath.floorDouble(this.boundingBox.getMinZ());
        int maxX = NukkitMath.ceilDouble(this.boundingBox.getMaxX());
        int maxY = NukkitMath.ceilDouble(this.boundingBox.getMaxY());
        int maxZ = NukkitMath.ceilDouble(this.boundingBox.getMaxZ());

        this.blocksAround = new ArrayList<>();

        for (int z = minZ; z <= maxZ; ++z) {
            for (int x = minX; x <= maxX; ++x) {
                for (int y = minY; y <= maxY; ++y) {
                    Block block = this.level.getBlock(this.temporalVector.setComponents(x, y, z));
                    this.blocksAround.add(block);
                }
            }
        }
    }

    return this.blocksAround;
}
 
Example #8
Source File: Level.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public void updateComparatorOutputLevel(Vector3 v) {
    for (BlockFace face : Plane.HORIZONTAL) {
        Vector3 pos = v.getSide(face);

        if (this.isChunkLoaded((int) pos.x >> 4, (int) pos.z >> 4)) {
            Block block1 = this.getBlock(pos);

            if (BlockRedstoneDiode.isDiode(block1)) {
                block1.onUpdate(BLOCK_UPDATE_REDSTONE);
            } else if (block1.isNormalBlock()) {
                pos = pos.getSide(face);
                block1 = this.getBlock(pos);

                if (BlockRedstoneDiode.isDiode(block1)) {
                    block1.onUpdate(BLOCK_UPDATE_REDSTONE);
                }
            }
        }
    }
}
 
Example #9
Source File: HugeTreesGenerator.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
/**
 * grow leaves in a circle
 */
protected void growLeavesLayer(ChunkManager worldIn, Vector3 layerCenter, int width) {
    int i = width * width;

    for (int j = -width; j <= width; ++j) {
        for (int k = -width; k <= width; ++k) {
            if (j * j + k * k <= i) {
                Vector3 blockpos = layerCenter.add(j, 0, k);
                int id = worldIn.getBlockIdAt((int) blockpos.x, (int) blockpos.y, (int) blockpos.z);

                if (id == Block.AIR || id == Block.LEAVES) {
                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
                }
            }
        }
    }
}
 
Example #10
Source File: ItemTool.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean useOn(Block block) {
    if (this.isUnbreakable() || isDurable()) {
        return true;
    }

    if (block.getToolType() == ItemTool.TYPE_PICKAXE && this.isPickaxe() ||
            block.getToolType() == ItemTool.TYPE_SHOVEL && this.isShovel() ||
            block.getToolType() == ItemTool.TYPE_AXE && this.isAxe() ||
            block.getToolType() == ItemTool.TYPE_SWORD && this.isSword() ||
            block.getToolType() == ItemTool.SHEARS && this.isShears()
            ) {
        this.meta++;
    } else if (!this.isShears() && block.getBreakTime(this) > 0) {
        this.meta += 2;
    } else if (this.isHoe()) {
        if (block.getId() == GRASS || block.getId() == DIRT) {
            this.meta++;
        }
    } else {
        this.meta++;
    }
    return true;
}
 
Example #11
Source File: ObjectTree.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public void placeObject(ChunkManager level, int x, int y, int z, NukkitRandom random) {

        this.placeTrunk(level, x, y, z, random, this.getTreeHeight() - 1);

        for (int yy = y - 3 + this.getTreeHeight(); yy <= y + this.getTreeHeight(); ++yy) {
            double yOff = yy - (y + this.getTreeHeight());
            int mid = (int) (1 - yOff / 2);
            for (int xx = x - mid; xx <= x + mid; ++xx) {
                int xOff = Math.abs(xx - x);
                for (int zz = z - mid; zz <= z + mid; ++zz) {
                    int zOff = Math.abs(zz - z);
                    if (xOff == mid && zOff == mid && (yOff == 0 || random.nextBoundedInt(2) == 0)) {
                        continue;
                    }
                    if (!Block.solid[level.getBlockIdAt(xx, yy, zz)]) {

                        level.setBlockIdAt(xx, yy, zz, this.getLeafBlock());
                        level.setBlockDataAt(xx, yy, zz, this.getType());
                    }
                }
            }
        }
    }
 
Example #12
Source File: HugeTreesGenerator.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
/**
 * grow leaves in a circle with the outsides being within the circle
 */
protected void growLeavesLayerStrict(ChunkManager worldIn, Vector3 layerCenter, int width) {
    int i = width * width;

    for (int j = -width; j <= width + 1; ++j) {
        for (int k = -width; k <= width + 1; ++k) {
            int l = j - 1;
            int i1 = k - 1;

            if (j * j + k * k <= i || l * l + i1 * i1 <= i || j * j + i1 * i1 <= i || l * l + k * k <= i) {
                Vector3 blockpos = layerCenter.add(j, 0, k);
                int id = worldIn.getBlockIdAt((int) blockpos.x, (int) blockpos.y, (int) blockpos.z);

                if (id == Block.AIR || id == Block.LEAVES) {
                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
                }
            }
        }
    }
}
 
Example #13
Source File: Level.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
public BlockColor getMapColorAt(int x, int z) {
    int y = getHighestBlockAt(x, z);
    while (y > 1) {
        Block block = getBlock(new Vector3(x, y, z));
        BlockColor blockColor = block.getColor();
        if (blockColor.getAlpha() == 0x00) {
            y--;
        } else {
            return blockColor;
        }
    }
    return BlockColor.VOID_BLOCK_COLOR;
}
 
Example #14
Source File: SpruceBigTreePopulator.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
private int getHighestWorkableBlock(int x, int z) {
    int y;
    for (y = 255; y > 0; --y) {
        int b = this.level.getBlockIdAt(x, y, z);
        if (b == Block.DIRT || b == Block.GRASS) {
            break;
        } else if (b != Block.AIR && b != Block.SNOW_LAYER) {
            return -1;
        }
    }

    return ++y;
}
 
Example #15
Source File: ObjectSpruceTree.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public void placeLeaves(ChunkManager level, int topSize, int lRadius, int x, int y, int z, NukkitRandom random)   {
    int radius = random.nextBoundedInt(2);
    int maxR = 1;
    int minR = 0;

    for (int yy = 0; yy <= topSize; ++yy) {
        int yyy = y + this.treeHeight - yy;

        for (int xx = x - radius; xx <= x + radius; ++xx) {
            int xOff = Math.abs(xx - x);
            for (int zz = z - radius; zz <= z + radius; ++zz) {
                int zOff = Math.abs(zz - z);
                if (xOff == radius && zOff == radius && radius > 0) {
                    continue;
                }

                if (!Block.solid[level.getBlockIdAt(xx, yyy, zz)]) {
                    level.setBlockAt(xx, yyy, zz, this.getLeafBlock(), this.getType());
                }
            }
        }

        if (radius >= maxR) {
            radius = minR;
            minR = 1;
            if (++maxR > lRadius) {
                maxR = lRadius;
            }
        } else {
            ++radius;
        }
    }
}
 
Example #16
Source File: BlockEntityBeacon.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
private int calculatePowerLevel() {
    int tileX = getFloorX();
    int tileY = getFloorY();
    int tileZ = getFloorZ();

    //The power level that we're testing for
    for (int powerLevel = 1; powerLevel <= POWER_LEVEL_MAX; powerLevel++) {
        int queryY = tileY - powerLevel; //Layer below the beacon block

        for (int queryX = tileX - powerLevel; queryX <= tileX + powerLevel; queryX++) {
            for (int queryZ = tileZ - powerLevel; queryZ <= tileZ + powerLevel; queryZ++) {

                int testBlockId = level.getBlockIdAt(queryX, queryY, queryZ);
                if (
                        testBlockId != Block.IRON_BLOCK &&
                                testBlockId != Block.GOLD_BLOCK &&
                                testBlockId != Block.EMERALD_BLOCK &&
                                testBlockId != Block.DIAMOND_BLOCK
                        ) {
                    return powerLevel - 1;
                }

            }
        }
    }

    return POWER_LEVEL_MAX;
}
 
Example #17
Source File: SwampTreePopulator.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
private int getHighestWorkableBlock(int x, int z) {
    int y;
    for (y = 127; y > 0; --y) {
        int b = this.level.getBlockIdAt(x, y, z);
        if (b == Block.DIRT || b == Block.GRASS) {
            break;
        } else if (b != Block.AIR && b != Block.SNOW_LAYER) {
            return -1;
        }
    }

    return ++y;
}
 
Example #18
Source File: GrassyBiome.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
public GrassyBiome() {
    this.setGroundCover(new Block[]{
            new BlockGrass(),
            new BlockDirt(),
            new BlockDirt(),
            new BlockDirt(),
            new BlockDirt()
    });
}
 
Example #19
Source File: PopulatorGroundFire.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
private int getHighestWorkableBlock(FullChunk chunk, int x, int z) {
    int y;
    for (y = 0; y <= 127; ++y) {
        int b = chunk.getBlockId(x, y, z);
        if (b == Block.AIR) {
            break;
        }
    }
    return y == 0 ? -1 : y;
}
 
Example #20
Source File: MushroomPopulator.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
private int getHighestWorkableBlock(int x, int z) {
    int y;
    for (y = 127; y > 0; --y) {
        int b = this.level.getBlockIdAt(x, y, z);
        if (b == Block.DIRT || b == Block.GRASS) {
            break;
        } else if (b != Block.AIR && b != Block.SNOW_LAYER) {
            return -1;
        }
    }

    return ++y;
}
 
Example #21
Source File: Level.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public AxisAlignedBB[] getCollisionCubes(Entity entity, AxisAlignedBB bb, boolean entities, boolean solidEntities) {
    int minX = NukkitMath.floorDouble(bb.getMinX());
    int minY = NukkitMath.floorDouble(bb.getMinY());
    int minZ = NukkitMath.floorDouble(bb.getMinZ());
    int maxX = NukkitMath.ceilDouble(bb.getMaxX());
    int maxY = NukkitMath.ceilDouble(bb.getMaxY());
    int maxZ = NukkitMath.ceilDouble(bb.getMaxZ());

    List<AxisAlignedBB> collides = new ArrayList<>();

    for (int z = minZ; z <= maxZ; ++z) {
        for (int x = minX; x <= maxX; ++x) {
            for (int y = minY; y <= maxY; ++y) {
                Block block = this.getBlock(this.temporalVector.setComponents(x, y, z), false);
                if (!block.canPassThrough() && block.collidesWithBB(bb)) {
                    collides.add(block.getBoundingBox());
                }
            }
        }
    }

    if (entities || solidEntities) {
        for (Entity ent : this.getCollidingEntities(bb.grow(0.25f, 0.25f, 0.25f), entity)) {
            if (solidEntities && !ent.canPassThrough()) {
                collides.add(ent.boundingBox.clone());
            }
        }
    }

    return collides.toArray(new AxisAlignedBB[0]);
}
 
Example #22
Source File: ItemEndCrystal.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) {
    if (!(target instanceof BlockBedrock) && !(target instanceof BlockObsidian)) return false;
    FullChunk chunk = level.getChunk((int) block.getX() >> 4, (int) block.getZ() >> 4);

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

    CompoundTag nbt = new CompoundTag()
            .putList(new ListTag<DoubleTag>("Pos")
                    .add(new DoubleTag("", block.getX() + 0.5))
                    .add(new DoubleTag("", block.getY()))
                    .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("", new Random().nextFloat() * 360))
                    .add(new FloatTag("", 0)));

    if (this.hasCustomName()) {
        nbt.putString("CustomName", this.getCustomName());
    }

    Entity entity = Entity.createEntity("EndCrystal", chunk, nbt);

    if (entity != null) {
        if (player.isSurvival()) {
            Item item = player.getInventory().getItemInHand();
            item.setCount(item.getCount() - 1);
            player.getInventory().setItemInHand(item);
        }
        entity.spawnToAll();
        return true;
    }
    return false;
}
 
Example #23
Source File: PopulatorSugarcane.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@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.canSugarcaneStay(x, y, z)) {
            this.level.setBlockIdAt(x, y, z, Block.SUGARCANE_BLOCK);
            this.level.setBlockDataAt(x, y, z, 1);
        }
    }
}
 
Example #24
Source File: Rail.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isRailBlock(int blockId) {
    switch (blockId) {
        case Block.RAIL:
        case Block.POWERED_RAIL:
        case Block.ACTIVATOR_RAIL:
        case Block.DETECTOR_RAIL:
            return true;
        default:
            return false;
    }
}
 
Example #25
Source File: ItemBoat.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@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 = (EntityBoat) Entity.createEntity("Boat",
            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() - (target instanceof BlockWater ? 0.0625 : 0)))
                    .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 (boat == null) {
        return false;
    }

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

    boat.spawnToAll();
    return true;
}
 
Example #26
Source File: ItemMinecartChest.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) {
    if (Rail.isRailBlock(target)) {
        Rail.Orientation type = ((BlockRail) target).getOrientation();
        double adjacent = 0.0D;
        if (type.isAscending()) {
            adjacent = 0.5D;
        }
        EntityMinecartChest minecart = new EntityMinecartChest(
                level.getChunk(target.getFloorX() >> 4, target.getFloorZ() >> 4), new CompoundTag("")
                .putList(new ListTag<>("Pos")
                        .add(new DoubleTag("", target.getX() + 0.5))
                        .add(new DoubleTag("", target.getY() + 0.0625D + adjacent))
                        .add(new DoubleTag("", target.getZ() + 0.5)))
                .putList(new ListTag<>("Motion")
                        .add(new DoubleTag("", 0))
                        .add(new DoubleTag("", 0))
                        .add(new DoubleTag("", 0)))
                .putList(new ListTag<>("Rotation")
                        .add(new FloatTag("", 0))
                        .add(new FloatTag("", 0)))
        );
        minecart.spawnToAll();
        count -= 1;
        return true;
    }
    return false;
}
 
Example #27
Source File: MushroomPopulator.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
private int getHighestWorkableBlock(int x, int z) {
    int y;
    for (y = 127; y > 0; --y) {
        int b = this.level.getBlockIdAt(x, y, z);
        if (b == Block.DIRT || b == Block.GRASS) {
            break;
        } else if (b != Block.AIR && b != Block.SNOW_LAYER) {
            return -1;
        }
    }

    return ++y;
}
 
Example #28
Source File: PopulatorCactus.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@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);
        }
    }
}
 
Example #29
Source File: ObjectSavannaTree.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
private void placeLeafAt(ChunkManager worldIn, Vector3 pos) {
    int material = worldIn.getBlockIdAt(pos.getFloorX(), pos.getFloorY(), pos.getFloorZ());

    if (material == Block.AIR || material == Block.LEAVES) {
        this.setBlockAndNotifyAdequately(worldIn, pos, LEAF);
    }
}
 
Example #30
Source File: EntityMinecartAbstract.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Set the minecart display block
 *
 * @param block The block that will changed. Set {@code null} for BlockAir
 * @param update Do update for the block. (This state changes if you want to show the block)
 * @return {@code true} if the block is normal block
 */
@API(usage = Usage.MAINTAINED, definition = Definition.UNIVERSAL)
public boolean setDisplayBlock(Block block, boolean update) {
    if(!update){
        if (block.isNormalBlock()) {
            blockInside = block;
        } else {
            blockInside = null;
        }
        return true;
    }
    if (block != null) {
        if (block.isNormalBlock()) {
            blockInside = block;
            int display = blockInside.getId()
                    | blockInside.getDamage() << 16;
            setDataProperty(new ByteEntityData(DATA_HAS_DISPLAY, 1));
            setDataProperty(new IntEntityData(DATA_DISPLAY_ITEM, display));
            setDisplayBlockOffset(6);
        }
    } else {
        // Set block to air (default).
        blockInside = null;
        setDataProperty(new ByteEntityData(DATA_HAS_DISPLAY, 0));
        setDataProperty(new IntEntityData(DATA_DISPLAY_ITEM, 0));
        setDisplayBlockOffset(0);
    }
    return true;
}