Botania (Fabric/Quilt)

Botania (Fabric/Quilt)

5M Downloads

Black hole talisman when attempting to extract using a crafty craft while empty deletes the talisman instead of dropping as is

Ampflower opened this issue ยท 5 comments

commented

Mod Loader

Fabric

Minecraft Version

1.19.2

Botania version

1.19.2-436-FABRIC-SNAPSHOT

Modloader version

Quilt: Loader v0.18.1-beta.10, Quilted Fabric API 4.0.0-beta.19+0.64.0-1.19.2

Modpack info

https://github.com/Oliver-makes-code/gaycraft-pack

The latest.log file

https://gist.github.com/KJP12/50795617495920bf3cbaa0a9cc2bebee

Issue description

When sending an empty black hole talisman through a crafty crate, instead of dropping it or holding onto it as expected, it instead deletes the talisman entirely.

Steps to reproduce

  1. Obtain talisman, crafty crate and hopper
  2. Place crafty crate and feed hopper into it.
    • Optionally give it a 1x1 placeholder.
  3. Give the crafty crate the talisman via the hopper.
  4. If not using the placeholder, right click with a wand of the forest.

Note: The talisman has to be empty for the bug to show, it'll otherwise extract the contents and drop itself as normal

Other information

Reproduced with a minimal set on the client of just QSL, Botania, Patchouli, LazyDFU and Trinkets, happens on server as well.

commented

Still present in 9803af6 under the Fabric development environment, will try to track down the issue more.

commented

Looking around, I believe this might be because the talisman sets itself to air when it is empty, which normally isn't reachable in the vanilla crafting table, but might be reachable by the crafty crate.

commented

One potential fix is to go ahead and make this only return true if the talisman isn't empty, else false otherwise. https://github.com/VazkiiMods/Botania/blob/1.19.x/Xplat/src/main/java/vazkii/botania/common/crafting/recipe/BlackHoleTalismanExtractRecipe.java#L35-L51

Although, this doesn't fix the fact that the crafty crate can still void items when the recipe returns air but matches.

commented

The other component of this would be to check if the stack is empty and bail before mutating the inventory.

Optional<CraftingRecipe> matchingRecipe = getMatchingRecipe(craft);
matchingRecipe.ifPresent(recipe -> {
craftResult = recipe.assemble(craft);
Container handler = getItemHandler();
List<ItemStack> remainders = recipe.getRemainingItems(craft);
for (int i = 0; i < craft.getContainerSize(); i++) {
ItemStack s = remainders.get(i);
ItemStack inSlot = handler.getItem(i);
if ((inSlot.isEmpty() && s.isEmpty())
|| (!inSlot.isEmpty() && inSlot.is(BotaniaItems.placeholder))) {
continue;
}
handler.setItem(i, s);
}
});
if (!matchingRecipe.isPresent()) {
matchFailed = true;
}

commented

A potential fix does seem to work.
image