Falling blocks, help!

Discussion in 'Plugin Development' started by quinster08, Apr 19, 2014.

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

    quinster08

    Hey i followed a tutorial of TheBCbroz and edited a code a bit.. it should shoot falling blocks on a explosion. But it doesn't.

    here is my code:
    Code:java
    1. package me.quinster;
    2.  
    3. import java.util.ArrayList;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.Effect;
    7. import org.bukkit.Material;
    8. import org.bukkit.Sound;
    9. import org.bukkit.block.Block;
    10. import org.bukkit.entity.FallingBlock;
    11. import org.bukkit.event.EventHandler;
    12. import org.bukkit.event.Listener;
    13. import org.bukkit.event.entity.EntityChangeBlockEvent;
    14. import org.bukkit.event.entity.EntityExplodeEvent;
    15. import org.bukkit.plugin.java.JavaPlugin;
    16. import org.bukkit.util.Vector;
    17.  
    18. public class main extends JavaPlugin
    19. implements Listener
    20. {
    21.  
    22. public static void Craz(String[] args) {
    23. System.out.println((float) -5 + (float) (Math.random() *((5 - -5) +1)));
    24. }
    25.  
    26. public void onEnable()
    27. {
    28. getServer().getPluginManager().registerEvents(this, this);
    29. }
    30.  
    31. ArrayList<FallingBlock> falledBlocks = new ArrayList<FallingBlock>();
    32.  
    33. @EventHandler
    34. public void onEntityExplode(EntityExplodeEvent e){
    35. for (Block b : e.blockList()){
    36. float x = (float) -2 + (float) (Math.random() * ((2 - -3) + 1));
    37. float y = (float) -3 + (float) (Math.random() * ((3 - -2) + 1));
    38. float z = (float) -2 + (float) (Math.random() * ((2 - -3) + 1));
    39.  
    40. @SuppressWarnings("deprecation")
    41. FallingBlock fb = b.getWorld().spawnFallingBlock(b.getLocation(), b.getType(), b.getData());
    42. fb.setDropItem(false);
    43. fb.setVelocity(new Vector(x, y, z));
    44. falledBlocks.add(fb);
    45. Particle.EXPLOSION.spawnParticle(fb.getWorld(), fb.getLocation(), 0.3F, 0.5F, 0.3F, 0.3F, 3);
    46. Particle.CLOUD.spawnParticle(fb.getWorld(), fb.getLocation(), 0.3F, 0.5F, 0.3F, 0.3F, 100);
    47. Particle.FLAME.spawnParticle(fb.getWorld(), fb.getLocation(), 0.3F, 0.5F, 0.3F, 0.3F, 500);
    48. Particle.PARTICLE_SMOKE.spawnParticle(fb.getWorld(), fb.getLocation(), 0.3F, 0.5F, 0.3F, 0.3F, 200);
    49. Particle.FIREWORKS_SPARK.spawnParticle(fb.getWorld(), fb.getLocation(), 0.3F, 0.5F, 0.3F, 0.3F, 200);
    50. Particle.PARTICLE_SMOKE.spawnParticle(fb.getWorld(), fb.getLocation(), 0.3F, 0.5F, 0.3F, 0.3F, 200);
    51. fb.getWorld().playSound(fb.getLocation(), Sound.EXPLODE, 20.0F, 1.0F);
    52. }
    53. e.setCancelled(true);
    54. }
    55.  
    56. @EventHandler
    57. public void onBlockChange(final EntityChangeBlockEvent e){
    58. e.setCancelled(true);
    59. if (e.getEntity() instanceof FallingBlock){
    60. FallingBlock fb = (FallingBlock) e.getEntity();
    61. fb.getWorld().playEffect(fb.getLocation(), Effect.STEP_SOUND, fb.getMaterial());
    62. fb.remove();
    63. }
    64. }
    65. }
    66.  
     
  2. Offline

    TryB4

    quinster08
    replace e.setCancelled(true); with e.blockList().clear();
     
  3. Offline

    quinster08

    TryB4 thx for reply but still doesn't work.

    Can someone help me out?

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

    TomFromCollege

    That doesn't give us any indication on what's happening, is the rest of the code working?
    Do the particles work?
    Have you tested the location of the block?
    Is the velocity you've given working correctly?
    Have you attempted to spawn it above the block?
     
  5. Offline

    quinster08

    TomFromCollege It gives no error in console. The particles do not work. I din't test location of block. I have set velocity correctly. No i haven't attempted to spawn it above the block.

    So nobody can help?

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

    Heirteir

  7. Offline

    quinster08

    Heirteir LOL your such a dick. I asked him for help and he said "I have to go to bed in 2 minutes" then he deleted me.
     
  8. Offline

    TomFromCollege

    Well do those things I said... This is a help forum ,we're not going to do the work for you.
     
    Bobit likes this.
Thread Status:
Not open for further replies.

Share This Page