Solved Set a block "Correctly" in the world

Discussion in 'Plugin Development' started by thomas15v, Nov 21, 2013.

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

    thomas15v

    Oke i have the following problem. I would like to replace certain blocks with a chest containing the block that has been replaced. The block itself loads the chunks so i can easily track them. The function itself is working but i get this error.

    Code:
    15:04:52 [SEVERE] Block at -129,64,189 is CHEST but has buildcraft.factory.TileQuarry@ee6b99e. Bukkit will attempt to fix this, but there may be additional damage that we cannot recover.
    This is the code i am using:

    Code:java
    1. for (World w : getServer().getWorlds()){
    2. getLogger().info("Checking " + w.getName());
    3. for (Chunk c : w.getLoadedChunks()){
    4. for (int x = 0; x < 16; x++){
    5. for(int y = 0; y < c.getWorld().getMaxHeight(); y++)
    6. {
    7. for(int z = 0; z < 16; z++)
    8. {
    9. Block block = c.getBlock(x, y, z);
    10.  
    11. if (block.getTypeId() == 153){
    12. getLogger().info("Quarry found on " + block.getX() + " " + block.getY() + " " + block.getZ());
    13.  
    14. block.setType(Material.CHEST);
    15. block.setData((byte) 0);
    16.  
    17. Chest chest = (Chest) block.getState();
    18.  
    19. chest.getInventory().addItem(new ItemStack(153,1));
    20.  
    21. return true;
    22.  
    23. }
    24. }
    25. }
    26. }
    27. }


    I know this is possible because i have seen coreprotect replacing these blocks without an error.

    Nvm i found that calling "block.breakNaturally(new ItemStack(0,0));" Breaks and cleans the block location correctly so you can correctly set them. Sorry for posting this :(. But maby it could be helpfull for other people

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
Thread Status:
Not open for further replies.

Share This Page