/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.mojang.serialization.Codec */ package net.minecraft.world.item.component; import com.mojang.serialization.Codec; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.ItemStack; public record UseRemainder(ItemStack convertInto) { public static final Codec CODEC = ItemStack.CODEC.xmap(UseRemainder::new, UseRemainder::convertInto); public static final StreamCodec STREAM_CODEC = StreamCodec.composite(ItemStack.STREAM_CODEC, UseRemainder::convertInto, UseRemainder::new); public ItemStack convertIntoRemainder(ItemStack usedStack, int stackCountBeforeUsing, boolean hasInfiniteMaterials, OnExtraCreatedRemainder onExtraCreatedRemainder) { if (hasInfiniteMaterials) { return usedStack; } if (usedStack.getCount() >= stackCountBeforeUsing) { return usedStack; } ItemStack remainderStack = this.convertInto.copy(); if (usedStack.isEmpty()) { return remainderStack; } onExtraCreatedRemainder.apply(remainderStack); return usedStack; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || this.getClass() != o.getClass()) { return false; } UseRemainder that = (UseRemainder)o; return ItemStack.matches(this.convertInto, that.convertInto); } @Override public int hashCode() { return ItemStack.hashItemAndComponents(this.convertInto); } @FunctionalInterface public static interface OnExtraCreatedRemainder { public void apply(ItemStack var1); } }