1.15.2 cancel BlockPistonExtendEvent and BlockPistonRetractEvent

Discussion in 'Spigot Plugin Development' started by Xuho, Feb 4, 2020.

  1. I'm working on a region system, and I want to cancel this events if any of the moved blocks interferes with a region.
    Example 1:
    We have a region X, and close to that region, a player tries to move some blocks using a piston (he can use slimeblocks to move blocks from the sides and that stuff) so I want to cancel the piston event if any of that blocks affected by the piston enters the region X if they are outside the region, or if they are inside but they somehow leaves the region.
     
  2. 1) loop through event.getBlocks()
    2) for each block in the loop add event.getDirection().getModX() getModY() getModZ()
    3) if the blocks + these offsets from the direction are outside the region cancel the event
     
  3. Thanks, it was easier than I thought :p