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

Java PotionEffectType类代码示例

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

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



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

示例1: registerDefaults

import org.spongepowered.api.effect.potion.PotionEffectType; //导入依赖的package包/类
@Override
public void registerDefaults() {
    registerOption("block_state", BlockState.class);
    registerOption("color", Color.class);
    registerOption("direction", Direction.class);
    registerOption("firework_effects", List.class,
            value -> value.isEmpty() ? new IllegalArgumentException("The firework effects list may not be empty") : null);
    registerOption("quantity", Integer.class,
            value -> value < 1 ? new IllegalArgumentException("Quantity must be at least 1") : null);
    registerOption("item_stack_snapshot", ItemStackSnapshot.class);
    registerOption("note", NotePitch.class);
    registerOption("offset", Vector3d.class);
    registerOption("potion_effect_type", PotionEffectType.class);
    registerOption("scale", Double.class,
            value -> value < 0 ? new IllegalArgumentException("Scale may not be negative") : null);
    registerOption("velocity", Vector3d.class);
    registerOption("slow_horizontal_velocity", Boolean.class);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:19,代码来源:ParticleOptionRegistryModule.java


示例2: buildContent

import org.spongepowered.api.effect.potion.PotionEffectType; //导入依赖的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


示例3: throwSlashPotion

import org.spongepowered.api.effect.potion.PotionEffectType; //导入依赖的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


示例4: throwSlashPotion

import org.spongepowered.api.effect.potion.PotionEffectType; //导入依赖的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


示例5: createPotionEffect

import org.spongepowered.api.effect.potion.PotionEffectType; //导入依赖的package包/类
private PotionEffect createPotionEffect(PotionEffectType type, int amplifier, int duration) {
	return PotionEffect.builder()
			.potionType(type)
			.amplifier(amplifier)
			.particles(true)
			.duration(duration).build();
}
 
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:8,代码来源:EEEffect.java


示例6: awardPlayer

import org.spongepowered.api.effect.potion.PotionEffectType; //导入依赖的package包/类
@Override
public boolean awardPlayer(Player player) {
    final Optional<String> potionEffectTypeIDOpt = Util.safeGetString(this.data, "potionEffectType");
    if (!potionEffectTypeIDOpt.isPresent()) {
        this.plugin.getLogger().error("No potion effect type specified. Aborting.");
        return false;
    }

    String potionEffectTypeID = potionEffectTypeIDOpt.get();

    final Optional<PotionEffectType> optType = Sponge.getRegistry().getType(PotionEffectType.class,
            potionEffectTypeID);
    if (!optType.isPresent()) {
        this.plugin.getLogger().error("Potion effect type " + potionEffectTypeID + " not found. Aborting.");
        return false;
    }

    PotionEffect.Builder builder = Sponge.getRegistry().createBuilder(PotionEffect.Builder.class)
            .potionType(optType.get());

    Optional<Integer> durationOpt = Util.safeGetInt(this.data, "duration");
    if (!durationOpt.isPresent()) {
        this.plugin.getLogger().error("Potion effect duration not specified. Aborting.");
        return false;
    }
    builder.duration(durationOpt.get());

    builder.amplifier(Util.safeGetInt(this.data, "amplifier").orElse(1));

    List<PotionEffect> currentEffects = player.get(Keys.POTION_EFFECTS).orElse(new ArrayList<>());
    currentEffects.add(builder.build());

    DataTransactionResult result = player.offer(Keys.POTION_EFFECTS, currentEffects);
    return result.isSuccessful();
}
 
开发者ID:BadgeUp,项目名称:badgeup-sponge-client,代码行数:36,代码来源:PotionEffectAward.java


示例7: MessagePlayOutAddPotionEffect

import org.spongepowered.api.effect.potion.PotionEffectType; //导入依赖的package包/类
public MessagePlayOutAddPotionEffect(int entityId, PotionEffectType potionEffectType, int duration, int amplifier,
        boolean ambient, boolean showParticles) {
    this.potionEffectType = potionEffectType;
    this.entityId = entityId;
    this.duration = duration;
    this.amplifier = amplifier;
    this.ambient = ambient;
    this.showParticles = showParticles;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:10,代码来源:MessagePlayOutAddPotionEffect.java


示例8: deserialize

import org.spongepowered.api.effect.potion.PotionEffectType; //导入依赖的package包/类
@Nullable
public static PotionEffect deserialize(DataView dataView) {
    final int internalId;

    if (dataView.get(IDENTIFIER).get() instanceof Byte) {
        internalId = dataView.getByte(IDENTIFIER).get() & 0xff;
    } else {
        internalId = dataView.getInt(IDENTIFIER).get();
    }

    final PotionEffectType effectType = PotionEffectTypeRegistryModule.get().getByInternalId(internalId).orElse(null);
    if (effectType == null) {
        Lantern.getLogger().warn("Unknown potion effect type: " + internalId);
        return null;
    }

    final int amplifier = dataView.getInt(AMPLIFIER).get();
    final int duration = dataView.getInt(DURATION).get();
    final boolean ambient = dataView.getInt(AMBIENT).orElse(0) > 0;
    final boolean particles = dataView.getInt(SHOW_PARTICLES).orElse(0) > 0;
    return PotionEffect.builder()
            .potionType(effectType)
            .ambience(ambient)
            .amplifier(amplifier)
            .duration(duration)
            .particles(particles)
            .build();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:29,代码来源:PotionEffectSerializer.java


示例9: bindPropertySupplier

import org.spongepowered.api.effect.potion.PotionEffectType; //导入依赖的package包/类
@Override
public <T> void bindPropertySupplier(ContainerProperty<T> propertyType, Supplier<T> supplier) {
    super.bindPropertySupplier(propertyType, supplier);
    int index = -1;
    if (propertyType == ContainerProperties.PRIMARY_POTION_EFFECT) {
        index = 0;
    } else if (propertyType == ContainerProperties.SECONDARY_POTION_EFFECT) {
        index = 1;
    }
    if (index != -1) {
        final Supplier<Optional<PotionEffectType>> supplier1 = (Supplier<Optional<PotionEffectType>>) supplier;
        bindInternalProperty(index, () -> supplier1.get()
                .map(type -> ((LanternPotionEffectType) type).getInternalId()).orElse(-1));
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:16,代码来源:BeaconClientContainer.java


示例10: LanternPotionEffect

import org.spongepowered.api.effect.potion.PotionEffectType; //导入依赖的package包/类
LanternPotionEffect(PotionEffectType effectType, int duration, int amplifier, boolean ambient, boolean showParticles) {
    this.effectType = checkNotNull(effectType, "effectType");
    this.showParticles = showParticles;
    this.duration = duration;
    this.amplifier = amplifier;
    this.ambient = ambient;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:8,代码来源:LanternPotionEffect.java


示例11: hasPotionEffect

import org.spongepowered.api.effect.potion.PotionEffectType; //导入依赖的package包/类
default boolean hasPotionEffect(PotionEffectType type) {
	List<PotionEffect> potionEffects = getEntity().get(Keys.POTION_EFFECTS).get();
	for (PotionEffect potionEffect : potionEffects) {
		if (potionEffect.getType() == type) {
			return true;
		}
	}
	return false;
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:10,代码来源:IEffectConsumer.java


示例12: SkillPotion

import org.spongepowered.api.effect.potion.PotionEffectType; //导入依赖的package包/类
public SkillPotion() {
	super(PotionEffect.name);
	Map<PotionEffectType, Long> list = new HashMap<>();
	Collection<PotionEffectType> allOf = Sponge.getRegistry().getAllOf(PotionEffectType.class);
	for (PotionEffectType type : allOf) {
		list.put(type, 19000L);
	}
	SkillSettings settings = new SkillSettings();
	settings.addNode("cooldown-reduced", 0, -125);
	settings.addObjectNode("potions", gson.toJson(list));
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:12,代码来源:SkillPotion.java


示例13: execute

import org.spongepowered.api.effect.potion.PotionEffectType; //导入依赖的package包/类
@Override
public void execute(CommandQueue queue, CommandEntry entry) {
    EntityTag ent = EntityTag.getFor(queue.error, entry.getArgumentObject(queue, 0));
    if (!ent.getInternal().supports(PotionEffectData.class)) {
        queue.handleError(entry, "This entity type does not support potion effects!");
        return;
    }
    PotionEffectData data = ent.getInternal().getOrCreate(PotionEffectData.class).get();
    String name = entry.getArgumentObject(queue, 1).toString().toLowerCase();
    Optional<PotionEffectType> type = Sponge.getRegistry().getType(PotionEffectType.class, name);
    if (!type.isPresent()) {
        queue.handleError(entry, "Invalid potion effect name: '" + name + "'!");
        return;
    }
    DurationTag dur = DurationTag.getFor(queue.error, entry.getArgumentObject(queue, 2));
    PotionEffect.Builder build = PotionEffect.builder().potionType(type.get()).duration((int) dur.getInternal() * 20);
    if (entry.namedArgs.containsKey("amplifier")) {
        IntegerTag amp = IntegerTag.getFor(queue.error, entry.getNamedArgumentObject(queue, "amplifier"));
        build.amplifier((int) amp.getInternal() - 1);
    }
    if (entry.namedArgs.containsKey("ambient")) {
        BooleanTag amb = BooleanTag.getFor(queue.error, entry.getNamedArgumentObject(queue, "ambient"));
        build.ambience(amb.getInternal());
    }
    else {
        build.particles(false);
    }
    if (entry.namedArgs.containsKey("particles")) {
        BooleanTag part = BooleanTag.getFor(queue.error, entry.getNamedArgumentObject(queue, "particles"));
        build.particles(part.getInternal());
    }
    else {
        build.particles(true);
    }
    if (queue.shouldShowGood()) {
        queue.outGood("Casting " + ColorSet.emphasis + type.get().getId() + ColorSet.good
                + " on " + ColorSet.emphasis + ent.debug() + ColorSet.good
                + " for " + ColorSet.emphasis + dur.debug() + ColorSet.good + " seconds!");
    }
    data.addElement(build.build());
    ent.getInternal().offer(data);
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:43,代码来源:CastCommand.java


示例14: PotionEffectTypeView

import org.spongepowered.api.effect.potion.PotionEffectType; //导入依赖的package包/类
public PotionEffectTypeView(PotionEffectType value) {
    super(value);

    this.id = value.getId();
    this.name = value.getTranslation().get();
}
 
开发者ID:Valandur,项目名称:Web-API,代码行数:7,代码来源:PotionEffectTypeView.java


示例15: MessagePlayOutRemovePotionEffect

import org.spongepowered.api.effect.potion.PotionEffectType; //导入依赖的package包/类
public MessagePlayOutRemovePotionEffect(int entityId, PotionEffectType potionEffectType) {
    this.potionEffectType = potionEffectType;
    this.entityId = entityId;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:MessagePlayOutRemovePotionEffect.java


示例16: getType

import org.spongepowered.api.effect.potion.PotionEffectType; //导入依赖的package包/类
public PotionEffectType getType() {
    return this.potionEffectType;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:4,代码来源:MessagePlayOutRemovePotionEffect.java


示例17: MessagePlayInAcceptBeaconEffects

import org.spongepowered.api.effect.potion.PotionEffectType; //导入依赖的package包/类
public MessagePlayInAcceptBeaconEffects(@Nullable PotionEffectType primaryEffect, @Nullable PotionEffectType secondaryEffect) {
    this.secondaryEffect = secondaryEffect;
    this.primaryEffect = primaryEffect;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:MessagePlayInAcceptBeaconEffects.java


示例18: BeaconEffectsEvent

import org.spongepowered.api.effect.potion.PotionEffectType; //导入依赖的package包/类
public BeaconEffectsEvent(@Nullable PotionEffectType primaryEffect, @Nullable PotionEffectType secondaryEffect) {
    this.secondaryEffect = secondaryEffect;
    this.primaryEffect = primaryEffect;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:BeaconEffectsEvent.java


示例19: handleEffects

import org.spongepowered.api.effect.potion.PotionEffectType; //导入依赖的package包/类
public void handleEffects(@Nullable PotionEffectType primaryEffect, @Nullable PotionEffectType secondaryEffect) {
    // Force the input item to update
    queueSilentSlotChange(this.slots[0]);
    tryProcessBehavior(behavior -> behavior.handleEvent(this, new BeaconEffectsEvent(primaryEffect, secondaryEffect)));
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:6,代码来源:BeaconClientContainer.java


示例20: getType

import org.spongepowered.api.effect.potion.PotionEffectType; //导入依赖的package包/类
@Override
public PotionEffectType getType() {
    return this.effectType;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:LanternPotionEffect.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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