本文整理汇总了Java中cn.nukkit.level.Explosion类的典型用法代码示例。如果您正苦于以下问题:Java Explosion类的具体用法?Java Explosion怎么用?Java Explosion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Explosion类属于cn.nukkit.level包,在下文中一共展示了Explosion类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: explode
import cn.nukkit.level.Explosion; //导入依赖的package包/类
public void explode(double square) {
double root = Math.sqrt(square);
if (root > 5.0D) {
root = 5.0D;
}
EntityExplosionPrimeEvent event = new EntityExplosionPrimeEvent(this, (4.0D + new Random().nextDouble() * 1.5D * root));
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
Explosion explosion = new Explosion(this, event.getForce(), this);
if (event.isBlockBreaking()) {
explosion.explodeA();
}
explosion.explodeB();
kill();
}
示例2: createExplosion
import cn.nukkit.level.Explosion; //导入依赖的package包/类
private boolean createExplosion(Level level, double x, double y, double z, float power, boolean setFire, boolean breakBlocks) {
// Base function called by all other createExplosion functions
// Nukkit does not yet support setFire
if (level == null) {
level = nukkit;
}
Explosion explosion = new Explosion(
new Position(x, y, z, level),
power,
null);
if (breakBlocks) {
explosion.explodeA();
}
explosion.explodeB();
return true;
}
示例3: explode
import cn.nukkit.level.Explosion; //导入依赖的package包/类
public void explode() {
EntityExplosionPrimeEvent event = new EntityExplosionPrimeEvent(this, 4);
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
Explosion explosion = new Explosion(this, event.getForce(), this);
if (event.isBlockBreaking()) {
explosion.explodeA();
}
explosion.explodeB();
}
示例4: explode
import cn.nukkit.level.Explosion; //导入依赖的package包/类
@Override
public void explode() {
this.close();
ExplosionPrimeEvent ev = new ExplosionPrimeEvent(this, 6);
this.getServer().getPluginManager().callEvent(ev);
if (!ev.isCancelled()) {
Explosion explosion = new Explosion(this, ev.getForce(), this);
if (ev.isBlockBreaking()) {
explosion.explodeA();
}
explosion.explodeB();
}
}
示例5: onActivate
import cn.nukkit.level.Explosion; //导入依赖的package包/类
@Override
public boolean onActivate(Item item, Player player) {
if (this.getLevel().getDimension() != Level.DIMENSION_OVERWORLD) {
BedExplosionEvent event = new BedExplosionEvent(player, this, 4);
Server.getInstance().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
Explosion explosion = new Explosion(this, event.getForce(), this);
explosion.explodeA();
return false;
}
int time = this.getLevel().getTime() % Level.TIME_FULL;
boolean isNight = (time >= Level.TIME_NIGHT && time < Level.TIME_SUNRISE);
if (player != null && !isNight) {
player.sendMessage(TextFormat.GRAY + "You can only sleep at night");
return true;
}
Block blockNorth = this.north();
Block blockSouth = this.south();
Block blockEast = this.east();
Block blockWest = this.west();
Block b;
if ((this.meta & 0x08) == 0x08) {
b = this;
} else {
if (blockNorth.getId() == this.getId() && (blockNorth.meta & 0x08) == 0x08) {
b = blockNorth;
} else if (blockSouth.getId() == this.getId() && (blockSouth.meta & 0x08) == 0x08) {
b = blockSouth;
} else if (blockEast.getId() == this.getId() && (blockEast.meta & 0x08) == 0x08) {
b = blockEast;
} else if (blockWest.getId() == this.getId() && (blockWest.meta & 0x08) == 0x08) {
b = blockWest;
} else {
if (player != null) {
player.sendMessage(TextFormat.GRAY + "This bed is incomplete");
}
return true;
}
}
if (player != null && !player.sleepOn(b)) {
player.sendMessage(TextFormat.GRAY + "This bed is occupied");
}
return true;
}