What's wrong with this code?

Discussion in 'Plugin Development' started by djyee, Dec 30, 2015.

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

    djyee

    What's wrong with this code?
    Code:
      @EventHandler
      public void onChunkLoad(ChunkLoadEvent event){
    
               for (int x = 0; x <= 30; x++) {
          for (int y = 0; y <= 100; y++) {
          for (int z = 0; z <= 30; z++) {
           
             
            
              if(event.getChunk().getBlock(x, y, z).hasMetadata("§9Zumrut Supriz Sandik")){
               
                  event.getChunk().getBlock(x, y, z).setType(Material.BEDROCK);
      
        
          }
          }
         
          }
          }
          }
     
  2. Offline

    mcdorli

    Create a 1 tick delay, and do this after that. Chunks didn't get loaded when the chunkloadevent fires. They only start to load.
     
  3. Offline

    djyee

    like this ? but this is not working to :(
    Code:
      @EventHandler
      final public void onChunkLoad(ChunkLoadEvent event){
    
              getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable()
                {
                public void run()
                {
                    for (int x = 0; x <= 30; x++)
                       
                          for (int y = 0; y <= 100; y++)
                          for (int z = 0; z <= 30; z++)
    
              if(event.getChunk().getBlock(x, y, z).hasMetadata("§9Zumrut Supriz Sandik")){
               
          
               event.getChunk().getBlock(x, y, z).setType(Material.BEDROCK);
                }
                }
              }, 100L);
     
  4. Offline

    PresentingTulip

    Thats 100 ticks.
     
  5. Offline

    djyee

    I try 1 ticks but not work
    Any idea ?
     
  6. Offline

    Zombie_Striker

    Last edited: Dec 30, 2015
    mine-care likes this.
  7. Offline

    djyee

Thread Status:
Not open for further replies.

Share This Page