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

The following examples show how to use cn.nukkit.item.Item#isShears() . 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: BlockTallGrass.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Item[] getDrops(Item item) {
    boolean dropSeeds = ThreadLocalRandom.current().nextInt(10) == 0;
    if (item.isShears()) {
        //todo enchantment
        if (dropSeeds) {
            return new Item[]{
                    new ItemSeedsWheat(),
                    Item.get(Item.TALL_GRASS, this.getDamage(), 1)
            };
        } else {
            return new Item[]{
                    Item.get(Item.TALL_GRASS, this.getDamage(), 1)
            };
        }
    }

    if (dropSeeds) {
        return new Item[]{
                new ItemSeedsWheat()
        };
    } else {
        return new Item[0];
    }
}
 
Example 2
Source File: BlockLeaves2.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Item[] getDrops(Item item) {
    if (item.isShears()) {
        return new Item[]{
                toItem()
        };
    } else {
        if ((int) ((Math.random()) * 200) == 0 && this.getDamage() == DARK_OAK) {
            return new Item[]{
                    new ItemApple()
            };
        }
        if ((int) ((Math.random()) * 20) == 0) {
            return new Item[]{
                    new ItemBlock(new BlockSapling(), this.getDamage() & 0x03, 1)
            };
        }
    }
    return new Item[0];
}
 
Example 3
Source File: BlockLeaves.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Item[] getDrops(Item item) {
    if (item.isShears()) {
        return new Item[]{
                toItem()
        };
    } else {
        if (this.canDropApple() && ThreadLocalRandom.current().nextInt(200) == 0) {
            return new Item[]{
                    Item.get(Item.APPLE)
            };
        }
        if (ThreadLocalRandom.current().nextInt(20) == 0) {
            if (ThreadLocalRandom.current().nextBoolean()) {
                return new Item[]{
                        Item.get(Item.STICK, 0, ThreadLocalRandom.current().nextInt(1, 2))
                };
            } else if ((this.getDamage() & 0x03) != JUNGLE || ThreadLocalRandom.current().nextInt(20) == 0) {
                return new Item[]{
                        this.getSapling()
                };
            }
        }
    }
    return new Item[0];
}
 
Example 4
Source File: BlockTallGrass.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Item[] getDrops(Item item) {
    boolean dropSeeds = new Random().nextInt(10) == 0;
    if (item.isShears()) {
        //todo enchantment
        if (dropSeeds) {
            return new Item[]{
                    new ItemSeedsWheat(),
                    Item.get(Item.TALL_GRASS, this.getDamage(), 1)
            };
        } else {
            return new Item[]{
                    Item.get(Item.TALL_GRASS, this.getDamage(), 1)
            };
        }
    }

    if (dropSeeds) {
        return new Item[]{
                new ItemSeedsWheat()
        };
    } else {
        return new Item[0];
    }
}
 
Example 5
Source File: Block.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
private static int toolType0(Item item) {
    if (item.isSword()) return ItemTool.TYPE_SWORD;
    if (item.isShovel()) return ItemTool.TYPE_SHOVEL;
    if (item.isPickaxe()) return ItemTool.TYPE_PICKAXE;
    if (item.isAxe()) return ItemTool.TYPE_AXE;
    if (item.isShears()) return ItemTool.TYPE_SHEARS;
    return ItemTool.TYPE_NONE;
}
 
Example 6
Source File: BlockVine.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Item[] getDrops(Item item) {
    if (item.isShears()) {
        return new Item[]{
                toItem()
        };
    } else {
        return new Item[0];
    }
}
 
Example 7
Source File: BlockDoublePlant.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() & TOP_HALF_BITMASK) != TOP_HALF_BITMASK) {
        switch (this.getDamage() & 0x07) {
            case TALL_GRASS:
            case LARGE_FERN:
                boolean dropSeeds = ThreadLocalRandom.current().nextInt(10) == 0;
                if (item.isShears()) {
                    //todo enchantment
                    if (dropSeeds) {
                        return new Item[]{
                                new ItemSeedsWheat(0, 1),
                                toItem()
                        };
                    } else {
                        return new Item[]{
                                toItem()
                        };
                    }
                }

                if (dropSeeds) {
                    return new Item[]{
                            new ItemSeedsWheat()
                    };
                } else {
                    return new Item[0];
                }
        }

        return new Item[]{toItem()};
    }

    return new Item[0];
}
 
Example 8
Source File: BlockDoublePlant.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 & 0x08) != 0x08) {
        switch (this.meta & 0x07) {
            case 2:
            case 3:
                boolean dropSeeds = new Random().nextInt(10) == 0;
                if (item.isShears()) {
                    //todo enchantment
                    if (dropSeeds) {
                        return new Item[]{
                                new ItemSeedsWheat(0, 1),
                                toItem()
                        };
                    } else {
                        return new Item[]{
                                toItem()
                        };
                    }
                }

                if (dropSeeds) {
                    return new Item[]{
                            new ItemSeedsWheat()
                    };
                } else {
                    return new Item[0];
                }
        }

        return new Item[]{toItem()};
    }

    return new Item[0];
}
 
Example 9
Source File: BlockVine.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Item[] getDrops(Item item) {
    if (item.isShears()) {
        return new Item[]{
                toItem()
        };
    } else {
        return new Item[0];
    }
}
 
