mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-30 04:09:09 +00:00
Configure powdered snow bucket stack size
This commit is contained in:
@@ -67,6 +67,7 @@ public final class GlobalConfiguration extends ConfigurationPart {
|
||||
|
||||
public IntOr.Default bucketStackSize = IntOr.Default.USE_DEFAULT;
|
||||
public boolean stackableMilkBuckets = false;
|
||||
public boolean stackablePowderedSnowBuckets = false;
|
||||
}
|
||||
|
||||
public Environment environment;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package me.samsuik.sakura.player.item;
|
||||
|
||||
import me.samsuik.sakura.configuration.GlobalConfiguration;
|
||||
import net.minecraft.core.component.DataComponentMap;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.core.component.PatchedDataComponentMap;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.world.item.SolidBucketItem;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public final class PowderedSnowBucketItem extends SolidBucketItem {
|
||||
public PowderedSnowBucketItem(final Properties properties) {
|
||||
super(Blocks.POWDER_SNOW, SoundEvents.BUCKET_EMPTY_POWDER_SNOW, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataComponentMap components() {
|
||||
final DataComponentMap components = super.components();
|
||||
return stackablePowderedSnowBuckets()
|
||||
? DataComponentHelper.updateBucketMaxStackSize(components)
|
||||
: components;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyComponentsSentToClient(final PatchedDataComponentMap components) {
|
||||
if (stackablePowderedSnowBuckets()) {
|
||||
components.set(DataComponents.MAX_STACK_SIZE, DataComponentHelper.bucketMaxStackSize());
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean stackablePowderedSnowBuckets() {
|
||||
final GlobalConfiguration config = GlobalConfiguration.get();
|
||||
return config != null && config.players.stackablePowderedSnowBuckets;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user