Paper/nms-patches/BlockDoor.patch

38 lines
2.0 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/BlockDoor.java
+++ b/net/minecraft/server/BlockDoor.java
2016-11-17 02:41:03 +01:00
@@ -2,6 +2,8 @@
import java.util.Random;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockDoor extends Block {
2016-02-29 22:32:46 +01:00
public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING;
2016-11-17 02:41:03 +01:00
@@ -137,9 +139,23 @@
this.b(world, blockposition, iblockdata, 0);
}
} else {
2016-11-17 02:41:03 +01:00
- boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || world.isBlockIndirectlyPowered(blockposition3);
2015-02-26 23:41:06 +01:00
2016-11-17 02:41:03 +01:00
- if (block != this && (flag1 || block.getBlockData().n()) && flag1 != ((Boolean) iblockdata2.get(BlockDoor.POWERED)).booleanValue()) {
+ // CraftBukkit start
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.block.Block bukkitBlock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
2016-11-17 02:41:03 +01:00
+ org.bukkit.block.Block blockTop = bworld.getBlockAt(blockposition3.getX(), blockposition3.getY(), blockposition3.getZ());
+
+ int power = bukkitBlock.getBlockPower();
+ int powerTop = blockTop.getBlockPower();
+ if (powerTop > power) power = powerTop;
2016-11-17 02:41:03 +01:00
+ int oldPower = (Boolean) iblockdata2.get(BlockDoor.POWERED) ? 15 : 0;
+
+ if (oldPower == 0 ^ power == 0) {
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, oldPower, power);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
2015-02-26 23:41:06 +01:00
+
+ boolean flag1 = eventRedstone.getNewCurrent() > 0;
2016-11-17 02:41:03 +01:00
+ // CraftBukkit end
world.setTypeAndData(blockposition3, iblockdata2.set(BlockDoor.POWERED, Boolean.valueOf(flag1)), 2);
if (flag1 != ((Boolean) iblockdata.get(BlockDoor.OPEN)).booleanValue()) {
world.setTypeAndData(blockposition, iblockdata.set(BlockDoor.OPEN, Boolean.valueOf(flag1)), 2);