9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-25 18:09:28 +00:00
This commit is contained in:
XiaoMoMi
2024-07-09 23:27:17 +08:00
parent f79948ecae
commit 64e49dbdeb
4 changed files with 7 additions and 4 deletions

View File

@@ -2660,6 +2660,9 @@ public class ItemManagerImpl implements ItemManager {
Pot currentPot = getPotByBlock(block);
if (currentPot != pot) {
plugin.getWorldManager().removePotAt(SimpleLocation.of(location));
if (currentPot != null) {
plugin.getWorldManager().addPotAt(new MemoryPot(SimpleLocation.of(location), currentPot.getKey()), SimpleLocation.of(location));
}
return;
}
if (pot.isVanillaBlock()) {

View File

@@ -85,7 +85,7 @@ public class ItemUtils {
public static void increaseDurability(ItemStack itemStack, int amount) {
if (itemStack == null || itemStack.getType() == Material.AIR)
return;
Item<ItemStack> item = BukkitItemFactory.getInstance().wrap(itemStack);
Item<ItemStack> item = BukkitItemFactory.getInstance().wrap(itemStack.clone());
int damage = Math.max(item.damage().orElse(0) - amount, 0);
item.damage(damage);
itemStack.setItemMeta(item.load().getItemMeta());
@@ -104,7 +104,7 @@ public class ItemUtils {
if (Math.random() > (double) 1 / (unBreakingLevel + 1)) {
return;
}
Item<ItemStack> item = BukkitItemFactory.getInstance().wrap(itemStack);
Item<ItemStack> item = BukkitItemFactory.getInstance().wrap(itemStack.clone());
int damage = item.damage().orElse(0) + amount;
if (damage > item.maxDamage().orElse((int) itemStack.getType().getMaxDurability())) {
itemStack.setAmount(0);