mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-01-19 00:45:27 +01:00
Fix a dupe bug that resulted from yet another change to piston code a couple mc patches ago. Oh well.
This commit is contained in:
parent
f85c54596a
commit
01a8a199d2
@ -67,24 +67,15 @@ public class BlockListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||||
BlockFace direction = event.getDirection();
|
BlockFace direction = event.getDirection();
|
||||||
Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished
|
Block movedBlock = event.getBlock();
|
||||||
|
movedBlock = movedBlock.getRelative(direction, 2);
|
||||||
|
|
||||||
if (futureEmptyBlock.getType() == Material.AIR) {
|
for (Block b : event.getBlocks()) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Block> blocks = event.getBlocks();
|
|
||||||
|
|
||||||
for (Block b : blocks) {
|
|
||||||
if (BlockUtils.shouldBeWatched(b.getState()) && mcMMO.getPlaceStore().isTrue(b)) {
|
if (BlockUtils.shouldBeWatched(b.getState()) && mcMMO.getPlaceStore().isTrue(b)) {
|
||||||
Block nextBlock = b.getRelative(direction);
|
movedBlock = b.getRelative(direction);
|
||||||
mcMMO.getPlaceStore().setTrue(nextBlock);
|
mcMMO.getPlaceStore().setTrue(movedBlock);
|
||||||
//b.getRelative(direction).setMetadata(mcMMO.blockMetadataKey, mcMMO.metadataValue);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed because blocks sometimes don't move when two pistons push towards each other
|
|
||||||
//new PistonTrackerTask(blocks, direction, futureEmptyBlock).runTaskLater(plugin, 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,36 +85,15 @@ public class BlockListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||||
// event.isSticky() always returns false
|
|
||||||
// if (!event.isSticky()){
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Sticky piston return PISTON_MOVING_PIECE and normal piston PISTON_BASE
|
|
||||||
if (event.getBlock().getType() != Material.PISTON_MOVING_PIECE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get opposite direction so we get correct block
|
// Get opposite direction so we get correct block
|
||||||
BlockFace direction = event.getDirection().getOppositeFace();
|
BlockFace direction = event.getDirection();
|
||||||
Block movedBlock = event.getBlock().getRelative(direction);
|
Block movedBlock = event.getBlock().getRelative(direction);
|
||||||
mcMMO.getPlaceStore().setTrue(movedBlock);
|
mcMMO.getPlaceStore().setTrue(movedBlock);
|
||||||
|
|
||||||
// If we're pulling a slime block, it might have something attached to it!
|
for (Block block : event.getBlocks()) {
|
||||||
if (movedBlock.getRelative(direction).getState().getType() == Material.SLIME_BLOCK) {
|
movedBlock = block.getRelative(direction);
|
||||||
for (Block block : event.getBlocks()) {
|
mcMMO.getPlaceStore().setTrue(movedBlock);
|
||||||
movedBlock = block.getRelative(direction);
|
|
||||||
mcMMO.getPlaceStore().setTrue(movedBlock);
|
|
||||||
// // Treat the slime blocks 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.
|
|
||||||
// new StickyPistonTrackerTask(direction, event.getBlock(), block).runTaskLater(plugin, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed only because under some circumstances Minecraft doesn't move the block
|
|
||||||
//new StickyPistonTrackerTask(direction, event.getBlock(), movedBlock).runTaskLater(plugin, 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user