summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/BlockStationary.java
blob: 51b9604ae7ff719e7c90e888c1b911a25886a087 (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
package net.minecraft.server;

import java.util.Random;

import org.bukkit.craftbukkit.event.CraftEventFactory;  // CraftBukkit

public class BlockStationary extends BlockFluids {

    protected BlockStationary(Material material) {
        super(material);
        this.a(false);
        if (material == Material.LAVA) {
            this.a(true);
        }
    }

    public void doPhysics(World world, int i, int j, int k, Block block) {
        super.doPhysics(world, i, j, k, block);
        if (world.getType(i, j, k) == this) {
            this.n(world, i, j, k);
        }
    }

    private void n(World world, int i, int j, int k) {
        int l = world.getData(i, j, k);

        world.setTypeAndData(i, j, k, Block.getById(Block.getId(this) - 1), l, 2);
        world.a(i, j, k, Block.getById(Block.getId(this) - 1), this.a(world));
    }

    public void a(World world, int i, int j, int k, Random random) {
        if (this.material == Material.LAVA) {
            int l = random.nextInt(3);

            int i1;

            // CraftBukkit start - Prevent lava putting something on fire, remember igniter block coords
            int x = i;
            int y = j;
            int z = k;
            // CraftBukkit end

            for (i1 = 0; i1 < l; ++i1) {
                i += random.nextInt(3) - 1;
                ++j;
                k += random.nextInt(3) - 1;
                Block block = world.getType(i, j, k);

                if (block.material == Material.AIR) {
                    if (this.o(world, i - 1, j, k) || this.o(world, i + 1, j, k) || this.o(world, i, j, k - 1) || this.o(world, i, j, k + 1) || this.o(world, i, j - 1, k) || this.o(world, i, j + 1, k)) {
                        // CraftBukkit start - Prevent lava putting something on fire
                        if (world.getType(i, j, k) != Blocks.FIRE) {
                            if (CraftEventFactory.callBlockIgniteEvent(world, i, j, k, x, y, z).isCancelled()) {
                                continue;
                            }
                        }
                        // CraftBukkit end

                        world.setTypeUpdate(i, j, k, Blocks.FIRE);
                        return;
                    }
                } else if (block.material.isSolid()) {
                    return;
                }
            }

            if (l == 0) {
                i1 = i;
                int j1 = k;

                for (int k1 = 0; k1 < 3; ++k1) {
                    i = i1 + random.nextInt(3) - 1;
                    k = j1 + random.nextInt(3) - 1;
                    if (world.isEmpty(i, j + 1, k) && this.o(world, i, j, k)) {
                        // CraftBukkit start - Prevent lava putting something on fire
                        if (world.getType(i, j + 1, k) != Blocks.FIRE) {
                            if (CraftEventFactory.callBlockIgniteEvent(world, i, j + 1, k, x, y, z).isCancelled()) {
                                continue;
                            }
                        }
                        // CraftBukkit end

                        world.setTypeUpdate(i, j + 1, k, Blocks.FIRE);
                    }
                }
            }
        }
    }

    private boolean o(World world, int i, int j, int k) {
        return world.getType(i, j, k).getMaterial().isBurnable();
    }
}