2015-02-26 23:41:06 +01:00
|
|
|
--- /home/matt/mc-dev-private//net/minecraft/server/EntityLightning.java 2015-02-26 22:40:22.607608139 +0000
|
|
|
|
+++ src/main/java/net/minecraft/server/EntityLightning.java 2015-02-26 22:40:22.611608139 +0000
|
|
|
|
@@ -2,30 +2,53 @@
|
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;
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ public boolean isEffect = false;
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
public EntityLightning(World world, double d0, double d1, double d2) {
|
|
|
|
+ this(world, d0, d1, d2, false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public EntityLightning(World world, double d0, double d1, double d2, boolean isEffect) {
|
|
|
|
+ // CraftBukkit end
|
|
|
|
super(world);
|
|
|
|
+
|
|
|
|
+ // CraftBukkit - Set isEffect
|
|
|
|
+ this.isEffect = isEffect;
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
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();
|
|
|
|
this.c = this.random.nextInt(3) + 1;
|
2015-02-26 23:41:06 +01:00
|
|
|
BlockPosition blockposition = new BlockPosition(this);
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2015-02-26 23:41:06 +01:00
|
|
|
- if (!world.isClientSide && world.getGameRules().getBoolean("doFireTick") && (world.getDifficulty() == EnumDifficulty.NORMAL || world.getDifficulty() == EnumDifficulty.HARD) && world.areChunksLoaded(blockposition, 10)) {
|
|
|
|
+ // CraftBukkit - add "!isEffect"
|
|
|
|
+ if (!isEffect && !world.isClientSide && world.getGameRules().getBoolean("doFireTick") && (world.getDifficulty() == EnumDifficulty.NORMAL || world.getDifficulty() == EnumDifficulty.HARD) && world.areChunksLoaded(blockposition, 10)) {
|
|
|
|
if (world.getType(blockposition).getBlock().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);
|
|
|
|
|
2015-02-26 23:41:06 +01:00
|
|
|
if (world.getType(blockposition1).getBlock().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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
@@ -35,7 +58,24 @@
|
|
|
|
public void t_() {
|
|
|
|
super.t_();
|
2014-11-25 22:32:16 +01:00
|
|
|
if (this.lifeTicks == 2) {
|
|
|
|
- this.world.makeSound(this.locX, this.locY, this.locZ, "ambient.weather.thunder", 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
|
|
|
|
+ // CraftBukkit start - Use relative location for far away sounds
|
|
|
|
+ //this.world.makeSound(this.locX, this.locY, this.locZ, "ambient.weather.thunder", 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
|
|
|
|
+ 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;
|
|
|
|
+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect("ambient.weather.thunder", relativeX, this.locY, relativeZ, 10000.0F, pitch));
|
|
|
|
+ } else {
|
|
|
|
+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect("ambient.weather.thunder", this.locX, this.locY, this.locZ, 10000.0F, pitch));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
this.world.makeSound(this.locX, this.locY, this.locZ, "random.explode", 2.0F, 0.5F + this.random.nextFloat() * 0.2F);
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:41:06 +01:00
|
|
|
@@ -49,13 +89,18 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
this.a = this.random.nextLong();
|
|
|
|
BlockPosition blockposition = new BlockPosition(this);
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit - add "!isEffect"
|
2015-02-26 23:41:06 +01:00
|
|
|
if (!this.world.isClientSide && this.world.getGameRules().getBoolean("doFireTick") && this.world.areChunksLoaded(blockposition, 10) && this.world.getType(blockposition).getBlock().getMaterial() == Material.AIR && Blocks.FIRE.canPlace(this.world, blockposition)) {
|
|
|
|
- this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2015-02-26 23:41:06 +01:00
|
|
|
+ if (!isEffect && !CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this).isCancelled()) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- 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);
|
2014-11-25 22:32:16 +01:00
|
|
|
} else {
|