当前位置: 首页>>代码示例>>Java>>正文


Java Arrow类代码示例

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


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

示例1: onTick

import org.spongepowered.api.entity.projectile.arrow.Arrow; //导入依赖的package包/类
@Override
public void onTick() {
	if (arrows != 0) {
		Living entity = getConsumer().getEntity();
		World world = entity.getWorld();
		Vector3d rotation = entity.getRotation();
		Vector3d direction = Quaterniond.fromAxesAnglesDeg(rotation.getX(), -rotation.getY(), rotation.getZ()).getDirection();

		Entity arrow = world.createEntity(EntityTypes.TIPPED_ARROW,
				entity.getLocation().getPosition()
						.add(cos((entity.getRotation().getX() - 90) % 360) * 0.2,
								1.8,
								sin((entity.getRotation().getX() - 90) % 360) * 0.2));
		Arrow sb = (Arrow) arrow;
		sb.setShooter(entity);
		world.spawnEntity(sb);
		sb.offer(Keys.VELOCITY, direction.mul(3f));
		arrows--;
	} else {
		setDuration(0); //remove the effect next effect scheduler phase
	}
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:23,代码来源:ArrowstormEffect.java

示例2: onProjectileTickEvent

import org.spongepowered.api.entity.projectile.arrow.Arrow; //导入依赖的package包/类
@Listener
public void onProjectileTickEvent(ProjectileTickEvent event) {
  Projectile projectile = event.getTargetEntity();

  if (!(projectile instanceof Arrow) || Probability.getChance(3)) {
    return;
  }

  Location<World> loc = projectile.getLocation();

  if (MultiTypeRegistry.isWater(loc.getBlockType()) && checkVelocity(projectile.getVelocity())) {
    ProjectileSource source = projectile.getShooter();
    double modifier = 1;

    if (source instanceof Living) {
      modifier = 50;
    }

    Optional<ModifierService> optService = Sponge.getServiceManager().provide(ModifierService.class);
    int rolls = 1;
    if (optService.isPresent() && optService.get().isActive(UBER_ARROW_FISHING)) {
      if (source instanceof Living) {
        rolls = 15;
      } else {
        rolls = 5;
      }
    }

    new ItemDropper(loc).dropStacks(dropTable.getDrops(rolls, modifier), SpawnTypes.DROPPED_ITEM);
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:32,代码来源:ArrowFishingHandler.java

示例3: onProjectileHit

import org.spongepowered.api.entity.projectile.arrow.Arrow; //导入依赖的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

示例4: remove

import org.spongepowered.api.entity.projectile.arrow.Arrow; //导入依赖的package包/类
@Override
public void remove() {
  remove(Monster.class, Animal.class, ExperienceOrb.class, Item.class, Arrow.class);
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:5,代码来源:TheButcherShopInstance.java

示例5: remove

import org.spongepowered.api.entity.projectile.arrow.Arrow; //导入依赖的package包/类
public void remove() {
  remove(Monster.class, ExperienceOrb.class, Item.class, Arrow.class);
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:4,代码来源:LegacyZoneBase.java

示例6: isSafe

import org.spongepowered.api.entity.projectile.arrow.Arrow; //导入依赖的package包/类
private boolean isSafe(Class entityClass)
{
    return !(Explosive.class.isAssignableFrom(entityClass) || Arrow.class == entityClass);
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:5,代码来源:ThrowCommands.java


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