1
+ package mod .acgaming .universaltweaks .bugfixes .misc .crafteditemstatistics .mixin ;
2
+
3
+ import net .minecraft .inventory .IInventory ;
4
+ import net .minecraft .inventory .Slot ;
5
+ import net .minecraft .inventory .SlotCrafting ;
6
+ import net .minecraft .item .ItemStack ;
7
+ import mod .acgaming .universaltweaks .config .UTConfigBugfixes ;
8
+ import org .spongepowered .asm .mixin .Mixin ;
9
+ import org .spongepowered .asm .mixin .Shadow ;
10
+ import org .spongepowered .asm .mixin .injection .At ;
11
+ import org .spongepowered .asm .mixin .injection .Inject ;
12
+ import org .spongepowered .asm .mixin .injection .callback .CallbackInfoReturnable ;
13
+
14
+ // MC-65198, MC-161869
15
+ // https://bugs.mojang.com/browse/MC-65198
16
+ // https://bugs.mojang.com/browse/MC-161869
17
+ // Courtesy of mrgrim
18
+ @ Mixin (SlotCrafting .class )
19
+ public abstract class UTSlotCraftingMixin extends Slot
20
+ {
21
+ @ Shadow
22
+ private int amountCrafted ;
23
+
24
+ public UTSlotCraftingMixin (IInventory inventoryIn , int index , int xPosition , int yPosition )
25
+ {
26
+ super (inventoryIn , index , xPosition , yPosition );
27
+ }
28
+
29
+ @ Inject (method = "decrStackSize" , at = @ At ("HEAD" ), cancellable = true )
30
+ private void utFixCraftingStats (int amount , CallbackInfoReturnable <ItemStack > cir )
31
+ {
32
+ if (UTConfigBugfixes .MISC .utCraftedItemStatisticsToggle )
33
+ {
34
+ ItemStack ret = super .decrStackSize (amount );
35
+ this .amountCrafted += ret .getCount ();
36
+
37
+ cir .setReturnValue (ret );
38
+ }
39
+ }
40
+ }
0 commit comments