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

Java ProjectileSource类代码示例

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

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



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

示例1: parse

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

import org.spongepowered.api.entity.projectile.source.ProjectileSource; //导入依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void PlayerTrownPotion(LaunchProjectileEvent e){ 
	
	Entity ent = e.getTargetEntity();    	
	RedProtect.get().logger.debug("player","Is PotionSplashEvent event.");
    
	Region r = RedProtect.get().rm.getTopRegion(ent.getLocation());    	        
    if (ent instanceof ThrownPotion){ 
    	
		ThrownPotion potion = (ThrownPotion) e.getTargetEntity();
		ProjectileSource thrower = potion.getShooter();    		
		
		if (thrower instanceof Player){
			if (r != null && !r.usePotions((Player)thrower)){
        		RPLang.sendMessage((Player)thrower, "playerlistener.region.cantuse");
        		e.setCancelled(true);
        		return;
        	}
		}
		
		List<PotionEffect> pottypes = potion.get(Keys.POTION_EFFECTS).get();
		//deny potion
        List<String> Pots = RedProtect.get().cfgs.getStringList("server-protection.deny-potions");
		for (PotionEffect t:pottypes){
			if (Pots.size() > 0 && Pots.contains(t.getType().getName().toUpperCase())){
				e.setCancelled(true);
				if (thrower instanceof Player){
    				RPLang.sendMessage((Player)thrower, RPLang.get("playerlistener.denypotion"));
    			}
                return;
            }
		}            
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:35,代码来源:RPPlayerListener.java


示例4: onProjectileTickEvent

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


示例5: onProjectileLaunch

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


示例6: throwEgg

import org.spongepowered.api.entity.projectile.source.ProjectileSource; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public Egg throwEgg() {
    if (getHandle() instanceof ProjectileSource) {
        return PoreEgg.of(
                ((ProjectileSource) getHandle()).launchProjectile(
                        org.spongepowered.api.entity.projectile.Egg.class
                ).orElse(null)
        );
    }
    // CB never returns null here so we shouldn't either
    // this will prevent ambiguity if something breaks (as opposed to if we let a plugin throw an NPE)
    throw new UnsupportedOperationException("Not a ProjectileSource");
}
 
开发者ID:LapisBlue,项目名称:Pore,代码行数:15,代码来源:PoreLivingEntity.java


示例7: throwSnowball

import org.spongepowered.api.entity.projectile.source.ProjectileSource; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public Snowball throwSnowball() {
    if (getHandle() instanceof ProjectileSource) {
        return PoreSnowball.of(
                ((ProjectileSource) getHandle()).launchProjectile(
                        org.spongepowered.api.entity.projectile.Snowball.class
                ).orElse(null)
        );
    }
    throw new UnsupportedOperationException("Not a ProjectileSource");
}
 
开发者ID:LapisBlue,项目名称:Pore,代码行数:13,代码来源:PoreLivingEntity.java


示例8: shootArrow

import org.spongepowered.api.entity.projectile.source.ProjectileSource; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public Arrow shootArrow() {
    if (getHandle() instanceof ProjectileSource) {
        return PoreArrow.of(
                ((ProjectileSource) getHandle()).launchProjectile(
                        org.spongepowered.api.entity.projectile.Arrow.class
                ).orElse(null)
        );
    }
    throw new UnsupportedOperationException("Not a ProjectileSource");
}
 
开发者ID:LapisBlue,项目名称:Pore,代码行数:13,代码来源:PoreLivingEntity.java


示例9: launchProjectile

import org.spongepowered.api.entity.projectile.source.ProjectileSource; //导入依赖的package包/类
@Override
public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity) {
    if (getHandle() instanceof ProjectileSource) {
        return ProjectileUtil.launchProjectile((ProjectileSource) getHandle(), projectile, velocity).orNull();
    }
    throw new UnsupportedOperationException();
}
 
开发者ID:LapisBlue,项目名称:Pore,代码行数:8,代码来源:PoreLivingEntity.java


示例10: registerDefaults

