mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
commit
5aa5ca1aed
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user