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

Java PotionEffect类代码示例

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

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



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

示例1: removePotion

import org.spongepowered.api.effect.potion.PotionEffect; //导入依赖的package包/类
public boolean removePotion(PotionEffect effect){
	if (this.user.get(Keys.POTION_EFFECTS).isPresent()){
		List<PotionEffect> effects = this.user.get(Keys.POTION_EFFECTS).get();
		boolean check = false;
		int cpt = 0;
		while(effects.size() > cpt && check == false){
			if (effects.get(cpt).equals(effect)){
				effects.remove(cpt);
				check = true;
			}
			cpt++;
		}
		this.user.offer(Keys.POTION_EFFECTS, effects);
		return true;
	} else {
		return false;
	}
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:19,代码来源:UserKeys.java


示例2: registerDefaults

import org.spongepowered.api.effect.potion.PotionEffect; //导入依赖的package包/类
@Override
public void registerDefaults() {
    register(new LanternFish("minecraft", "cod", "item.fish.cod.raw.name", 0,
            builder -> builder
                    .add(foodRestoration(2))
                    .add(saturation(0.4))));
    register(new LanternFish("minecraft", "salmon", "item.fish.salmon.raw.name", 1,
            builder -> builder
                    .add(foodRestoration(2))
                    .add(saturation(0.4))));
    register(new LanternFish("minecraft", "clownfish", "item.fish.clownfish.raw.name", 2,
            builder -> builder
                    .add(foodRestoration(1))
                    .add(saturation(0.2))));
    register(new LanternFish("minecraft", "pufferfish", "item.fish.pufferfish.raw.name", 3,
            builder -> builder
                    .add(foodRestoration(1))
                    .add(saturation(0.2))
                    .add(applicableEffects(
                            PotionEffect.of(PotionEffectTypes.POISON, 3, 1200),
                            PotionEffect.of(PotionEffectTypes.HUNGER, 2, 300),
                            PotionEffect.of(PotionEffectTypes.NAUSEA, 1, 300)))));
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:24,代码来源:FishRegistryModule.java


示例3: get

import org.spongepowered.api.effect.potion.PotionEffect; //导入依赖的package包/类
@Override
public Collection<PotionEffect> get(ItemType itemType, @Nullable ItemStack itemStack) {
    if (itemStack == null) {
        return Collections.emptyList();
    }
    final PotionType potionType = itemStack.get(LanternKeys.POTION_TYPE).orElse(null);
    List<PotionEffect> potionEffects = null;
    if (potionType != null) {
        potionEffects = potionType.getEffects();
    }
    final List<PotionEffect> extraPotionEffects = itemStack.get(Keys.POTION_EFFECTS).orElse(null);
    if (extraPotionEffects != null) {
        if (potionEffects != null) {
            potionEffects = PotionEffectHelper.merge(potionEffects, extraPotionEffects);
        } else {
            potionEffects = extraPotionEffects;
        }
    }
    return potionEffects == null ? ImmutableSet.of() : ImmutableSet.copyOf(potionEffects);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:21,代码来源:PotionEffectsProvider.java


示例4: serialize

import org.spongepowered.api.effect.potion.PotionEffect; //导入依赖的package包/类
public static DataView serialize(PotionEffect potionEffect) {
    final DataView dataView = DataContainer.createNew(DataView.SafetyMode.NO_DATA_CLONED);
    dataView.set(AMPLIFIER, (byte) potionEffect.getAmplifier());
    dataView.set(DURATION, potionEffect.getDuration());
    dataView.set(AMBIENT, (byte) (potionEffect.isAmbient() ? 1 : 0));
    if (potionEffect.getShowParticles()) {
        dataView.set(SHOW_PARTICLES, (byte) 1);
    }
    final LanternPotionEffectType potionEffectType = (LanternPotionEffectType) potionEffect.getType();
    final int internalId = potionEffectType.getInternalId();
    if (internalId > 0xff) {
        dataView.set(IDENTIFIER, internalId);
    } else {
        dataView.set(IDENTIFIER, (byte) internalId);
    }
    return dataView;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:18,代码来源:PotionEffectSerializer.java


示例5: buildContent

import org.spongepowered.api.effect.potion.PotionEffect; //导入依赖的package包/类
@Override
protected Optional<PotionEffect> buildContent(DataView container) throws InvalidDataException {
    checkNotNull(container);
    if (!container.contains(DataQueries.POTION_TYPE) || !container.contains(DataQueries.POTION_DURATION)
            || !container.contains(DataQueries.POTION_AMPLIFIER) || !container.contains(DataQueries.POTION_AMBIANCE)
            || !container.contains(DataQueries.POTION_SHOWS_PARTICLES)) {
        return Optional.empty();
    }
    String effectName = container.getString(DataQueries.POTION_TYPE).get();
    Optional<PotionEffectType> optional = Sponge.getRegistry().getType(PotionEffectType.class, effectName);
    if (!optional.isPresent()) {
        throw new InvalidDataException("The container has an invalid potion type name: " + effectName);
    }
    int duration = container.getInt(DataQueries.POTION_DURATION).get();
    int amplifier = container.getInt(DataQueries.POTION_AMPLIFIER).get();
    boolean ambient = container.getBoolean(DataQueries.POTION_AMBIANCE).get();
    boolean showParticles = container.getBoolean(DataQueries.POTION_SHOWS_PARTICLES).get();
    return Optional.of(new LanternPotionEffect(optional.get(), duration, amplifier, ambient, showParticles));
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:20,代码来源:LanternPotionEffectBuilder.java


示例6: run

import org.spongepowered.api.effect.potion.PotionEffect; //导入依赖的package包/类
@Override
public void run() {
  PotionEffect speedEffect = PotionEffect.builder()
      .duration(3 * 20)
      .amplifier(5)
      .particles(false)
      .potionType(PotionEffectTypes.SPEED)
      .build();

  for (World world : getWorlds()) {
    for (Entity entity : world.getEntities(p -> p.getType().equals(EntityTypes.PLAYER))) {
      if (entity.get(Keys.GAME_MODE).orElse(GameModes.CREATIVE) != GameModes.SURVIVAL) {
        continue;
      }

      List<PotionEffect> potionEffects = entity.getOrElse(Keys.POTION_EFFECTS, new ArrayList<>(1));
      potionEffects.add(speedEffect);
      entity.offer(Keys.POTION_EFFECTS, potionEffects);
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:22,代码来源:MainWorldWrapper.java


示例7: run

import org.spongepowered.api.effect.potion.PotionEffect; //导入依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
  int duration = (int) (EntityHealthUtil.getHealth(owner) * 20);

  Optional<PotionEffectData> optPotionEffectData = target.getOrCreate(PotionEffectData.class);
  if (optPotionEffectData.isPresent()) {
    PotionEffectData potionEffectData = optPotionEffectData.get();

    potionEffectData.addElement(PotionEffect.of(PotionEffectTypes.BLINDNESS, 1, duration));

    target.offer(potionEffectData);
  }

  target.offer(Keys.FIRE_TICKS, duration);

  notify(owner, Text.of(TextColors.YELLOW, "Your sword releases a deadly blaze."));
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:18,代码来源:FearBlaze.java


示例8: run

import org.spongepowered.api.effect.potion.PotionEffect; //导入依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
  int duration = (int) Math.min(20 * 60 * 5, EntityHealthUtil.getHealth(owner) * 18);

  Optional<PotionEffectData> optOwnerPotionEffectData = owner.getOrCreate(PotionEffectData.class);
  if (optOwnerPotionEffectData.isPresent()) {
    PotionEffectData ownerPotionEffectData = optOwnerPotionEffectData.get();
    ownerPotionEffectData.addElement(PotionEffect.of(PotionEffectTypes.SPEED, 2, duration));
    owner.offer(ownerPotionEffectData);
  }

  Optional<PotionEffectData> optTargetPotionEffectData = target.getOrCreate(PotionEffectData.class);
  if (optTargetPotionEffectData.isPresent()) {
    PotionEffectData targetPotionEffectData = optTargetPotionEffectData.get();
    targetPotionEffectData.addElement(PotionEffect.of(PotionEffectTypes.SLOWNESS, 2, duration));
    target.offer(targetPotionEffectData);
  }

  if (optOwnerPotionEffectData.isPresent() || optTargetPotionEffectData.isPresent()) {
    notify(owner, Text.of(TextColors.YELLOW, "You gain an agile advantage over your opponent."));
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:23,代码来源:Agility.java


示例9: run

import org.spongepowered.api.effect.potion.PotionEffect; //导入依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
  Optional<PotionEffectData> optPotionEffectData = target.getOrCreate(PotionEffectData.class);
  if (!optPotionEffectData.isPresent()) {
    return;
  }

  PotionEffectData potionEffectData = optPotionEffectData.get();

  int duration = (int) (EntityHealthUtil.getHealth(owner) * 18);
  potionEffectData.addElement(PotionEffect.of(PotionEffectTypes.SLOWNESS, 2, duration));
  potionEffectData.addElement(PotionEffect.of(PotionEffectTypes.WEAKNESS, 2, duration));

  target.offer(potionEffectData);

  notify(owner, Text.of(TextColors.YELLOW, "Your bow slows its victim."));
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:18,代码来源:MagicChain.java


示例10: run

import org.spongepowered.api.effect.potion.PotionEffect; //导入依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
  Optional<PotionEffectData> optPotionEffectData = owner.getOrCreate(PotionEffectData.class);
  if (!optPotionEffectData.isPresent()) {
    return;
  }

  PotionEffectData potionEffectData = optPotionEffectData.get();

  int duration = (int) (EntityHealthUtil.getHealth(target) * 10);
  potionEffectData.addElement(PotionEffect.of(PotionEffectTypes.REGENERATION, 2, duration));

  owner.offer(potionEffectData);

  notify(owner, Text.of(TextColors.YELLOW, "You gain a healing aura."));
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:17,代码来源:Regen.java


示例11: run

import org.spongepowered.api.effect.potion.PotionEffect; //导入依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
  Optional<PotionEffectData> optPotionEffectData = target.getOrCreate(PotionEffectData.class);
  if (!optPotionEffectData.isPresent()) {
    return;
  }

  PotionEffectData potionEffectData = optPotionEffectData.get();

  int duration = (int) (EntityHealthUtil.getHealth(target) * 10);
  potionEffectData.addElement(PotionEffect.of(PotionEffectTypes.SLOWNESS, 9, duration));
  if (target instanceof Player) {
    potionEffectData.addElement(PotionEffect.of(PotionEffectTypes.BLINDNESS, 0, 20 * 4));
  }

  target.offer(potionEffectData);

  target.getWorld().playSound(SoundTypes.ENTITY_GHAST_SCREAM, target.getLocation().getPosition(), 1, .02F);

  notify(owner, Text.of(TextColors.YELLOW, "Your weapon traps your foe in their own sins."));
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:22,代码来源:EvilFocus.java


示例12: run

import org.spongepowered.api.effect.potion.PotionEffect; //导入依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
  Optional<PotionEffectData> optPotionEffectData = target.getOrCreate(PotionEffectData.class);
  if (!optPotionEffectData.isPresent()) {
    return;
  }

  PotionEffectData potionEffectData = optPotionEffectData.get();

  int duration = (int) Math.min(20 * 60 * 5, EntityHealthUtil.getHealth(owner) * 24);
  potionEffectData.addElement(PotionEffect.of(PotionEffectTypes.WITHER, 2, duration));

  target.offer(potionEffectData);

  notify(owner, Text.of(TextColors.YELLOW, "Your weapon curses its victim."));
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:17,代码来源:Curse.java


示例13: run

import org.spongepowered.api.effect.potion.PotionEffect; //导入依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
  Optional<PotionEffectData> optPotionEffectData = target.getOrCreate(PotionEffectData.class);
  if (!optPotionEffectData.isPresent()) {
    return;
  }

  PotionEffectData potionEffectData = optPotionEffectData.get();

  int duration = (int) Math.min(1200, EntityHealthUtil.getHealth(owner) * 18);
  potionEffectData.addElement(PotionEffect.of(PotionEffectTypes.NAUSEA, 1, duration));

  target.offer(potionEffectData);

  notify(owner, Text.of(TextColors.YELLOW, "Your sword confuses its victim."));

}
 
开发者ID:Skelril,项目名称:Skree,代码行数:18,代码来源:Confuse.java


示例14: run

import org.spongepowered.api.effect.potion.PotionEffect; //导入依赖的package包/类
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
  int duration = (int) Math.min(20 * 60 * 5, EntityHealthUtil.getHealth(owner) * 18);

  Optional<PotionEffectData> optOwnerPotionEffectData = owner.getOrCreate(PotionEffectData.class);
  if (optOwnerPotionEffectData.isPresent()) {
    PotionEffectData ownerPotionEffectData = optOwnerPotionEffectData.get();
    ownerPotionEffectData.addElement(PotionEffect.of(PotionEffectTypes.STRENGTH, 1, duration));
    owner.offer(ownerPotionEffectData);
  }

  Optional<PotionEffectData> optTargetPotionEffectData = target.getOrCreate(PotionEffectData.class);
  if (optTargetPotionEffectData.isPresent()) {
    PotionEffectData targetPotionEffectData = optTargetPotionEffectData.get();
    targetPotionEffectData.addElement(PotionEffect.of(PotionEffectTypes.WEAKNESS, 1, duration));
    target.offer(targetPotionEffectData);
  }

  if (optOwnerPotionEffectData.isPresent() || optTargetPotionEffectData.isPresent()) {
    notify(owner, Text.of(TextColors.YELLOW, "Your sword leaches strength from its victim."));
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:23,代码来源:Weaken.java


示例15: runFrimus

import org.spongepowered.api.effect.potion.PotionEffect; //导入依赖的package包/类
private void runFrimus() {
  createWall(
      getRegion(FreakyFourBoss.FRIMUS),
      type -> type == BlockTypes.AIR,
      type -> type == BlockTypes.LAVA || type == BlockTypes.FLOWING_LAVA,
      BlockTypes.AIR,
      BlockTypes.LAVA,
      config.frimusWallDensity,
      -1
  );

  for (Player player : getPlayers(PlayerClassifier.PARTICIPANT)) {
    List<PotionEffect> oldPotions = player.get(Keys.POTION_EFFECTS).orElse(new ArrayList<>());
    List<PotionEffect> newPotions = oldPotions.stream().filter(
        effect -> effect.getType() != PotionEffectTypes.FIRE_RESISTANCE
    ).collect(Collectors.toList());

    if (oldPotions.size() != newPotions.size()) {
      player.offer(Keys.POTION_EFFECTS, newPotions);
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:23,代码来源:FreakyFourInstance.java


示例16: throwSlashPotion

import org.spongepowered.api.effect.potion.PotionEffect; //导入依赖的package包/类
private void throwSlashPotion(Location<World> location) {

    PotionEffectType[] thrownTypes = new PotionEffectType[] {
        PotionEffectTypes.INSTANT_DAMAGE, PotionEffectTypes.INSTANT_DAMAGE,
        PotionEffectTypes.POISON, PotionEffectTypes.WEAKNESS
    };

    Entity entity = location.getExtent().createEntity(EntityTypes.SPLASH_POTION, location.getPosition());
    entity.setVelocity(new Vector3d(
        random.nextDouble() * .5 - .25,
        random.nextDouble() * .4 + .1,
        random.nextDouble() * .5 - .25
    ));

    PotionEffectType type = Probability.pickOneOf(thrownTypes);
    PotionEffect effect = PotionEffect.of(type, 2, type.isInstant() ? 1 : 15 * 20);
    entity.offer(Keys.POTION_EFFECTS, Lists.newArrayList(effect));

    getRegion().getExtent().spawnEntity(entity, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
  }
 
开发者ID:Skelril,项目名称:Skree,代码行数:21,代码来源:PatientXInstance.java


示例17: throwSlashPotion

import org.spongepowered.api.effect.potion.PotionEffect; //导入依赖的package包/类
private void throwSlashPotion(Location<World> location) {

    PotionEffectType[] thrownTypes = new PotionEffectType[] {
        PotionEffectTypes.INSTANT_DAMAGE, PotionEffectTypes.INSTANT_DAMAGE,
        PotionEffectTypes.POISON, PotionEffectTypes.WEAKNESS
    };

    Entity entity = location.getExtent().createEntity(EntityTypes.SPLASH_POTION, location.getPosition());
    entity.setVelocity(new Vector3d(
        random.nextDouble() * .5 - .25,
        random.nextDouble() * .4 + .1,
        random.nextDouble() * .5 - .25
    ));

    PotionEffectType type = Probability.pickOneOf(thrownTypes);
    PotionEffect effect = PotionEffect.of(type, 2, type.isInstant() ? 1 : 15 * 20);
    entity.offer(Keys.POTION_EFFECTS, Lists.newArrayList(effect));

    location.getExtent().spawnEntity(entity, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
  }
 
开发者ID:Skelril,项目名称:Skree,代码行数:21,代码来源:DeadlyPotionCurse.java


示例18: handle

import org.spongepowered.api.effect.potion.PotionEffect; //导入依赖的package包/类
@Override
public void handle(BrewingEvent.Start event) {
    event.filter(stack -> {
        if (stack.getItem() == ItemTypes.SPLASH_POTION) {
            return false;
        }
        if (stack.getItem() == ItemTypes.LINGERING_POTION) {
            return false;
        }
        if (stack.supports(Keys.POTION_EFFECTS)) {
            Optional<List<PotionEffect>> optPotions = stack.get(Keys.POTION_EFFECTS);
            if (!optPotions.isPresent()) {
                return true;
            }
            for (PotionEffect effect : optPotions.get()) {
                if (effect.getType() == PotionEffectTypes.REGENERATION) {
                    return false;
                }
                if (effect.getAmplifier() > 1) {
                    return false;
                }
            }
        }
        return true;
    });
}
 
开发者ID:liachmodded,项目名称:UHC-Reloaded,代码行数:27,代码来源:CancelPotionBrewingListener.java


示例19: move

import org.spongepowered.api.effect.potion.PotionEffect; //导入依赖的package包/类
@Command(desc = "Moves a world into another universe")
public void move(CommandSource context, World world, String universe)
{
    // TODO old universe is not removed
    String previous = module.getUniverse(world);
    if (previous.equals(universe))
    {
        i18n.send(context, NEGATIVE, "{world} is already in the universe {name}", world, universe);
        return;
    }
    module.setUniverse(world, universe);
    i18n.send(context, POSITIVE, "{world} is now in the universe {input}!", world, universe);

    Sponge.getServer().getOnlinePlayers().stream().filter(player -> player.getWorld().equals(world)).forEach(
        p -> {
            MultiverseData data = p.get(MultiverseData.class).get();
            data.from(previous, world).applyFromPlayer(p);
            data.from(universe, world).applyToPlayer(p);
            i18n.send(p, NEUTRAL, "The sky opens up and sucks in the whole world.");
            p.playSound(SoundTypes.BLOCK_PORTAL_TRIGGER, p.getLocation().getPosition(), 1);
            p.offer(Keys.POTION_EFFECTS, Arrays.asList(PotionEffect.of(PotionEffectTypes.BLINDNESS, 1, 2 * 20)));
            i18n.send(p, NEUTRAL, "When you open your eyes you now are in {input#univserse}.", universe);
            p.offer(data);
        });
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:26,代码来源:MultiverseCommands.java


示例20: addPotion

import org.spongepowered.api.effect.potion.PotionEffect; //导入依赖的package包/类
public boolean addPotion(PotionEffect potion){
	List<PotionEffect> effects = new ArrayList<PotionEffect>();
	if (this.user.get(Keys.POTION_EFFECTS).isPresent()){
		effects = this.user.get(Keys.POTION_EFFECTS).get();
	}
	effects.add(potion);
	this.user.offer(Keys.POTION_EFFECTS, effects);
	return true;
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:10,代码来源:UserKeys.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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