1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Block updating bug

Discussion in 'Development' started by KygekDev, Sep 30, 2020.

  1. KygekDev

    KygekDev Witch

    Messages:
    72
    GitHub:
    KygekDev
    Hello!

    I just modified an OreGenerator plugin. The plugin will generate a random ore block above Glowing Obsidian with 1 second delay. The problem is, when I place or destroy a block beside the generated ore block, the plugin will regenerate another ore block. Also there were no errors in the console.

    Is there any solution? Any help would be very appreciated!

    WARNING: Don't talk about the in_array() unless it's the cause! I know that it returns boolean and the most impotant thing is that it worked on randomizing the ore block generating chance.

    NOTE: Video for illustration is available here (tell me if the link don't work) and plugin source code is available below.
     

    Attached Files:

  2. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    Only place blocks if the above block is empty
     
  3. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    Can you please upload the plugin to github and the video to some video uploading page?
     
  4. KygekDev

    KygekDev Witch

    Messages:
    72
    GitHub:
    KygekDev
    Well, I've fixed it using this:

    PHP:
    $x $this->block->getX();
    $y $this->block->getY();
    $z $this->block->getZ();
    $upblock = $$this->block->getLevel()->getBlock(new Vector3($x$y$z));
    if (
    $upblock instanceof Air)
        
    $this->block->getLevel()->setBlock($this->block$newBlocktruefalse);
    Thanks for your help!
     
  5. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    nice job
     
  6. KygekDev

    KygekDev Witch

    Messages:
    72
    GitHub:
    KygekDev
    Thanks.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.