Search in sources :

Example 1 with SpongeParticleType

use of org.spongepowered.common.effect.particle.SpongeParticleType in project SpongeCommon by SpongePowered.

the class AreaEffectCloudDataProcessor method set.

@SuppressWarnings("unchecked")
@Override
protected boolean set(EntityAreaEffectCloud dataHolder, Map<Key<?>, Object> keyValues) {
    final int age = (int) keyValues.get(Keys.AREA_EFFECT_CLOUD_AGE);
    final Color color = (Color) keyValues.get(Keys.AREA_EFFECT_CLOUD_COLOR);
    final double radius = (double) keyValues.get(Keys.AREA_EFFECT_CLOUD_RADIUS);
    final double radiusOnUse = (double) keyValues.get(Keys.AREA_EFFECT_CLOUD_RADIUS_ON_USE);
    final int duration = (int) keyValues.get(Keys.AREA_EFFECT_CLOUD_DURATION);
    final int durationOnUse = (int) keyValues.get(Keys.AREA_EFFECT_CLOUD_DURATION_ON_USE);
    final int waitTime = (int) keyValues.get(Keys.AREA_EFFECT_CLOUD_WAIT_TIME);
    final int reapplicationDelay = (int) keyValues.get(Keys.AREA_EFFECT_CLOUD_REAPPLICATION_DELAY);
    final List<PotionEffect> potionEffects = (List<PotionEffect>) keyValues.get(Keys.POTION_EFFECTS);
    final ParticleType particleType = (ParticleType) keyValues.get(Keys.AREA_EFFECT_CLOUD_PARTICLE_TYPE);
    dataHolder.ticksExisted = age;
    dataHolder.setColor(color.getRgb());
    dataHolder.setRadius((float) radius);
    dataHolder.setRadiusOnUse((float) radiusOnUse);
    dataHolder.setDuration(duration);
    ((IMixinAreaEffectCloud) dataHolder).setDurationOnUse(durationOnUse);
    dataHolder.setWaitTime(waitTime);
    final EnumParticleTypes internalType = ((SpongeParticleType) particleType).getInternalType();
    dataHolder.setParticle(internalType == null ? EnumParticleTypes.SPELL_MOB : internalType);
    final List<net.minecraft.potion.PotionEffect> effects = new ArrayList<>();
    for (PotionEffect effect : potionEffects) {
        effects.add((net.minecraft.potion.PotionEffect) effect);
    }
    ((IMixinAreaEffectCloud) dataHolder).setPotionEffects(effects);
    ((IMixinAreaEffectCloud) dataHolder).setReapplicationDelay(reapplicationDelay);
    return true;
}
Also used : SpongeParticleType(org.spongepowered.common.effect.particle.SpongeParticleType) PotionEffect(org.spongepowered.api.effect.potion.PotionEffect) Color(org.spongepowered.api.util.Color) ArrayList(java.util.ArrayList) SpongeParticleType(org.spongepowered.common.effect.particle.SpongeParticleType) ParticleType(org.spongepowered.api.effect.particle.ParticleType) EnumParticleTypes(net.minecraft.util.EnumParticleTypes) ArrayList(java.util.ArrayList) List(java.util.List) IMixinAreaEffectCloud(org.spongepowered.common.mixin.core.entity.IMixinAreaEffectCloud)

Example 2 with SpongeParticleType

use of org.spongepowered.common.effect.particle.SpongeParticleType in project SpongeCommon by SpongePowered.

the class AreaEffectCloudParticleTypeProcessor method set.

@Override
protected boolean set(EntityAreaEffectCloud container, ParticleType value) {
    final EnumParticleTypes internalType = ((SpongeParticleType) value).getInternalType();
    if (internalType == null) {
        return false;
    }
    container.setParticle(internalType);
    return true;
}
Also used : SpongeParticleType(org.spongepowered.common.effect.particle.SpongeParticleType) EnumParticleTypes(net.minecraft.util.EnumParticleTypes)

Example 3 with SpongeParticleType

use of org.spongepowered.common.effect.particle.SpongeParticleType in project SpongeCommon by SpongePowered.

the class ParticleRegistryModule method addEffectType.

private void addEffectType(String id, @Nullable EnumParticleTypes internalType, Map<ParticleOption<?>, Object> options) {
    SpongeParticleType particleType = new SpongeParticleType("minecraft:" + id, id, internalType, options);
    this.particleMappings.put(id, particleType);
    this.particleByName.put(particleType.getId().toLowerCase(Locale.ENGLISH), particleType);
}
Also used : SpongeParticleType(org.spongepowered.common.effect.particle.SpongeParticleType)

Aggregations

SpongeParticleType (org.spongepowered.common.effect.particle.SpongeParticleType)3 EnumParticleTypes (net.minecraft.util.EnumParticleTypes)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ParticleType (org.spongepowered.api.effect.particle.ParticleType)1 PotionEffect (org.spongepowered.api.effect.potion.PotionEffect)1 Color (org.spongepowered.api.util.Color)1 IMixinAreaEffectCloud (org.spongepowered.common.mixin.core.entity.IMixinAreaEffectCloud)1