mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-28 19:39:22 +00:00
* fix: fix grindstone curse book overstacking * fix: remove unused import
This commit is contained in:
@@ -216,7 +216,7 @@ public class LithiumStackList extends NonNullList<ItemStack> implements LithiumD
|
||||
for (int j = 0; j < inventorySize; ++j) {
|
||||
ItemStack itemStack = this.get(j);
|
||||
if (!itemStack.isEmpty()) {
|
||||
f += (float) itemStack.getCount() / (float) Math.min(this.maxCountPerStack, itemStack.getMaxStackSize());
|
||||
f += org.leavesmc.leaves.util.ItemOverstackUtils.getItemStackSignalStrength(this.maxCountPerStack, itemStack);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.leavesmc.leaves.util;
|
||||
|
||||
import io.papermc.paper.datacomponent.DataComponentTypes;
|
||||
import io.papermc.paper.datacomponent.item.ItemEnchantments;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
@@ -7,8 +9,8 @@ import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.component.CustomData;
|
||||
import net.minecraft.world.item.component.ItemContainerContents;
|
||||
import net.minecraft.world.item.enchantment.ItemEnchantments;
|
||||
import net.minecraft.world.level.block.ShulkerBoxBlock;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.LeavesConfig;
|
||||
|
||||
@@ -88,6 +90,14 @@ public class ItemOverstackUtils {
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public static float getItemStackSignalStrength(int maxStackSize, ItemStack itemStack) {
|
||||
float result = (float) itemStack.getCount() / Math.min(maxStackSize, itemStack.getMaxStackSize());
|
||||
if (LeavesConfig.modify.oldMC.allowGrindstoneOverstacking && CurseEnchantedBook.isCursedEnchantedBook(itemStack)) {
|
||||
return result;
|
||||
}
|
||||
return Math.clamp(result, 0f, 1f);
|
||||
}
|
||||
|
||||
public static boolean isStackable(ItemStack itemStack) {
|
||||
return getItemStackMaxCount(itemStack) > 1 && (!itemStack.isDamageableItem() || !itemStack.isDamaged());
|
||||
}
|
||||
@@ -169,12 +179,12 @@ public class ItemOverstackUtils {
|
||||
|
||||
public static class CurseEnchantedBook implements ItemUtil {
|
||||
public static boolean isCursedEnchantedBook(ItemStack stack) {
|
||||
ItemEnchantments enchantments = stack.getOrDefault(DataComponents.STORED_ENCHANTMENTS, ItemEnchantments.EMPTY);
|
||||
if (enchantments.size() != 1) {
|
||||
ItemEnchantments enchantments = stack.getBukkitStack().getData(DataComponentTypes.STORED_ENCHANTMENTS);
|
||||
if (enchantments == null || enchantments.enchantments().size() != 1) {
|
||||
return false;
|
||||
}
|
||||
return stack.getBukkitStack().getEnchantmentLevel(org.bukkit.enchantments.Enchantment.BINDING_CURSE) == 1 ||
|
||||
stack.getBukkitStack().getEnchantmentLevel(org.bukkit.enchantments.Enchantment.BINDING_CURSE) == 1;
|
||||
return enchantments.enchantments().containsKey(Enchantment.BINDING_CURSE) ||
|
||||
enchantments.enchantments().containsKey(Enchantment.VANISHING_CURSE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user