|
4 | 4 | import cn.nukkit.item.Item; |
5 | 5 | import cn.nukkit.item.ItemBlock; |
6 | 6 | import cn.nukkit.item.ItemDye; |
| 7 | +import cn.nukkit.item.ItemTool; |
7 | 8 | import cn.nukkit.level.Level; |
8 | 9 | import cn.nukkit.level.particle.BoneMealParticle; |
| 10 | +import cn.nukkit.level.particle.DestroyBlockParticle; |
9 | 11 | import cn.nukkit.math.BlockFace; |
10 | 12 | import cn.nukkit.utils.BlockColor; |
11 | 13 |
|
@@ -100,9 +102,13 @@ public boolean onBreak(Item item) { |
100 | 102 | if ((this.getDamage() & TOP_HALF_BITMASK) == TOP_HALF_BITMASK) { // Top half |
101 | 103 | Block down = down(); |
102 | 104 | if (down instanceof BlockDoublePlant) { |
103 | | - this.getLevel().useBreakOn(down); |
| 105 | + this.getLevel().useBreakOn(down, item, null, true); |
104 | 106 | } |
105 | 107 | } else { |
| 108 | + Block up = up(); |
| 109 | + if (up instanceof BlockDoublePlant) { |
| 110 | + this.getLevel().addParticle(new DestroyBlockParticle(this.add(0.5, 1), this)); |
| 111 | + } |
106 | 112 | this.getLevel().setBlock(this, Block.get(BlockID.AIR), true, true); |
107 | 113 | } |
108 | 114 |
|
@@ -176,4 +182,14 @@ public boolean onActivate(Item item, Player player) { |
176 | 182 | public Item toItem() { |
177 | 183 | return new ItemBlock(this, this.getDamage() & 0x07, 1); |
178 | 184 | } |
| 185 | + |
| 186 | + @Override |
| 187 | + public int getToolType() { |
| 188 | + return ItemTool.TYPE_SHEARS; |
| 189 | + } |
| 190 | + |
| 191 | + @Override |
| 192 | + public boolean breakWhenPushed() { |
| 193 | + return true; |
| 194 | + } |
179 | 195 | } |
0 commit comments