Selective Walls, Possible?

Discussion in 'Plugin Development' started by ccrama, Dec 11, 2013.

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

    ccrama

    Hello Bukkit,
    I am trying to make a system where players of a certian team can walk through their colored wool as a wall, while other teams cannot pass through. Is something like this possible? If so, please explain the method.
    Thanks!
    ccrama
     
  2. Offline

    mattrick

    ccrama
    You can change the block to air for the players on the team only, but not allow players to pass through. Alternatively, you can tp the player through the wall, if you can somehow find a way to detect a collision.
     
  3. Offline

    ccrama

    mattrick, can I make the block air for one team, another block for the other?
     
  4. Offline

    mattrick

    ccrama
    Yes, loop through all players on that tam and use sendBlockChange()
     
  5. Offline

    ccrama

  6. Offline

    mattrick

  7. Offline

    ccrama

    mattrick This code got VERY ugly VERY fast. Is there a more simplified way to do this?

    Code:java
    1. for(String s : Lists.getLists().Blue){
    2. Player pla = Bukkit.getServer().getPlayer(s);
    3.  
    4. for(Chunk chunk : Bukkit.getWorld((String) Main.gamesconfig.get(keynumb + ".World")).getLoadedChunks()){
    5. for(BlockState tileEntity : chunk.getTileEntities()) {
    6. Block mat = tileEntity.getBlock();
    7. if(mat.getType() == Material.HARD_CLAY) {
    8. Location loc = mat.getLocation();
    9. pla.sendBlockChange(loc, Material.AIR, (byte) 0);
    10. }
    11.  
    12. }
    13. }
    14.  
    15. }


    Im pretty sure with that many loops, there will be a LOT of lag.

    Thanks!

    FYI, that will be doubled, one for each of the teams...
     
  8. Offline

    mattrick

    ccrama
    AFAIK that is the best way to do that, it can get quite complicated. Maybe one of the better people can help you...
     
  9. Offline

    ccrama

    mattrick, all right, I'll see if anyone else replies. This method totally fails, but I hope that the block changing works for what I'm trying to do
     
  10. Offline

    mattrick

  11. Offline

    ccrama

    I figured getting all chunks in the whole world is a little overdoing it, as I only need to change blocks in a 15 radius of my spawnpoints. Is there a simple radius method that I could use to get all the blocks in the radius into an array, loop through the array, and get the locations of all hardened clay blocks?

    Thanks,
    ccrama
     
  12. Offline

    Jnorr44

    Also, playermove works, but it does slow things down a bit.
     
  13. Offline

    NathanWolf

    You'd want something like
    Code:java
    1. Location playerLocation = player.getLocation();
    2. for (dx = -3; dx <= 3; dx++) {
    3. for (dz = -3; dz <= 3; dz++) {
    4. Location blockLocation = playerLocation.clone();
    5. blockLocation.add(dx, 0, dz);
    6. Block block = blockLocation.getBlock();
    7. if (block.getType() == Material.STAINED_CLAY) {
    8. block.setType(Material.AIR);
    9. }
    10. }
    11. }


    Just a thought on this in general, though- if you go the route it seems you're going, this could be a very destructive ability. People like to decorate with stained clay, and you're in danger of destroying anything like that by walking near it while crouching :)

    What I do for things like this to try for maximum safety is I only replace air and a subset of very "common" materials like dirt. I do stone, too, but even that is potentially dangerous since people do build with that.

    Whenever I replace a block, I store it in a list. Then when I want to restore that block, I do so using the original material and data that was there before I replaced it.
     
  14. Offline

    ccrama

    NathanWolf it's 100% minigame server ( a recreation of TF2). I am looking for a way to keep teams out of each other's bases, and this seems like the best method. I will test your method, hope it works! Thanks!

    Hmm, still isnt working. Here is my code:
    Code:java
    1. for(String s : Lists.getLists().Blue){
    2. Player pla = Bukkit.getPlayer(s);
    3. Location a = locmaker(".Location.A");
    4. for (int dx = -3; dx <= 3; dx++) {
    5. for (int dz = -3; dz <= 3; dz++) {
    6. Location blockLocation = a.clone();
    7. blockLocation.add(dx, 0, dz);
    8. Block block = blockLocation.getBlock();
    9. if (block.getType() == Material.HARD_CLAY) {
    10. pla.sendBlockChange(blockLocation, Material.AIR, (byte) 0);
    11. System.out.println("HIDING CLAY!");
    12. }
    13. }
    14. }
    15.  
    16. }


    The problem is NOT with the locmaker part. All that does is return a location from the config. Any obvious problems you notice?

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

    NathanWolf

    Is it not working at all? Or just that you can't walk through it?

    I'm not really sure this send block change stuff is going to work, but I've never tried it myself. I wouldn't expect the server to let you walk through the blocks, unless you're handling that in a special way.

    Also, I apologize for kind of answering the wrong question... But I think what I gave you is still semi applicable.
     
  16. Offline

    ccrama

    Not working at all. The blocks aren't hiding, and the system print isn't printing. All the other parts of the method are working flawlessly though... just this part is not working. You do bring up a good point though. I don't know if you could walk through a wall with changed state o.o

    I'm thinking there's a way to do this using doors possibly, open the door for a specific player if he is right in front of it (to minimize non-team members from entering)? If you have any other ideas on how I can keep players out (preferably without setting movement using the to from method), that would be awesome.

    Cheers,
    ccrama

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

    MrDynamo

    This may not be as efficient for you, but get the block locations for all the 'doors', or colored wool, and if the player is on the team just send the block change
     
  18. Offline

    ccrama

    I think the changing block method won't work (I've been trying to get it to work all day). Is there an easy way to just force open a door if a player is touching it?
     
Thread Status:
Not open for further replies.

Share This Page