|
@@ -2,7 +2,6 @@ package com.gmail.nossr50.listeners;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
-import org.bukkit.Bukkit;
|
|
|
import org.bukkit.GameMode;
|
|
|
import org.bukkit.Location;
|
|
|
import org.bukkit.Material;
|
|
@@ -65,10 +64,6 @@ public class BlockListener implements Listener {
|
|
|
*/
|
|
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
|
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
|
|
- if (!EventUtils.shouldProcessEvent(event.getBlock(), true)) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
BlockFace direction = event.getDirection();
|
|
|
Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished
|
|
|
|
|
@@ -95,27 +90,35 @@ public class BlockListener implements Listener {
|
|
|
*/
|
|
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
|
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
|
|
- if (!EventUtils.shouldProcessEvent(event.getBlock(), false)) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ // event.isSticky() always returns false
|
|
|
+ // if (!event.isSticky()){
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
|
|
|
- // Don't even work, return ALLWAYS false xD
|
|
|
- /*if (!event.isSticky()){
|
|
|
- return;
|
|
|
- }*/
|
|
|
-
|
|
|
- // Sticky piston return PISTON_MOVING_PIECE and normal piston PISTON_BASE, so mess stuff
|
|
|
+ // Sticky piston return PISTON_MOVING_PIECE and normal piston PISTON_BASE
|
|
|
if (event.getBlock().getType() != Material.PISTON_MOVING_PIECE) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // event.getRetractLocation() return wrong side and too far away
|
|
|
- // Get opposite direction so we get correct block, so mess stuff
|
|
|
- Block movedBlock = event.getBlock().getRelative(event.getDirection().getOppositeFace());
|
|
|
+ // Get opposite direction so we get correct block
|
|
|
+ BlockFace direction = event.getDirection().getOppositeFace();
|
|
|
+ Block movedBlock = event.getBlock().getRelative(direction);
|
|
|
+
|
|
|
+ // If we're pulling a slime block, it might have something attached to it!
|
|
|
+ if (movedBlock.getRelative(direction).getState().getType() == Material.SLIME_BLOCK) {
|
|
|
+ // Check if any other slime blocks are attached, because they can also pull blocks
|
|
|
+ List<Block> adjacentBlocks = BlockUtils.getAdjacentBlocks(movedBlock.getRelative(direction), Material.SLIME_BLOCK);
|
|
|
+ for (Block b : adjacentBlocks) {
|
|
|
+ new StickyPistonTrackerTask(direction, event.getBlock(), b).runTaskLater(plugin, 2);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Treat the slime block as if it is the sticky piston itself, because pulling
|
|
|
+ // a slime block with a sticky piston is effectively the same as moving a sticky piston.
|
|
|
+ movedBlock = movedBlock.getRelative(direction);
|
|
|
+ }
|
|
|
|
|
|
// Needed only because under some circumstances Minecraft doesn't move the block
|
|
|
- // Opposite side here too
|
|
|
- new StickyPistonTrackerTask(event.getDirection().getOppositeFace(), event.getBlock(), movedBlock).runTaskLater(plugin, 2);
|
|
|
+ new StickyPistonTrackerTask(direction, event.getBlock(), movedBlock).runTaskLater(plugin, 2);
|
|
|
}
|
|
|
|
|
|
/**
|