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;
}
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;
}
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;
}
Aggregations