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

import java.util.Random;

// CraftBukkit start
import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.event.block.BlockIgniteEvent;
// CraftBukkit end

public class BlockStationary extends BlockFluids {

    protected BlockStationary(int i, Material material) {
        super(i, material);
        this.b(false);
        if (material == Material.LAVA) {
            this.b(true);
        }
    }

    public boolean c(IBlockAccess iblockaccess, int i, int j, int k) {
        return this.material != Material.LAVA;
    }

    public void doPhysics(World world, int i, int j, int k, int l) {
        super.doPhysics(world, i, j, k, l);
        if (world.getTypeId(i, j, k) == this.id) {
            this.l(world, i, j, k);
        }
    }

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

        world.suppressPhysics = true;
        world.setRawTypeIdAndData(i, j, k, this.id - 1, l);
        world.e(i, j, k, i, j, k);
        world.a(i, j, k, this.id - 1, this.r_());
        world.suppressPhysics = false;
    }

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

            int i1;
            int j1;

            // CraftBukkit start - prevent lava putting something on fire
            org.bukkit.World bworld = world.getWorld();
            BlockIgniteEvent.IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.LAVA;
            // CraftBukkit end

            for (i1 = 0; i1 < l; ++i1) {
                i += random.nextInt(3) - 1;
                ++j;
                k += random.nextInt(3) - 1;
                j1 = world.getTypeId(i, j, k);
                if (j1 == 0) {
                    if (this.n(world, i - 1, j, k) || this.n(world, i + 1, j, k) || this.n(world, i, j, k - 1) || this.n(world, i, j, k + 1) || this.n(world, i, j - 1, k) || this.n(world, i, j + 1, k)) {
                        // CraftBukkit start - prevent lava putting something on fire
                        org.bukkit.block.Block block = bworld.getBlockAt(i, j, k);
                        if (block.getTypeId() != Block.FIRE.id) {
                            if (CraftEventFactory.callEvent(new BlockIgniteEvent(block, igniteCause, null)).isCancelled()) {
                                continue;
                            }
                        }
                        // CraftBukkit end

                        world.setTypeId(i, j, k, Block.FIRE.id);
                        return;
                    }
                } else if (Block.byId[j1].material.isSolid()) {
                    return;
                }
            }

            if (l == 0) {
                i1 = i;
                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.n(world, i, j, k)) {
                        // CraftBukkit start - prevent lava putting something on fire
                        org.bukkit.block.Block block = bworld.getBlockAt(i, j + 1, k);
                        if (block.getTypeId() != Block.FIRE.id) {
                            if (CraftEventFactory.callEvent(new BlockIgniteEvent(block, igniteCause, null)).isCancelled()) {
                                continue;
                            }
                        }
                        // CraftBukkit end

                        world.setTypeId(i, j + 1, k, Block.FIRE.id);
                    }
                }
            }
        }
    }

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