Call BlockRedstoneEvent for fence gates (#3026)

Co-authored-by: Jan Boerman <Janboerman95@gmail.com>
This commit is contained in:
Jan 2020-03-14 14:39:54 +01:00 committed by GitHub
parent c8dea96ee1
commit 0ad8cf73ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 2 deletions

View File

@ -1,4 +1,4 @@
From 0b298d491792d27eb44e0f47efa1bf643b5297fb Mon Sep 17 00:00:00 2001
From 5350778e510bb69d70efd8d83fb58caf1cdf8fd9 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 28 Dec 2016 01:18:55 -0500
Subject: [PATCH] Fireworks API's
@ -37,5 +37,5 @@ index f844d5aa..e8c04c13 100644
+ // Paper end
}
--
2.25.0.windows.1
2.14.1.windows.1

View File

@ -0,0 +1,31 @@
From 916bcb6ec2a4b12f0e11095eacd09a56aaa0dfe1 Mon Sep 17 00:00:00 2001
From: Jan Boerman <Janboerman95@gmail.com>
Date: Sat, 14 Mar 2020 14:17:35 +0100
Subject: [PATCH] Call BlockRedstoneEvent for fence gates
diff --git a/src/main/java/net/minecraft/server/BlockFenceGate.java b/src/main/java/net/minecraft/server/BlockFenceGate.java
index 432e47bb..583eb688 100644
--- a/src/main/java/net/minecraft/server/BlockFenceGate.java
+++ b/src/main/java/net/minecraft/server/BlockFenceGate.java
@@ -103,6 +103,17 @@ public class BlockFenceGate extends BlockFacingHorizontal {
public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) {
if (!world.isClientSide) {
boolean flag1 = world.isBlockIndirectlyPowered(blockposition);
+ // Paper start
+ boolean isOldPowered = iblockdata.get(BlockFenceGate.POWERED);
+ if (flag1 != isOldPowered) {
+ int newPower = flag1 ? 15 : 0;
+ int oldPower = isOldPowered ? 15 : 0;
+ org.bukkit.block.Block bukkitBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, blockposition);
+ org.bukkit.event.block.BlockRedstoneEvent eventRedstone = new org.bukkit.event.block.BlockRedstoneEvent(bukkitBlock, oldPower, newPower);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+ flag1 = eventRedstone.getNewCurrent() > 0;
+ }
+ // Paper end
if ((Boolean) iblockdata.get(BlockFenceGate.POWERED) != flag1) {
world.setTypeAndData(blockposition, (IBlockData) ((IBlockData) iblockdata.set(BlockFenceGate.POWERED, flag1)).set(BlockFenceGate.OPEN, flag1), 2);
--
2.14.1.windows.1