2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/EntityLightning.java
|
|
|
|
+++ b/net/minecraft/server/EntityLightning.java
|
2016-02-29 22:32:46 +01:00
|
|
|
@@ -2,15 +2,19 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
|
|
|
+
|
|
|
|
public class EntityLightning extends EntityWeather {
|
|
|
|
|
|
|
|
private int lifeTicks;
|
|
|
|
public long a;
|
|
|
|
private int c;
|
2016-02-29 22:32:46 +01:00
|
|
|
private final boolean d;
|
|
|
|
+ public boolean isEffect; // CraftBukkit
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
public EntityLightning(World world, double d0, double d1, double d2, boolean flag) {
|
2014-11-25 22:32:16 +01:00
|
|
|
super(world);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ this.isEffect = flag; // CraftBukkit
|
2014-11-25 22:32:16 +01:00
|
|
|
this.setPositionRotation(d0, d1, d2, 0.0F, 0.0F);
|
|
|
|
this.lifeTicks = 2;
|
|
|
|
this.a = this.random.nextLong();
|
2016-02-29 22:32:46 +01:00
|
|
|
@@ -20,14 +24,22 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
if (!flag && !world.isClientSide && world.getGameRules().getBoolean("doFireTick") && (world.getDifficulty() == EnumDifficulty.NORMAL || world.getDifficulty() == EnumDifficulty.HARD) && world.areChunksLoaded(blockposition, 10)) {
|
|
|
|
if (world.getType(blockposition).getMaterial() == Material.AIR && Blocks.FIRE.canPlace(world, blockposition)) {
|
2014-11-25 22:32:16 +01:00
|
|
|
- world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (!CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this).isCancelled()) {
|
|
|
|
+ world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; ++i) {
|
|
|
|
BlockPosition blockposition1 = blockposition.a(this.random.nextInt(3) - 1, this.random.nextInt(3) - 1, this.random.nextInt(3) - 1);
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
if (world.getType(blockposition1).getMaterial() == Material.AIR && Blocks.FIRE.canPlace(world, blockposition1)) {
|
2014-11-25 22:32:16 +01:00
|
|
|
- world.setTypeUpdate(blockposition1, Blocks.FIRE.getBlockData());
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (!CraftEventFactory.callBlockIgniteEvent(world, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ(), this).isCancelled()) {
|
|
|
|
+ world.setTypeUpdate(blockposition1, Blocks.FIRE.getBlockData());
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-02-29 22:32:46 +01:00
|
|
|
@@ -41,7 +53,24 @@
|
2017-05-14 04:00:00 +02:00
|
|
|
public void B_() {
|
|
|
|
super.B_();
|
2014-11-25 22:32:16 +01:00
|
|
|
if (this.lifeTicks == 2) {
|
2017-05-14 04:00:00 +02:00
|
|
|
- this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dK, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - Use relative location for far away sounds
|
2017-05-14 04:00:00 +02:00
|
|
|
+ // this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dG, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ float pitch = 0.8F + this.random.nextFloat() * 0.2F;
|
|
|
|
+ int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16;
|
2015-02-26 23:41:06 +01:00
|
|
|
+ for (EntityPlayer player : (List<EntityPlayer>) (List) this.world.players) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ double deltaX = this.locX - player.locX;
|
|
|
|
+ double deltaZ = this.locZ - player.locZ;
|
|
|
|
+ double distanceSquared = deltaX * deltaX + deltaZ * deltaZ;
|
|
|
|
+ if (distanceSquared > viewDistance * viewDistance) {
|
|
|
|
+ double deltaLength = Math.sqrt(distanceSquared);
|
|
|
|
+ double relativeX = player.locX + (deltaX / deltaLength) * viewDistance;
|
|
|
|
+ double relativeZ = player.locZ + (deltaZ / deltaLength) * viewDistance;
|
2017-05-14 04:00:00 +02:00
|
|
|
+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.dK, SoundCategory.WEATHER, relativeX, this.locY, relativeZ, 10000.0F, pitch));
|
2014-11-25 22:32:16 +01:00
|
|
|
+ } else {
|
2017-05-14 04:00:00 +02:00
|
|
|
+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.dK, SoundCategory.WEATHER, this.locX, this.locY, this.locZ, 10000.0F, pitch));
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2017-05-14 04:00:00 +02:00
|
|
|
this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dJ, SoundCategory.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F);
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
@@ -57,13 +86,17 @@
|
|
|
|
BlockPosition blockposition = new BlockPosition(this);
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
if (this.world.getGameRules().getBoolean("doFireTick") && this.world.areChunksLoaded(blockposition, 10) && this.world.getType(blockposition).getMaterial() == Material.AIR && Blocks.FIRE.canPlace(this.world, blockposition)) {
|
|
|
|
- this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
|
|
|
|
+ // CraftBukkit start - add "!isEffect"
|
|
|
|
+ if (!isEffect && !CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this).isCancelled()) {
|
|
|
|
+ this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (this.lifeTicks >= 0) {
|
|
|
|
+ if (this.lifeTicks >= 0 && !this.isEffect) { // CraftBukkit - add !this.isEffect
|
2015-02-26 23:41:06 +01:00
|
|
|
if (this.world.isClientSide) {
|
|
|
|
this.world.d(2);
|
2016-02-29 22:32:46 +01:00
|
|
|
} else if (!this.d) {
|