9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-29 03:39:07 +00:00

Fix exception with milk buckets

This commit is contained in:
Samsuik
2025-02-13 19:27:11 +00:00
parent 7cc2b6a99a
commit 7b51267294
2 changed files with 8 additions and 2 deletions

View File

@@ -1,14 +1,20 @@
package me.samsuik.sakura.player.item;
import me.samsuik.sakura.configuration.GlobalConfiguration;
import net.minecraft.core.component.DataComponentMap;
import net.minecraft.core.component.DataComponents;
public final class DataComponentHelper {
public static int bucketMaxStackSize() {
me.samsuik.sakura.configuration.GlobalConfiguration config = me.samsuik.sakura.configuration.GlobalConfiguration.get();
GlobalConfiguration config = GlobalConfiguration.get();
return config == null || !config.players.bucketStackSize.isDefined() ? -1 : config.players.bucketStackSize.intValue();
}
public static boolean stackableMilkBuckets() {
GlobalConfiguration config = GlobalConfiguration.get();
return config != null && config.players.stackableMilkBuckets;
}
public static DataComponentMap copyComponentsAndModifyMaxStackSize(DataComponentMap componentMap, int maxItemSize) {
if (maxItemSize > 0 && maxItemSize <= 99) {
return DataComponentMap.builder()

View File

@@ -15,7 +15,7 @@ public final class MilkBucketItem extends Item {
@Override
public void verifyComponentsAfterLoad(ItemStack stack) {
int maxStackSize = DataComponentHelper.bucketMaxStackSize();
if (GlobalConfiguration.get().players.stackableMilkBuckets && maxStackSize > 0 && maxStackSize < 100) {
if (DataComponentHelper.stackableMilkBuckets() && maxStackSize > 0 && maxStackSize < 100) {
stack.set(DataComponents.MAX_STACK_SIZE, maxStackSize);
}
}