Set Block?

Discussion in 'Plugin Development' started by ninjinharock123, Jun 13, 2014.

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

    ninjinharock123

    how setting a type of a coordinated block to another example:
    10,10,10 to 20,20,20 set a block of diamond
     
  2. Offline

    unrealdesign

    Get the location for the black you want to replace and the block you want to mimic;
    Location replaceLoc = new Location(world, x, y, z);
    Location mimicLoc = new Location(world, x, y, z);

    replaceLoc.getBlock().setType(mimicLoc.getBlock().getType());
     
  3. Offline

    ninjinharock123

    Thus, for example?
    Location replaceLoc = new Location(world, 10, 10, 10);
    Location mimicLoc = new Location(world, 20, 20, 20);

    replaceLoc.getBlock().setType(mimicLoc.getBlock().getType(Material.DIAMOND_BLOCK));

    Hello...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  4. Offline

    unrealdesign

    No. It'd just be replaceLoc.getBlock().setType(mimicLoc.getBlock().getType());

    Just test before you ask, it's not that hard haha.

    Also chill out, you waited 12 minutes for a response. I'm not just sitting on these forums waiting eagerly for peoples responses lol. If you tag a person who replied to your post, then they will get an alert that someone asked you a question.
     
  5. Offline

    Beasty

    Hello ninjanharock123, To set a block at a Location Specified, You can do

    Code:java
    1. public class Main extends JavaPlugin {
    2.  
    3. public Location blok;
    4.  
    5. public void onEnable(){
    6. }
    7.  
    8. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
    9. {
    10. Player p = (Player)sender;
    11. if (commandLabel.equalsIgnoreCase("block")) {
    12. Location loc = p.getLocation();
    13. //Then you do
    14. this.blok = new Location(getServer().getWorld(p.getWorld().getName()), 10, 10, 10);
    15. p.getWorld().getBlockAt(this.blok).setType(Material.DIAMOND_BLOCK);
    16. }
    17.  
    18.  
    19.  
     
Thread Status:
Not open for further replies.

Share This Page