[solved]An error in determining the block type

Discussion in 'Plugin Development' started by RiseOfDeath, Sep 27, 2011.

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

    RiseOfDeath

    Good day.

    Napial for personal use utility, which counts the blocks (the number of those or other units). However, it obviouslydoes not work, because it does not count the several pre-set no natural blocks.

    Sources below:
    Code:
    if(commandLabel.contains("statistic"))
            {
                //искать стронгхолды до 65-го чанка
                if(sender.isOp()){
                sender.sendMessage("Ok, you can do this...");
                double work;
                double count=0;
                double done = 0;
                String done_str;
                work = (16900);//это так... //don't look here.. this is a vestige
                try{
                    sender.sendMessage("Try get statistic...");
                    for(int i = -5;i<=5;i++){
                        for(int j =-5;j<=5;j++){
                            readblocks(sender.getServer().getWorld(args[0]).getChunkAt(i, j));
                            sender.getServer().getWorld(args[0]).unloadChunk(i, j);
                            count++;
    
                        }
                        done = count/work*100;//[SIZE=16px][FONT=arial][COLOR=rgb(51, 51, 51)]this is a vestige too[/COLOR][/FONT][/SIZE]
                        done_str = Double.toString(done);[SIZE=16px][FONT=arial][COLOR=rgb(51, 51, 51)]this is a vestige too[/COLOR][/FONT][/SIZE]
                        sender.sendMessage("Now done: " + done_str + "%");   //[SIZE=16px][FONT=arial][COLOR=rgb(51, 51, 51)]this is a vestige too[/COLOR][/FONT][/SIZE]
                    }
                    for(int i=0;i<256;i++)
                    {
                        sender.sendMessage("Block " + i + ": " +Integer.toString(blocks[i]));
                    }
                    sender.sendMessage("Job is done");
                }
                catch(CommandException e){
                    sender.sendMessage(e.toString());
                }
                }
                else
                {
                    sender.sendMessage("Oh... you don't OP, sorry...");
                }
            }
    Code:
    boolean readblocks(Chunk chunk)
        {
            for(int i=0;i<16;i++)
            {
                for(int j=0;j<16;j++)
                {
                    for(int k=0;k<128;k++)
                    {
                        blocks[chunk.getBlock(i, j, k).getTypeId()]++;
                    }
                }
            }
            return false;
        }
    I placed few blocks 98, but plugin not counted them. (sorry for long log, i don't know how add spoiler)

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

    nisovin

    In your loops, i=x, j=z, and k=y. However, when you call getBlock(), you don't use them in that order.
     
  3. Offline

    RiseOfDeath

    really I mixed up places y and s

    It's a shame when wrong. It is doubly a shame if an error is very stupid.

    Thank you for your help.
     
Thread Status:
Not open for further replies.

Share This Page