Library [1.8] ParticleEffect v1.7

Discussion in 'Resources' started by DarkBladee12, Jun 20, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    DarkBladee12

    97waterpolo Well you'd have to get the players looking direction and get the location of the block in opposite direction and add 0.5 to x and z so you get the center of the block. This should work: PLAYER.getLocation().getBlock().getRelative(OPPOSITEDIRECTION).getLocation().add(0.5, 0, 0.5)
     
    97waterpolo likes this.
  2. Offline

    97WaterPolo

    DarkBladee12
    Tried it, but I never defined a variable as Oppositedirection. DO you have the variable definition for that?
     
  3. Offline

    DarkBladee12

    97waterpolo Well you'd need a method that gets the player looking direction as a BlockFace like that:

    Code:java
    1. public BlockFace getDirection(Player p) {
    2. double rotation = (p.getLocation().getYaw() - 90) % 360;
    3. if (rotation < 0)
    4. rotation += 360.0;
    5. if (0 <= rotation && rotation < 22.5)
    6. return BlockFace.NORTH;
    7. else if (22.5 <= rotation && rotation < 67.5)
    8. return BlockFace.NORTH_EAST;
    9. else if (67.5 <= rotation && rotation < 112.5)
    10. return BlockFace.EAST;
    11. else if (112.5 <= rotation && rotation < 157.5)
    12. return BlockFace.SOUTH_EAST;
    13. else if (157.5 <= rotation && rotation < 202.5)
    14. return BlockFace.SOUTH;
    15. else if (202.5 <= rotation && rotation < 247.5)
    16. return BlockFace.SOUTH_WEST;
    17. else if (247.5 <= rotation && rotation < 292.5)
    18. return BlockFace.WEST;
    19. else if (292.5 <= rotation && rotation < 337.5)
    20. return BlockFace.NORTH_WEST;
    21. else if (337.5 <= rotation && rotation < 360.0)
    22. return BlockFace.NORTH;
    23. else
    24. return null;
    25. }


    Now you'd have to replace OPPOSITEDIRECTION with getDirection(PLAYER).getOppositeFace()
     
  4. Offline

    97WaterPolo

  5. Offline

    DarkBladee12

    97waterpolo Well maybe the method for getting the player direction is invalid, search on the forums for another one. (I've also searched that one quick, because I only had one for North, East, South, West)
     
  6. Offline

    97WaterPolo

    Well the one you gave me would have been the second I have tried :L

    Is there any other way?

    Well after playing around withit for awhile, I got it to work. This gets the trail right behind the player
    Code:java
    1. public BlockFace getDirection(Player player) {
    2. double rotation = (player.getLocation().getYaw() - 180) % 360;
    3. if (rotation < 0)
    4. rotation += 360.0;
    5. if (0 <= rotation && rotation < 40.0)
    6. return BlockFace.NORTH;
    7. else if (40.0 <= rotation && rotation < 80.0)
    8. return BlockFace.NORTH_EAST;
    9. else if (80.0 <= rotation && rotation < 120.0)
    10. return BlockFace.EAST;
    11. else if (120.0 <= rotation && rotation < 160.0)
    12. return BlockFace.SOUTH_EAST;
    13. else if (160.0 <= rotation && rotation < 200.0)
    14. return BlockFace.SOUTH;
    15. else if (200.0 <= rotation && rotation < 240.0)
    16. return BlockFace.SOUTH_WEST;
    17. else if (240.0 <= rotation && rotation < 280.0)
    18. return BlockFace.WEST;
    19. else if (280.0 <= rotation && rotation < 320.0)
    20. return BlockFace.NORTH_WEST;
    21. else if (320.0 <= rotation && rotation < 360.0)
    22. return BlockFace.NORTH;
    23. else
    24. return null;
    25. }


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Oct 29, 2015
  7. Offline

    Qwahchees

    Thanks for the share, unfortunately my IDE can't find ReflectionUtil even after I add it.

    Any ideas? :S
     
  8. Offline

    DarkBladee12

    Qwahchees Try to press ctrl + shift + o because this will automatically import stuff ;)
     
  9. Offline

    Qwahchees

    I tried, still something is missing :\
     
  10. Offline

    97WaterPolo

    DarkBladee12
    Not sure if its just me, but I can't get bubble or explosion to work. Bubble and nothing happens, and for explosion its just clouds. I was looking for explosion thats similar to TnT.

    You don't import, you added it to your project right? Should look like this.
    [​IMG]

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Oct 29, 2015
  11. Offline

    HeavyMine13

    what was added in v1.3?
     
  12. Offline

    DarkBladee12

    HeavyMine13 I removed the speed paramater for displayBlockCrack, because I found out that it doesn't modify anything on that type of particle effect.
     
  13. Offline

    97WaterPolo

    DarkBladee12
    What do bubbles to?

    Explosion looks just like clouds, not TNT explosion.

    If using citizens, console spams "Can not send particle to (NPC)"
     
  14. Offline

    DarkBladee12

    97waterpolo Bubbles look like the bubbles when you throw/shoot something in the water, but this will only work when you're underwater. Thanks for reporting this again, another guy told me that a long time ago and I must admit that I have forgot that. I'll fix that immediately ;)

    EDIT: Code at the gist was updated and should no longer conflict with Citizens or any other type of NPC plugin!
     
    97waterpolo likes this.
  15. Offline

    97WaterPolo

    DarkBladee12 Also, two more questions/requests.
    1. Any way you can make the explosion particle look like the TnT explosion particle?
    2. How would you add colored smoke? :confused: saw some plugins and servers that have it and it entices me to know :3

    EDIT: You will need to add
    Code:java
    1. import [YOUR PACKAGE].ReflectionUtil.DynamicPackage;

    in the ParticleEffect.Java
     
  16. Offline

    DoctorDark

    Thanks for this, I can see myself finding this very useful.

    Is there anyway to only send the particle packet to one player by any chance?

    DarkBladee12
     
  17. Offline

    DarkBladee12

    DoctorDark Yes it is, you have to use the method with the Player... parameter. You can put as many players you want to send it to in there. (they have to be seperated with ,)
     
  18. Offline

    DoctorDark

    DarkBladee12

    Sorry for any inconvenience, but it doesn't seem to allow me to do that;

    Screenshot_1.png

    Example (open)

    Code:java
    1. if (arrow.getShooter() instanceof Player) {
    2.  
    3. Player shooter = (Player) arrow.getShooter();
    4. Player damaged = (Player) e.getEntity();
    5.  
    6. ParticleEffect.FIREWORKS_SPARK.display(shooter, damaged.getLocation().add(0, 1, 0), 0, 0, 0, (float) 0.25, 50);
    7.  
    8. }



    In summary, I want the 'shooter' player to only see these particles.
     
  19. Offline

    DarkBladee12

    DoctorDark You'd have to put the player argument at the end, so it looks like that: ParticleEffect.FIREWORKS_SPARK.display(damaged.getLocation().add(0, 1, 0), 0, 0, 0, 0.25F, 50, shooter);
     
    DoctorDark likes this.
  20. Offline

    InfamousSheep

    EDIT: I had a problem with an excessive amount of particles being spawned but I accidentally had it in a for loop. Derp moment. Anyway, thanks a lot for this! You're awesome c:
     
  21. Offline

    iKeirNez

    DarkBlade12 I believe this needs updated for the latest ProtocolLib API and also I was getting a missing class error (SubPackageType and a few others)
     
  22. I am also getting missing class errors:
    PacketType,
    SubPackageType,
    PackageType.
     
  23. Offline

    DarkBladee12

    SheerAwesomeness iKeirNez You have to use the new ReflectionHandler, whose classes are uploaded here! Sorry I forgot to update the main page, will do that right now!
     
  24. DarkBladee12 Thanks man :)

    Just one thing, getting an unknown error for FieldPair. Is there another class?
     
  25. Offline

    DarkBladee12

    SheerAwesomeness Oh thanks for reporting that, forgot to add it. Take a look at the gist, it should be visible now ;)
     
  26. Offline

    iKeirNez

    Thanks! Greatly appreciated
     
  27. Offline

    DarkBladee12

    Another thing I want to mention is that maybe an API for particles will finally be implemented soon, because SpaceManiac recently submitted a pull request to Bukkit + CraftBukkit which adds support for particle effects!
     
  28. Offline

    Captain Dory

    DarkBladee12

    My particles aren't showing up :c Code:
    Code:java
    1. @EventHandler
    2. public void onSheepClick (PlayerInteractEntityEvent e) {
    3.  
    4. Sheep s = (Sheep) e.getRightClicked();
    5.  
    6. if (e.getRightClicked() instanceof Sheep) {
    7.  
    8. System.out.println(s.getColor());
    9. Location loc = new Location (Bukkit.getWorld("world"),100,65,100);
    10. ParticleEffect.EXPLOSION.display(loc, 1.0F, 1.0F, 1.0F, 0.9F, 33);
    11. }


    Am i supposed to do something else in the class or another class?
     
  29. Offline

    DarkBladee12

    Captain Dory What effect ist EXPLOSION??? Because that one doesn't exist in my library, there is only HUGE_EXPLOSION and LARGE_EXPLODE!
     
  30. Offline

    Captain Dory

    Oops.. I thought because it wasn't getting any errors it was in the library xD I'll try HUGE_EXPLOSION, brb.

    EDIT: Still doesn't work :p
     
Thread Status:
Not open for further replies.

Share This Page