Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package net.minecraft.server;
2
3import org.bukkit.craftbukkit.CraftWorld;
4import org.bukkit.event.block.BlockIgniteEvent;
5import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
6
7import java.util.List;
8
9// CraftBukkit start
10// CraftBukkit end
11
12public class EntityWeatherStorm extends EntityWeather {
13
14 private int lifeTicks;
15 public long a = 0L;
16 private int c;
17
18 // CraftBukkit start
19 private CraftWorld cworld;
20 public boolean isEffect = false;
21
22 public EntityWeatherStorm(World world, double d0, double d1, double d2) {
23 this(world, d0, d1, d2, false);
24 }
25
26 public EntityWeatherStorm(World world, double d0, double d1, double d2, boolean isEffect) {
27 // CraftBukkit end
28
29 super(world);
30
31 // CraftBukkit start
32 this.isEffect = isEffect;
33 this.cworld = world.getWorld();
34 // CraftBukkit end
35
36 this.setPositionRotation(d0, d1, d2, 0.0F, 0.0F);
37 this.lifeTicks = 2;
38 this.a = this.random.nextLong();
39 this.c = this.random.nextInt(3) + 1;
40 // CraftBukkit
41 if (!isEffect && world.spawnMonsters >= 2 && world.areChunksLoaded(MathHelper.floor(d0), MathHelper.floor(d1), MathHelper.floor(d2), 10)) {
42 int i = MathHelper.floor(d0);
43 int j = MathHelper.floor(d1);
44 int k = MathHelper.floor(d2);
45
46 if (world.getTypeId(i, j, k) == 0 && Block.FIRE.canPlace(world, i, j, k)) {
47 // CraftBukkit start
48 BlockIgniteEvent event = new BlockIgniteEvent(this.cworld.getBlockAt(i, j, k), IgniteCause.LIGHTNING, null);
49 world.getServer().getPluginManager().callEvent(event);
50
51 if (!event.isCancelled()) {
52 world.setTypeId(i, j, k, Block.FIRE.id);
53 }
54 // CraftBukkit end
55 }
56
57 for (i = 0; i < 4; ++i) {
58 j = MathHelper.floor(d0) + this.random.nextInt(3) - 1;
59 k = MathHelper.floor(d1) + this.random.nextInt(3) - 1;
60 int l = MathHelper.floor(d2) + this.random.nextInt(3) - 1;
61
62 if (world.getTypeId(j, k, l) == 0 && Block.FIRE.canPlace(world, j, k, l)) {
63 // CraftBukkit start
64 BlockIgniteEvent event = new BlockIgniteEvent(this.cworld.getBlockAt(j, k, l), IgniteCause.LIGHTNING, null);
65 world.getServer().getPluginManager().callEvent(event);
66
67 if (!event.isCancelled()) {
68 world.setTypeId(j, k, l, Block.FIRE.id);
69 }
70 // CraftBukkit end
71 }
72 }
73 }
74 }
75
76 public void m_() {
77 super.m_();
78 if (this.lifeTicks == 2) {
79 this.world.makeSound(this.locX, this.locY, this.locZ, "ambient.weather.thunder", 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
80 this.world.makeSound(this.locX, this.locY, this.locZ, "random.explode", 2.0F, 0.5F + this.random.nextFloat() * 0.2F);
81 }
82
83 --this.lifeTicks;
84 if (this.lifeTicks < 0) {
85 if (this.c == 0) {
86 this.die();
87 } else if (this.lifeTicks < -this.random.nextInt(10)) {
88 --this.c;
89 this.lifeTicks = 1;
90 this.a = this.random.nextLong();
91 // CraftBukkit
92 if (!this.isEffect && this.world.areChunksLoaded(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ), 10)) {
93 int i = MathHelper.floor(this.locX);
94 int j = MathHelper.floor(this.locY);
95 int k = MathHelper.floor(this.locZ);
96
97 if (this.world.getTypeId(i, j, k) == 0 && Block.FIRE.canPlace(this.world, i, j, k)) {
98 // CraftBukkit start
99 BlockIgniteEvent event = new BlockIgniteEvent(this.cworld.getBlockAt(i, j, k), IgniteCause.LIGHTNING, null);
100 this.world.getServer().getPluginManager().callEvent(event);
101
102 if (!event.isCancelled()) {
103 this.world.setTypeId(i, j, k, Block.FIRE.id);
104 }
105 // CraftBukkit end
106 }
107 }
108 }
109 }
110
111 if (this.lifeTicks >= 0 && !this.isEffect) { // CraftBukkit
112 double d0 = 3.0D;
113 List list = this.world.b((Entity) this, AxisAlignedBB.b(this.locX - d0, this.locY - d0, this.locZ - d0, this.locX + d0, this.locY + 6.0D + d0, this.locZ + d0));
114
115 for (int l = 0; l < list.size(); ++l) {
116 Entity entity = (Entity) list.get(l);
117
118 entity.a(this);
119 }
120
121 this.world.n = 2;
122 }
123 }
124
125 protected void b() {
126 }
127
128 protected void a(NBTTagCompound nbttagcompound) {
129 }
130
131 protected void b(NBTTagCompound nbttagcompound) {
132 }
133}