Search in sources :

Example 1 with IMixinAreaEffectCloud

use of org.spongepowered.common.mixin.core.entity.IMixinAreaEffectCloud in project SpongeCommon by SpongePowered.

the class AreaEffectCloudDataProcessor method getValues.

@Override
protected Map<Key<?>, ?> getValues(EntityAreaEffectCloud dataHolder) {
    final HashMap<Key<?>, Object> map = new HashMap<>();
    map.put(Keys.AREA_EFFECT_CLOUD_AGE, dataHolder.ticksExisted);
    map.put(Keys.AREA_EFFECT_CLOUD_COLOR, Color.ofRgb(dataHolder.getColor()));
    map.put(Keys.AREA_EFFECT_CLOUD_RADIUS, dataHolder.getRadius());
    final IMixinAreaEffectCloud mixinAreaEffect = (IMixinAreaEffectCloud) dataHolder;
    final List<net.minecraft.potion.PotionEffect> potionEffects = mixinAreaEffect.getPotionEffects();
    final List<PotionEffect> effects = new ArrayList<>(potionEffects.size());
    for (net.minecraft.potion.PotionEffect potionEffect : potionEffects) {
        effects.add((PotionEffect) potionEffect);
    }
    map.put(Keys.POTION_EFFECTS, effects);
    map.put(Keys.AREA_EFFECT_CLOUD_RADIUS_ON_USE, mixinAreaEffect.getRadiusOnUse());
    map.put(Keys.AREA_EFFECT_CLOUD_RADIUS_PER_TICK, mixinAreaEffect.getRadiusPerTick());
    map.put(Keys.AREA_EFFECT_CLOUD_DURATION, dataHolder.getDuration());
    map.put(Keys.AREA_EFFECT_CLOUD_DURATION_ON_USE, mixinAreaEffect.getDurationOnUse());
    map.put(Keys.AREA_EFFECT_CLOUD_REAPPLICATION_DELAY, mixinAreaEffect.getReapplicationDelay());
    map.put(Keys.AREA_EFFECT_CLOUD_WAIT_TIME, mixinAreaEffect.getWaitTime());
    map.put(Keys.AREA_EFFECT_CLOUD_PARTICLE_TYPE, ParticleTypes.MOB_SPELL);
    return map;
}
Also used : HashMap(java.util.HashMap) PotionEffect(org.spongepowered.api.effect.potion.PotionEffect) ArrayList(java.util.ArrayList) IMixinAreaEffectCloud(org.spongepowered.common.mixin.core.entity.IMixinAreaEffectCloud) Key(org.spongepowered.api.data.key.Key)

Example 2 with IMixinAreaEffectCloud

use of org.spongepowered.common.mixin.core.entity.IMixinAreaEffectCloud 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 3 with IMixinAreaEffectCloud

use of org.spongepowered.common.mixin.core.entity.IMixinAreaEffectCloud in project SpongeCommon by SpongePowered.

the class AreaEffectCloudPotionEffectsProcessor method set.

@Override
protected boolean set(EntityAreaEffectCloud container, List<PotionEffect> value) {
    final List<net.minecraft.potion.PotionEffect> effects = new ArrayList<>(value.size());
    for (PotionEffect effect : value) {
        effects.add((net.minecraft.potion.PotionEffect) effect);
    }
    ((IMixinAreaEffectCloud) container).setPotionEffects(effects);
    return true;
}
Also used : PotionEffect(org.spongepowered.api.effect.potion.PotionEffect) ArrayList(java.util.ArrayList) IMixinAreaEffectCloud(org.spongepowered.common.mixin.core.entity.IMixinAreaEffectCloud)

Aggregations

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