Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
unilock opened this issue Oct 3, 2023 · 3 comments
Assignees
Labels
mod compat Mod compatibility issue question Further information is requested

Comments

@unilock
Copy link

unilock commented Oct 3, 2023

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
@Ampflower Ampflower added the mod compat Mod compatibility issue label Oct 4, 2023
@Ampflower Ampflower self-assigned this Oct 4, 2023
@unilock
Copy link
Author

unilock commented Dec 16, 2023

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?

@Mixin(RecipeManager.class)
public class RecipeManagerMixin {
//note: C is actually CraftingInventory, treat it accordingly
@Inject(method = "getRemainingItemsFor",at = @At("HEAD"),cancellable = true)
private <C extends Container, T extends Recipe<C>> void techRebornWorkAround(RecipeType<T> recipeType, C craftInput, Level world, CallbackInfoReturnable<NonNullList<ItemStack>> cir) {
if (MixinHooks.hascachedrecipe) {
if (MixinHooks.lastRecipe != null) cir.setReturnValue(MixinHooks.lastRecipe.getRemainingItems((CraftingContainer) craftInput));
else cir.setReturnValue(((CraftingInventoryAccessor) craftInput).getItems());
MixinHooks.hascachedrecipe = false;
}
}
}

@Ampflower
Copy link
Member

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.

@Ampflower Ampflower added the question Further information is requested label Aug 30, 2024
@unilock
Copy link
Author

unilock commented Aug 30, 2024

I believe it was the latest version for 1.19.2?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mod compat Mod compatibility issue question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants