PG85 / OpenTerrainGenerator

Minecraft Terrain Generator for Bukkit/Spigot/Forge
MIT License
200 stars 82 forks source link

[Bug]: BlockPlaceEvent#getBlock() returning wrong Block #955

Open YellowZaki opened 2 years ago

YellowZaki commented 2 years ago

Is there an existing issue for this?

Current Behavior

Spigot 1.12, OTG v9.4 BiomeBundle

When I listen to BlockPlaceEvent, sometimes, BlockPlaceEvent#getBlock() or BlockPlaceEvent#getPlacedBlock() returns a block on wrong coordinates. When I break the placed block and I placed again, the issue is fixed.

I've tried with only OTG installed (no other plugins) and the issue is still there.

Expected Behavior

BlockPlaceEvent#getPlacedBlock() should return the correct Block

Which platforms have you reproduced this issue using?

Spigot/Paper

OTG Version

1.12.2 v9.4

Platform Version

Paper 1.12.2 (Latest build)

Steps To Reproduce

  1. Setup a listener to BlockPlaceEvent like:
    @EventHandler
    public void onPlace(BlockPlaceEvent e) {
        e.getPlayer().sendMessage("debug0: " + e.getBlock().getLocation());
    }
  1. Generate map by flying on the world, and try to place a block anywhere.
  2. Sometimes (if the bug doesn't happen, keep trying), e.getBlock().getLocation() returns a location on other coords.

Log file

No errors

Anything else?

No response

SXRWahrheit commented 2 years ago

Thanks for this report. We have mostly reached EOL for 1.12.2 support, but if you can provide an MCVE demonstrating that OTG is interfering with this event, someone might be able to look into it. You're also welcome to PR any improvements.

YellowZaki commented 2 years ago

Thanks for this report. We have mostly reached EOL for 1.12.2 support, but if you can provide an MCVE demonstrating that OTG is interfering with this event, someone might be able to look into it. You're also welcome to PR any improvements.

Thank you, what is MCVE?

SXRWahrheit commented 2 years ago

https://stackoverflow.com/help/minimal-reproducible-example

YellowZaki commented 2 years ago

https://stackoverflow.com/help/minimal-reproducible-example

Thank you. I've written this code:

    @EventHandler
    public void onPlace(BlockPlaceEvent e) {
        e.getPlayer().sendMessage("PlacedBlockLocation: " + e.getBlock().getLocation());
        e.getPlayer().sendMessage("PlayerLocation: " + e.getPlayer().getLocation());
        if (e.getBlock().getLocation().distance(e.getPlayer().getLocation()) > 8) {
            e.getPlayer().sendMessage("ERROR: Wrong PlacedBlockLocation");
        }
        e.getPlayer().sendMessage("----------");       

    }

If the placed block is more than 8 blocks distance from player, it is on wrong location, since it is impossible to place a block 8 blocks away from your current location.

SXRWahrheit commented 2 years ago

Can you create a sample server setup with a minimal plugin demonstrating the issue and attach it as a zip?