mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-20 23:46:57 +01:00
#823: Add Block#isPreferredTool
By: Flo0 <unconfigured@null.spigotmc.org>
This commit is contained in:
parent
1eb2ceea36
commit
d6327a1b65
1 changed files with 12 additions and 1 deletions
|
@ -658,7 +658,7 @@ public class CraftBlock implements Block {
|
|||
net.minecraft.world.item.ItemStack nms = CraftItemStack.asNMSCopy(item);
|
||||
|
||||
// Modelled off EntityHuman#hasBlock
|
||||
if (item == null || !iblockdata.isRequiresSpecialTool() || nms.canDestroySpecialBlock(iblockdata)) {
|
||||
if (item == null || isPreferredTool(iblockdata, nms)) {
|
||||
return net.minecraft.world.level.block.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 {
|
||||
|
@ -666,6 +666,17 @@ public class CraftBlock implements Block {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPreferredTool(ItemStack item) {
|
||||
IBlockData iblockdata = getNMS();
|
||||
net.minecraft.world.item.ItemStack nms = CraftItemStack.asNMSCopy(item);
|
||||
return isPreferredTool(iblockdata, nms);
|
||||
}
|
||||
|
||||
private boolean isPreferredTool(IBlockData iblockdata, net.minecraft.world.item.ItemStack nmsItem) {
|
||||
return !iblockdata.isRequiresSpecialTool() || nmsItem.canDestroySpecialBlock(iblockdata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
|
||||
getCraftWorld().getBlockMetadata().setMetadata(this, metadataKey, newMetadataValue);
|
||||
|
|
Loading…
Reference in a new issue