Remove one block from WorldEdit Selection

Discussion in 'Plugin Development' started by Emphytos, Apr 29, 2012.

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

    Emphytos

    Hi,

    I want to make a glass wall with my worldedit selection when I place a specific sign. My problem is the glass wall destroy the sign, and want to remove the sign from the WorldEdit selection to safe the sign. :)

    How can I do that ?

    Thanks, Emphytos.
     
  2. Offline

    Waffletastic

    Loop through all the blocks in the selection using clipboard.getheight etc. it can get a little mathy, if you need more help pm me

    Oh and in the loop check if the block is the one you want, and if it is, set it to air.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
  3. Offline

    Emphytos

    Can you give me a little code to see what you want to say please, I don't speak english very well. x)
     
  4. Offline

    d33k40

    Code:
            for(int x = minx;x <= maxx; x=x+1){
                for(int y = miny;y <= maxy; y=y+1){
                    for(int z = minz;z <= maxz; z=z+1){
                        blockscan.setX(x);
                        blockscan.setY(y);
                        blockscan.setZ(z);
                        if(blockscan.getBlock().getType().equals(Material.SIGN_POST)){
                            Sign sign = (Sign) blockscan.getBlock().getState();
                            if(sign.getLine(0).equals("something in line")){
                                //what you want
                            }
                        }
                    }
                }
            }
    This scan the cuboid for a sign, if the sign has in their line 0 something that you set do something.

    I will not give to you the full code for walls, do something.
     
  5. Offline

    Emphytos

    No,
    I know how to make the walls.
    My problem is I just want to save the sign,
    this is my code
    PHP:
                    LocalSession session this.plugin.WorldEdit.getSession(p);
                    
    EditSession editSession session.createEditSession(lp);
                    
                    
    BaseBlock GLASS = new BaseBlock(Material.GLASS.getId());
                    
                    try {
                        
    //editSession.replaceBlocks(r, AIR, GLASS);
                        
    editSession.makeCuboidWalls(rGLASS);
                    } catch (
    MaxChangedBlocksException e2) {
                        
    e2.printStackTrace();
                    }
     
  6. Offline

    d33k40

    The thing is that you use de worldecit api, check for the location of the sign, and then qhen you create the wall, recreate the sign, make a clone of the block.
     
  7. Offline

    Emphytos

    How ? :/
     
  8. Offline

    d33k40

    You place the sign so get the location of your placed sign, just that, then regenerate it.

    Simple.
     
  9. Offline

    Emphytos

    My code doesn't work :/

    PHP:
                    try {
                        
    //editSession.replaceBlocks(r, AIR, GLASS);
                        
    editSession.makeCuboidWalls(rGLASS);
                       
                    } catch (
    MaxChangedBlocksException e2) {
                        
    e2.printStackTrace();
                    }
                            
    block.setType(Material.SIGN);
                    
    Sign s = (Sign)b.getLocation().getBlock().getState();
                    
    e.setLine(0ChatColor.AQUA "Parcelle de");
                    
    e.setLine(1ChatColor.GREEN.toString() + sizeX " x " sizeY " x " sizeZ);
                    
    e.setLine(2ChatColor.AQUA.toString() + prix " Imps");
                    
    s.update();
                    
    e.setLine(3ChatColor.GOLD "EN ATTENTE");
                    
    plugin.config.set("nextids."+parentnextid+1);
                    
    plugin.saveConfig();
    There is no block and when I interact with the block I'm kicked with this message: "Internal Error"
     
  10. Offline

    d33k40

    on BlockPlaceEvent you do:

    Code:
    Block block = event.getBlock();
    That is the block you placed, in this case a sign.

    Put all the code of that event,
     
  11. Offline

    Emphytos

    Why onBlockPlace ?
     
  12. Offline

    ItsHarry

    Why not?
     
  13. Offline

    Emphytos

    Because my event is onSignChange..
     
  14. Offline

    Emphytos

    I find how to place a block, but the face of the sign don't is the same when I place the sign, can I change the face of the sign ?
     
Thread Status:
Not open for further replies.

Share This Page