Java Code Examples for cn.nukkit.item.Item#isHoe()

The following examples show how to use cn.nukkit.item.Item#isHoe() . 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: BlockGrass.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onActivate(Item item, Player player) {
    if (item.getId() == Item.DYE && item.getDamage() == 0x0F) {
        item.count--;
        ObjectTallGrass.growGrass(this.getLevel(), this, new NukkitRandom(), 15, 10);
        return true;
    } else if (item.isHoe()) {
        item.useOn(this);
        this.getLevel().setBlock(this, new BlockFarmland());
        return true;
    } else if (item.isShovel()) {
        item.useOn(this);
        this.getLevel().setBlock(this, new BlockGrassPath());
        return true;
    }

    return false;
}
 
Example 2
Source File: BlockGrass.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onActivate(Item item, Player player) {
    if (item.getId() == Item.DYE && item.getDamage() == 0x0F) {
        if (player != null && (player.gamemode & 0x01) == 0) {
            item.count--;
        }
        this.level.addParticle(new BoneMealParticle(this));
        ObjectTallGrass.growGrass(this.getLevel(), this, new NukkitRandom());
        return true;
    } else if (item.isHoe()) {
        item.useOn(this);
        this.getLevel().setBlock(this, Block.get(BlockID.FARMLAND));
        return true;
    } else if (item.isShovel()) {
        item.useOn(this);
        this.getLevel().setBlock(this, Block.get(BlockID.GRASS_PATH));
        return true;
    }

    return false;
}
 
Example 3
Source File: BlockGrass.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onActivate(Item item, Player player) {
    if (item.getId() == Item.DYE && item.getDamage() == 0x0F) {
        item.count--;
        ObjectTallGrass.growGrass(this.getLevel(), this, new NukkitRandom(), 15, 10);
        return true;
    } else if (item.isHoe()) {
        item.useOn(this);
        this.getLevel().setBlock(this, new BlockFarmland());
        return true;
    } else if (item.isShovel()) {
        item.useOn(this);
        this.getLevel().setBlock(this, new BlockGrassPath());
        return true;
    }

    return false;
}
 
Example 4
Source File: BlockDirt.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onActivate(Item item, Player player) {
    if (item.isHoe()) {
        item.useOn(this);
        this.getLevel().setBlock(this, new BlockFarmland(), true);

        return true;
    }

    return false;
}
 
Example 5
Source File: BlockGrassPath.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onActivate(Item item, Player player) {
    if (item.isHoe()) {
        item.useOn(this);
        this.getLevel().setBlock(this, get(FARMLAND), true);
        return true;
    }

    return false;
}
 
Example 6
Source File: BlockDirt.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onActivate(Item item, Player player) {
    if (item.isHoe()) {
        item.useOn(this);
        this.getLevel().setBlock(this, this.getDamage() == 0 ? get(FARMLAND) : get(DIRT), true);

        return true;
    }

    return false;
}
 
Example 7
Source File: BlockDirt.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onActivate(Item item, Player player) {
    if (item.isHoe()) {
        item.useOn(this);
        this.getLevel().setBlock(this, new BlockFarmland(), true);

        return true;
    }

    return false;
}