Fix Block stacks giving one less block when destroyed

This commit is contained in:
ceze88 2023-04-05 11:57:17 +02:00
parent 93aa9a7532
commit a43230f3b1
2 changed files with 9 additions and 2 deletions

View File

@ -55,6 +55,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -109,9 +109,15 @@ public class BlockListeners implements Listener {
} }
} }
stack.add(amountToRemove); stack.add(amountToRemove);
if (stack.getAmount() < 2) if (stack.getAmount() < 2) {
stack.destroy(); stack.destroy();
else { ItemStack item = stack.getMaterial().getItem();
if (Settings.ADD_TO_INVENTORY.getBoolean()) {
player.getInventory().addItem(item);
} else {
block.getWorld().dropItemNaturally(block.getLocation().clone().add(.5, 1, .5), item);
}
} else {
plugin.updateHologram(stack); plugin.updateHologram(stack);
plugin.getDataManager().updateBlock(stack); plugin.getDataManager().updateBlock(stack);
} }