Solved Tree logs and wood constantly turn into dirt

Discussion in 'Spigot Plugin Development' started by Hex_27, Jan 27, 2020.

  1. I'm utterly confused, but when I use setblock or NMS methods to place wood or logs, it periodically turns into dirt. Like if I break the dirt and replace it with wood in game, after a while, it'll turn back into dirt. I'd provide some kind of code, but at this rate, the plugin is thousands of lines and tens of classes big, and I can't pinpoint what in the world could even cause a behaviour like this. I have no schedulers active. Is this some obscure vanilla behaviour regarding wood blocks? I can't find it online

    EDIT: And this seems to exclusively only happen to logs and wood

    EDIT: Nope it replaced my iron block that I placed there, so apparently my trees spawn random bits that will keep turning into dirt

    EDIT: If I remove the wood from above and below the bugged dirt, and break the dirt, it never comes back
     
    #1 Hex_27, Jan 27, 2020
    Last edited: Jan 27, 2020
    • Funny Funny x 1
  2. Code (Java):
        @Override
        public void setType(int x, int y, int z, Material type) {
            w.getBlockAt(x, y, z).setType(type);
        }

        @Override
        public void setBlockData(int x, int y, int z, BlockData data) {
            w.getBlockAt(x,y,z).setBlockData(data);
        }
    I don't only do it with NMS, it also doesn't work for this method, where w is a world object
     
  3. I faced this exact problem some months ago, I was using block populators back then. Haven’t had that happen ever since I stopped using block populators. you seem to face all the problems I faced writing my generator :| you can add me on discord if you want and ask whenever you have some issue, I had no one to ask and it sucked. I tried asking here but almost no one knows how world generation works, and the only person who ever helped me was md_5, he told me to “write your own data systems” haha
     
    • Friendly Friendly x 1
  4. But to answer this exact issue, it seems to happen when placing a lot of blocks with block populators, for some reason it starts to place dirt blocks as if it’s overflowing or something. At first I thought it was a floating point inaccuracy but it happened even when I started using integers. Very strange.

    I tested to see if there were any calls to setBlock and there weren’t, so it was set at a lower level.
    I also tested if this occurred when no new chunks generated, and it didn’t, so these dirt blocks pop when new chunks generate affecting their neighbours somehow.
    And yes it would pop back in after I’d fix the dirt.

    This would be a very interesting bug to debug if I had Minecraft’s source code. So random and obscure.

    Also I didn’t use NMS, so this definitely happens when using setBlock() inside a populator. It affects far away chunks for some reason.
     
    #6 the3rdnumber, Jan 27, 2020
    Last edited: Jan 27, 2020
    • Informative Informative x 1
  5. It seems to be caused by the same bug in that bug report you linked, maybe mojang didn’t patch it completely, and we are triggering it somehow.
     
  6. Yikes. It definitely does affect NMS too though, I'm getting it in my generated trees in some rare-ish cases. But if NMS is the lowest level to set a block, how'd you manage to place a block in a way that doesn't trigger NMS?
     
  7. I do everything through the chunk generator. I avoid Minecraft’s classes entirely now :p you can see why.
     
  8. Hm. I do extend minecraft's nms chunk generator to place blocks though. I copy Craftbukkit's CustomChunkGenerator's implementation of bukkit chunkgenerator, so the way I place blocks should be near identical. Maybe it's the addDecorator method that's problematic
     
  9. All I did was using .setBlock() from the block populator.
     
  10. Just did my first real test generation of 5000x5000 blocks. One of the stuff I did was to check for this issue, and I’m glad to say it’s somehow gone. Perhaps it doesn’t affect NMS after all?

    definitely seems like some kind of odd minecraft bug. I’ll mark this as solved for now