|
11 | 11 | import org.bukkit.Material;
|
12 | 12 | import org.bukkit.OfflinePlayer;
|
13 | 13 | import org.bukkit.Particle;
|
| 14 | +import org.bukkit.World; |
14 | 15 | import org.bukkit.block.Block;
|
15 | 16 | import org.bukkit.block.BlockFace;
|
16 | 17 | import org.bukkit.inventory.ItemStack;
|
@@ -134,37 +135,38 @@ protected void moveAndDig(Block b, BlockMenu menu, BlockFace face, Block block)
|
134 | 135 |
|
135 | 136 | @ParametersAreNonnullByDefault
|
136 | 137 | private void breakBlock(BlockMenu menu, Collection<ItemStack> drops, Block block) {
|
137 |
| - |
138 |
| - if (!block.getWorld().getWorldBorder().isInside(block.getLocation())) { |
| 138 | + World world = block.getWorld(); |
| 139 | + if (!world.getWorldBorder().isInside(block.getLocation())) { |
139 | 140 | return;
|
140 | 141 | }
|
141 | 142 |
|
142 |
| - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType()); |
| 143 | + world.playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType()); |
143 | 144 |
|
144 | 145 | // Push our drops to the inventory
|
145 | 146 | for (ItemStack drop : drops) {
|
146 | 147 | menu.pushItem(drop, getOutputSlots());
|
147 | 148 | }
|
148 | 149 |
|
149 | 150 | // Check if Block Generator optimizations should be applied.
|
150 |
| - if (applyOptimizations.getValue()) { |
151 |
| - InfiniteBlockGenerator generator = InfiniteBlockGenerator.findAt(block); |
152 |
| - |
153 |
| - // If we found a generator, continue. |
154 |
| - if (generator != null) { |
155 |
| - if (firesEvent.getValue()) { |
156 |
| - generator.callEvent(block); |
157 |
| - } |
158 |
| - |
159 |
| - // "poof" a "new" block was generated |
160 |
| - SoundEffect.MINER_ANDROID_BLOCK_GENERATION_SOUND.playAt(block); |
161 |
| - block.getWorld().spawnParticle(Particle.SMOKE_NORMAL, block.getX() + 0.5, block.getY() + 1.25, block.getZ() + 0.5, 8, 0.5, 0.5, 0.5, 0.015); |
162 |
| - } else { |
163 |
| - block.setType(Material.AIR); |
164 |
| - } |
165 |
| - } else { |
| 151 | + if (!applyOptimizations.getValue()) { |
166 | 152 | block.setType(Material.AIR);
|
| 153 | + return; |
167 | 154 | }
|
| 155 | + |
| 156 | + // If we didn't find a generator ignore the block. |
| 157 | + InfiniteBlockGenerator generator = InfiniteBlockGenerator.findAt(block); |
| 158 | + if (generator == null) { |
| 159 | + block.setType(Material.AIR); |
| 160 | + return; |
| 161 | + } |
| 162 | + |
| 163 | + if (firesEvent.getValue()) { |
| 164 | + generator.callEvent(block); |
| 165 | + } |
| 166 | + |
| 167 | + // "poof" a "new" block was generated |
| 168 | + SoundEffect.MINER_ANDROID_BLOCK_GENERATION_SOUND.playAt(block); |
| 169 | + world.spawnParticle(Particle.SMOKE_NORMAL, block.getX() + 0.5, block.getY() + 1.25, block.getZ() + 0.5, 8, 0.5, 0.5, 0.5, 0.015); |
168 | 170 | }
|
169 | 171 |
|
170 | 172 | }
|
0 commit comments