mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-04 14:04:49 +01:00
SPIGOT-5641: Add Block.getDrops(ItemStack, Entity)
This commit is contained in:
parent
e25a2272f8
commit
f325b9beac
1 changed files with 8 additions and 1 deletions
|
@ -38,9 +38,11 @@ import org.bukkit.block.data.BlockData;
|
|||
import org.bukkit.craftbukkit.CraftFluidCollisionMode;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.craftbukkit.util.CraftRayTraceResult;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
@ -612,12 +614,17 @@ public class CraftBlock implements Block {
|
|||
|
||||
@Override
|
||||
public Collection<ItemStack> getDrops(ItemStack item) {
|
||||
return getDrops(item, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> getDrops(ItemStack item, Entity entity) {
|
||||
IBlockData iblockdata = getNMS();
|
||||
net.minecraft.server.ItemStack nms = CraftItemStack.asNMSCopy(item);
|
||||
|
||||
// Modelled off EntityHuman#hasBlock
|
||||
if (iblockdata.getMaterial().isAlwaysDestroyable() || nms.canDestroySpecialBlock(iblockdata)) {
|
||||
return net.minecraft.server.Block.getDrops(iblockdata, (WorldServer) world.getMinecraftWorld(), position, world.getTileEntity(position), null, nms)
|
||||
return net.minecraft.server.Block.getDrops(iblockdata, (WorldServer) world.getMinecraftWorld(), position, world.getTileEntity(position), entity == null ? null : ((CraftEntity) entity).getHandle(), nms)
|
||||
.stream().map(CraftItemStack::asBukkitCopy).collect(Collectors.toList());
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
|
|
Loading…
Reference in a new issue