• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Explosion类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.spongepowered.api.world.explosion.Explosion的典型用法代码示例。如果您正苦于以下问题:Java Explosion类的具体用法?Java Explosion怎么用?Java Explosion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Explosion类属于org.spongepowered.api.world.explosion包,在下文中一共展示了Explosion类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: preventExplosion

import org.spongepowered.api.world.explosion.Explosion; //导入依赖的package包/类
private void preventExplosion(ExplosionEvent.Pre event) {
    //"Clone" explosion, as we cannot change the existing one?
    Explosion old = event.getExplosion();
    Explosion newExplosion = Explosion.builder()
            .from(old)
            .shouldBreakBlocks(config.BREAK_BLOCKS)
            .shouldPlaySmoke(config.SHOW_PARTICLES)
            .sourceExplosive(null) //Do not check for a creeper in next Event listener Iteration
            .build();

    //Cancel default event...
    event.setCancelled(true);
    //...but trigger new event
    Cause genericCause = Cause.of(NamedCause.owner(container));
    newExplosion.getWorld().triggerExplosion(newExplosion, genericCause);

    //Remove the creeper (as the default event is canceled);
    ((Creeper) event.getCause().root()).remove();
}
 
开发者ID:Felfio,项目名称:treepers-sponge,代码行数:20,代码来源:Treepers.java


示例2: onProjectileHit

