Files
2020-10-30 11:35:16 +08:00

33 lines
1.1 KiB
Diff

--- ../src-base/minecraft/org/bukkit/inventory/ItemStack.java
+++ ../src-work/minecraft/org/bukkit/inventory/ItemStack.java
@@ -9,6 +9,7 @@
import org.bukkit.Material;
import org.bukkit.Utility;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.MaterialData;
@@ -22,6 +23,7 @@
private MaterialData data = null;
private short durability = 0;
private ItemMeta meta;
+ private net.minecraft.item.ItemStack mNMSItem = null; //add by cc
@Utility
protected ItemStack() {}
@@ -271,6 +273,13 @@
*/
@Utility
public int getMaxStackSize() {
+ if (this.mNMSItem == null) {
+ this.mNMSItem = CraftItemStack.asNMSCopy(this);
+ }
+
+ if (this.mNMSItem != null) {
+ return this.mNMSItem.getItem().getItemStackLimit(this.mNMSItem);
+ }
Material material = getType();
if (material != null) {
return material.getMaxStackSize();