Add provided Material to getDrops
This commit is contained in:
31
patches/api/0006-Add-provided-Material-to-getDrops.patch
Normal file
31
patches/api/0006-Add-provided-Material-to-getDrops.patch
Normal file
@@ -0,0 +1,31 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Cryptite <cryptite@gmail.com>
|
||||
Date: Wed, 29 Sep 2021 08:40:37 -0500
|
||||
Subject: [PATCH] Add provided Material to getDrops
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java
|
||||
index 6ef43ae39a8ad4ed0e9a7bf68c17840576e235ea..7a8c5e87e429c711e23dab3fa9449601aa07a414 100644
|
||||
--- a/src/main/java/org/bukkit/block/Block.java
|
||||
+++ b/src/main/java/org/bukkit/block/Block.java
|
||||
@@ -587,6 +587,20 @@ public interface Block extends Metadatable, net.kyori.adventure.translation.Tran
|
||||
@NotNull
|
||||
Collection<ItemStack> getDrops(@NotNull ItemStack tool, @Nullable Entity entity);
|
||||
|
||||
+ // Slice start
|
||||
+ /**
|
||||
+ * Returns a list of items which would drop by the entity destroying this
|
||||
+ * block as though it were a given Material with a specific tool
|
||||
+ *
|
||||
+ * @param blockType The block type to use as the source loot
|
||||
+ * @param tool The tool or item in hand used for digging
|
||||
+ * @param entity the entity destroying the block
|
||||
+ * @return a list of dropped items for this type of block
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ Collection<ItemStack> getDrops(@NotNull Material blockType, @NotNull ItemStack tool, @Nullable Entity entity);
|
||||
+ // Slice end
|
||||
+
|
||||
/**
|
||||
* Returns if the given item is a preferred choice to break this Block.
|
||||
*
|
||||
38
patches/server/0011-Add-provided-Material-to-getDrops.patch
Normal file
38
patches/server/0011-Add-provided-Material-to-getDrops.patch
Normal file
@@ -0,0 +1,38 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Cryptite <cryptite@gmail.com>
|
||||
Date: Wed, 29 Sep 2021 08:40:37 -0500
|
||||
Subject: [PATCH] Add provided Material to getDrops
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
index 68fbf05b07ffe028993184261dbd1a61c3c45aa5..3aa0f3e1ab17e5fcb89fde9f3a1802c605a3f7e4 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
@@ -705,7 +705,18 @@ public class CraftBlock implements Block {
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> getDrops(ItemStack item, Entity entity) {
|
||||
- net.minecraft.world.level.block.state.BlockState iblockdata = this.getNMS();
|
||||
+ return getDrops(null, item, entity); // Slice start
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Collection<ItemStack> getDrops(Material blockType, ItemStack item, Entity entity) {
|
||||
+ net.minecraft.world.level.block.state.BlockState iblockdata;
|
||||
+ if (blockType == null) {
|
||||
+ iblockdata = this.getNMS();
|
||||
+ } else {
|
||||
+ iblockdata = ((CraftBlockData) blockType.createBlockData()).getState();
|
||||
+ }
|
||||
+
|
||||
net.minecraft.world.item.ItemStack nms = CraftItemStack.asNMSCopy(item);
|
||||
|
||||
// Modelled off EntityHuman#hasBlock
|
||||
@@ -716,6 +727,7 @@ public class CraftBlock implements Block {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
+ // Slice end
|
||||
|
||||
@Override
|
||||
public boolean isPreferredTool(ItemStack item) {
|
||||
Reference in New Issue
Block a user