public void killAll(Vector3f pos) {
    List ents =
        _world.getEntitiesWithinAABB(
            Entity.class,
            AxisAlignedBB.getBoundingBox(
                pos.getX() - 100,
                pos.getY() - 100,
                pos.getZ() - 100,
                pos.getX() + 100,
                pos.getY() + 100,
                pos.getZ() + 100));
    for (Object object : ents) {
      if (object instanceof EntityItem) {
        _world.removeEntity(((EntityItem) object));
      }
      if (object instanceof EntityXPOrb) {
        _world.removeEntity(((EntityXPOrb) object));
      }

      if (object instanceof EntityTNTPrimed) {
        _world.removeEntity(((EntityTNTPrimed) object));
      }

      if (object instanceof EntityMob) {
        _world.removeEntity(((EntityMob) object));
      }

      if (object instanceof EntityArrow) {
        _world.removeEntity(((EntityArrow) object));
      }
    }
  }
 public void activate(Vector3f pos) {
   if (_world.blockExists((int) pos.getX(), (int) pos.getY(), (int) pos.getZ())) {
     Block blk =
         Block.blocksList[_world.getBlockId((int) pos.getX(), (int) pos.getY(), (int) pos.getZ())];
     blk.onBlockActivated(
         _world, (int) pos.getX(), (int) pos.getY(), (int) pos.getZ(), _player, 0, 0, 0, 0);
   }
 }
 // Bugged right now
 public void dropBlockEnt(Vector3f loc) {
   if (_world.getBlockId((int) loc.getX(), (int) loc.getY(), (int) loc.getZ()) != 0) {
     EntityFallingSand s =
         new EntityFallingSand(
             _world,
             loc.getX(),
             loc.getY(),
             loc.getZ(),
             _world.getBlockId((int) loc.getX(), (int) loc.getY(), (int) loc.getZ()),
             _world.getBlockMetadata((int) loc.getX(), (int) loc.getY(), (int) loc.getZ()));
     _world.spawnEntityInWorld(s);
     setBlock(0, loc);
   }
 }
 public void spawnFirecode(Vector3f pos, int flightTime, Object func) {
   final IFunction explodeFunc = JSScriptingManager.getInstance().getFunction(func);
   final EntityPlayer owner = _player;
   ItemStack stk = new ItemStack(Item.firework);
   NBTTagCompound baseComp = new NBTTagCompound();
   baseComp.setCompoundTag("Fireworks", new NBTTagCompound("Fireworks"));
   baseComp.getCompoundTag("Fireworks").setByte("Flight", (byte) flightTime);
   stk.setTagCompound(baseComp);
   EntityFireworkRocket fireWork =
       new EntityFireworkRocket(
           _world, (int) pos.getX(), (int) pos.getY(), (int) pos.getZ(), stk) {
         @Override
         public void onUpdate() {
           super.onUpdate();
           if (this.isDead) {
             if (explodeFunc != null && !worldObj.isRemote) {
               try {
                 JSScriptingManager.getInstance()
                     .runFunction(
                         new ScriptRunnerPlayer(owner),
                         explodeFunc,
                         new Vector3f(this.posX, this.posY, this.posZ));
               } catch (InternalScriptingException e) {
                 owner.sendChatToPlayer("Error in firecode: " + e.getMessage());
               }
             }
           }
         }
       };
   _world.spawnEntityInWorld(fireWork);
 }
 public void spawn(Vector3f pos, String name) throws ScriptErrorException {
   EntityLiving ent = null;
   if (name.equals("creeper")) {
     ent = new EntityCreeper(_world);
   } else if (name.equals("zombie")) {
     ent = new EntityZombie(_world);
   } else if (name.equals("spider")) {
     ent = new EntitySpider(_world);
   } else if (name.equals("skeleton")) {
     ent = new EntitySkeleton(_world);
   } else if (name.equals("pig")) {
     ent = new EntityPig(_world);
   } else if (name.equals("cow")) {
     ent = new EntityCow(_world);
   } else if (name.equals("chicken")) {
     ent = new EntityChicken(_world);
   } else if (name.equals("pigzombie")) {
     ent = new EntityPigZombie(_world);
   } else if (name.equals("enderman")) {
     ent = new EntityEnderman(_world);
   } else if (name.equals("enderdragon")) {
     ent = new EntityDragon(_world);
   } else if (name.equals("bat")) {
     ent = new EntityBat(_world);
   } else if (name.equals("villager")) {
     ent = new EntityVillager(_world);
   } else {
     throw new ScriptErrorException("Ent not found");
   }
   ent.initCreature();
   ent.setPosition(pos.getX(), pos.getY(), pos.getZ());
   _world.spawnEntityInWorld(ent);
 }
 public void dropBlock(Vector3f loc) {
   if (_world.getBlockId((int) loc.getX(), (int) loc.getY(), (int) loc.getZ()) != 0) {
     EntityItem t =
         new EntityItem(
             _world,
             loc.getX(),
             loc.getY(),
             loc.getZ(),
             new ItemStack(
                 _world.getBlockId((int) loc.getX(), (int) loc.getY(), (int) loc.getZ()),
                 1,
                 _world.getBlockMetadata((int) loc.getX(), (int) loc.getY(), (int) loc.getZ())));
     _world.spawnEntityInWorld(t);
     setBlock(0, loc);
   }
 }
 public void explode(int amo, Vector3f loc) throws ScriptErrorException {
   if (amo > 200) {
     throw new ScriptErrorException("Bad Idea");
   }
   if (!this._world.isRemote) {
     this._world.createExplosion(this._player, loc.getX(), loc.getY(), loc.getZ(), amo, true);
   }
 }
 public boolean spawnBigTree(
     Vector3f pos, double heightLimit, double scaleWidth, double leafDensity)
     throws ScriptErrorException {
   if (heightLimit < 4 && scaleWidth < 3 && leafDensity < 3) {
     WorldGenBigTree t = new WorldGenBigTree(true);
     t.setScale(heightLimit, scaleWidth, leafDensity);
     return t.generate(_world, _world.rand, (int) pos.getX(), (int) pos.getY(), (int) pos.getZ());
   } else {
     throw new ScriptErrorException("growBigTree is limited");
   }
 }
 public void killDrops(Vector3f pos, boolean killExp) {
   List ents =
       _world.getEntitiesWithinAABB(
           EntityItem.class,
           AxisAlignedBB.getBoundingBox(
               pos.getX() - 100,
               pos.getY() - 100,
               pos.getZ() - 100,
               pos.getX() + 100,
               pos.getY() + 100,
               pos.getZ() + 100));
   for (Object object : ents) {
     if (object instanceof EntityItem) {
       _world.removeEntity(((EntityItem) object));
     }
     if (killExp && object instanceof EntityXPOrb) {
       _world.removeEntity(((EntityXPOrb) object));
     }
   }
 }
 public void addItemToChest(Vector3f pos, int itemId, int itemCount) throws ScriptErrorException {
   if (_world.getBlockTileEntity((int) pos.getX(), (int) pos.getY(), (int) pos.getZ()) != null
       && _world.getBlockTileEntity((int) pos.getX(), (int) pos.getY(), (int) pos.getZ())
           instanceof TileEntityChest) {
     TileEntityChest chest =
         (TileEntityChest)
             _world.getBlockTileEntity((int) pos.getX(), (int) pos.getY(), (int) pos.getZ());
     for (int i = 0; i < chest.getSizeInventory(); i++) {
       if (chest.getStackInSlot(i) == null) {
         chest.setInventorySlotContents(
             i,
             new ItemStack(
                 itemId, itemCount,
                 0)); // combining stacks will come later, too many edge cases right now
         break;
       }
     }
   } else {
     throw new ScriptErrorException("Block is not a chest");
   }
 }
 /*
  * If you want to do this on something big then do a "slow replace", register a tick handler that calls this method until it returns true, setting a limit of about 5
  */
 public boolean replaceCube(
     int srcType, int targetType, Vector3f v1, Vector3f v2, int limit, boolean hollow)
     throws ScriptErrorException {
   if (limit > 4000) {
     limit = 4000;
   }
   int x1f, x2f, y1f, y2f, z1f, z2f;
   if (v2.getX() < v1.getX()) {
     x1f = (int) v2.getX();
     x2f = (int) v1.getX();
   } else {
     x1f = (int) v1.getX();
     x2f = (int) v2.getX();
   }
   if (v2.getY() < v1.getY()) {
     y1f = (int) v2.getY();
     y2f = (int) v1.getY();
   } else {
     y1f = (int) v1.getY();
     y2f = (int) v2.getY();
   }
   if (v2.getZ() < v1.getZ()) {
     z1f = (int) v2.getZ();
     z2f = (int) v1.getZ();
   } else {
     z1f = (int) v1.getZ();
     z2f = (int) v2.getZ();
   }
   int blocks = 0;
   for (int x = x1f; x < x2f; x++) {
     for (int y = y1f; y < y2f; y++) {
       for (int z = z1f; z < z2f; z++) {
         if (hollow
             && x > x1f
             && x < x2f - 1
             && y > y1f
             && y < y2f - 1
             && z > z1f
             && z < z2f - 1) {
           continue;
         }
         if (_world.getBlockId(x, y, z) == srcType || srcType < 0) {
           if (_world.getBlockId(x, y, z) == targetType) {
             continue;
           }
           this._world.setBlockAndMetadataWithUpdate(x, y, z, targetType, 0, true);
           blocks++;
           if (blocks > limit) {
             return false;
           }
         }
       }
     }
   }
   return true;
 }
 public void spawnTnt(Vector3f pos, int fuse, int size) throws ScriptErrorException {
   final int expSize = size;
   EntityTNTPrimed tnt =
       new EntityTNTPrimed(_world) {
         @Override
         public void onUpdate() {
           super.onUpdate();
           if (isDead) {
             this.worldObj.createExplosion((Entity) null, posX, posY, posZ, expSize, true);
           }
         }
       };
   tnt.fuse = fuse;
   tnt.setPosition(pos.getX(), pos.getY(), pos.getZ());
   _world.spawnEntityInWorld(tnt);
 }
 // happy new years
 public void spawnFirework(Vector3f pos, int color, int type, int flightTime, int explodeCount) {
   Random rand = new Random(_world.rand.nextLong());
   ItemStack stk = new ItemStack(Item.firework);
   NBTTagCompound baseComp = new NBTTagCompound();
   baseComp.setCompoundTag("Fireworks", new NBTTagCompound("Fireworks"));
   baseComp.getCompoundTag("Fireworks").setByte("Flight", (byte) flightTime);
   NBTTagList lst = baseComp.getCompoundTag("Fireworks").getTagList("Explosions");
   for (int i = 0; i < explodeCount; i++) {
     NBTTagCompound explosion = new NBTTagCompound();
     explosion.setByte("Type", (byte) type);
     explosion.setBoolean("Trail", true);
     explosion.setBoolean("Flicker", rand.nextBoolean());
     explosion.setIntArray("Colors", new int[] {color + (rand.nextInt(400) - 200)});
     explosion.setIntArray("FadeColors", new int[] {color + (rand.nextInt(400) - 200)});
     lst.appendTag(explosion);
   }
   baseComp.getCompoundTag("Fireworks").setTag("Explosions", lst);
   stk.setTagCompound(baseComp);
   EntityFireworkRocket fireWork =
       new EntityFireworkRocket(_world, (int) pos.getX(), (int) pos.getY(), (int) pos.getZ(), stk);
   _world.spawnEntityInWorld(fireWork);
 }
 public int getBlock(Vector3f loc) {
   return _world.getBlockId((int) loc.getX(), (int) loc.getY(), (int) loc.getZ());
 }
 public void playNoteSound(Vector3f loc, String type, int pitch) {
   float realPitch = (float) Math.pow(2.0D, (double) (pitch - 12) / 12.0D);
   _world.playSoundEffect(loc.getX(), loc.getY(), loc.getZ(), "note." + type, 3.0f, realPitch);
 }
 public void spawnVein(Vector3f pos, int blockId, int amount) {
   WorldGenMinable m = new WorldGenMinable(blockId, amount);
   m.generate(_world, _world.rand, (int) pos.getX(), (int) pos.getY(), (int) pos.getZ());
 }
 public boolean grow(Vector3f pos) {
   ItemStack t = new ItemStack(Item.dyePowder, 1);
   t.setItemDamage(15);
   return Item.dyePowder.onItemUse(
       t, _player, _world, (int) pos.getX(), (int) pos.getY(), (int) pos.getZ(), 0, 0, 0, 0);
 }
 public boolean spawnTree(Vector3f pos) {
   WorldGenTrees t = new WorldGenTrees(true);
   return t.generate(_world, _world.rand, (int) pos.getX(), (int) pos.getY(), (int) pos.getZ());
 }
 public void dropItem(int id, int count, Vector3f pos) {
   EntityItem t =
       new EntityItem(_world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(id, count, 0));
   _world.spawnEntityInWorld(t);
 }
 public void setBlock(int blockType, int metadata, Vector3f loc, boolean update) {
   this._world.setBlockAndMetadataWithUpdate(
       (int) loc.getX(), (int) loc.getY(), (int) loc.getZ(), blockType, metadata, update);
 }