Example 10
Source File: BlockDeadBush.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Item[] getDrops(Item item) {
    if (item.isShears()) {
        return new Item[]{
                toItem()
        };
    } else {
        return new Item[]{
                new ItemStick(0, new Random().nextInt(3))
        };
    }
}
 
Example 11
Source File: BlockVine.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Item[] getDrops(Item item) {
    if (item.isShears()) {
        return new Item[]{
                toItem()
        };
    } else {
        return new Item[0];
    }
}
 
Example 12
Source File: Block.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
private static boolean correctTool0(int blockToolType, Item item) {
    return (blockToolType == ItemTool.TYPE_SWORD && item.isSword()) ||
            (blockToolType == ItemTool.TYPE_SHOVEL && item.isShovel()) ||
            (blockToolType == ItemTool.TYPE_PICKAXE && item.isPickaxe()) ||
            (blockToolType == ItemTool.TYPE_AXE && item.isAxe()) ||
            (blockToolType == ItemTool.TYPE_SHEARS && item.isShears()) ||
            blockToolType == ItemTool.TYPE_NONE;
}
 
Example 13
Source File: BlockDoublePlant.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() & 0x08) != 0x08) {
        switch (this.getDamage() & 0x07) {
            case 2:
            case 3:
                boolean dropSeeds = new Random().nextInt(10) == 0;
                if (item.isShears()) {
                    //todo enchantment
                    if (dropSeeds) {
                        return new Item[]{
                                new ItemSeedsWheat(0, 1),
                                toItem()
                        };
                    } else {
                        return new Item[]{
                                toItem()
                        };
                    }
                }

                if (dropSeeds) {
                    return new Item[]{
                            new ItemSeedsWheat()
                    };
                } else {
                    return new Item[0];
                }
        }

        return new Item[]{toItem()};
    }

    return new Item[0];
}
 
Example 14
Source File: EnchantmentEfficiency.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean canEnchant(Item item) {
    return item.isShears() || super.canEnchant(item);
}
 
Example 15
Source File: EnchantmentSilkTouch.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean canEnchant(Item item) {
    return item.isShears() || super.canEnchant(item);
}
 
Example 16
Source File: EnchantmentEfficiency.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean canEnchant(Item item) {
    return item.isShears() || super.canEnchant(item);
}
 
Example 17
Source File: EnchantmentEfficiency.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean canEnchant(Item item) {
    return item.isShears() || super.canEnchant(item);
}
 
Example 18
Source File: Block.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @deprecated This function is lack of Player class and is not accurate enough, use #getBreakTime(Item, Player)
 */
@Deprecated
public double getBreakTime(Item item) {
    double base = this.getHardness() * 1.5;
    if (this.canBeBrokenWith(item)) {
        if (this.getToolType() == ItemTool.TYPE_SHEARS && item.isShears()) {
            base /= 15;
        } else if (
                (this.getToolType() == ItemTool.TYPE_PICKAXE && item.isPickaxe()) ||
                        (this.getToolType() == ItemTool.TYPE_AXE && item.isAxe()) ||
                        (this.getToolType() == ItemTool.TYPE_SHOVEL && item.isShovel())
                ) {
            int tier = item.getTier();
            switch (tier) {
                case ItemTool.TIER_WOODEN:
                    base /= 2;
                    break;
                case ItemTool.TIER_STONE:
                    base /= 4;
                    break;
                case ItemTool.TIER_IRON:
                    base /= 6;
                    break;
                case ItemTool.TIER_DIAMOND:
                    base /= 8;
                    break;
                case ItemTool.TIER_GOLD:
                    base /= 12;
                    break;
            }
        }
    } else {
        base *= 3.33;
    }

    if (item.isSword()) {
        base *= 0.5;
    }

    return base;
}
 
Example 19
Source File: Block.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @deprecated This function is lack of Player class and is not accurate enough, use #getBreakTime(Item, Player)
 */
@Deprecated
public double getBreakTime(Item item) {
    double base = this.getHardness() * 1.5;
    if (this.canBeBrokenWith(item)) {
        if (this.getToolType() == ItemTool.TYPE_SHEARS && item.isShears()) {
            base /= 15;
        } else if (
                (this.getToolType() == ItemTool.TYPE_PICKAXE && item.isPickaxe()) ||
                        (this.getToolType() == ItemTool.TYPE_AXE && item.isAxe()) ||
                        (this.getToolType() == ItemTool.TYPE_SHOVEL && item.isShovel())
                ) {
            int tier = item.getTier();
            switch (tier) {
                case ItemTool.TIER_WOODEN:
                    base /= 2;
                    break;
                case ItemTool.TIER_STONE:
                    base /= 4;
                    break;
                case ItemTool.TIER_IRON:
                    base /= 6;
                    break;
                case ItemTool.TIER_DIAMOND:
                    base /= 8;
                    break;
                case ItemTool.TIER_GOLD:
                    base /= 12;
                    break;
            }
        }
    } else {
        base *= 3.33;
    }

    if (item.isSword()) {
        base *= 0.5;
    }

    return base;
}
 
Example 20
Source File: EnchantmentSilkTouch.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean canEnchant(Item item) {
    return item.isShears() || super.canEnchant(item);
}