Skip to content

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

Open

Description

@unilock

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

Activity

  1. self-assigned this
    on Oct 4, 2023
  2. unilock commented on Dec 16, 2023

    @unilock
    Author

    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;
    }
    }
    }

  3. Ampflower commented on Aug 30, 2024

    @Ampflower
    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.

  4. unilock commented on Aug 30, 2024

    @unilock
    Author

    I believe it was the latest version for 1.19.2?

  5. added theissue type on Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

mod compatMod compatibility issuequestionFurther information is requested

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions