Solved Spawning a Custom Mob Crashing Client

Discussion in 'Plugin Development' started by Axe2760, Aug 16, 2013.

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

    Axe2760

    So I was trying to follow Jacek 's tutorial on creating custom mobs, and i wanted to test spawning the mob.

    Mob Class:
    Code:
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.craftbukkit.v1_6_R2.CraftWorld;
    import org.bukkit.entity.FallingSand;
    import org.bukkit.util.Vector;
     
    import net.minecraft.server.v1_6_R2.EntityCreeper;
    import net.minecraft.server.v1_6_R2.World;
     
    public class BlitzCreeper extends EntityCreeper {
    private int bp;
        private int fuseTicks;
        private int maxFuseTicks = 15;
        private int explosionRadius = 8;
    public BlitzCreeper(World world) {
    super(world);
    }
     
    public void l_(){
    if (this.isAlive()) {
                this.bp = this.fuseTicks;
                int i = this.bV();
     
                if (i > 0 && this.fuseTicks == 0) {
                    this.makeSound("random.fuse", 1.0F, 0.5F);
                }
     
                this.fuseTicks += i;
                if (this.fuseTicks < 0) {
                    this.fuseTicks = 0;
                }
     
                if (this.fuseTicks >= this.maxFuseTicks) {
                    this.fuseTicks = this.maxFuseTicks;
                    if (!this.world.isStatic) {
                        boolean flag = this.world.getGameRules().getBoolean("mobGriefing");
     
                        if (this.isPowered()) {
                            this.world.explode(this, this.locX, this.locY, this.locZ, (float) (this.explosionRadius * 2), flag);
                        } else {
                            this.world.explode(this, this.locX, this.locY, this.locZ, (float) this.explosionRadius, flag);
                        }
                        CraftWorld w = (CraftWorld) this.getBukkitEntity().getWorld();
                        for (int num = 0; i <= 350; i += 10){
                      FallingSand s = (FallingSand) w.spawnFallingBlock(new Location(w,this.locX,this.locY,this.locZ, (float)num, 20), Material.OBSIDIAN.getId(), (Byte) null);
                      Vector v = s.getLocation().getDirection();
                      v.multiply(5);
                      s.setVelocity(v);
                        }
                        this.die();
                    }
                }
            }
     
            super.l_();
    }
    }
    
    So i made a simple command:
    Code:
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.craftbukkit.v1_6_R2.CraftWorld;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class MobBlitz extends JavaPlugin{
    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    if (cmd.getName().equalsIgnoreCase("bmd") && sender instanceof Player){
    CraftWorld cw = (CraftWorld)((Player)sender).getWorld();
    BlitzCreeper bc = new BlitzCreeper(cw.getHandle());
    bc.setPosition(((Player)sender).getLocation().getX(), ((Player)sender).getLocation().getY(), ((Player)sender).getLocation().getZ());
    cw.getHandle().addEntity(bc);
    sender.sendMessage("spawned blitz creeper");
    return true;
    }
    return false;
    }
     
    }
    
    When I try to do /bmd, it crashes my client. There are no errors or anything. What did i do wrong? :p
    Thanks!
     
  2. Offline

    Kazzababe

    You clearly didn't follow his tutorial completely. You left out an entire method that is actually required in order for your custom entity to be registered.

    Just go look at the tutorial again.
     
  3. Offline

    Axe2760

    Kazzababe Derp, i did! Thank you! (Derp moment ;L)
     
Thread Status:
Not open for further replies.

Share This Page