本文整理汇总了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);
}
}
}
示例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());
}
示例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");
}
}
}
示例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;
}
示例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;
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
}
示例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());
}
}
示例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);
}
}