Create an explosion which only affects a single block.
(World world, BlockPos pos)
| 272 | |
| 273 | /** Create an explosion which only affects a single block. */ |
| 274 | public static void explodeBlock(World world, BlockPos pos) { |
| 275 | if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { |
| 276 | return; |
| 277 | } |
| 278 | |
| 279 | double x = pos.getX() + 0.5; |
| 280 | double y = pos.getY() + 0.5; |
| 281 | double z = pos.getZ() + 0.5; |
| 282 | |
| 283 | Explosion explosion = new Explosion(world, null, x, y, z, 3f, false, false); |
| 284 | explosion.getAffectedBlockPositions().add(pos); |
| 285 | explosion.doExplosionB(true); |
| 286 | |
| 287 | for (EntityPlayer player : world.playerEntities) { |
| 288 | if (!(player instanceof EntityPlayerMP)) { |
| 289 | continue; |
| 290 | } |
| 291 | |
| 292 | if (player.getDistanceSq(pos) < 4096) { |
| 293 | ((EntityPlayerMP) player).connection.sendPacket(new SPacketExplosion(x, y, z, 3f, explosion.getAffectedBlockPositions(), null)); |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | public static long computeBlockBreakPower(World world, BlockPos pos) { |
| 299 | IBlockState state = world.getBlockState(pos); |
no test coverage detected