import org.spongepowered.api.entity.projectile.source.ProjectileSource; //导入依赖的package包/类
@Override
public void registerDefaults() {
    // Sponge
    register(new LanternEventContextKey<>("sponge", "creator", "Creator", User.class));
    register(new LanternEventContextKey<>("sponge", "damage_type", "Damage Type", DamageType.class));
    register(new LanternEventContextKey<>("sponge", "dismount_type", "Dimension Type", DismountType.class));
    register(new LanternEventContextKey<>("sponge", "igniter", "Igniter", User.class));
    register(new LanternEventContextKey<>("sponge", "last_damage_source", "Last Damage Source", DamageSource.class));
    register(new LanternEventContextKey<>("sponge", "liquid_mix", "Liquid Mix", World.class));
    register(new LanternEventContextKey<>("sponge", "notifier", "Notifier", User.class));
    register(new LanternEventContextKey<>("sponge", "owner", "Owner", User.class));
    register(new LanternEventContextKey<>("sponge", "player", "Player", Player.class));
    register(new LanternEventContextKey<>("sponge", "player_simulated", "Game Profile", GameProfile.class));
    register(new LanternEventContextKey<>("sponge", "projectile_source", "Projectile Source", ProjectileSource.class));
    register(new LanternEventContextKey<>("sponge", "service_manager", "Service Manager", ServiceManager.class));
    register(new LanternEventContextKey<>("sponge", "spawn_type", "Spawn Type", SpawnType.class));
    register(new LanternEventContextKey<>("sponge", "teleport_type", "Teleport Type", TeleportType.class));
    register(new LanternEventContextKey<>("sponge", "thrower", "Thrower", User.class));
    register(new LanternEventContextKey<>("sponge", "weapon", "Weapon", ItemStackSnapshot.class));
    register(new LanternEventContextKey<>("sponge", "fake_player", "Fake Player", Player.class));
    register(new LanternEventContextKey<>("sponge", "player_break", "Player Break", World.class));
    register(new LanternEventContextKey<>("sponge", "player_place", "Player Place", World.class));
    register(new LanternEventContextKey<>("sponge", "fire_spread", "Fire Spread", World.class));
    register(new LanternEventContextKey<>("sponge", "leaves_decay", "Leaves Decay", World.class));
    register(new LanternEventContextKey<>("sponge", "piston_retract", "Piston Retract", World.class));
    register(new LanternEventContextKey<>("sponge", "piston_extend", "Piston Extend", World.class));
    register(new LanternEventContextKey<>("sponge", "block_hit", "Block Hit", BlockSnapshot.class));
    register(new LanternEventContextKey<>("sponge", "entity_hit", "Entity Hit", BlockSnapshot.class));
    register(new LanternEventContextKey<>("sponge", "used_item", "Used Item", ItemStackSnapshot.class));
    register(new LanternEventContextKey<>("sponge", "plugin", "Plugin", PluginContainer.class));

    // Lantern

    /// Behavior context keys
    register(new LanternEventContextKey<>("lantern", "used_item_stack", "Used Item Stack", ItemStack.class));
    register(new LanternEventContextKey<>("lantern", "used_block_state", "Used Block State", BlockState.class));
    register(new LanternEventContextKey<>("lantern", "interaction_location", "Interaction Location", new TypeToken<Location<World>>() {}));
    register(new LanternEventContextKey<>("lantern", "interaction_face", "Interaction Face", Direction.class));
    register(new LanternEventContextKey<>("lantern", "interaction_hand", "Interaction Hand", HandType.class));
    register(new LanternEventContextKey<>("lantern", "block_location", "Block Location", new TypeToken<Location<World>>() {}));
    register(new LanternEventContextKey<>("lantern", "block_type", "Block Type", BlockType.class));
    register(new LanternEventContextKey<>("lantern", "block_snapshot", "Block Snapshot", BlockSnapshot.class));
    register(new LanternEventContextKey<>("lantern", "item_type", "Item Type", ItemType.class));
    register(new LanternEventContextKey<>("lantern", "used_slot", "Used Slot", Slot.class));

    /// Event context keys
    register(new LanternEventContextKey<>("lantern", "original_item_stack", "Original Item Stack", ItemStack.class));
    register(new LanternEventContextKey<>("lantern", "rest_item_stack", "Rest Item Stack", ItemStack.class));
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:50,代码来源:EventContextKeysModule.java


示例11: onPotionSplash

import org.spongepowered.api.entity.projectile.source.ProjectileSource; //导入依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onPotionSplash(LaunchProjectileEvent event) {
	
	if (event.getTargetEntity() instanceof ThrownPotion){
		ThrownPotion potion = (ThrownPotion) event.getTargetEntity();
		ProjectileSource thrower = potion.getShooter();    		
		
		RedProtect.get().logger.debug("entity","RPEntityListener - LaunchProjectileEvent entity "+event.getTargetEntity().getType().getName()); 
		
		List<PotionEffect> pottypes = potion.get(Keys.POTION_EFFECTS).get();
		for (PotionEffect t:pottypes){
			if (!t.getType().equals(PotionEffectTypes.BLINDNESS) && 
					!t.equals(PotionEffectTypes.WEAKNESS) && 
					!t.equals(PotionEffectTypes.NAUSEA) && 
					!t.equals(PotionEffectTypes.HUNGER) && 
					!t.equals(PotionEffectTypes.POISON) && 
					!t.equals(PotionEffectTypes.MINING_FATIGUE) && 
					!t.equals(PotionEffectTypes.HASTE) &&
					!t.equals(PotionEffectTypes.SLOWNESS) &&
					!t.equals(PotionEffectTypes.WITHER)) {
                return;
            }
		}
        
        
        Player shooter;
        if (thrower instanceof Player) {
            shooter = (Player)thrower;
        } else {
            return;
        }
        
        RedProtect.get().logger.debug("entity","RPEntityListener - LaunchProjectileEvent shooter "+shooter.getName()); 
        
        Entity e2 = event.getTargetEntity();
        Region r = RedProtect.get().rm.getTopRegion(e2.getLocation());
        if (e2 instanceof Player){
        	if (r != null && r.flagExists("pvp") && !r.canPVP(shooter)) {
                event.setCancelled(true);
            }
        } else {
        	if (r != null && !r.canInteractPassives(shooter)) {
                event.setCancelled(true);
            }
        }
	} 
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:48,代码来源:RPEntityListener.java


示例12: onProjectileHit

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java WSDLPortProperties类代码示例发布时间:2022-05-22
下一篇:
Java Annotation类代码示例发布时间: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