0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git synced 2024-11-22 10:06:16 +00:00
craftbukkit/nms-patches/net/minecraft/world/level/block/BlockDoor.patch
2024-10-23 02:15:00 +11:00

39 lines
2.3 KiB
Diff

--- a/net/minecraft/world/level/block/BlockDoor.java
+++ b/net/minecraft/world/level/block/BlockDoor.java
@@ -39,6 +39,8 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockDoor extends Block {
public static final MapCodec<BlockDoor> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
@@ -222,9 +224,24 @@
@Override
protected void neighborChanged(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, @Nullable Orientation orientation, boolean flag) {
- boolean flag1 = world.hasNeighborSignal(blockposition) || world.hasNeighborSignal(blockposition.relative(iblockdata.getValue(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER ? EnumDirection.UP : EnumDirection.DOWN));
+ // CraftBukkit start
+ BlockPosition otherHalf = blockposition.relative(iblockdata.getValue(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER ? EnumDirection.UP : EnumDirection.DOWN);
- if (!this.defaultBlockState().is(block) && flag1 != (Boolean) iblockdata.getValue(BlockDoor.POWERED)) {
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.block.Block bukkitBlock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ org.bukkit.block.Block blockTop = bworld.getBlockAt(otherHalf.getX(), otherHalf.getY(), otherHalf.getZ());
+
+ int power = bukkitBlock.getBlockPower();
+ int powerTop = blockTop.getBlockPower();
+ if (powerTop > power) power = powerTop;
+ int oldPower = (Boolean) iblockdata.getValue(BlockDoor.POWERED) ? 15 : 0;
+
+ if (oldPower == 0 ^ power == 0) {
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, oldPower, power);
+ world.getCraftServer().getPluginManager().callEvent(eventRedstone);
+
+ boolean flag1 = eventRedstone.getNewCurrent() > 0;
+ // CraftBukkit end
if (flag1 != (Boolean) iblockdata.getValue(BlockDoor.OPEN)) {
this.playSound((Entity) null, world, blockposition, flag1);
world.gameEvent((Entity) null, (Holder) (flag1 ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE), blockposition);