From 507109284f2eb9a02b2e7b9a4b14540a889393c6 Mon Sep 17 00:00:00 2001 From: Daniel Voznyy Date: Sat, 2 May 2020 21:52:15 -0400 Subject: [PATCH] Added piston retract event listener (#32) * Check all blocks moved by piston instead of only one. * Added retract event listener --- .../synchronization/SectionSyncListener.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/derongan/minecraft/deeperworld/synchronization/SectionSyncListener.kt b/src/main/java/com/derongan/minecraft/deeperworld/synchronization/SectionSyncListener.kt index fc68057..21d92d3 100644 --- a/src/main/java/com/derongan/minecraft/deeperworld/synchronization/SectionSyncListener.kt +++ b/src/main/java/com/derongan/minecraft/deeperworld/synchronization/SectionSyncListener.kt @@ -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 ->