1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Merge pull request #2595 from AnotherMC/master

Fix ghost blocks
This commit is contained in:
TheBusyBiscuit 2020-12-10 21:51:00 +01:00 committed by GitHub
commit 5aa5ca1aed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,6 +41,7 @@ import me.mrCookieSlime.Slimefun.api.Slimefun;
*
* @author TheBusyBiscuit
* @author Linox
* @author Patbox
*
* @see BlockPlaceHandler
* @see BlockBreakHandler
@ -58,7 +59,20 @@ public class BlockListener implements Listener {
// This prevents Players from placing a block where another block already exists
// While this can cause ghost blocks it also prevents them from replacing grass
// or saplings etc...
if (BlockStorage.hasBlockInfo(e.getBlock())) {
Block block = e.getBlock();
if (e.getBlockReplacedState().getType().isAir()) {
SlimefunItem sfItem = BlockStorage.check(block);
if (sfItem != null) {
for (ItemStack item : sfItem.getDrops()) {
if (item != null && !item.getType().isAir()) {
block.getWorld().dropItemNaturally(block.getLocation(), item);
}
}
BlockStorage.clearBlockInfo(block);
}
} else if (BlockStorage.hasBlockInfo(e.getBlock())) {
e.setCancelled(true);
}
}