import org.spongepowered.api.world.explosion.Explosion; //导入依赖的package包/类
@Listener
public void onProjectileHit(CollideEvent.Impact event, @First Entity entity) {
  Optional<PatientXInstance> optInst = manager.getApplicableZone(entity);
  if (!optInst.isPresent()) {
    return;
  }

  if (entity instanceof Snowball) {
    if (!event.getCause().containsType(Player.class)) {
      entity.getLocation().getExtent().triggerExplosion(
          Explosion.builder()
              .radius(3)
              .location(entity.getLocation())
              .shouldDamageEntities(true)
              .build(),
          Cause.source(SkreePlugin.container()).build()
      );
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:21,代码来源:PatientXListener.java


示例3: execute

import org.spongepowered.api.world.explosion.Explosion; //导入依赖的package包/类
@Override
public void execute(CommandQueue queue, CommandEntry entry) {
    LocationTag loc = LocationTag.getFor(queue.error, entry.getArgumentObject(queue, 0));
    NumberTag radius = NumberTag.getFor(queue.error, entry.getArgumentObject(queue, 1));
    Explosion.Builder build = Explosion.builder();
    build.location(loc.getInternal().toLocation()).radius((float) radius.getInternal());
    if (entry.namedArgs.containsKey("fire")) {
        BooleanTag fire = BooleanTag.getFor(queue.error, entry.getNamedArgumentObject(queue, "fire"));
        build.canCauseFire(fire.getInternal());
    }
    if (entry.namedArgs.containsKey("break_blocks")) {
        BooleanTag break_blocks = BooleanTag.getFor(queue.error, entry.getNamedArgumentObject(queue, "break_blocks"));
        build.shouldBreakBlocks(break_blocks.getInternal());
    }
    if (entry.namedArgs.containsKey("damage_entities")) {
        BooleanTag damage_entities = BooleanTag.getFor(queue.error, entry.getNamedArgumentObject(queue, "damage_entities"));
        build.shouldDamageEntities(damage_entities.getInternal());
    }
    if (entry.namedArgs.containsKey("smoke")) {
        BooleanTag smoke = BooleanTag.getFor(queue.error, entry.getNamedArgumentObject(queue, "smoke"));
        build.shouldPlaySmoke(smoke.getInternal());
    }
    loc.getInternal().world.triggerExplosion(build.build());
    if (queue.shouldShowGood()) {
        queue.outGood("Successfully created an explosion at location " +
                ColorSet.emphasis + loc.debug() + ColorSet.good + "!");
    }
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:29,代码来源:ExplodeCommand.java


示例4: onExplosionOccurs

import org.spongepowered.api.world.explosion.Explosion; //导入依赖的package包/类
@Listener
public void onExplosionOccurs(ExplosionEvent.Detonate evt) {
    ExplosionOccursScriptEvent event = (ExplosionOccursScriptEvent) clone();
    event.internal = evt;
    event.location = new LocationTag(evt.getExplosion().getLocation());
    ListTag locs = new ListTag();
    for (Location<World> loc : evt.getAffectedLocations()) {
        locs.getInternal().add(new LocationTag(loc));
    }
    event.blocks = locs;
    ListTag ents = new ListTag();
    for (Entity ent : evt.getEntities()) {
        ents.getInternal().add(new EntityTag(ent));
    }
    event.entities = ents;
    Explosion exp = evt.getExplosion();
    MapTag data = new MapTag();
    data.getInternal().put("radius", new NumberTag(exp.getRadius()));
    data.getInternal().put("fire", new BooleanTag(exp.canCauseFire()));
    data.getInternal().put("break_blocks", new BooleanTag(exp.shouldBreakBlocks()));
    data.getInternal().put("damage_entities", new BooleanTag(exp.shouldDamageEntities()));
    data.getInternal().put("smoke", new BooleanTag(exp.shouldPlaySmoke()));
    event.explosion_data = data;
    event.cancelled = evt.isCancelled();
    event.run();
    evt.setCancelled(event.cancelled);
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:28,代码来源:ExplosionOccursScriptEvent.java


示例5: ExplosionView

import org.spongepowered.api.world.explosion.Explosion; //导入依赖的package包/类
public ExplosionView(Explosion value) {
    super(value);

    this.causeFire = value.canCauseFire();
    this.radius = value.getRadius();
    this.breakBlocks = value.shouldBreakBlocks();
    this.damageEntities = value.shouldDamageEntities();
    this.playSmoke = value.shouldPlaySmoke();
}
 
开发者ID:Valandur,项目名称:Web-API,代码行数:10,代码来源:ExplosionView.java


示例6: onEntityExplosionPre

import org.spongepowered.api.world.explosion.Explosion; //导入依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onEntityExplosionPre(ExplosionEvent.Pre event) {
    if (!GPFlags.EXPLOSION || !GriefPreventionPlugin.instance.claimsEnabledForWorld(event.getTargetWorld().getProperties())) {
        return;
    }

    GPTimings.ENTITY_EXPLOSION_PRE_EVENT.startTimingIfSync();
    Location<World> location = event.getExplosion().getLocation();
    GPClaim claim =  GriefPreventionPlugin.instance.dataStore.getClaimAt(location);

    User user = CauseContextHelper.getEventUser(event);
    Explosive explosive = null;
    if (event.getExplosion() instanceof Explosion) {
        explosive = ((Explosion) event.getExplosion()).getSourceExplosive().orElse(null);
    }

    if (explosive != null) {
        Entity entity = (Entity) explosive;

        if (user == null) {
            UUID uuid = entity.getCreator().orElse(null);
            if (uuid != null) {
                user = GriefPreventionPlugin.getOrCreateUser(uuid);
            }
        }

        if(GPPermissionHandler.getClaimPermission(event, location, claim, GPPermissions.EXPLOSION, entity, location, user, true) == Tristate.FALSE) {
            event.setCancelled(true);
            GPTimings.ENTITY_EXPLOSION_PRE_EVENT.stopTimingIfSync();
            return;
        }
    }

    GPTimings.ENTITY_EXPLOSION_PRE_EVENT.stopTimingIfSync();
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:36,代码来源:EntityEventHandler.java


示例7: onBlockStartBurn

import org.spongepowered.api.world.explosion.Explosion; //导入依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
  public void onBlockStartBurn(IgniteEntityEvent e){
  	
  	Entity b = e.getTargetEntity();
  	Cause ignit = e.getCause(); 
  	if (b == null){
  		return;
  	}
  	
  	RedProtect.get().logger.debug("blocks","Is BlockIgniteEvent event. Canceled? " + e.isCancelled());
  	
  	Region r = RedProtect.get().rm.getTopRegion(b.getLocation());
if (r != null && !r.canFire()){
	if (ignit.first(Player.class).isPresent()){
		Player p = ignit.first(Player.class).get();
		if (!r.canBuild(p)){
			RPLang.sendMessage(p, "blocklistener.region.cantplace");
			e.setCancelled(true);
			return;
		}
	} else {
		e.setCancelled(true);
   		return;
	}
	
	if (ignit.first(BlockSnapshot.class).isPresent() && (ignit.first(BlockSnapshot.class).get().getState().getType().equals(BlockTypes.FIRE) || ignit.first(BlockSnapshot.class).get().getState().getType().getName().contains("lava"))){
		e.setCancelled(true);
   		return;
	} 
	if (ignit.first(Lightning.class).isPresent() || ignit.first(Explosion.class).isPresent() || ignit.first(Fireball.class).isPresent()){
		e.setCancelled(true);
          }
}
  }
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:35,代码来源:RPBlockListener.java


示例8: apply

import org.spongepowered.api.world.explosion.Explosion; //导入依赖的package包/类
@Override
public Optional<Instruction<DamagedCondition, Boss<Zombie, CatacombsBossDetail>>> apply(
    DamagedCondition damagedCondition, Boss<Zombie, CatacombsBossDetail> zombieCatacombsBossDetailBoss
) {
  CatacombsBossDetail detail = zombieCatacombsBossDetailBoss.getDetail();
  CatacombsInstance inst = detail.getZone();
  Zombie boss = zombieCatacombsBossDetailBoss.getTargetEntity().get();

  if (activate(detail)) {
    List<Entity> arrows = VelocityEntitySpawner.sendRadial(
        EntityTypes.TIPPED_ARROW,
        boss,
        Cause.source(SpawnCause.builder().type(SpawnTypes.PROJECTILE).build()).build()
    );

    Task.builder().execute(() -> {
      for (Entity arrow : arrows) {
        Location<World> target = arrow.getLocation();
        target.getExtent().triggerExplosion(
            Explosion.builder()
                .location(target)
                .radius(explosionStrength(detail))
                .canCauseFire(allowFire(detail))
                .shouldBreakBlocks(allowBlockBreak(detail))
                .shouldDamageEntities(true)
                .build(),
            Cause.source(SkreePlugin.container()).owner(boss).build()
        );
      }
    }).delay(getDelay(detail), TimeUnit.SECONDS).submit(SkreePlugin.inst());
  }

  return Optional.empty();
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:35,代码来源:ExplosiveArrowBarrage.java


示例9: dabombDetonate

import org.spongepowered.api.world.explosion.Explosion; //导入依赖的package包/类
public void dabombDetonate(double percentEffectiveness) {
  ZoneBoundingBox dabombRG = getRegion(FreakyFourBoss.DA_BOMB);

  Vector3i min = dabombRG.getMinimumPoint();
  Vector3i max = dabombRG.getMaximumPoint();

  int minX = min.getX();
  int minY = min.getY();
  int minZ = min.getZ();
  int maxX = max.getX();
  int maxZ = max.getZ();

  int dmgFact = (int) Math.max(3, percentEffectiveness * config.daBombTNTStrength);

  for (int x = minX; x < maxX; ++x) {
    for (int z = minZ; z < maxZ; ++z) {
      if (Probability.getChance(config.daBombTNT)) {
        getRegion().getExtent().triggerExplosion(
            Explosion.builder()
                .location(new Location<>(getRegion().getExtent(), new Vector3d(x, minY, z)))
                .radius(dmgFact)
                .canCauseFire(false)
                .shouldDamageEntities(true)
                .build(),
            Cause.source(SkreePlugin.container()).build()
        );
      }
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:31,代码来源:FreakyFourInstance.java


示例10: onBlockDamage

import org.spongepowered.api.world.explosion.Explosion; //导入依赖的package包/类
@Listener
public void onBlockDamage(ExplosionEvent.Pre event, @First Entity cause)
{
    if (this.handleEntity(cause))
    {
        event.setExplosion(Explosion.builder().from(event.getExplosion()).shouldBreakBlocks(false).shouldDamageEntities(false).build());
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:9,代码来源:ThrowCommands.java


示例11: onEntityExplode

import org.spongepowered.api.world.explosion.Explosion; //导入依赖的package包/类
@Listener
public void onEntityExplode(final ExplosionEvent.Pre event, @First PrimedTNT cause)
{
    if (noBlockDamageSet.contains(cause))
    {
        noBlockDamageSet.remove(cause);
        event.setExplosion(Explosion.builder().from(event.getExplosion())
                                    .shouldBreakBlocks(false)
                                    .shouldDamageEntities(false).build());
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:12,代码来源:NukeCommand.java


示例12: createExplosion

import org.spongepowered.api.world.explosion.Explosion; //导入依赖的package包/类
@Override
public boolean createExplosion(Location loc, float power) {
    Explosion explosion = Explosion.builder()
            .world(((PoreWorld) loc.getWorld()).getHandle())
            .origin(LocationConverter.toVector3d(loc))
            .radius(power)
            .build();

    explosion.getWorld().triggerExplosion(explosion);
    return true; // TODO
}
 
开发者ID:LapisBlue,项目名称:Pore,代码行数:12,代码来源:PoreWorld.java


示例13: triggerExplosion

import org.spongepowered.api.world.explosion.Explosion; //导入依赖的package包/类
@Override
public void triggerExplosion(Explosion explosion) {
    // TODO Auto-generated method stub
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:LanternWorld.java


示例14: onProjectileHit

import org.spongepowered.api.world.explosion.Explosion; //导入依赖的package包/类
@Listener
public void onProjectileHit(CollideEvent.Impact event, @First Entity entity) {
  Optional<JungleRaidInstance> optInst = manager.getApplicableZone(entity);
  if (!optInst.isPresent()) {
    return;
  }

  JungleRaidInstance inst = optInst.get();

  if (inst.getState() != JungleRaidState.IN_PROGRESS) {
    return;
  }

  int explosionSize = 2;

  if (entity.getType() == EntityTypes.TIPPED_ARROW) {
    if (inst.isFlagEnabled(JungleRaidFlag.TORMENT_ARROWS)) {
      ProjectileSource shooter = ((Arrow) entity).getShooter();

      CuboidContainmentPredicate predicate = new CuboidContainmentPredicate(entity.getLocation().getPosition(), 4, 4, 4);
      for (Entity e : entity.getNearbyEntities(en -> predicate.test(en.getLocation().getPosition()))) {
        if (e.equals(shooter)) {
          continue;
        }
        if (e instanceof Living && shooter instanceof Living) {
          e.damage(1, IndirectEntityDamageSource.builder().type(
              DamageTypes.PROJECTILE
          ).entity(entity).proxySource((Living) shooter).build());

          if (Probability.getChance(5)) {
            EntityHealthUtil.heal((Living) shooter, 1);
          }
        }
      }
    }
    if (inst.isFlagEnabled(JungleRaidFlag.EXPLOSIVE_ARROWS)) {
      if (inst.isFlagEnabled(JungleRaidFlag.SUPER)) {
        explosionSize = 4;
      }
    } else {
      return;
    }
  }
  if (entity instanceof Snowball) {
    if (inst.isFlagEnabled(JungleRaidFlag.GRENADES)) {
      if (inst.isFlagEnabled(JungleRaidFlag.SUPER)) {
        explosionSize = 10;
      } else {
        explosionSize = 6;
      }
    } else {
      return;
    }
  }

  if (entity instanceof ThrownPotion) {
    return;
  }

  entity.getLocation().getExtent().triggerExplosion(
      Explosion.builder()
          .radius(explosionSize)
          .location(entity.getLocation())
          .shouldDamageEntities(true)
          .shouldBreakBlocks(true)
          .build(),
      Cause.source(SkreePlugin.container()).build()
  );
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:70,代码来源:JungleRaidEffectListener.java


示例15: setYield

import org.spongepowered.api.world.explosion.Explosion; //导入依赖的package包/类
@Override
public void setYield(float yield) {
    getHandle().setExplosion(Explosion.builder().from(getHandle().getExplosion()).radius(yield).build());
}
 
开发者ID:LapisBlue,项目名称:Pore,代码行数:5,代码来源:PoreEntityExplodeEvent.java


示例16: triggerExplosion

import org.spongepowered.api.world.explosion.Explosion; //导入依赖的package包/类
@Override public void triggerExplosion(Explosion explosion) {

    }
 
开发者ID:InspireNXE,项目名称:Pulse,代码行数:4,代码来源:ServerWorld.java



注:本文中的org.spongepowered.api.world.explosion.Explosion类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ZipHelper类代码示例发布时间:2022-05-22
下一篇:
Java SecurityContext类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap