I want to create a meteor

Discussion in 'Plugin Development' started by Huffmanbran, Oct 17, 2014.

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

    Huffmanbran

    I've researched all over block manipulation but they don't get me the results I'm looking for. Could someone please elaborate to me how I could build a fairly decent sized METEOR that will fit into space accordingly? Thanks!
     
  2. Offline

    Skionz

    What? A comet as in a bunch of falling blocks aligned into a sphere or what? Please elaborate if you want to use falling blocks you should look into vectors and velocity.
     
  3. Offline

    Huffmanbran

    Sorry about that, don't know what I was thinking. I meant a meteor!
     
  4. Offline

    fireblast709

    Do you have a visual representation of what your meteor should look like? (like an image, a drawing, etc)
     
  5. Offline

    Huffmanbran

    As simple as this
    [​IMG]
    I want to add some diamondore and gold ore as well.
     
  6. Offline

    _Filip

    What code do you have so far?
     
  7. Offline

    Huffmanbran

    The building of the meteor was my first section of the code to complete, so really I only have the scheduler where the meteor will be spawned and despawned accordingly.

    Code:java
    1. public class MeteorCore extends JavaPlugin{
    2. protected static int WAIT_TIME = 3600;
    3. protected static int DURATION = 1800;
    4.  
    5. public void onEnable() {
    6. BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
    7. scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
    8. @Override
    9. public void run() {
    10.  
    11. //build meteor here
    12.  
    13. }
    14. }, WAIT_TIME*5, DURATION*5);
    15. }
    16.  
    17. public void onDisable() {
    18.  
    19. }
    20.  
    21. }
    22.  



    EDIT: Not a comet! Meteor! Sorry.
     
  8. Offline

    _Filip

    First of all, a comet and a meteor are completely different.
    Second, please TRY to "build" the meteor first, then we can offer help.
     
  9. Offline

    Huffmanbran

    Sorry, I keep putting comet and I don't mean too :p
    "Building" the meteor is the problem I'm having. Could you provide some sort of source for me to find out how to build this? :D
     
  10. Offline

    _Filip

    One way would be to use falling blocks.
     
  11. Offline

    Huffmanbran

    I want the meteor to remain stationary.
     
  12. Offline

    xepisolonxx

  13. Offline

    TheCwispyOne

    Huffmanbran getWorld().setBlock(); if I'm not mistaken. Just get the center and then get the blocks around it and set whichever ones you want to coal.
     
  14. Offline

    Huffmanbran

    Thanks guys, but that's not quite what I'm looking for. I want the plugin to spawn a stationary meteor that is made of all sorts of unrefined oreblocks randomly. Essentially, I need to know how to build the meteor I just don't follow anyone else's logic on how it's done.. :/
     
  15. Offline

    teej107

    Huffmanbran I doubt there is a Bukkit method to get all of the ore blocks. One way of doing it is......

    1. Make an array of your desired materials (the ores in your case)
    2. If you want a cuboid, make 3 nested for-loops looping through the coordinates (where you want to spawn it) and set them to a material grabbed randomly out of your array.
    D. ???
    #. Profit!!!!!!!!!
     
  16. Offline

    Huffmanbran

    Ok I made an array with the materials I want the meteor to have in it
    Code:java
    1. static List<Material> meteorBlocks = new ArrayList<Material>();
    2.  
    3. public void onEnable() {
    4. meteorBlocks.add(Material.DIAMOND_ORE);
    5. meteorBlocks.add(Material.GOLD_ORE);
    6. meteorBlocks.add(Material.COAL_ORE);
    7. meteorBlocks.add(Material.STONE);
    8. meteorBlocks.add(Material.DIRT);
    9. meteorBlocks.add(Material.GLOWSTONE);
    10. meteorBlocks.add(Material.WOOL);


    I made 3 nested for loops to create a sphere
    Code:java
    1. public static List<Location> generateSphere(Location centerBlock,
    2. int radius, boolean hollow) {
    3. List<Location> centerBlocks = new ArrayList<Location>();
    4.  
    5. radius = 15;
    6.  
    7. int bX = centerBlock.getBlockX();
    8. int bY = centerBlock.getBlockY();
    9. int bZ = centerBlock.getBlockZ();
    10. for (int x = bX - radius; x <= bX + radius; x++) {
    11. for (int y = bY - radius; y <= bY + radius; y++) {
    12. for (int z = bZ - radius; z <= bZ + radius; z++) {
    13.  
    14. double distance = ((bX - x) * (bX - x))
    15. + ((bZ - z) * (bZ - z) + ((bY - y)) * (bY - y));
    16.  
    17. if (distance < radius * radius
    18. && !(hollow && distance < ((radius - 1) * (radius - 1)))) {
    19.  
    20.  
    21. for (Location l : generateSphere(centerBlock, radius,
    22. hollow)) {
    23. Material type = meteorBlocks
    24. .get((int) (Math.random() * meteorBlocks.size()));
    25. l.getBlock().setType(type);
    26.  
    27. centerBlocks.add(l);
    28.  
    29. }
    30. }
    31.  
    32. }
    33.  
    34. }
    35.  
    36. }
    37. return centerBlocks;
    38. }


    My question is how do I make the actual sphere spawn in game at random coordinates?
     
  17. Offline

    Skionz

    @Huggmanbran Use the Random class
     
  18. Offline

    Huffmanbran

    Well I have tried. I just want to actually see if this meteor will spawn. I get lots of nullpointers because I don't know what to set the location to in the condition of generateSphere();

    heres the code:
    Code:java
    1. public void onEnable() {
    2. meteorBlocks.add(Material.DIAMOND_ORE);
    3. meteorBlocks.add(Material.GOLD_ORE);
    4. meteorBlocks.add(Material.COAL_ORE);
    5. meteorBlocks.add(Material.STONE);
    6. meteorBlocks.add(Material.DIRT);
    7. meteorBlocks.add(Material.GLOWSTONE);
    8. meteorBlocks.add(Material.WOOL);
    9.  
    10.  
    11.  
    12. BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
    13. scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
    14. @Override
    15. public void run() {
    16. generateSphere(null, 25, isEnabled());//what do I set null to?
    17. }
    18. }, WAIT_TIME * 5, DURATION * 5);
    19. }
     
  19. Offline

    d3v1n302418

    Huffmanbran the center block... it literally says it in your generateSphere method. Did you happen to copy and paste/watch a bcbroz video? I remeber that being on one :p
     
  20. Offline

    SleepyDog

    Use worldedit,
    Take a players loaction, add 60 to the players up coord, then make it set another coord diagonally 2 blocks, then make worldedit do '/set 60%coalore,40%air' this will make a random meteor, then enable the gravity tag on the items?
     
Thread Status:
Not open for further replies.

Share This Page