Skip to content

Commit

Permalink
use import in ShulkerBoxUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
MC-XiaoHei committed Nov 15, 2024
1 parent b01dc3b commit 4fefed3
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions patches/server/0040-Stackable-ShulkerBoxes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -418,17 +418,18 @@ index f7a6296773defc95215bdf36d8ea105cf9590a9e..5f394cda052271b6ecfafc325733e5ae
ignoreTileUpdates = true; // Paper - Perf: Optimize Hoppers
diff --git a/src/main/java/org/leavesmc/leaves/util/ShulkerBoxUtils.java b/src/main/java/org/leavesmc/leaves/util/ShulkerBoxUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..bcb13315000a16f4f2dbdcbef751940743ce297d
index 0000000000000000000000000000000000000000..64344eb9310690dd31e7fadcfb29ed8dda559716
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/util/ShulkerBoxUtils.java
@@ -0,0 +1,38 @@
@@ -0,0 +1,39 @@
+package org.leavesmc.leaves.util;
+
+import net.minecraft.core.component.DataComponents;
+import net.minecraft.world.item.BlockItem;
+import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.component.ItemContainerContents;
+import net.minecraft.world.level.block.ShulkerBoxBlock;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.jetbrains.annotations.NotNull;
+import org.leavesmc.leaves.LeavesConfig;
+
Expand All @@ -440,18 +441,18 @@ index 0000000000000000000000000000000000000000..bcb13315000a16f4f2dbdcbef7519407
+
+ public static int getItemStackMaxCount(ItemStack stack) {
+ if (LeavesConfig.shulkerBoxStackSize > 1 && stack.getItem() instanceof BlockItem bi &&
+ bi.getBlock() instanceof ShulkerBoxBlock && org.leavesmc.leaves.util.ShulkerBoxUtils.shulkerBoxNoItem(stack)) {
+ return org.leavesmc.leaves.LeavesConfig.shulkerBoxStackSize;
+ bi.getBlock() instanceof ShulkerBoxBlock && shulkerBoxNoItem(stack)) {
+ return LeavesConfig.shulkerBoxStackSize;
+ }
+ return stack.getMaxStackSize();
+ }
+
+ public static net.minecraft.world.item.ItemStack correctItemStackMaxStackSize(net.minecraft.world.item.ItemStack itemStack) {
+ int trulyMaxStackSize = org.leavesmc.leaves.util.ShulkerBoxUtils.getItemStackMaxCount(itemStack);
+ public static ItemStack correctItemStackMaxStackSize(ItemStack itemStack) {
+ int trulyMaxStackSize = getItemStackMaxCount(itemStack);
+ if (itemStack.getMaxStackSize() != trulyMaxStackSize) {
+ org.bukkit.inventory.ItemStack bkStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemStack);
+ org.bukkit.inventory.ItemStack bkStack = CraftItemStack.asBukkitCopy(itemStack);
+ bkStack.editMeta(meta -> meta.setMaxStackSize(trulyMaxStackSize));
+ itemStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(bkStack);
+ itemStack = CraftItemStack.asNMSCopy(bkStack);
+ }
+ return itemStack;
+ }
Expand Down

0 comments on commit 4fefed3

Please sign in to comment.