use of org.spongepowered.common.accessor.world.entity.projectile.ArrowAccessor in project SpongeCommon by SpongePowered.
the class ArrowData method register.
// @formatter:off
public static void register(final DataProviderRegistrator registrator) {
registrator.asMutable(Arrow.class).create(Keys.POTION_EFFECTS).get(h -> {
final Set<MobEffectInstance> effects = ((ArrowAccessor) h).accessor$effects();
return effects.stream().map(effect -> (PotionEffect) new MobEffectInstance(effect.getEffect(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.isVisible())).collect(Collectors.toList());
}).set((h, v) -> {
((ArrowAccessor) h).accessor$effects().clear();
for (final PotionEffect effect : v) {
final MobEffectInstance mcEffect = new MobEffectInstance(((MobEffectInstance) effect).getEffect(), (int) effect.duration().ticks(), effect.amplifier(), effect.isAmbient(), effect.showsParticles());
h.addEffect(mcEffect);
}
});
}
Aggregations