Turning fallenBlock into Primed TNT

Discussion in 'Plugin Development' started by NDUGAR, May 10, 2014.

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

    NDUGAR

    So I've been at this for hours, trying to create a meteor plugin where random meteors fall from the sky, these are just fallingBlocks with the particle effect of explosion although I cannot get this to work... I am using DarkBladee12's particle effect class. And I can't see why this isn't working...
    Only my main is coming up with errors and I think the entire plugin wouldn't work... Any help please!

    My main:

    Code:java
    1. package me.Schnel.BetterExplosions;
    2.  
    3. import java.util.Random;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.Location;
    7. import org.bukkit.Material;
    8. import org.bukkit.World;
    9. import org.bukkit.block.Block;
    10. import org.bukkit.entity.FallingBlock;
    11. import org.bukkit.entity.Player;
    12. import org.bukkit.event.Event;
    13. import org.bukkit.event.EventHandler;
    14. import org.bukkit.event.Listener;
    15. import org.bukkit.event.entity.EntityExplodeEvent;
    16. import org.bukkit.plugin.java.JavaPlugin;
    17. import org.bukkit.scheduler.BukkitScheduler;
    18. import org.bukkit.util.Vector;
    19.  
    20. public class main extends JavaPlugin implements Listener{
    21.  
    22.  
    23. public void onEnable(){
    24. getServer().getPluginManager().registerEvents(this, this);
    25. getLogger().info("Better Explosions Enabled");
    26. getLogger().severe("Uh oh! The plugin is DEAD!!! (or broken)");
    27. getConfig().options().copyDefaults(true);
    28. saveConfig();
    29. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    30. }
    31.  
    32. public void onDisable(){
    33. getLogger().info("Better Explosions Disabled");
    34. getLogger().severe("Uh oh! The plugin is DEAD!!! (or broken)");
    35. }
    36.  
    37. @EventHandler
    38. public void onEntityExplode(final EntityExplodeEvent event) {
    39. for(Block b : event.blockList()){
    40. /*Generates random location to spray blocks*/
    41. float x = (float) -2 + (float) (Math.random() * ((2- -2) +1));
    42. float y = (float) -3 + (float) (Math.random() * ((3- -3) +1));
    43. float z = (float) -2 + (float) (Math.random() * ((2- -2) +1));
    44.  
    45. @SuppressWarnings("deprecation")/*Creates the blocks flying module*/
    46. FallingBlock fallingBlock = b.getWorld().spawnFallingBlock(
    47. b.getLocation(), b.getType(), b.getData());
    48. fallingBlock.setDropItem(false);
    49. fallingBlock.setVelocity(new Vector(x, y, z));
    50.  
    51. b.setType(Material.AIR);
    52. }
    53.  
    54.  
    55. Random rand = new Random();
    56.  
    57. BukkitScheduler scheduler = Bukkit.getServer().getScheduler();/*Schedules random event*/
    58. scheduler.scheduleSyncDelayedTask(this, new Runnable() {
    59. @Override
    60. public void run() {
    61. int random = new Random().nextInt(Bukkit.getOnlinePlayers().length);
    62. Player player = Bukkit.getOnlinePlayers()[random];
    63. Location location = player.getLocation();
    64. World world = player.getWorld();
    65. Location center = location;
    66. Random rand = new Random();
    67. double angle = rand.nextDouble()*360; //Generate a random angle
    68. double x = center.getX() + (rand.nextDouble()*100*Math.cos(Math.toRadians(angle)));
    69. double z = center.getZ() + (rand.nextDouble()*100*Math.sin(Math.toRadians(angle)));
    70. double y = center.getY() + 700; /*Finds new location*/
    71. Location newloc = new Location(world, x, y, z);
    72. FallingBlock TNT = location.getWorld().spawnFallingBlock(newloc, Material.TNT, (byte)0); //creates the falling block
    73. TNT.setVelocity(new Vector());
    74. ParticleEffect.EXPLODE.display;//display cannot be resolved or is not a field
    75. if (event.getEntity() instanceof FallingBlock); {
    76. FallingBlock.setType(Material.AIR);//The method setType(Material) is undefined for the type FallingBlock
    77. }
    78. }
    79. }, (long) rand.nextInt(567));
    80.  
    81. }
    82. }
    83.  


    Any help please?
     
  2. Offline

    Bobit

    What part does work?
    Insert System.out.println()'s along code to help you find out.
     
  3. Offline

    NDUGAR


    Well the tnt exploding works- the blocks scattering, also I think the random location generator works, the falling block should work. But in my IDE it says 2 errors,

    1. Multiple markers at this line
    - The method display(Location, float, float, float, float, int) in the
    type ParticleEffect is not applicable for the arguments ()
    - Occurrence of 'display'

    2. The method setType(Material) is undefined for the type
    FallingBlock

    Scratch all this, how would I check if the FallingBlock is over air?

    Bump please?

    Anyone, please help?

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

    Bobit

    ParticleEffect.EXPLOSION.display needs parameters. I would guess you would want to put the location as where you want it to happen, and the floats and ints as 1, but idk.

    I would guess to get the location, you would do TNT.getLocation(). O_0
     
Thread Status:
Not open for further replies.

Share This Page