Wither Multi-shot

Discussion in 'Plugin Development' started by Hex_27, Jul 28, 2015.

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

    Hex_27

    I'm trying to make the wither shoot multiple witherskulls at once, here's my current code:
    Code:
        public void onWitherAttack(ProjectileLaunchEvent event){
            if(event.getEntity() instanceof WitherSkull){
                for (int i = 0; i < 3; i++) {
                    WitherSkull e = (WitherSkull) event.getEntity().getWorld().spawnEntity(event.getEntity().getLocation().add(randInt(-1, 1), randInt(-1, 1),randInt(-1, 1)),EntityType.WITHER_SKULL);
                    e.setVelocity(event.getEntity().getVelocity());
                }
            }
    
    public int randInt(int min, int max) {
    
            Random rand = new Random();
    
            int randomNum = rand.nextInt((max - min) + 1) + min;
    
            return randomNum;
        }
        }
        

    I keep getting this error:
    Code:
    at net.minecraft.server.v1_8_R2.World.addEntity(World.java:1020) ~[spigot-1.8.3.jar:git-Spigot-2ec6f06-7722428]
        at org.bukkit.craftbukkit.v1_8_R2.CraftWorld.spawn(CraftWorld.java:1121) ~[spigot-1.8.3.jar:git-Spigot-2ec6f06-7722428]
        at org.bukkit.craftbukkit.v1_8_R2.CraftWorld.spawn(CraftWorld.java:861) ~[spigot-1.8.3.jar:git-Spigot-2ec6f06-7722428]
        at org.bukkit.craftbukkit.v1_8_R2.CraftWorld.spawnEntity(CraftWorld.java:377) ~[spigot-1.8.3.jar:git-Spigot-2ec6f06-7722428]
        at me.leothepro555.campaign.Specter.onWitherAttack(Specter.java:135) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor469.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_11]
        at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_11]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:301) ~[spigot-1.8.3.jar:git-Spigot-2ec6f06-7722428]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.8.3.jar:git-Spigot-2ec6f06-7722428]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) ~[spigot-1.8.3.jar:git-Spigot-2ec6f06-7722428]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) ~[spigot-1.8.3.jar:git-Spigot-2ec6f06-7722428]
    Specter.java line 135 is
    WitherSkull e = (WitherSkull) event.getEntity().getWorld().spawnEntity(event.getEntity().getLocation().add(randInt(-1, 1), randInt(-1, 1),randInt(-1, 1)),EntityType.WITHER_SKULL);
     
  2. @Hex_27
    Try using Wither#launchProjectile(WitherSkull.class)
     
  3. Offline

    Hex_27

    @megamichiel Same error

    @megamichiel Okay, i tried other projectiles, and they all work except witherskull

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 11, 2016
  4. @Hex_27
    What is the full error
     
  5. Offline

    Hex_27

    @megamichiel that is the full error. Just multipied by 100 + times, over and over again then the server crashes.
     
  6. @Hex_27
    Code:
    Caused by: java.lang.SomeWeirdException
     
  7. Offline

    _Error

  8. Offline

    Hex_27

    @megamichiel I used the search function on the log where this happened for the word (or part of word) Exception, but found none that was applicable.
     
  9. @_Error
    But it's not something 1.8-only, therefor he's fine to ask here.
     
  10. Offline

    _Error

    Doesn't matter, Even my plugin.yml question was moved to bukkit alternates.
     
  11. Offline

    Hex_27

    Hey, back to topic here..?
     
  12. Offline

    Hex_27

  13. Offline

    Hex_27

Thread Status:
Not open for further replies.

Share This Page