aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChristopheG <[email protected]>2022-09-20 04:35:38 +0200
committerGitHub <[email protected]>2022-09-20 03:35:38 +0100
commit8db45c43121185f0e65cf31767ede2d79d2f4a65 (patch)
tree5e51fec38ac4dbc1ab9814244e8f3bc52f653709
parentad3dffe715cef9e4de62af281c86bb198b3356c7 (diff)
downloadPaper-8db45c43121185f0e65cf31767ede2d79d2f4a65.tar.gz
Paper-8db45c43121185f0e65cf31767ede2d79d2f4a65.zip
Copper clear on lightning strike calls EntityChangeBlockEvent (#8126)
-rw-r--r--patches/server/0939-Fire-EntityChangeBlockEvent-in-more-places.patch74
1 files changed, 74 insertions, 0 deletions
diff --git a/patches/server/0939-Fire-EntityChangeBlockEvent-in-more-places.patch b/patches/server/0939-Fire-EntityChangeBlockEvent-in-more-places.patch
index b63f507fd2..0239bf3a4f 100644
--- a/patches/server/0939-Fire-EntityChangeBlockEvent-in-more-places.patch
+++ b/patches/server/0939-Fire-EntityChangeBlockEvent-in-more-places.patch
@@ -3,7 +3,81 @@ From: Jake Potrebic <[email protected]>
Date: Mon, 9 Aug 2021 20:45:46 -0700
Subject: [PATCH] Fire EntityChangeBlockEvent in more places
+Co-authored-by: ChristopheG <[email protected]>
+diff --git a/src/main/java/net/minecraft/world/entity/LightningBolt.java b/src/main/java/net/minecraft/world/entity/LightningBolt.java
+index 359c78b4f98c38c81af27a2c4cf0939da51e5a0b..50612c00f53821ccafce94835caf1ba442be299a 100644
+--- a/src/main/java/net/minecraft/world/entity/LightningBolt.java
++++ b/src/main/java/net/minecraft/world/entity/LightningBolt.java
+@@ -100,7 +100,7 @@ public class LightningBolt extends Entity {
+ }
+
+ this.powerLightningRod();
+- LightningBolt.clearCopperOnLightningStrike(this.level, this.getStrikePosition());
++ LightningBolt.clearCopperOnLightningStrike(this.level, this.getStrikePosition(), this); // Paper - transmit LightningBolt instance to call EntityChangeBlockEvent
+ this.gameEvent(GameEvent.LIGHTNING_STRIKE);
+ }
+ }
+@@ -194,7 +194,7 @@ public class LightningBolt extends Entity {
+ }
+ }
+
+- private static void clearCopperOnLightningStrike(Level world, BlockPos pos) {
++ private static void clearCopperOnLightningStrike(Level world, BlockPos pos, Entity lightning) { // Paper - transmit LightningBolt instance to call EntityChangeBlockEvent
+ BlockState iblockdata = world.getBlockState(pos);
+ BlockPos blockposition1;
+ BlockState iblockdata1;
+@@ -208,24 +208,29 @@ public class LightningBolt extends Entity {
+ }
+
+ if (iblockdata1.getBlock() instanceof WeatheringCopper) {
+- world.setBlockAndUpdate(blockposition1, WeatheringCopper.getFirst(world.getBlockState(blockposition1)));
++ // Paper start - call EntityChangeBlockEvent
++ BlockState newBlock = WeatheringCopper.getFirst(world.getBlockState(blockposition1));
++ if (!CraftEventFactory.callEntityChangeBlockEvent(lightning, blockposition1, newBlock).isCancelled()) {
++ world.setBlockAndUpdate(blockposition1, newBlock);
++ }
++ // Paper end
+ BlockPos.MutableBlockPos blockposition_mutableblockposition = pos.mutable();
+ int i = world.random.nextInt(3) + 3;
+
+ for (int j = 0; j < i; ++j) {
+ int k = world.random.nextInt(8) + 1;
+
+- LightningBolt.randomWalkCleaningCopper(world, blockposition1, blockposition_mutableblockposition, k);
++ LightningBolt.randomWalkCleaningCopper(world, blockposition1, blockposition_mutableblockposition, k, lightning); // Paper - transmit LightningBolt instance to call EntityChangeBlockEvent
+ }
+
+ }
+ }
+
+- private static void randomWalkCleaningCopper(Level world, BlockPos pos, BlockPos.MutableBlockPos mutablePos, int count) {
++ private static void randomWalkCleaningCopper(Level world, BlockPos pos, BlockPos.MutableBlockPos mutablePos, int count, Entity lightning) { // Paper - transmit LightningBolt instance to call EntityChangeBlockEvent
+ mutablePos.set(pos);
+
+ for (int j = 0; j < count; ++j) {
+- Optional<BlockPos> optional = LightningBolt.randomStepCleaningCopper(world, mutablePos);
++ Optional<BlockPos> optional = LightningBolt.randomStepCleaningCopper(world, mutablePos, lightning); // Paper - transmit LightningBolt instance to call EntityChangeBlockEvent
+
+ if (!optional.isPresent()) {
+ break;
+@@ -236,7 +241,7 @@ public class LightningBolt extends Entity {
+
+ }
+
+- private static Optional<BlockPos> randomStepCleaningCopper(Level world, BlockPos pos) {
++ private static Optional<BlockPos> randomStepCleaningCopper(Level world, BlockPos pos, Entity lightning) { // Paper - transmit LightningBolt instance to call EntityChangeBlockEvent
+ Iterator iterator = BlockPos.randomInCube(world.random, 10, pos, 1).iterator();
+
+ BlockPos blockposition1;
+@@ -253,6 +258,7 @@ public class LightningBolt extends Entity {
+
+ BlockPos blockposition1Final = blockposition1; // CraftBukkit - decompile error
+ WeatheringCopper.getPrevious(iblockdata).ifPresent((iblockdata1) -> {
++ if (!CraftEventFactory.callEntityChangeBlockEvent(lightning, blockposition1Final, iblockdata1).isCancelled()) // Paper - call EntityChangeBlockEvent
+ world.setBlockAndUpdate(blockposition1Final, iblockdata1); // CraftBukkit - decompile error
+ });
+ world.levelEvent(3002, blockposition1, -1);
diff --git a/src/main/java/net/minecraft/world/item/AxeItem.java b/src/main/java/net/minecraft/world/item/AxeItem.java
index 03a6a99dcc0c8fcc32776dd49cf6092b899bf6ed..9c49d8f696864d2aad23208422c4ab5b598a0cd9 100644
--- a/src/main/java/net/minecraft/world/item/AxeItem.java