Modflower / QuickBench

Other
3 stars 1 forks source link

Mystical Agriculture: Refabricated's "Infusion Crystal" is incorrectly completely consumed with QuickBench installed #3

Open unilock opened 11 months ago

unilock commented 11 months ago

The mod Mystical Agriculture: Refabricated adds an "Infusion Crystal", an item used as a catalyst in crafting recipes.

Instead of being completely consumed in its recipes, it instead takes a point of damage per recipe it's used in. (Note, however, that it does not take damage in the form of durability - instead, the damage taken seems to be stored as an integer in the item's NBT data.) (afaict it does take damage in the form of durability, but hides the durability bar in the inventory?)

With QuickBench installed, the Crystal is completely consumed in its crafting recipes, when it should only take a single point of damage. Not ideal.

image image
unilock commented 9 months ago

Mystical Agriculture's Infusion Crystals extend Cucumber's BaseReusableItem, which appears to work by setting its recipe remainder to itself, minus one durability point. (source)

@Override
public ItemStack getRecipeRemainder(ItemStack stack) {
    var copy = stack.copy();

    copy.setCount(1);

    if (!this.damage)
        return copy;

    var unbreaking = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.UNBREAKING, stack);

    for (var i = 0; i < unbreaking; i++) {
        if (DigDurabilityEnchantment.shouldIgnoreDurabilityDrop(stack, unbreaking, Utils.RANDOM))
            return copy;
    }

    copy.setDamageValue(stack.getDamageValue() + 1);

    if (copy.getDamageValue() > stack.getMaxDamage())
        return ItemStack.EMPTY;

    return copy;
}

I'm guessing this is the relevant code in QuickBench?

https://github.com/Modflower/QuickBench/blob/b6c01d7e1b1b0121e53cf3cf17aa81ea2cd37db3/src/main/java/tfar/fastbench/mixin/RecipeManagerMixin.java#L31-L43

Ampflower commented 2 weeks ago

Can't reproduce with 4.1.0+1.20.1 on 1.20.1 with Mystical Agriculture 3.0.2 in creative and survival, both with shift+click and single-clicking. The item does momentarily disappear but immediately reappears.

What exact versions were you using when you reproduced the bug? Because it seems that upstream inadvertently fixed it; although I'd like to fix it here too.

unilock commented 2 weeks ago

I believe it was the latest version for 1.19.2?