35 lines
1.4 KiB
Java
35 lines
1.4 KiB
Java
package online.astradev.cauldron.mixin;
|
|
|
|
import net.minecraft.core.Holder;
|
|
import net.minecraft.core.component.*;
|
|
import net.minecraft.world.item.Item;
|
|
import net.minecraft.world.item.ItemStack;
|
|
|
|
import online.astradev.cauldron.AstraCauldron;
|
|
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
import org.spongepowered.asm.mixin.injection.*;
|
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
|
|
/** Per-stack patch is sent to vanilla clients; no change to their assumed item defaults. */
|
|
@Mixin(ItemStack.class)
|
|
abstract class SoupStackMixin {
|
|
@Inject(
|
|
method =
|
|
"<init>(Lnet/minecraft/core/Holder;ILnet/minecraft/core/component/PatchedDataComponentMap;)V",
|
|
at = @At("RETURN"))
|
|
private void soups$stackSize(
|
|
Holder<Item> item, int count, PatchedDataComponentMap components, CallbackInfo ci) {
|
|
var key = item.unwrapKey().orElse(null);
|
|
if (key == null || !key.identifier().getNamespace().equals("minecraft")) return;
|
|
switch (key.identifier().getPath()) {
|
|
case "mushroom_stew", "rabbit_stew", "beetroot_soup", "suspicious_stew" -> {
|
|
var config = AstraCauldron.config();
|
|
if (config.normalizeVanillaSoups)
|
|
components.set(DataComponents.MAX_STACK_SIZE, config.soupStackSize);
|
|
}
|
|
default -> {}
|
|
}
|
|
}
|
|
}
|