Easy Villagers

Easy Villagers

13M Downloads

Converting villager for without the use of a potion

mrdejong opened this issue ยท 1 comments

commented

Bug description
When converting a villager you have to use a villager, golden apple and a potion of weakness the villager converts normally when you try it again with the same villager (or an other doesn't matter) it converts the villager without a potion.

Steps to reproduce the issue
Important to follow these steps! In this sample I count from 1 instead of 0. ;) So there are 4 slots [1] [2] ... etc. this important to remember.

  1. In a converter put the following items in the slots; 1. Villager; 2. golden apples; 3. Weakness potion
  2. Wait for convertion
  3. Take the converted villager put it back in slot 1 and if there are no golden apples then put a golden apple in slot 2, important do not put anything in slot 3, otherwise the issue doesn't reproduce.
  4. See that it works, villager converts without any problem and more important without the use of a potion.

I pointed out that you shouldn't put anything in slot 3, if you do that itemstack assigned to that slot gets overwritten and thus removes the "ghost" potion itemstack, atleast I think it is a "ghost" itemstack. I have taken a look in the code, and my guess is is that the method ItemStack->shrink(int n) doesn't work properly with non-stackable items. Why I think that this is the problem is because you set potionStack to null before (see code reference under here) before checking if it is there, the function won't return true if potionStack is null and thus the villager will not be converted. Now even creasier this doesn't work with golden apples, when the last apple is used the ItemStack in the inputInventory will be reset.

    private boolean consumeConvertItems() {
        ItemStack appleStack = null;
        ItemStack potionStack = null;
        for (ItemStack stack : inputInventory) {
            if (appleStack == null && stack.getItem() == Items.GOLDEN_APPLE) {
                appleStack = stack;
            }
            if (potionStack == null && isWeakness(stack)) {
                potionStack = stack;
            }
        }

        if (appleStack != null && potionStack != null) {
            appleStack.shrink(1);
            potionStack.shrink(1);
            return true;
        } else {
            return false;
        }
    }

Expected behavior
The convertion block should use a new potion each time.

Log files
Checked log files no mention of this issue, and thus not including any logs.

Versions

  • Minecraft version: 1.20.2
  • Mod loader: Forge
  • Mod loader version: 48.1.0
  • Mod version: 1.0.17

Other mods
Only minecraft, forge and easy villagers

commented

Thank you for investigating this issue!