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

import java.util.Random;

// CraftBukkit start
import org.bukkit.craftbukkit.CraftBlock;
import org.bukkit.craftbukkit.CraftPlayer;
import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockInteractEvent;
// CraftBukkit end

public class BlockFurnace extends BlockContainer {

    private final boolean a;

    protected BlockFurnace(int i, boolean flag) {
        super(i, Material.d);
        a = flag;
        bh = 45;
    }

    public int a(int i, Random random) {
        return Block.aB.bi;
    }

    public void e(World world, int i, int j, int k) {
        super.e(world, i, j, k);
        g(world, i, j, k);
    }

    private void g(World world, int i, int j, int k) {
        int l = world.a(i, j, k - 1);
        int i1 = world.a(i, j, k + 1);
        int j1 = world.a(i - 1, j, k);
        int k1 = world.a(i + 1, j, k);
        byte byte0 = 3;

        if (Block.o[l] && !Block.o[i1]) {
            byte0 = 3;
        }
        if (Block.o[i1] && !Block.o[l]) {
            byte0 = 2;
        }
        if (Block.o[j1] && !Block.o[k1]) {
            byte0 = 5;
        }
        if (Block.o[k1] && !Block.o[j1]) {
            byte0 = 4;
        }
        world.c(i, j, k, ((int) (byte0)));
    }

    public int a(int i) {
        if (i == 1) {
            return bh + 17;
        }
        if (i == 0) {
            return bh + 17;
        }
        if (i == 3) {
            return bh - 1;
        } else {
            return bh;
        }
    }

    public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) {
        if (world.z) {
            return true;
        } else {
            // CraftBukkit start - Interact Furnace
            CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
            CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
            BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player);

            ((WorldServer) world).getServer().getPluginManager().callEvent(bie);

            if (bie.isCancelled()) return true;
            // CraftBukkit end

            TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.m(i, j, k);

            entityplayer.a(tileentityfurnace);
            return true;
        }
    }

    public static void a(boolean flag, World world, int i, int j, int k) {
        int l = world.b(i, j, k);
        TileEntity tileentity = world.m(i, j, k);

        if (flag) {
            world.e(i, j, k, Block.aC.bi);
        } else {
            world.e(i, j, k, Block.aB.bi);
        }
        world.c(i, j, k, l);
        world.a(i, j, k, tileentity);
    }

    protected TileEntity a_() {
        return ((TileEntity) (new TileEntityFurnace()));
    }

    public void a(World world, int i, int j, int k, EntityLiving entityliving) {
        int l = MathHelper.b((double) ((entityliving.v * 4F) / 360F) + 0.5D) & 3;

        if (l == 0) {
            world.c(i, j, k, 2);
        }
        if (l == 1) {
            world.c(i, j, k, 5);
        }
        if (l == 2) {
            world.c(i, j, k, 3);
        }
        if (l == 3) {
            world.c(i, j, k, 4);
        }
    }
}