-
Notifications
You must be signed in to change notification settings - Fork 183
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
[Bug] Wrong Products Count of Smelting Raw Cassiterite Sand #210
Comments
This is an, uhh, fundamental flaw in the furnace's logic that forge patches Guess we'll have to do that too |
But this is in fabric. |
I fixed it by mixin: @Mixin(AbstractFurnaceBlockEntity.class)
abstract class MAbstractFurnaceBlockEntity {
@Unique
private static final ThreadLocal<ItemStack> LOCAL_craftRecipe_itemStack2 = new ThreadLocal<>();
@Redirect(method = "craftRecipe", at = @At(value = "INVOKE", target = "Lnet/minecraft/recipe/Recipe;getOutput(Lnet/minecraft/registry/DynamicRegistryManager;)Lnet/minecraft/item/ItemStack;"))
private static ItemStack correctIncrement(Recipe<?> instance, DynamicRegistryManager dynamicRegistryManager) {
var r = instance.getOutput(dynamicRegistryManager);
LOCAL_craftRecipe_itemStack2.set(r);
return r;
}
@Redirect(method = "craftRecipe", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;increment(I)V"))
private static void correctIncrement(ItemStack instance, int amount) {
ItemStack output = LOCAL_craftRecipe_itemStack2.get();
if (output == null) {
instance.increment(amount);
} else {
instance.increment(output.getCount());
}
}
} |
maybe PR this to fabric API as well? so it could get actually fixed for everyone |
My mixin doesn't entirely solve the bug. It doesn't check the count of the existing result stack to avoid over max count. It just prevents loss in survival gameplay. |
I completely sovled the bug. Now the count won't increase to over max count. @Mixin(AbstractFurnaceBlockEntity.class)
abstract class MAbstractFurnaceBlockEntity {
@Unique
private static final ThreadLocal<ItemStack> LOCAL_recipe_output = new ThreadLocal<>();
@Redirect(method = "craftRecipe", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;increment(I)V"))
private static void correctIncrement(ItemStack instance, int amount) {
ItemStack output = LOCAL_recipe_output.get();
if (output == null) {
Enchantist.LOGGER.error("LOCAL_recipe_output.get() == null");
instance.increment(amount);
} else {
instance.increment(output.getCount());
}
}
/**
@param itemStack recipe output
@param itemStack2 output slot
*/
@Inject(method = "canAcceptRecipeOutput", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;areItemsEqual(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Z"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
private static void correctPredicate(DynamicRegistryManager registryManager, @Nullable Recipe<?> recipe, DefaultedList<ItemStack> slots, int count, CallbackInfoReturnable<Boolean> cir, ItemStack itemStack, ItemStack itemStack2) {
LOCAL_recipe_output.set(itemStack);
cir.setReturnValue(itemStack2.isEmpty() || ItemStack.canCombine(itemStack, itemStack2) && itemStack.getCount() + itemStack2.getCount() <= itemStack2.getMaxCount());
}
} |
fabric is deead, fabric is dee-ee-eeaaad |
GregTech CEu Version
1.20.1-1.0.8
Recipe Viewer Installed
EMI
Environment
Singleplayer
Cross-Mod Interaction
No
Expected Behavior
EMI shows that I can get two tin ingots from each raw cassiterite sand.
Actual Behavior
When I smelted 32 sands in furnace, I only got 33 ingots.
Steps to Reproduce
Additional Information
It seems that if there is existing ingots in the result slot of furnace, following smelting only produces one ingot.
The text was updated successfully, but these errors were encountered: