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
2024-04-24 01:15:00 +10:00
@@ -30,6 +30,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;
2024-04-24 01:15:00 +10:00
@@ -121,7 +126,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;
2024-04-24 01:15:00 +10:00
@@ -130,7 +135,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) {
2024-04-24 01:15:00 +10:00
@@ -164,8 +169,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) {
2024-04-24 01:15:00 +10:00
@@ -173,8 +182,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
}
}
2024-04-24 01:15:00 +10:00
@@ -238,8 +251,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);