2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/BlockPiston.java
|
|
|
|
+++ b/net/minecraft/server/BlockPiston.java
|
2015-02-26 23:41:06 +01:00
|
|
|
@@ -2,6 +2,18 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2015-02-26 23:41:06 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
+// CraftBukkit start
|
2014-11-25 22:32:16 +01:00
|
|
|
+import java.util.AbstractList;
|
|
|
|
+import java.util.Collection;
|
|
|
|
+import java.util.Iterator;
|
|
|
|
+import java.util.ListIterator;
|
|
|
|
+
|
2015-01-20 00:27:40 +01:00
|
|
|
+import com.google.common.collect.ImmutableList;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.craftbukkit.block.CraftBlock;
|
|
|
|
+import org.bukkit.event.block.BlockPistonRetractEvent;
|
|
|
|
+import org.bukkit.event.block.BlockPistonExtendEvent;
|
|
|
|
+// CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
public class BlockPiston extends Block {
|
|
|
|
|
2015-02-26 23:41:06 +01:00
|
|
|
public static final BlockStateDirection FACING = BlockStateDirection.of("facing");
|
|
|
|
@@ -56,6 +68,17 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
world.playBlockAction(blockposition, this, 0, enumdirection.a());
|
|
|
|
}
|
|
|
|
} else if (!flag && ((Boolean) iblockdata.get(BlockPiston.EXTENDED)).booleanValue()) {
|
|
|
|
+ // CraftBukkit start
|
2015-02-26 23:41:06 +01:00
|
|
|
+ if (!this.N) {
|
2015-01-20 00:27:40 +01:00
|
|
|
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
|
|
|
+ BlockPistonRetractEvent event = new BlockPistonRetractEvent(block, ImmutableList.<org.bukkit.block.Block>of(), CraftBlock.notchToBlockFace(enumdirection));
|
|
|
|
+ world.getServer().getPluginManager().callEvent(event);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2015-01-20 00:27:40 +01:00
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
world.setTypeAndData(blockposition, iblockdata.set(BlockPiston.EXTENDED, Boolean.valueOf(false)), 2);
|
|
|
|
world.playBlockAction(blockposition, this, 1, enumdirection.a());
|
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
@@ -146,7 +169,7 @@
|
2015-01-20 00:27:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:41:06 +01:00
|
|
|
- if (!flag1 && block.getMaterial() != Material.AIR && a(block, world, blockposition1, enumdirection.opposite(), false) && (block.k() == 0 || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) {
|
|
|
|
+ if (!flag1 && a(block, world, blockposition1, enumdirection.opposite(), false) && (block.k() == 0 || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) { // CraftBukkit - remove 'block.getMaterial() != Material.AIR' condition
|
2015-01-20 00:27:40 +01:00
|
|
|
this.a(world, blockposition, enumdirection, false);
|
|
|
|
}
|
|
|
|
} else {
|
2015-03-09 23:34:05 +01:00
|
|
|
@@ -286,10 +309,53 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
if (!pistonextendschecker.a()) {
|
|
|
|
return false;
|
|
|
|
} else {
|
2015-01-20 00:27:40 +01:00
|
|
|
+ // CraftBukkit start
|
2014-11-25 22:32:16 +01:00
|
|
|
+ final org.bukkit.block.Block bblock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
|
|
|
+
|
2015-03-09 23:34:05 +01:00
|
|
|
+ final List<BlockPosition> moved = pistonextendschecker.getMovedBlocks();
|
|
|
|
+ final List<BlockPosition> broken = pistonextendschecker.getBrokenBlocks();
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
+ List<org.bukkit.block.Block> blocks = new AbstractList<org.bukkit.block.Block>() {
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public int size() {
|
|
|
|
+ return moved.size() + broken.size();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public org.bukkit.block.Block get(int index) {
|
|
|
|
+ if (index >= size() || index < 0) {
|
|
|
|
+ throw new ArrayIndexOutOfBoundsException(index);
|
|
|
|
+ }
|
|
|
|
+ BlockPosition pos = (BlockPosition) (index < moved.size() ? moved.get(index) : broken.get(index - moved.size()));
|
|
|
|
+ return bblock.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
2014-12-05 16:11:22 +01:00
|
|
|
int i = list.size() + list1.size();
|
|
|
|
Block[] ablock = new Block[i];
|
|
|
|
EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.opposite();
|
|
|
|
|
2015-01-20 00:27:40 +01:00
|
|
|
+ org.bukkit.event.block.BlockPistonEvent event;
|
|
|
|
+ if (flag) {
|
|
|
|
+ event = new BlockPistonExtendEvent(bblock, blocks, CraftBlock.notchToBlockFace(enumdirection1));
|
|
|
|
+ } else {
|
|
|
|
+ event = new BlockPistonRetractEvent(bblock, blocks, CraftBlock.notchToBlockFace(enumdirection1));
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
2015-03-09 23:34:05 +01:00
|
|
|
+ for (BlockPosition b : broken) {
|
|
|
|
+ world.notify(b);
|
|
|
|
+ }
|
|
|
|
+ for (BlockPosition b : moved) {
|
|
|
|
+ world.notify(b);
|
|
|
|
+ world.notify(b.shift(enumdirection1));
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2014-12-05 16:11:22 +01:00
|
|
|
+
|
|
|
|
int j;
|
|
|
|
BlockPosition blockposition1;
|
|
|
|
|