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

import java.util.Random;

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

public class BlockRedstoneLamp extends Block {

    private final boolean a;

    public BlockRedstoneLamp(int i, boolean flag) {
        super(i, 211, Material.BUILDABLE_GLASS);
        this.a = flag;
        if (flag) {
            this.a(1.0F);
            ++this.textureId;
        }
    }

    public void onPlace(World world, int i, int j, int k) {
        if (!world.isStatic) {
            if (this.a && !world.isBlockIndirectlyPowered(i, j, k)) {
                world.a(i, j, k, this.id, 4);
            } else if (!this.a && world.isBlockIndirectlyPowered(i, j, k)) {
                // CraftBukkit start
                if (CraftEventFactory.callRedstoneChange(world, i, j, k, 0, 15).getNewCurrent() != 15) {
                    return;
                }
                // CraftBukkit end

                world.setTypeId(i, j, k, Block.REDSTONE_LAMP_ON.id);
            }
        }
    }

    public void doPhysics(World world, int i, int j, int k, int l) {
        if (!world.isStatic) {
            if (this.a && !world.isBlockIndirectlyPowered(i, j, k)) {
                world.a(i, j, k, this.id, 4);
            } else if (!this.a && world.isBlockIndirectlyPowered(i, j, k)) {
                // CraftBukkit start
                if (CraftEventFactory.callRedstoneChange(world, i, j, k, 0, 15).getNewCurrent() != 15) {
                    return;
                }
                // CraftBukkit end

                world.setTypeId(i, j, k, Block.REDSTONE_LAMP_ON.id);
            }
        }
    }

    public void b(World world, int i, int j, int k, Random random) {
        if (!world.isStatic && this.a && !world.isBlockIndirectlyPowered(i, j, k)) {
            // CraftBukkit start
            if (CraftEventFactory.callRedstoneChange(world, i, j, k, 15, 0).getNewCurrent() != 0) {
                return;
            }
            // CraftBukkit end

            world.setTypeId(i, j, k, Block.REDSTONE_LAMP_OFF.id);
        }
    }

    public int getDropType(int i, Random random, int j) {
        return Block.REDSTONE_LAMP_OFF.id;
    }
}