craftbukkit/nms-patches/net/minecraft/world/entity/EntityLightning.patch

63 lines
2.8 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/entity/EntityLightning.java
+++ b/net/minecraft/world/entity/EntityLightning.java
2025-03-26 03:05:00 +11:00
@@ -29,6 +29,11 @@
2021-03-16 09:00:00 +11:00
import net.minecraft.world.phys.AxisAlignedBB;
2021-06-11 15:00:00 +10:00
import net.minecraft.world.phys.Vec3D;
2021-03-16 09:00:00 +11:00
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityRemoveEvent;
2021-03-16 09:00:00 +11:00
+// CraftBukkit end
+
2019-04-23 12:00:00 +10:00
public class EntityLightning extends Entity {
2021-06-11 15:00:00 +10:00
private static final int START_LIFE = 2;
2025-03-26 03:05:00 +11:00
@@ -112,7 +117,7 @@
}
}
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
} else if (this.life < -this.random.nextInt(10)) {
--this.flashes;
this.life = 1;
2025-03-26 03:05:00 +11:00
@@ -121,7 +126,7 @@
}
}
2021-06-11 15:00:00 +10:00
- if (this.life >= 0) {
2021-11-22 09:00:00 +11:00
+ if (this.life >= 0 && !this.visualOnly) { // CraftBukkit - add !this.visualOnly
2023-06-08 01:30:00 +10:00
if (!(this.level() instanceof WorldServer)) {
this.level().setSkyFlashTime(2);
2021-06-11 15:00:00 +10:00
} else if (!this.visualOnly) {
2025-03-26 03:05:00 +11:00
@@ -158,8 +163,12 @@
2024-10-23 02:15:00 +11:00
IBlockData iblockdata = BlockFireAbstract.getState(this.level(), blockposition);
2018-07-15 10:00:00 +10:00
2024-10-23 02:15:00 +11:00
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
- this.level().setBlockAndUpdate(blockposition, iblockdata);
- ++this.blocksSetOnFire;
+ // CraftBukkit start - add "!visualOnly"
+ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(this.level(), blockposition, this).isCancelled()) {
+ this.level().setBlockAndUpdate(blockposition, iblockdata);
+ ++this.blocksSetOnFire;
+ }
+ // CraftBukkit end
}
2018-07-15 10:00:00 +10:00
2024-10-23 02:15:00 +11:00
for (int j = 0; j < i; ++j) {
2025-03-26 03:05:00 +11:00
@@ -167,8 +176,12 @@
2018-07-15 10:00:00 +10:00
2024-10-23 02:15:00 +11:00
iblockdata = BlockFireAbstract.getState(this.level(), blockposition1);
if (this.level().getBlockState(blockposition1).isAir() && iblockdata.canSurvive(this.level(), blockposition1)) {
- this.level().setBlockAndUpdate(blockposition1, iblockdata);
- ++this.blocksSetOnFire;
+ // CraftBukkit start - add "!visualOnly"
+ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(this.level(), blockposition1, this).isCancelled()) {
+ this.level().setBlockAndUpdate(blockposition1, iblockdata);
+ ++this.blocksSetOnFire;
+ }
+ // CraftBukkit end
}
}
2018-07-15 10:00:00 +10:00