summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/BlockSnow.java
blob: 201cb2a6dfa7b6086017a6a1e9028a13a60f817e (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;

public class BlockSnow extends Block {

    protected BlockSnow() {
        super(Material.PACKED_ICE);
        this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
        this.a(true);
        this.a(CreativeModeTab.c);
        this.b(0);
    }

    public AxisAlignedBB a(World world, int i, int j, int k) {
        int l = world.getData(i, j, k) & 7;
        float f = 0.125F;

        return AxisAlignedBB.a((double) i + this.minX, (double) j + this.minY, (double) k + this.minZ, (double) i + this.maxX, (double) ((float) j + (float) l * f), (double) k + this.maxZ);
    }

    public boolean c() {
        return false;
    }

    public boolean d() {
        return false;
    }

    public void g() {
        this.b(0);
    }

    public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) {
        this.b(iblockaccess.getData(i, j, k));
    }

    protected void b(int i) {
        int j = i & 7;
        float f = (float) (2 * (1 + j)) / 16.0F;

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

    public boolean canPlace(World world, int i, int j, int k) {
        Block block = world.getType(i, j - 1, k);

        return block != Blocks.ICE && block != Blocks.PACKED_ICE ? (block.getMaterial() == Material.LEAVES ? true : (block == this && (world.getData(i, j - 1, k) & 7) == 7 ? true : block.c() && block.material.isSolid())) : false;
    }

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

    private boolean m(World world, int i, int j, int k) {
        if (!this.canPlace(world, i, j, k)) {
            this.b(world, i, j, k, world.getData(i, j, k), 0);
            world.setAir(i, j, k);
            return false;
        } else {
            return true;
        }
    }

    public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
        int i1 = l & 7;

        this.a(world, i, j, k, new ItemStack(Items.SNOW_BALL, i1 + 1, 0));
        world.setAir(i, j, k);
        entityhuman.a(StatisticList.MINE_BLOCK_COUNT[Block.b((Block) this)], 1);
    }

    public Item getDropType(int i, Random random, int j) {
        return Items.SNOW_BALL;
    }

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

    public void a(World world, int i, int j, int k, Random random) {
        if (world.b(EnumSkyBlock.BLOCK, i, j, k) > 11) {
            // CraftBukkit start
            if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(i, j, k), Blocks.AIR).isCancelled()) {
                return;
            }
            // CraftBukkit end

            this.b(world, i, j, k, world.getData(i, j, k), 0);
            world.setAir(i, j, k);
        }
    }
}