Spawn Chest with Items

Discussion in 'Plugin Development' started by wannezz, Jun 4, 2012.

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

    wannezz

    How do I spawn a chest on the location I want (spawn). I want to have some items in it...
     
  2. Offline

    XbannisherX

    so you want to have in your spawn a chest with items? well for the location i think u need to use GetWorld()GetLocation(y,x,z)
    excuse me if im wrong
     
    1Camer0471 likes this.
  3. Offline

    wannezz

    I think it is getServer().getWorld("world").getSpawnLocation
    But how can I get a chest there?

     
  4. Offline

    XbannisherX

    loc = Location
    Location loc.getBlock().setType(Material.CHEST);

    but in this case loc would be your spawn location
     
  5. Offline

    wannezz

    It worked, I did it like this:

    Code:
    Location loc = Bukkit.getServer().getWorld("Survival").getSpawnLocation();
            Block block = loc.getBlock();
            loc.getBlock().setType(Material.CHEST);
            Chest chest = (Chest)block.getState();
            Inventory inv = chest.getInventory();
           
            ItemStack diamond_sword = new ItemStack(Material.DIAMOND_SWORD, 1);
            ItemStack web = new ItemStack(Material.WEB, 3);
            ItemStack gold_boots = new ItemStack(Material.GOLD_BOOTS, 1);
            ItemStack fish = new ItemStack(Material.COOKED_FISH, 1);
            ItemStack golden_apple = new ItemStack(Material.GOLDEN_APPLE, 1);
            ItemStack enderpearl = new ItemStack(Material.ENDER_PEARL, 2);
           
            inv.addItem(diamond_sword, web, gold_boots, fish, golden_apple, enderpearl);
     
    bryansolis13 likes this.
  6. Offline

    XbannisherX

Thread Status:
Not open for further replies.

Share This Page