mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-24 09:16:06 +01:00
SPIGOT-5641: Add Block.getDrops(ItemStack, Entity)
By: md_5 <git@md-5.net>
This commit is contained in:
parent
51b2cd767e
commit
466de0ab57
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.CraftFluidCollisionMode;
|
||||||
import org.bukkit.craftbukkit.CraftWorld;
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||||
import org.bukkit.craftbukkit.util.CraftRayTraceResult;
|
import org.bukkit.craftbukkit.util.CraftRayTraceResult;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.metadata.MetadataValue;
|
import org.bukkit.metadata.MetadataValue;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
@ -612,12 +614,17 @@ public class CraftBlock implements Block {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<ItemStack> getDrops(ItemStack item) {
|
public Collection<ItemStack> getDrops(ItemStack item) {
|
||||||
|
return getDrops(item, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<ItemStack> getDrops(ItemStack item, Entity entity) {
|
||||||
IBlockData iblockdata = getNMS();
|
IBlockData iblockdata = getNMS();
|
||||||
net.minecraft.server.ItemStack nms = CraftItemStack.asNMSCopy(item);
|
net.minecraft.server.ItemStack nms = CraftItemStack.asNMSCopy(item);
|
||||||
|
|
||||||
// Modelled off EntityHuman#hasBlock
|
// Modelled off EntityHuman#hasBlock
|
||||||
if (iblockdata.getMaterial().isAlwaysDestroyable() || nms.canDestroySpecialBlock(iblockdata)) {
|
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());
|
.stream().map(CraftItemStack::asBukkitCopy).collect(Collectors.toList());
|
||||||
} else {
|
} else {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
|
Loading…
Add table
Reference in a new issue