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


Java Projectile类代码示例

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


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

示例1: parse

import org.spongepowered.api.entity.projectile.Projectile; //导入依赖的package包/类
default void parse(CollideEntityEvent.Impact event) {
  Optional<Projectile> optProjectile = event.getCause().first(Projectile.class);
  if (!optProjectile.isPresent()) {
    return;
  }

  Projectile projectile = optProjectile.get();
  ProjectileSource source = optProjectile.get().getShooter();
  if (!(source instanceof Player)) {
    return;
  }

  Player attacker = (Player) source;

  for (Entity anEntity : event.getEntities()) {
    if (anEntity instanceof Player) {
      Player defender = (Player) anEntity;

      processPvP(attacker, defender);
      processPvP(attacker, defender, projectile);
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:24,代码来源:PlayerCombatParser.java

示例2: onBlockCollide

import org.spongepowered.api.entity.projectile.Projectile; //导入依赖的package包/类
@Listener
public void onBlockCollide(CollideEvent.Impact event, @First Projectile projectile) {
  ProjectileSource source = projectile.getShooter();
  if (!(source instanceof Living)) {
    return;
  }

  Living sourceEntity = (Living) source;
  ItemStackSnapshot shootingItemStack = projectile.get(SHOOTING_ITEM_DATA_KEY).map(Optional::get).orElse(null);
  if (!applicabilityTest.test(sourceEntity, shootingItemStack)) {
    return;
  }

  if (cooldownHandler.canUseAbility(sourceEntity)) {
    cooldownHandler.useAbility(sourceEntity);
  } else {
    return;
  }

  attackCluster.getNextAbilityToRun().run(sourceEntity, event.getImpactPoint());
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:22,代码来源:PointOfContactClusterListener.java

示例3: onEntityDamage

import org.spongepowered.api.entity.projectile.Projectile; //导入依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
   public void onEntityDamage(DamageEntityEvent e, @First Entity e2) {
   	    	
       Entity e1 = e.getTargetEntity();
       Location<World> loc = e1.getLocation();
       
       Player damager = null;
   	if (e2 instanceof Projectile){
   		Projectile proj = (Projectile)e2;
   		if (proj.getShooter() instanceof Player){
   			damager = (Player) proj.getShooter();
   		}
   	} else if (e2 instanceof Player){
   		damager = (Player) e2;
   	}       
   	
	Region r1 = RedProtect.get().rm.getTopRegion(loc);
	
	if (r1 == null){
		//global flags
		if (e1 instanceof ArmorStand){
           	if (e2 instanceof Player) {
                   if (!RedProtect.get().cfgs.getGlobalFlag(loc.getExtent().getName(),"build")){
                   	e.setCancelled(true);
                   	return;
                   }
               }                  
           }            
           return;
	} 
	
	if (e1 instanceof ArmorStand){
       	if (r1 != null && !r1.canBuild(damager)){
           	e.setCancelled(true);
           	RPLang.sendMessage(damager, "blocklistener.region.cantbreak");
           }
       }        
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:39,代码来源:RPMine18.java

示例4: cast

import org.spongepowered.api.entity.projectile.Projectile; //导入依赖的package包/类
@Override
public SkillResult cast(IActiveCharacter character, ExtendedSkillInfo info, SkillModifier modifier) {
	Optional<Projectile> projectile = character.getPlayer().launchProjectile(getProjectile(character, info));
	if (projectile.isPresent()) {
		ProjectileProperties projectileProperties = getProjectileProperties(character, info, modifier, projectile.get());
		projectileProperties.onHit(getHitConsumer());
		return SkillResult.OK;
	}
	return SkillResult.CANCELLED;
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:11,代码来源:SkillShot.java

示例5: ProjectileHitEvent

import org.spongepowered.api.entity.projectile.Projectile; //导入依赖的package包/类
public ProjectileHitEvent(IEntity shooter, IEntity target, double projectileDamage, Projectile projectile) {

		this.shooter = shooter;
		this.target = target;
		this.projectileDamage = projectileDamage;
		this.projectile = projectile;
	}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:8,代码来源:ProjectileHitEvent.java

示例6: onIndirectEntityDamage

import org.spongepowered.api.entity.projectile.Projectile; //导入依赖的package包/类
@Listener
public void onIndirectEntityDamage(DamageEntityEvent event,
								   @First(typeFilter = IndirectEntityDamageSource.class)
										   IndirectEntityDamageSource indirectEntityDamageSource) {

	Projectile projectile = (Projectile) indirectEntityDamageSource.getSource();
	IEntity shooter = entityService.get((Entity) projectile.getShooter());
	IEntity target = entityService.get(event.getTargetEntity());
	ProjectileProperties projectileProperties = ProjectileProperties.cache.get(projectile);
	if (projectileProperties != null) {
		ProjectileProperties.cache.remove(projectile);
		projectileProperties.consumer.accept(shooter, target);
		return;
	}

	double projectileDamage = 0;
	if (shooter.getType() == IEntityType.CHARACTER) {
		IActiveCharacter c = (IActiveCharacter) shooter;
		projectileDamage = damageService.getCharacterProjectileDamage(c, projectile.getType());
	} else if (shooter.getType() == IEntityType.MOB) {
		if (!PluginConfig.OVERRIDE_MOBS) {
			projectileDamage = entityService.getMobDamage(shooter.getEntity().getType());
		}
	}

	ProjectileHitEvent event1 = new ProjectileHitEvent(shooter, target, projectileDamage, projectile);
	Sponge.getGame().getEventManager().post(event1);
	if (event1.isCancelled() || event1.getProjectileDamage() <= 0) {
		event.setCancelled(true);
		return;
	}

	event.setBaseDamage(event1.getProjectileDamage());
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:35,代码来源:BasicListener.java

示例7: onPlayerCombat

import org.spongepowered.api.entity.projectile.Projectile; //导入依赖的package包/类
@Listener
public void onPlayerCombat(CollideEntityEvent.Impact event, @First Projectile projectile) {
  if (!isApplicable(projectile)) {
    return;
  }

  createFor(event).parse(event);
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:9,代码来源:MainWorldWrapper.java

示例8: onPlayerCombat

import org.spongepowered.api.entity.projectile.Projectile; //导入依赖的package包/类
@Listener
public void onPlayerCombat(CollideEntityEvent.Impact event, @First Projectile projectile) {
  Optional<Integer> optLevel = getLevel(projectile.getLocation());
  if (!optLevel.isPresent()) {
    return;
  }

  createFor(event, optLevel.get()).parse(event);
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:10,代码来源:WildernessWorldWrapper.java

示例9: onProjectileTickEvent

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

示例10: onPlayerCombat

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

  JungleRaidInstance inst = optInst.get();

  createFor(event, inst).parse(event);
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:12,代码来源:JungleRaidListener.java

示例11: onPlayerCombat

import org.spongepowered.api.entity.projectile.Projectile; //导入依赖的package包/类
@Listener
public void onPlayerCombat(CollideEntityEvent.Impact event, @First Projectile projectile) {
  Optional<SkyWarsInstance> optInst = manager.getApplicableZone(projectile);

  if (!optInst.isPresent()) {
    return;
  }

  SkyWarsInstance inst = optInst.get();

  createFor(event, inst).parse(event);
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:13,代码来源:SkyWarsListener.java

示例12: onPlayerCombat

import org.spongepowered.api.entity.projectile.Projectile; //导入依赖的package包/类
@Listener
public void onPlayerCombat(CollideEntityEvent.Impact event, @First Projectile projectile) {
  Optional<TheForgeInstance> optInst = manager.getApplicableZone(projectile);
  if (!optInst.isPresent()) {
    return;
  }

  createCombatParser(event, optInst.get()).parse(event);
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:10,代码来源:TheForgeListener.java

示例13: onProjectileLaunch

import org.spongepowered.api.entity.projectile.Projectile; //导入依赖的package包/类
@Listener
public void onProjectileLaunch(SpawnEntityEvent event) {
  for (Entity entity : event.getEntities()) {
    if (!(entity instanceof Projectile)) {
      continue;
    }

    ProjectileSource shooter = ((Projectile) entity).getShooter();
    if (shooter instanceof ArmorEquipable) {
      entity.offer(new ShootingItemData((((ArmorEquipable) shooter).getItemInHand(HandTypes.MAIN_HAND).map(ItemStack::createSnapshot).orElse(null))));
    }

    track((Projectile) entity, event.getCause());
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:16,代码来源:ProjectileWatcherServiceImpl.java

示例14: track

import org.spongepowered.api.entity.projectile.Projectile; //导入依赖的package包/类
@Override
public void track(Projectile projectile, Cause cause) {
  watched.put(projectile.getUniqueId(), new TrackedProjectileInfoImpl(projectile, cause));
  if (task == null) {
    task = Task.builder().execute(this).delayTicks(1).intervalTicks(1).submit(SkreePlugin.inst());
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:8,代码来源:ProjectileWatcherServiceImpl.java

示例15: throwItem

import org.spongepowered.api.entity.projectile.Projectile; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void throwItem()
{

    Vector3d rotation = player.getTransform().getRotationAsQuaternion().getDirection().normalize();
    Location location = this.player.getLocation()
            .add(0, player.getProperty(EyeHeightProperty.class).get().getValue(), 0)
            .add(rotation.mul(2));

    Entity entity;
    if (Projectile.class.isAssignableFrom(this.type.getEntityClass()))
    {
        entity = this.player.launchProjectile((Class<? extends Projectile>)this.type.getEntityClass()).get();
    }
    else
    {
        entity = player.getWorld().createEntity(type, location.getPosition());
        Sponge.getCauseStackManager().pushCause(player);
        player.getWorld().spawnEntity(entity);
        entity.setVelocity(rotation.mul(8));
        if (entity instanceof ExperienceOrb)
        {
            entity.offer(Keys.CONTAINED_EXPERIENCE, 0);
        }
    }
    if (this.preventDamage && !this.save)
    {
        throwListener.add(entity);
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:31,代码来源:ThrowCommands.java


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