@@ -47,14 +47,14 @@ public ItemStackInventoryManager(Player player)
4747 public virtual List < StackResponseContainerInfo > HandleItemStackActions ( int requestId , ItemStackActionList actions )
4848 {
4949 var stackResponses = new List < StackResponseContainerInfo > ( ) ;
50- uint recipeNetworkId = 0 ;
50+ byte TimesCrafted = 1 ;
5151 foreach ( ItemStackAction stackAction in actions )
5252 {
5353 switch ( stackAction )
5454 {
5555 case CraftAction craftAction :
5656 {
57- recipeNetworkId = ProcessCraftAction ( craftAction ) ;
57+ TimesCrafted = ProcessCraftAction ( craftAction ) ;
5858 break ;
5959 }
6060 case CraftAutoAction CraftAuto :
@@ -80,7 +80,7 @@ public virtual List<StackResponseContainerInfo> HandleItemStackActions(int reque
8080 }
8181 case CraftResultDeprecatedAction craftResultDeprecatedAction :
8282 {
83- ProcessCraftResultDeprecatedAction ( craftResultDeprecatedAction ) ;
83+ ProcessCraftResultDeprecatedAction ( craftResultDeprecatedAction , TimesCrafted ) ;
8484 break ;
8585 }
8686 case TakeAction takeAction :
@@ -405,26 +405,37 @@ protected virtual void ProcessTakeAction(TakeAction action, List<StackResponseCo
405405 {
406406 byte count = action . Count ;
407407 Item sourceItem ;
408+ Item destinationItem ;
408409 Item destItem ;
409410 StackRequestSlotInfo source = action . Source ;
410411 StackRequestSlotInfo destination = action . Destination ;
411412
412413 sourceItem = GetContainerItem ( source . ContainerId , source . Slot ) ;
413- Log . Debug ( $ "Take { sourceItem } " ) ;
414+ destinationItem = GetContainerItem ( destination . ContainerId , destination . Slot ) ;
414415
415- if ( sourceItem . Count == count || sourceItem . Count - count <= 0 )
416+
417+ if ( source . ContainerId == 60 && sourceItem . Id == destinationItem . Id )
416418 {
417- destItem = sourceItem ;
419+ destItem = ( Item ) destinationItem . Clone ( ) ;
420+ destItem . Count += count ;
421+ destItem . UniqueId = Environment . TickCount ;
422+ }
423+ else if ( source . ContainerId != 60 && sourceItem . Count == count )
424+ {
425+ destItem = ( Item ) sourceItem . Clone ( ) ;
426+ destItem . Count = ( byte ) ( destinationItem . Count + count ) ;
427+ destItem . UniqueId = Environment . TickCount ;
418428 sourceItem = new ItemAir ( ) ;
419429 sourceItem . UniqueId = 0 ;
420430 SetContainerItem ( source . ContainerId , source . Slot , sourceItem ) ;
421431 }
422432 else
423433 {
424434 destItem = ( Item ) sourceItem . Clone ( ) ;
425- sourceItem . Count -= count ;
426435 destItem . Count = count ;
427436 destItem . UniqueId = Environment . TickCount ;
437+ sourceItem . Count -= count ;
438+ SetContainerItem ( source . ContainerId , source . Slot , sourceItem ) ;
428439 }
429440
430441 SetContainerItem ( destination . ContainerId , destination . Slot , destItem ) ;
@@ -469,15 +480,12 @@ protected virtual void ProcessTakeAction(TakeAction action, List<StackResponseCo
469480 } ) ;
470481 }
471482
472- protected virtual void ProcessCraftResultDeprecatedAction ( CraftResultDeprecatedAction action )
483+ protected virtual void ProcessCraftResultDeprecatedAction ( CraftResultDeprecatedAction action , byte TimesCrafted )
473484 {
474- //BUG: Won't work proper with anvil anymore.
475485 if ( GetContainerItem ( 59 , 50 ) . UniqueId > 0 ) return ;
476-
477- //TODO: We only use this for anvils right now. Until we fixed the anvil merge ourselves.
478486 Item craftingResult = action . ResultItems . FirstOrDefault ( ) ;
479487 if ( craftingResult == null ) return ;
480-
488+ craftingResult . Count = ( byte ) ( craftingResult . Count * TimesCrafted ) ;
481489 craftingResult . UniqueId = Environment . TickCount ;
482490 SetContainerItem ( 59 , 50 , craftingResult ) ;
483491 }
@@ -486,14 +494,20 @@ protected virtual void ProcessCraftNotImplementedDeprecatedAction(CraftNotImplem
486494 {
487495 }
488496
489- protected virtual uint ProcessCraftAction ( CraftAction action )
497+ protected virtual byte ProcessCraftAction ( CraftAction action )
490498 {
491- return action . RecipeNetworkId ;
499+ return action . TimesCrafted ;
500+ /*RecipeManager.resultMap.TryGetValue((int) action.RecipeNetworkId, out Item item);
501+ Item craftedItem = ItemFactory.GetItem(item.Id, item.Metadata, item.Count);
502+ craftedItem.Count = (byte) ((item.Count + GetContainerItem(59, 0).Count) * action.TimesCrafted);
503+ Log.Error(GetContainerItem(59, 0).Id);
504+ Log.Error(GetContainerItem(59, 0).Count);
505+ SetContainerItem(59, 0, craftedItem);*/
492506 }
493507 protected virtual void ProcessCraftAuto ( CraftAutoAction action )
494508 {
495509 RecipeManager . resultMap . TryGetValue ( ( int ) action . RecipeNetworkId , out Item item ) ;
496- _player . Inventory . UiInventory . Slots [ 50 ] = ItemFactory . GetItem ( item . Id , item . Metadata , item . Count * action . craftCount ) ;
510+ _player . Inventory . UiInventory . Slots [ 50 ] = ItemFactory . GetItem ( item . Id , item . Metadata , item . Count * action . TimesCrafted ) ;
497511 }
498512
499513 protected virtual void ProcessCraftCreativeAction ( CraftCreativeAction action )
0 commit comments