Solved Making A Firework Wave That Does Damge

Discussion in 'Plugin Development' started by superjesse07, Nov 10, 2013.

Thread Status:
Not open for further replies.
  1. I want to know how to make a wave of firework like in the ferryempire plugin i thing ferrybig can help me out but i don't know if he wants to otherwise someone help me
     
  2. Offline

    RealDope

    What have you tried?
     
  3. Offline

    chasechocolate

    What do you mean by "a wave of firework"?
     
  4. Use a Block Iterator, and for every 3 blocks, play a firework on that location, and some other effects if you want
     
  5. If you want to make the fireworks themselves deal damage, I suspect that some sort of event is fired when fireworks detonate. I'll give that a look once I have some free time.
     
  6. superjesse07
    Code:
    final BlockIterator blocks = new BlockIterator(player);
    new BukkitRunnable()
    {int tick;public void run(){
    tick++; if(tick > 100 || !blocks.hasNext()) cancel();
    Block next = blocks.next();
    Location location = next.getLocation();
    // Play firework effect at location, there are codes on bukkit forums to do that
    }}.startTaskTimer(plugin,1,1);
    I may not be 100% correct about startTaskTimer because I typed it from my head
     
  7. Offline

    ArthurHoeke

    ferrybig Could you make a tutorial on your channel about making wands and firework? :D
     
  8. ferrybig i get a error in the console this is my code
    Code:java
    1. final BlockIterator blocks = new BlockIterator(p);
    2. new BukkitRunnable()
    3. {int tick;public void run(){
    4. tick++; if(tick > 100 || !blocks.hasNext()) cancel();
    5. Block next = blocks.next();
    6. Location location = next.getLocation();
    7. Firework fw = (Firework) location.getWorld().spawn(location, Firework.class);
    8. FireworkEffect effect = FireworkEffect.builder().trail(true).flicker(true).withColor(Color.BLACK).withFade(Color.RED).with(Type.BURST).build();
    9. FireworkMeta fwm = fw.getFireworkMeta();
    10. fwm.clearEffects();
    11. fwm.addEffect(effect);
    12. Field f;
    13. try {
    14. f = fwm.getClass().getDeclaredField("power");
    15. f.setAccessible(true);
    16. f.set(fwm, -2);
    17. } catch (NoSuchFieldException e) {
    18. // TODO Auto-generated catch block
    19. e.printStackTrace();
    20. } catch (SecurityException e) {
    21. // TODO Auto-generated catch block
    22. e.printStackTrace();
    23. // TODO Auto-generated catch block
    24. e.printStackTrace();
    25. } catch (IllegalAccessException e) {
    26. // TODO Auto-generated catch block
    27. e.printStackTrace();
    28. }
    29.  
    30.  
    31. fw.setFireworkMeta(fwm);
    32. for(LivingEntity en : fw.getWorld().getEntitiesByClass(LivingEntity.class)){
    33. if(en.getLocation().distance(fw.getLocation()) <= 3)//or your distance{
    34. en.damage(5);
    35. }
    36. }}.runTaskTimer(plugin,1,1);


    ArthurHoeke making wands is more than only a little bit of coding it took me a while to make one

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

    sgavster

    Use this for fireworks:
    PHP:
    Firework f = (Fireworkplayer.getWorld().spawn(player.getLocation(), Firework.class);
             
                
    FireworkMeta fm f.getFireworkMeta();
                
    fm.addEffect(FireworkEffect.builder().flicker(false).trail(false).with(Type.CREEPER).withColor(Color.ORANGE).withFade(Color.RED).build());
                
    fm.setPower(3);
                
    f.setFireworkMeta(fm);
     
  10. if you read the hole tread you will see that i already have fireworks
     
  11. Offline

    sgavster

    superjesse07 *facepalm* I should read more, I skimmed over, I thought what you were using was different, sorry xD
     
  12. Offline

    maxben34

    Please bump once daily only. It looks like your problem or question was answered already by chasechocolate .
     
  13. ferrybig can you help i get a error this is my code
    Code:
                final BlockIterator blocks = new BlockIterator(p);
                new BukkitRunnable()
                {int tick;public void run(){
                tick++; if(tick > 100 || !blocks.hasNext()) cancel();
                Block next = blocks.next();
                Location location = next.getLocation();
                Firework fw = (Firework) location.getWorld().spawn(location, Firework.class);
                FireworkEffect effect = FireworkEffect.builder().trail(true).flicker(true).withColor(Color.BLACK).withFade(Color.RED).with(Type.BURST).build();
                FireworkMeta fwm = fw.getFireworkMeta();
                fwm.clearEffects();
                fwm.addEffect(effect);
                Field f;
                try {
                        f = fwm.getClass().getDeclaredField("power");
                        f.setAccessible(true);
                        f.set(fwm, -2);
                } catch (NoSuchFieldException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (SecurityException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (IllegalArgumentException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (IllegalAccessException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
     
     
                fw.setFireworkMeta(fwm);
                for(LivingEntity en : fw.getWorld().getEntitiesByClass(LivingEntity.class)){
                    if(en.getLocation().distance(fw.getLocation()) <= 3)//or your distance{
                    en.damage(5);
                }
                }}.runTaskTimer(plugin,1,1);
    ferrybig i got you on skype

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  14. what is the error you get?
     
  15. ferrybig this is the error in the console
    11.11 20:41:51 [Server] INFO at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    11.11 20:41:51 [Server] INFO at me.jesse.deathmagic.Main.onPlayerInteract1(Main.java:210)
    11.11 20:41:51 [Server] INFO at org.bukkit.scheduler.BukkitRunnable.runTaskTimer(BukkitRunnable.java:98)
    11.11 20:41:51 [Server] INFO at org.bukkit.craftbukkit.v1_6_R3.scheduler.CraftScheduler.runTaskTimer(CraftScheduler.java:120)
    11.11 20:41:51 [Server] INFO at org.bukkit.craftbukkit.v1_6_R3.scheduler.CraftScheduler.validate(CraftScheduler.java:391)
    11.11 20:41:51 [Server] INFO at org.apache.commons.lang.Validate.notNull(Validate.java:192)
    11.11 20:41:51 [Server] INFO Caused by: java.lang.IllegalArgumentException: Plugin cannot be null
    11.11 20:41:51 [Server] INFO at net.minecraft.server.v1_6_R3.ThreadServerApplication.run(SourceFile:583)
    11.11 20:41:51 [Server] INFO at net.minecraft.server.v1_6_R3.MinecraftServer.run(MinecraftServer.java:415)
    11.11 20:41:51 [Server] INFO at net.minecraft.server.v1_6_R3.MinecraftServer.s(MinecraftServer.java:483)
    11.11 20:41:51 [Server] INFO at net.minecraft.server.v1_6_R3.DedicatedServer.t(DedicatedServer.java:240)
    11.11 20:41:51 [Server] INFO at net.minecraft.server.v1_6_R3.MinecraftServer.t(MinecraftServer.java:594)
    11.11 20:41:51 [Server] INFO at org.spigotmc.netty.NettyServerConnection.b(NettyServerConnection.java:132)
    11.11 20:41:51 [Server] INFO at net.minecraft.server.v1_6_R3.ServerConnection.b(SourceFile:37)
    11.11 20:41:51 [Server] INFO at net.minecraft.server.v1_6_R3.PlayerConnection.e(PlayerConnection.java:116)
    11.11 20:41:51 [Server] INFO at org.spigotmc.netty.NettyNetworkManager.b(NettyNetworkManager.java:230)
    11.11 20:41:51 [Server] INFO at net.minecraft.server.v1_6_R3.Packet18ArmAnimation.handle(SourceFile:41)
    11.11 20:41:51 [Server] INFO at net.minecraft.server.v1_6_R3.PlayerConnection.a(PlayerConnection.java:1019)
    11.11 20:41:51 [Server] INFO at org.bukkit.craftbukkit.v1_6_R3.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:177)
    11.11 20:41:51 [Server] INFO at org.bukkit.craftbukkit.v1_6_R3.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:207)
    11.11 20:41:51 [Server] INFO at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:463)
    11.11 20:41:51 [Server] INFO at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:478)
    11.11 20:41:51 [Server] INFO at org.bukkit.plugin.TimedRegisteredListener.callEvent(TimedRegisteredListener.java:30)
    11.11 20:41:51 [Server] INFO at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
    11.11 20:41:51 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:427)
    11.11 20:41:51 [Server] INFO org.bukkit.event.EventException
    11.11 20:41:51 [Server] SEVERE Could not pass event PlayerInteractEvent to DarkMagic v1.0

    i got you on skype

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

    xTrollxDudex

Thread Status:
Not open for further replies.

Share This Page