1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Colored particles?

Discussion in 'Development' started by Redux, Jan 20, 2017.

  1. Redux

    Redux Spider Jockey

    Messages:
    49
    GitHub:
    reduxredstone
    As someone who has been using command blocks in the PC addition of Minecraft for several years now, I'm well aware that there are several particle effects that can be manipulated to display an RGB color instead of the normal color. The list, at least for PC is
    1. reddust (redstone dust)
    2. mobSpell
    3. mobSpellAmbient
    4. and fallingdust
    However I can only seem to get PMMP to color the fallingdust type and none others. The following code works as expected:

    Code:
    $level->addParticle(new DustParticle(new Vector3($x, $y, $z), $r, $g, $b));
    

    It creates a particle with the specified RGB values. However when I tried to change out DustParticle for RedstoneParticle it didn't work at all. It resulted in this nightmare:
    [​IMG]

    Upon looking in the source of PMMP I found that there are no particle effects that seem to support RGB values other than DustParticle.

    My question is this:
    Is there any way to color any of the other particles that are supposed to be supported (preferably the RedstoneParticle), or will only DustParticle work? I don't want to use DustParticle since the particle is affected by gravity, and falls down ruining the effect.
     
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    i am assuming here, but i dont think so that PE client supports it like how PC does
     
  3. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    PHP:
    new GenericParticle($posParticle::YOUR_PARTICLE, (($a 0xff) << 24) | (($r 0xff) << 16) | (($g 0xff) << 8) | ($b 0xff));
    should do the trick for all particles that support rgba color. $a is alpha, if you don't know what that is set 255 [transparency]
     
  4. Redux

    Redux Spider Jockey

    Messages:
    49
    GitHub:
    reduxredstone
    I know that alpha means transparency.
    But using GenericParticle results in the same issue. RGB values seem to scale the redstone particle rather than color it.
    [​IMG]
    I suppose PMMP, or maybe just PocketEdition itself doesn't support coloring the redstone particle
     
  5. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
  6. Redux

    Redux Spider Jockey

    Messages:
    49
    GitHub:
    reduxredstone
    TYPE_MOB_SPELL, TYPE_MOB_SPELL_AMBIENT, and TYPE_MOB_SPELL_AMBIENT all only make blue colored ones. I know for a fact that the RGBA values are correct because when I use the Dust type it colors the particles correctly.

    It would probably help if I provided what I'm trying to accomplish. In short I have a plugin that reads 16x16 images images of wings from a directory and then displays them on the backs of players via particle effects. I already have it basically all done, it reads the RGBA values properly and can display the particles correctly as well. But I cannot color the particles. The falling dust particle seems to be the only one which accepts RGB values correctly, however that particle falls and ruins the look of the wings.

    I've made something similar on the PC version using the redstone particle and it worked very well. Any suggestions on a possible work around? Every particle type I've tried has failed to work.
    [​IMG]
     
  7. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    well, sad enough.
    maybe mcpe simply doesn't support it or the way we're trying to encode RGB(A) is not right, someone with IDA skills might find out.
    Maybe try striking out alpha helps?
    PHP:
    new GenericParticle($posParticle::YOUR_PARTICLE, (($r 0xff) << 16) | (($g 0xff) << 8) | ($b 0xff)); 
    #just removing it should work, we have 8bit values here, and shift them 8 bits each.
     
  8. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    But potions in MCPE have colored particles too, so at least MobSpell should work
     
  9. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    but it still decays over time?
     
  10. Redux

    Redux Spider Jockey

    Messages:
    49
    GitHub:
    reduxredstone
    PMMP may just not support them then.

    Removing the alpha made my game lag to absolute hell, unplayable levels of lag.

    Maybe the issue is before the particle? Do you think it could be I'm pulling the RGB values in a way that the particle doesn't like?

    Code:
    $image = imagecreatefrompng($fullPath); //$fullPath is the path to the image file
    
    for($h=0;$h<16;$h++) {
        for($w=0;$w<16;$w++) {
            $rgb = imagecolorat($image, $w, $h);
                    $a = ($rgb >> 24) & 0xFF;
                    $r = ($rgb >> 16) & 0xFF;
                    $g = ($rgb >> 8) & 0xFF;
                    $b = $rgb & 0xFF;
                    // Some other code that isn't related to getting colors
            }
    }
    
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.