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

69 Zeilen
2.3 KiB
Java

2012-02-02 22:57:30 +01:00
package net.minecraft.server;
import java.util.Random;
public class BlockTNT extends Block {
public BlockTNT(int i, int j) {
super(i, j, Material.TNT);
2012-07-29 09:33:13 +02:00
this.a(CreativeModeTab.d);
2012-02-02 22:57:30 +01:00
}
public int a(int i) {
return i == 0 ? this.textureId + 2 : (i == 1 ? this.textureId + 1 : this.textureId);
}
public void onPlace(World world, int i, int j, int k) {
super.onPlace(world, i, j, k);
if (!world.suppressPhysics && world.isBlockIndirectlyPowered(i, j, k)) { // CraftBukkit
2012-02-02 22:57:30 +01:00
this.postBreak(world, i, j, k, 1);
world.setTypeId(i, j, k, 0);
}
}
public void doPhysics(World world, int i, int j, int k, int l) {
if (l > 0 && Block.byId[l].isPowerSource() && world.isBlockIndirectlyPowered(i, j, k)) {
this.postBreak(world, i, j, k, 1);
world.setTypeId(i, j, k, 0);
}
}
public int a(Random random) {
2012-07-29 09:33:13 +02:00
return 1;
2012-02-02 22:57:30 +01:00
}
public void wasExploded(World world, int i, int j, int k) {
if (!world.isStatic) {
EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F));
2012-02-02 22:57:30 +01:00
entitytntprimed.fuseTicks = world.random.nextInt(entitytntprimed.fuseTicks / 4) + entitytntprimed.fuseTicks / 8;
world.addEntity(entitytntprimed);
}
2012-02-02 22:57:30 +01:00
}
public void postBreak(World world, int i, int j, int k, int l) {
if (!world.isStatic) {
2012-07-29 09:33:13 +02:00
if ((l & 1) == 1) {
2012-02-02 22:57:30 +01:00
EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F));
world.addEntity(entitytntprimed);
world.makeSound(entitytntprimed, "random.fuse", 1.0F, 1.0F);
}
}
}
2012-07-29 09:33:13 +02:00
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) {
if (entityhuman.bC() != null && entityhuman.bC().id == Item.FLINT_AND_STEEL.id) {
2012-03-30 23:33:51 +02:00
this.postBreak(world, i, j, k, 1);
world.setTypeId(i, j, k, 0);
return true;
} else {
2012-07-29 09:33:13 +02:00
return super.interact(world, i, j, k, entityhuman, l, f, f1, f2);
2012-03-30 23:33:51 +02:00
}
2012-02-02 22:57:30 +01:00
}
2012-07-29 09:33:13 +02:00
protected ItemStack c_(int i) {
2012-02-02 22:57:30 +01:00
return null;
}
}