Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package net.minecraft.server;
2
3import org.bukkit.craftbukkit.event.CraftEventFactory;
4
5import java.util.Random;
6
7public class BlockSnow extends Block {
8
9 protected BlockSnow(int i, int j) {
10 super(i, j, Material.SNOW_LAYER);
11 this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
12 this.a(true);
13 }
14
15 public AxisAlignedBB e(World world, int i, int j, int k) {
16 int l = world.getData(i, j, k) & 7;
17
18 return l >= 3 ? AxisAlignedBB.b((double) i + this.minX, (double) j + this.minY, (double) k + this.minZ, (double) i + this.maxX, (double) ((float) j + 0.5F), (double) k + this.maxZ) : null;
19 }
20
21 public boolean a() {
22 return false;
23 }
24
25 public boolean b() {
26 return false;
27 }
28
29 public void a(IBlockAccess iblockaccess, int i, int j, int k) {
30 int l = iblockaccess.getData(i, j, k) & 7;
31 float f = (float) (2 * (1 + l)) / 16.0F;
32
33 this.a(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F);
34 }
35
36 public boolean canPlace(World world, int i, int j, int k) {
37 int l = world.getTypeId(i, j - 1, k);
38
39 return l != 0 && Block.byId[l].a() ? world.getMaterial(i, j - 1, k).isSolid() : false;
40 }
41
42 public void doPhysics(World world, int i, int j, int k, int l) {
43 this.g(world, i, j, k);
44 }
45
46 private boolean g(World world, int i, int j, int k) {
47 if (!this.canPlace(world, i, j, k)) {
48 this.g(world, i, j, k, world.getData(i, j, k));
49 world.setTypeId(i, j, k, 0);
50 return false;
51 } else {
52 return true;
53 }
54 }
55
56 public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
57 int i1 = Item.SNOW_BALL.id;
58 float f = 0.7F;
59 double d0 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
60 double d1 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
61 double d2 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
62 EntityItem entityitem = new EntityItem(world, (double) i + d0, (double) j + d1, (double) k + d2, new ItemStack(i1, 1, 0));
63
64 entityitem.pickupDelay = 10;
65 world.addEntity(entityitem);
66 world.setTypeId(i, j, k, 0);
67 entityhuman.a(StatisticList.C[this.id], 1);
68 }
69
70 public int a(int i, Random random) {
71 return Item.SNOW_BALL.id;
72 }
73
74 public int a(Random random) {
75 return 0;
76 }
77
78 public void a(World world, int i, int j, int k, Random random) {
79 if (world.a(EnumSkyBlock.BLOCK, i, j, k) > 11) {
80 // CraftBukkit start
81 if (CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(i, j, k), 0).isCancelled()) {
82 return;
83 }
84 // CraftBukkit end
85
86 this.g(world, i, j, k, world.getData(i, j, k));
87 world.setTypeId(i, j, k, 0);
88 }
89 }
90}