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

74 lines
3.2 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
@@ -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;
@@ -120,7 +125,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;
@@ -129,7 +134,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) {
@@ -163,8 +168,12 @@
2023-06-08 01:30:00 +10:00
IBlockData iblockdata = BlockFireAbstract.getState(this.level(), blockposition);
2018-07-15 10:00:00 +10:00
2023-06-08 01:30:00 +10:00
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
- this.level().setBlockAndUpdate(blockposition, iblockdata);
2021-06-11 15:00:00 +10:00
- ++this.blocksSetOnFire;
2021-11-22 09:00:00 +11:00
+ // CraftBukkit start - add "!visualOnly"
2023-06-08 01:30:00 +10:00
+ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(this.level(), blockposition, this).isCancelled()) {
+ this.level().setBlockAndUpdate(blockposition, iblockdata);
2021-06-11 15:00:00 +10:00
+ ++this.blocksSetOnFire;
2018-07-15 10:00:00 +10:00
+ }
+ // CraftBukkit end
}
for (int j = 0; j < i; ++j) {
@@ -172,8 +181,12 @@
2018-07-15 10:00:00 +10:00
2023-06-08 01:30:00 +10:00
iblockdata = BlockFireAbstract.getState(this.level(), blockposition1);
if (this.level().getBlockState(blockposition1).isAir() && iblockdata.canSurvive(this.level(), blockposition1)) {
- this.level().setBlockAndUpdate(blockposition1, iblockdata);
2021-06-11 15:00:00 +10:00
- ++this.blocksSetOnFire;
2021-11-22 09:00:00 +11:00
+ // CraftBukkit start - add "!visualOnly"
2023-06-08 01:30:00 +10:00
+ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(this.level(), blockposition1, this).isCancelled()) {
+ this.level().setBlockAndUpdate(blockposition1, iblockdata);
2021-06-11 15:00:00 +10:00
+ ++this.blocksSetOnFire;
2018-07-15 10:00:00 +10:00
+ }
+ // CraftBukkit end
}
}
@@ -237,8 +250,9 @@
2021-11-22 09:00:00 +11:00
iblockdata = world.getBlockState(blockposition1);
2021-06-11 15:00:00 +10:00
} while (!(iblockdata.getBlock() instanceof WeatheringCopper));
+ BlockPosition blockposition1Final = blockposition1; // CraftBukkit - decompile error
2021-11-22 09:00:00 +11:00
WeatheringCopper.getPrevious(iblockdata).ifPresent((iblockdata1) -> {
- world.setBlockAndUpdate(blockposition1, iblockdata1);
+ world.setBlockAndUpdate(blockposition1Final, iblockdata1); // CraftBukkit - decompile error
2021-06-11 15:00:00 +10:00
});
2021-11-22 09:00:00 +11:00
world.levelEvent(3002, blockposition1, -1);
2021-06-11 15:00:00 +10:00
return Optional.of(blockposition1);