mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
Add getDrops to BlockState
Originally added isPreferredTool to BlockData but upstream added that.
This commit is contained in:
parent
074f19e7fb
commit
492ebf1459
@ -347,5 +347,24 @@ public class CraftBlockState implements BlockState {
|
||||
public boolean isCollidable() {
|
||||
return this.data.getBlock().hasCollision;
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.util.Collection<org.bukkit.inventory.ItemStack> getDrops(org.bukkit.inventory.ItemStack item, org.bukkit.entity.Entity entity) {
|
||||
this.requirePlaced();
|
||||
net.minecraft.world.item.ItemStack nms = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(item);
|
||||
|
||||
// Modelled off EntityHuman#hasBlock
|
||||
if (item == null || !data.requiresCorrectToolForDrops() || nms.isCorrectToolForDrops(data)) {
|
||||
return net.minecraft.world.level.block.Block.getDrops(
|
||||
data,
|
||||
world.getHandle(),
|
||||
position,
|
||||
world.getHandle().getBlockEntity(position), entity == null ? null :
|
||||
((org.bukkit.craftbukkit.entity.CraftEntity) entity).getHandle(), nms
|
||||
).stream().map(org.bukkit.craftbukkit.inventory.CraftItemStack::asBukkitCopy).toList();
|
||||
} else {
|
||||
return java.util.Collections.emptyList();
|
||||
}
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user