Skip to content

Commit

Permalink
Added piston retract event listener (#32)
Browse files Browse the repository at this point in the history
* Check all blocks moved by piston instead of only one.

* Added retract event listener
  • Loading branch information
0ffz committed May 3, 2020
1 parent 2971e40 commit 5071092
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,21 @@ object SectionSyncListener : Listener {
updateCorrespondingBlock(location, updateBlockData)
}


/** Disables pistons if they are in the overlap of two sections */
/** Disables pistons extending if they are in the overlap of two sections */
@EventHandler
fun onPistonEvent(event: BlockPistonExtendEvent) {
fun onPistonExtendEvent(event: BlockPistonExtendEvent) {
//TODO handle pistons properly instead of just cancelling the event
if (event.blocks.any { it.location.correspondingSection != null })
event.isCancelled = true
}

/** Disables pistons retracting if they are in the overlap of two sections */
@EventHandler
fun onPistonRetractEvent(event: BlockPistonRetractEvent) {
if (event.blocks.any { it.location.correspondingSection != null })
event.isCancelled = true
}

@EventHandler
fun onWaterEmptyEvent(event: PlayerBucketEmptyEvent) =
updateCorrespondingBlock(event.block.location) { orig, corr ->
Expand Down

0 comments on commit 5071092

Please sign in to comment.