3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-24 15:20:11 +01:00
Paper/nms-patches/BlockPiston.patch

86 Zeilen
3.7 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/BlockPiston.java
+++ b/net/minecraft/server/BlockPiston.java
2019-12-10 23:00:00 +01:00
@@ -7,6 +7,14 @@
import java.util.Map;
import java.util.Map.Entry;
2015-02-26 23:41:06 +01:00
+// CraftBukkit start
+import com.google.common.collect.ImmutableList;
+import java.util.AbstractList;
+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
+
2016-02-29 22:32:46 +01:00
public class BlockPiston extends BlockDirectional {
2019-04-23 04:00:00 +02:00
public static final BlockStateBoolean EXTENDED = BlockProperties.g;
2020-06-25 02:00:00 +02:00
@@ -103,6 +111,18 @@
}
2018-07-15 02:00:00 +02:00
}
+ // CraftBukkit start
+ if (!this.sticky) {
+ 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);
+
+ if (event.isCancelled()) {
+ return;
+ }
+ }
+ // PAIL: checkME - what happened to setTypeAndData?
+ // CraftBukkit end
2020-06-25 02:00:00 +02:00
world.playBlockAction(blockposition, this, b0, enumdirection.c());
}
2020-06-25 02:00:00 +02:00
@@ -277,6 +297,48 @@
IBlockData[] aiblockdata = new IBlockData[list.size() + list2.size()];
2016-02-29 22:32:46 +01:00
EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.opposite();
2020-06-25 02:00:00 +02:00
int j = 0;
+ // CraftBukkit start
+ final org.bukkit.block.Block bblock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+
+ final List<BlockPosition> moved = pistonextendschecker.getMovedBlocks();
+ final List<BlockPosition> broken = pistonextendschecker.getBrokenBlocks();
+
+ 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());
+ }
+ };
+ 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));
+ }
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ for (BlockPosition b : broken) {
2016-02-29 22:32:46 +01:00
+ world.notify(b, Blocks.AIR.getBlockData(), world.getType(b), 3);
+ }
+ for (BlockPosition b : moved) {
2016-02-29 22:32:46 +01:00
+ world.notify(b, Blocks.AIR.getBlockData(), world.getType(b), 3);
+ b = b.shift(enumdirection1);
+ world.notify(b, Blocks.AIR.getBlockData(), world.getType(b), 3);
+ }
+ return false;
+ }
+ // CraftBukkit end
2018-08-26 04:00:00 +02:00
BlockPosition blockposition3;
2018-12-06 00:00:00 +01:00
int k;