cn.nukkit.item.ItemDye Java Examples

The following examples show how to use cn.nukkit.item.ItemDye. 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: BlockOreLapis.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Item[] getDrops(Item item) {
    if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_STONE) {
        if (item.isSilkTouch()){
            return new Item[]{
                    this.toItem()
            };
        } else {
            return new Item[]{
                    new ItemDye(4, new NukkitRandom().nextRange(4, 8))
            };
        }
    } else {
        return new Item[0];
    }
}
 
Example #2
Source File: BlockOreLapis.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Item[] getDrops(Item item) {
    if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_STONE) {
        int count = 4 + ThreadLocalRandom.current().nextInt(5);
        Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
        if (fortune != null && fortune.getLevel() >= 1) {
            int i = ThreadLocalRandom.current().nextInt(fortune.getLevel() + 2) - 1;

            if (i < 0) {
                i = 0;
            }

            count *= (i + 1);
        }

        return new Item[]{
                new ItemDye(4, new Random().nextInt(4) + 4)
        };
    } else {
        return new Item[0];
    }
}
 
Example #3
Source File: BlockOreLapis.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Item[] getDrops(Item item) {
    if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_STONE) {
        int count = 4 + ThreadLocalRandom.current().nextInt(5);
        Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
        if (fortune != null && fortune.getLevel() >= 1) {
            int i = ThreadLocalRandom.current().nextInt(fortune.getLevel() + 2) - 1;

            if (i < 0) {
                i = 0;
            }

            count *= (i + 1);
        }

        return new Item[]{
                new ItemDye(4, new Random().nextInt(4) + 4)
        };
    } else {
        return new Item[0];
    }
}
 
Example #4
Source File: EntitySheep.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onInteract(Player player, Item item) {
    if (item.getId() == Item.DYE) {
        this.setColor(((ItemDye) item).getDyeColor().getDyedData());
        return true;
    }

    return item.getId() == Item.SHEARS && shear();
}
 
Example #5
Source File: BlockCocoa.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Item[] getDrops(Item item) {
    if (this.meta >= 8) {
        return new Item[]{
                new ItemDye(3, 3)
        };
    } else {
        return new Item[]{
                new ItemDye(3, 1)
        };
    }
}
 
Example #6
Source File: EntitySheep.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onInteract(Player player, Item item, Vector3 clickedPos) {
    if (item.getId() == Item.DYE) {
        this.setColor(((ItemDye) item).getDyeColor().getWoolData());
        return true;
    }

    return item.getId() == Item.SHEARS && shear();
}
 
Example #7
Source File: BlockCocoa.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Item[] getDrops(Item item) {
    if (this.getDamage() >= 8) {
        return new Item[]{
                new ItemDye(3, 3)
        };
    } else {
        return new Item[]{
                new ItemDye(3, 1)
        };
    }
}
 
Example #8
Source File: EntitySheep.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onInteract(Player player, Item item) {
    if (item.getId() == Item.DYE) {
        this.setColor(((ItemDye) item).getDyeColor().getWoolData());
        return true;
    }

    return item.getId() == Item.SHEARS && shear();
}
 
Example #9
Source File: BlockCocoa.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Item[] getDrops(Item item) {
    if (this.getDamage() >= 8) {
        return new Item[]{
                new ItemDye(3, 3)
        };
    } else {
        return new Item[]{
                new ItemDye(3, 1)
        };
    }
}
 
Example #10
Source File: EntitySquid.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Item[] getDrops() {
    return new Item[]{new ItemDye(DyeColor.BLACK.getDyeData(), random.nextRange(1, 3))};
}
 
Example #11
Source File: EntitySquid.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Item[] getDrops() {
    return new Item[]{new ItemDye(DyeColor.BLACK.getDyeData())};
}
 
Example #12
Source File: BlockCocoa.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Item toItem() {
    return new ItemDye(DyeColor.BROWN.getDyeData());
}
 
Example #13
Source File: EntitySquid.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Item[] getDrops() {
    return new Item[]{new ItemDye(DyeColor.BLACK.getDyeData())};
}