Fire around player.

Discussion in 'Plugin Development' started by DusRonald, Sep 14, 2014.

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

    DusRonald

    Hey Bukkit,

    I was wondering how to spread fire around a player on ground?

    Here a example of my idea with picture: (It can with different radius, You know.)
    [​IMG]

    Greeting,
    Ronald.
     
  2. Offline

    Skionz

    for loops
     
  3. Offline

    DusRonald

    Really informative reaction...

    Instructions or some code is a better reaction..
     
    Skionz likes this.
  4. Offline

    Skionz

    Sorry haha so what exactly do you want to do? I'm assuming something like use a command and a square of fire is created around you?
     
  5. Offline

    DusRonald

    I want to have: If a player (For example myself), use /fire or any trigger maybe event, then spawn a square or circle of fire around the player (on the blocks around him), i don't know to code that. but i know i must using for loops.
     
  6. Offline

    4thegame3

    get the aerea and start replacing all air blocks in fire ones. Maybe ill post some code later
     
  7. Offline

    Skionz

    DusRonald I can't seem to think of a clean way to do this, to generate a square you would just increment x and z from a location but that would create a square where the player is at one of the corners. The only way I can think of to do it is have 4 small squares incrementing both x and z, incrementing x while negatively incrementing z, negative incrementing both, and negative incrementing x while incrementing z. Sorry if that is confusing but heres a link I found too http://pastebin.com/AspGRgAD
     
  8. Offline

    DusRonald

    Replace the air blocks is easy, but how get the area?
     
  9. Offline

    4thegame3

    you have to think mate, think to logic and your sexy math prof
     
  10. Offline

    DusRonald

    I don't understand the logic of Java...
     
  11. Offline

    EnchantedMiners

  12. Offline

    4thegame3

    Code:java
    1. mPoint = p.getLocation().add((double)radius -1,(double)radius -1,0); // You find the first corner
     
  13. Offline

    DusRonald

    Marked as useless reaction.
     
  14. Offline

    4thegame3

  15. Offline

    DusRonald

    And the second corner?

    What..? I don't understand that..

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  16. Offline

    4thegame3

    .subtract(same thing) you find the opposite corner
     
  17. Offline

    DusRonald

    4thegame3 Can you give me a full example code?

    Bytheway: Thanks for help.
     
  18. Offline

    EnchantedMiners

    DusRonald maybe something like
    Location safeblockloc = p.getlocation().substract(0,1,0);
    Block block = safeblockloc.getblock();
    block.settype(material.grass);
    safeblockloc.add(1,0,1);
    for(int i = 0; i <= 3; i++){
    Block blocksonfire = safeblockloc.add(1,0,1).getblock();
    blocksonfire.setType(material.netherrack);
    }
    //the fire on top you figure out i wrote this on a tablet so too hard to write code from a tablet or phone
     
  19. Offline

    rrhett

    For a circle, you'd want something like:

    Code:java
    1.  
    2. Location playerLocation = p.getLocation();
    3. int centerX = playerLocation.getBlockX();
    4. int centerZ = playerLocation.getBlockZ();
    5. int radius = 5; // or whatever you want
    6. int rSquared = radius * radius;
    7. for (int x = centerX - radius; x <= centerX + radius; ++x) {
    8. int xSquared = (x - centerX) * (x - centerX);
    9. for (int deltaZ = 0; xSquared + deltaZ * deltaZ <= rSquared; deltaZ++) {
    10. // Do something with these coordinates:
    11. // (x, playerLocation.getBlockY(), centerZ + deltaZ)
    12. // (x, playerLocation.getBlockY(), centerZ - deltaZ)
    13. }
    14. }
    15.  
     
    DusRonald likes this.
  20. Offline

    4thegame3

    im working on a code that calculates every point of a cyrcle perimeter, but it will take time idk if ill ever end it.
     
  21. Offline

    DusRonald

    No, it's not.

    Okay.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  22. Offline

    EnchantedMiners

  23. Offline

    DusRonald

    It's not really hard to type on a mobile device.
     
  24. Offline

    EnchantedMiners

    DusRonald ok so have you tried the code i put or you planing on changing the topic to "is it easy or hard to type on a mobile device" ... not a mean comment just saying xD
     
  25. Offline

    DusRonald

    See this topic: Click here.
    Link from above: http://forums.bukkit.org/threads/poll-write-code-on-mobile-device-is-hard.311894/

    Have anyone Craftbukkit.jar?

    You do not use:
    Code:java
    1. int centerZ = playerLocation.getBlockZ();


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  26. Offline

    4thegame3

    i have found this
    Code:java
    1. public static Point PointOnCircle(float radius, float angleInDegrees, PointF origin)
    2. {
    3. // Convert from degrees to radians via multiplication by PI/180
    4. float x = (float)(radius * Math.Cos(angleInDegrees * Math.PI / 180F)) + origin.X;
    5. float y = (float)(radius * Math.Sin(angleInDegrees * Math.PI / 180F)) + origin.Y;
    6.  
    7. return new Point(x, y);
    8. }
     
  27. Offline

    rrhett


    Sure I do. In the comment where I say use these coordinates. I add and subtract deltaZ to and from centerZ to get the coordinates.

    [edits: not so much syntax, looks bad]
     
  28. Offline

    DusRonald

    Can you give me full code of that? Include set the block.
     
  29. Offline

    mythbusterma

    DusRonald

    Figure it out for yourself, spoonfeeding is not desirable. The JavaDocs for Bukkit are easily available, and many threads have been made on the subject.
     
    AronTheGamer likes this.
  30. Offline

    DusRonald

    I'm lazy XD
    Tomorrow i figured out.
     
Thread Status:
Not open for further replies.

Share This Page