1.8.8 My general questions which I have never done before.

Discussion in 'Spigot Plugin Development' started by Wilsoon, Feb 9, 2020.

  1. This is going to be kind of intermediate stuff, but
    1. How do I create an explosion using Java? (And set the explosion power and whether blocks are broken during this explosion)
    2. How do I create some kind of launching effect on a player using Java? (They fly up to the sky and something happens to them.)
  2. World#createExplosion
    Set the player's velocity with Entity#setVelocity
  3. Hmm thanks, but am I being an idiot:
    I can't seem to get the World#createExplosion.
    I'm doing this code on a different package than my main class btw.
  4. That's because you are directly accessing the "World" class, which would only show static methods, it would be targetworld.createExplosion(..) in your case.
    • Optimistic Optimistic x 1
  5. Oops..
  6. I'm trying to explode the player:
    But it only allows Location, float, boolean no matter what I choose.

    I wanted this:

    However even if I pick that one inside my IDE it wants me to reduce it down to the one above ^^
  7. Is this the javadoc for your version?
    Probably 1.8.x didn't have that.

    Pass a second boolean.
  8. Nope, don't really know how to go to the 1.8 Javadocs.

    Don't really understand what this means, all I want is to stop blocks from exploding when this command is ran to explode.
  9. I misread the screenshot. Remove the second boolean parameter. 1.8.x has no option to pass a flag for "do not destroy blocks" I guess.
    Just upgrade to 1.15.2
    • Agree Agree x 1
  10. I think Ima try to circumvent the explosion to blocks by teleporting the player to a location.
    However, I don't know how to make a location for teleportation when I only have the separate X Y and Z. Javadocs doesn't seem to teach me on how to do this.. or maybe it does and I'm just blind.
  11. You can initialize a new location object by simply doing Location loc = new Location(world,x,y,z)

  12. Yup, I'm blind, thanks for helping.
    • Friendly Friendly x 1
  13. These are done. However, this is gonna be a very weird question.
    I plan on making some kind of void plugin that slowly remove blocks one by one under the player until they reach the void and replaces the blocks back after a period of time. What does it take to do that?

    Another thing is:
    If I am to put a vector like so:
    Code (Java):

    Vector vec = new Vector(x, y, z)
    How would I make it so all these values are random between a 0 - 20?
    #13 Wilsoon, Feb 9, 2020
    Last edited: Feb 9, 2020
  14. Random#nextInt
    Note that this is not a static method.
  15. Playermoveevent to check when they move, bukkitrunnable to add block back after time
  16. But this will mean I have to store all the blocks under the player, is there any way around this?
  17. Thanks! I'll try this out.
  18. it's only bad if you have a long block replace duration or have lots of players online.

    you don't need to store blocks either, just integers of the block's location and the world name.
    don't store blocks otherwise you are saving other data which you don't need.
  19. But I would have to replace the block back with the block material though...
    I don't seem to know how I could make my down to the void when every player may be on a different Y level.

    (It's a private server, usually a maximum of 10 people only, I think block replace duration would be the problem.)