Sponge: ParticleEffect.builder().from(..)... causes an UnsupportedOperationException

Created on 1 Nov 2016  路  1Comment  路  Source: SpongePowered/Sponge

If you build a ParticleEffect...

ParticleEffect baseEffect = ParticleEffect.builder()
            .type(ParticleTypes.DRAGON_BREATH)
            .quantity(50)
            .offset(Vector3d.ONE)
            .velocity(Vector3d.ONE)
            .build();

... and from this one, try to create a new builder ...

ParticleEffect.builder()
            .from(baseEffect)    // <- this causes the exception, i think
            .quantity(4)         // <- this throws the exception
            .type(ParticleTypes.CRITICAL_HIT)
            .velocity(Vector3d.ZERO)
            .build()

It throws this Exception:

 java.lang.UnsupportedOperationException
    at com.google.common.collect.ImmutableMap.put(ImmutableMap.java:326) ~[guava-17.0.jar:?]
    at org.spongepowered.common.effect.particle.SpongeParticleEffectBuilder.option(SpongeParticleEffectBuilder.java:108) ~[SpongeParticleEffectBuilder.class:?]
    at org.spongepowered.api.effect.particle.ParticleEffect$Builder.quantity(ParticleEffect.java:149) ~[ParticleEffect$Builder.class:?]
    at de.craftednature.sponge.cnplugin.test.TestModul.test2(TestModul.java:41) ~[TestModul.class:?]

I think this is because the SpongeParticleEffectBuilder class tries to modify an ImmutableMap:
https://github.com/SpongePowered/SpongeCommon/blob/bleeding/src/main/java/org/spongepowered/common/effect/particle/SpongeParticleEffectBuilder.java#L79
__(particleEffect.getOptions() returns an ImmutableMap!)__

https://github.com/SpongePowered/SpongeCommon/blob/bleeding/src/main/java/org/spongepowered/common/effect/particle/SpongeParticleEffectBuilder.java#L108

I found this issue in my development environment, so i don't have any Sponge Versions, but it was the Sponge-Forge Version built from the bleeding branch.
Minecraft: 1.10.2
Minecraft Forge: 12.18.2.2107

bug

Most helpful comment

This is my mistake, I will fix this in: https://github.com/SpongePowered/SpongeCommon/pull/986

>All comments

This is my mistake, I will fix this in: https://github.com/SpongePowered/SpongeCommon/pull/986

Was this page helpful?
0 / 5 - 0 ratings

Related issues

XakepSDK picture XakepSDK  路  5Comments

PurpleIsEverything picture PurpleIsEverything  路  4Comments

XakepSDK picture XakepSDK  路  3Comments

JoeSGT picture JoeSGT  路  5Comments

DarkArc picture DarkArc  路  3Comments