summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/EntityWeatherStorm.java
blob: cacb06ea98746ad1eacee1e72a45c79214c04bf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package net.minecraft.server;

import java.util.List;

// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
// CraftBukkit end

public class EntityWeatherStorm extends EntityWeather {

    private int b;
    public long a = 0L;
    private int c;

    // CraftBukkit start
    private CraftWorld cworld;
    private CraftServer server;
    public boolean isEffect = false;

    public EntityWeatherStorm(World world, double d0, double d1, double d2) {
        this(world, d0, d1, d2, false);
    }

    public EntityWeatherStorm(World world, double d0, double d1, double d2, boolean isEffect) {
    // CraftBukkit end

        super(world);

        // CraftBukkit start
        this.isEffect = isEffect;
        cworld = ((WorldServer) world).getWorld();
        server = ((WorldServer) world).getServer();
        // CraftBukkit end

        this.setPositionRotation(d0, d1, d2, 0.0F, 0.0F);
        this.b = 2;
        this.a = this.random.nextLong();
        this.c = this.random.nextInt(3) + 1;
        // CraftBukkit start
        if (!isEffect && world.spawnMonsters >= 2 && world.a(MathHelper.floor(d0), MathHelper.floor(d1), MathHelper.floor(d2), 10)) {
        // CraftBukkit end
            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
                org.bukkit.block.Block theBlock = cworld.getBlockAt(i, j, k);
                BlockIgniteEvent event = new BlockIgniteEvent(theBlock, IgniteCause.LIGHTNING, null);
                ((WorldServer) world).getServer().getPluginManager().callEvent(event);
                if (!event.isCancelled()) {
                    world.setTypeId(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
                    org.bukkit.block.Block theBlock = cworld.getBlockAt(j, k, l);
                    BlockIgniteEvent event = new BlockIgniteEvent(theBlock, IgniteCause.LIGHTNING, null);
                    ((WorldServer) world).getServer().getPluginManager().callEvent(event);
                    if (!event.isCancelled()) {
                        world.setTypeId(j, k, l, Block.FIRE.id);
                    }
                    // CraftBukkit end
                }
            }
        }
    }

    public void p_() {
        super.p_();
        if (this.b == 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.b;
        if (this.b < 0) {
            if (this.c == 0) {
                this.die();
            } else if (this.b < -this.random.nextInt(10)) {
                --this.c;
                this.b = 1;
                this.a = this.random.nextLong();
                // CraftBukkit start
                if (!isEffect && this.world.a(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ), 10)) {
                // CraftBukkit end
                    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
                        org.bukkit.block.Block theBlock = cworld.getBlockAt(i, j, k);
                        BlockIgniteEvent event = new BlockIgniteEvent(theBlock, IgniteCause.LIGHTNING, null);
                        ((WorldServer) world).getServer().getPluginManager().callEvent(event);
                        if (!event.isCancelled()) {
                            this.world.setTypeId(i, j, k, Block.FIRE.id);
                        }
                        // CraftBukkit end
                    }
                }
            }
        }

        // CraftBukkit start
        if (!isEffect && this.b >= 0) {
        // CraftBukkit end
            double d0 = 3.0D;
            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));

            for (int l = 0; l < list.size(); ++l) {
                Entity entity = (Entity) list.get(l);

                entity.a(this);
            }

            this.world.i = 2;
        }
    }

    protected void b() {}

    protected void a(NBTTagCompound nbttagcompound) {}

    protected void b(NBTTagCompound nbttagcompound) {}
}