Block Breaking and Placing

Discussion in 'Plugin Development' started by GoogleMaps, Dec 5, 2015.

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

    GoogleMaps

    So I wanna make a plugin that you type /box and when you're under ground it will dig out the blocks. Not all at once, like a player breaking them but quicker. After that is done I want it to place the walls, roof and floor with a block. I can't figure out how to do a cube (Hollow). And how to make it so it does it block by block, so It looks like a player is doing it.
    Here is my cube thing
    I will make it so it replaces with air.
    But it does it all at once
    Code:
    for(int x = p.getLocation().getBlockX(); x<p.getLocation().getBlockX() + 10; x++)
                    {
                        for(int y = p.getLocation().getBlockY(); y<p.getLocation().getBlockY() + 10 ; y++)
                        {
                            for(int z = p.getLocation().getBlockZ(); z<p.getLocation().getBlockZ() + 10; z++)
                            {
                                Location location = new Location(p.getWorld(),x,y,z);
                                if(!p.getInventory().contains(Material.STONE, 1000) || p.getGameMode().equals(GameMode.CREATIVE))
                                {
                                    p.sendMessage(ChatColor.RED +"Nah Mate, not enough resources. 1000 Stone");
                                   
                                }else if(p.getInventory().contains(Material.STONE, 1000) || p.getGameMode().equals(GameMode.CREATIVE)){
                                   
                                    location.getBlock().setType(Material.EMERALD_BLOCK);
                                   
                                }
     
  2. Offline

    Scimiguy

    It's doing it all at once because the entire code is running really quickly.

    Your best bet is to get the location of each of your blocks through your loops and put them in a HashSet.
    Once you're done, set a BukkitRunnable to repeat and gradually set each of those locations in the HashSet to whatever you want
     
  3. Offline

    GoogleMaps

    Ohh that's too hard :p
     
  4. Offline

    mcdorli

    *facepalm* this is nowhere near hard, learn java please, because all this is 10 lines.
     
Thread Status:
Not open for further replies.

Share This Page