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

import java.util.Random;

public class BlockCake extends Block {

    protected BlockCake() {
        super(Material.CAKE);
        this.a(true);
    }

    public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) {
        int l = iblockaccess.getData(i, j, k);
        float f = 0.0625F;
        float f1 = (float) (1 + l * 2) / 16.0F;
        float f2 = 0.5F;

        this.a(f1, 0.0F, f, 1.0F - f, f2, 1.0F - f);
    }

    public void g() {
        float f = 0.0625F;
        float f1 = 0.5F;

        this.a(f, 0.0F, f, 1.0F - f, f1, 1.0F - f);
    }

    public AxisAlignedBB a(World world, int i, int j, int k) {
        int l = world.getData(i, j, k);
        float f = 0.0625F;
        float f1 = (float) (1 + l * 2) / 16.0F;
        float f2 = 0.5F;

        return AxisAlignedBB.a((double) ((float) i + f1), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) ((float) j + f2 - f), (double) ((float) (k + 1) - f));
    }

    public boolean d() {
        return false;
    }

    public boolean c() {
        return false;
    }

    public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) {
        this.b(world, i, j, k, entityhuman);
        return true;
    }

    public void attack(World world, int i, int j, int k, EntityHuman entityhuman) {
        this.b(world, i, j, k, entityhuman);
    }

    private void b(World world, int i, int j, int k, EntityHuman entityhuman) {
        if (entityhuman.g(false)) {
            // CraftBukkit start
            int oldFoodLevel = entityhuman.getFoodData().foodLevel;

            org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, 2 + oldFoodLevel);

            if (!event.isCancelled()) {
                entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 0.1F);
            }

            ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel));
            // CraftBukkit end
            int l = world.getData(i, j, k) + 1;

            if (l >= 6) {
                world.setAir(i, j, k);
            } else {
                world.setData(i, j, k, l, 2);
            }
        }
    }

    public boolean canPlace(World world, int i, int j, int k) {
        return !super.canPlace(world, i, j, k) ? false : this.j(world, i, j, k);
    }

    public void doPhysics(World world, int i, int j, int k, Block block) {
        if (!this.j(world, i, j, k)) {
            world.setAir(i, j, k);
        }
    }

    public boolean j(World world, int i, int j, int k) {
        return world.getType(i, j - 1, k).getMaterial().isBuildable();
    }

    public int a(Random random) {
        return 0;
    }

    public Item getDropType(int i, Random random, int j) {
        return null;
    }
}