Paper/src/main/java/net/minecraft/server/EntityLightning.java

118 Zeilen
4.4 KiB
Java

package net.minecraft.server;
import java.util.List;
2011-04-26 03:19:44 +02:00
import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
2012-07-29 09:33:13 +02:00
public class EntityLightning extends EntityWeather {
private int lifeTicks;
2013-07-01 13:03:00 +02:00
public long a;
private int c;
2011-04-26 03:19:44 +02:00
// CraftBukkit start
public boolean isEffect = false;
2012-07-29 09:33:13 +02:00
public EntityLightning(World world, double d0, double d1, double d2) {
this(world, d0, d1, d2, false);
}
2012-07-29 09:33:13 +02:00
public EntityLightning(World world, double d0, double d1, double d2, boolean isEffect) {
2011-06-12 00:02:58 +02:00
// CraftBukkit end
2011-04-26 03:19:44 +02:00
super(world);
// CraftBukkit start
this.isEffect = isEffect;
// CraftBukkit end
2011-04-26 03:19:44 +02: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;
2011-11-20 09:01:14 +01:00
2011-05-14 16:29:42 +02:00
// CraftBukkit
2013-07-01 13:03:00 +02:00
if (!isEffect && !world.isStatic && world.getGameRules().getBoolean("doFireTick") && world.difficulty >= 2 && world.areChunksLoaded(MathHelper.floor(d0), MathHelper.floor(d1), MathHelper.floor(d2), 10)) {
int i = MathHelper.floor(d0);
int j = MathHelper.floor(d1);
int k = MathHelper.floor(d2);
if (world.getTypeId(i, j, k) == 0 && Block.FIRE.canPlace(world, i, j, k)) {
// CraftBukkit start
if (!CraftEventFactory.callBlockIgniteEvent(world, i, j, k, this).isCancelled()) {
2013-03-13 23:33:27 +01:00
world.setTypeIdUpdate(i, j, k, Block.FIRE.id);
}
// CraftBukkit end
}
for (i = 0; i < 4; ++i) {
j = MathHelper.floor(d0) + this.random.nextInt(3) - 1;
k = MathHelper.floor(d1) + this.random.nextInt(3) - 1;
int l = MathHelper.floor(d2) + this.random.nextInt(3) - 1;
if (world.getTypeId(j, k, l) == 0 && Block.FIRE.canPlace(world, j, k, l)) {
// CraftBukkit start
if (!CraftEventFactory.callBlockIgniteEvent(world, j, k, l, this).isCancelled()) {
world.setTypeIdUpdate(i, j, k, Block.FIRE.id);
}
// CraftBukkit end
}
}
}
}
2013-03-13 23:33:27 +01:00
public void l_() {
super.l_();
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);
this.world.makeSound(this.locX, this.locY, this.locZ, "random.explode", 2.0F, 0.5F + this.random.nextFloat() * 0.2F);
}
--this.lifeTicks;
if (this.lifeTicks < 0) {
if (this.c == 0) {
this.die();
} else if (this.lifeTicks < -this.random.nextInt(10)) {
--this.c;
this.lifeTicks = 1;
this.a = this.random.nextLong();
2011-05-26 14:48:22 +02:00
// CraftBukkit
2013-07-01 13:03:00 +02:00
if (!isEffect && !this.world.isStatic && this.world.getGameRules().getBoolean("doFireTick") && this.world.areChunksLoaded(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ), 10)) {
int i = MathHelper.floor(this.locX);
int j = MathHelper.floor(this.locY);
int k = MathHelper.floor(this.locZ);
if (this.world.getTypeId(i, j, k) == 0 && Block.FIRE.canPlace(this.world, i, j, k)) {
// CraftBukkit start
if (!CraftEventFactory.callBlockIgniteEvent(world, i, j, k, this).isCancelled()) {
world.setTypeIdUpdate(i, j, k, Block.FIRE.id);
}
// CraftBukkit end
}
}
}
}
2012-12-20 05:03:52 +01:00
if (this.lifeTicks >= 0 && !this.isEffect) { // CraftBukkit - add !this.isEffect
if (this.world.isStatic) {
this.world.q = 2;
} else {
double d0 = 3.0D;
List list = this.world.getEntities(this, AxisAlignedBB.a().a(this.locX - d0, this.locY - d0, this.locZ - d0, this.locX + d0, this.locY + 6.0D + d0, this.locZ + d0));
2012-12-20 05:03:52 +01:00
for (int l = 0; l < list.size(); ++l) {
Entity entity = (Entity) list.get(l);
2012-12-20 05:03:52 +01:00
entity.a(this);
}
}
}
}
2012-07-29 09:33:13 +02:00
protected void a() {}
protected void a(NBTTagCompound nbttagcompound) {}
protected void b(NBTTagCompound nbttagcompound) {}
}