Paper/src/main/java/net/minecraft/server/BlockSnow.java

94 Zeilen
2.7 KiB
Java

package net.minecraft.server;
import java.util.Random;
public class BlockSnow extends Block {
2013-11-04 14:07:38 +01:00
protected BlockSnow() {
super(Material.PACKED_ICE);
this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
2013-11-04 14:07:38 +01:00
this.a(true);
2012-07-29 09:33:13 +02:00
this.a(CreativeModeTab.c);
2013-11-04 14:07:38 +01:00
this.b(0);
}
2013-11-04 14:07:38 +01:00
public AxisAlignedBB a(World world, int i, int j, int k) {
int l = world.getData(i, j, k) & 7;
2013-03-13 23:33:27 +01:00
float f = 0.125F;
2014-03-21 05:26:30 +01:00
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;
}
2013-11-04 14:07:38 +01:00
public boolean d() {
return false;
}
2013-03-13 23:33:27 +01:00
public void g() {
2013-11-04 14:07:38 +01:00
this.b(0);
2013-03-13 23:33:27 +01:00
}
public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) {
2013-11-04 14:07:38 +01:00
this.b(iblockaccess.getData(i, j, k));
2013-03-13 23:33:27 +01:00
}
2013-11-04 14:07:38 +01:00
protected void b(int i) {
2013-03-13 23:33:27 +01:00
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) {
2013-11-04 14:07:38 +01:00
Block block = world.getType(i, j - 1, k);
2013-11-04 14:07:38 +01:00
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;
}
2013-11-04 14:07:38 +01:00
public void doPhysics(World world, int i, int j, int k, Block block) {
2013-03-13 23:33:27 +01:00
this.m(world, i, j, k);
}
2013-03-13 23:33:27 +01:00
private boolean m(World world, int i, int j, int k) {
if (!this.canPlace(world, i, j, k)) {
2013-11-04 14:07:38 +01:00
this.b(world, i, j, k, world.getData(i, j, k), 0);
2013-03-13 23:33:27 +01:00
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) {
2013-11-04 14:07:38 +01:00
int i1 = l & 7;
2013-11-04 14:07:38 +01:00
this.a(world, i, j, k, new ItemStack(Items.SNOW_BALL, i1 + 1, 0));
2013-03-13 23:33:27 +01:00
world.setAir(i, j, k);
2014-03-21 05:26:30 +01:00
entityhuman.a(StatisticList.MINE_BLOCK_COUNT[Block.b((Block) this)], 1);
}
2013-11-04 14:07:38 +01:00
public Item getDropType(int i, Random random, int j) {
return Items.SNOW_BALL;
}
public int a(Random random) {
return 0;
}
2013-03-13 23:33:27 +01:00
public void a(World world, int i, int j, int k, Random random) {
2012-07-29 09:33:13 +02:00
if (world.b(EnumSkyBlock.BLOCK, i, j, k) > 11) {
// CraftBukkit start
2013-11-04 14:07:38 +01:00
if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(i, j, k), Blocks.AIR).isCancelled()) {
return;
}
// CraftBukkit end
2013-11-04 14:07:38 +01:00
this.b(world, i, j, k, world.getData(i, j, k), 0);
2013-03-13 23:33:27 +01:00
world.setAir(i, j, k);
}
}
}