1818import turing .tmb .RecipeIngredient ;
1919import turing .tmb .TMB ;
2020import turing .tmb .TooltipBuilder ;
21+ import turing .tmb .api .ISupportsRecipeFilling ;
2122import turing .tmb .api .drawable .IIngredientList ;
2223import turing .tmb .api .drawable .builder .ITooltipBuilder ;
2324import turing .tmb .api .ingredient .IIngredientRenderer ;
@@ -53,6 +54,7 @@ public class ScreenTMBRecipe extends Screen {
5354 private final ButtonElement tabLeftButton = new ButtonElement (2 , 0 , 0 , "<" );
5455 private final ButtonElement tabRightButton = new ButtonElement (3 , 0 , 0 , ">" );
5556 private String tooltip = "" ;
57+ private int debounce = 10 ;
5658
5759 public ScreenTMBRecipe (Screen parent ) {
5860 super (parent );
@@ -220,6 +222,9 @@ private void scroll(int direction) {
220222 @ Override
221223 @ SuppressWarnings ("unchecked" )
222224 public void render (int mx , int my , float partialTick ) {
225+ if (debounce > 0 ){
226+ debounce --;
227+ }
223228 renderBackground ();
224229 GL11 .glEnable (3042 );
225230 GL11 .glColor4f (1.0F , 1.0F , 1.0F , 1.0F );
@@ -440,6 +445,7 @@ private void renderTab(int x, int mx, int my, boolean selected, IRecipeCategory<
440445
441446 @ Override
442447 public void keyPressed (char eventCharacter , int eventKey , int mx , int my ) {
448+ if (debounce > 0 ) return ;
443449 if (eventKey == Keyboard .KEY_BACK ) {
444450 mc .displayScreen (getParentScreen ());
445451 } else if (eventKey == Keyboard .KEY_ESCAPE || eventKey == mc .gameSettings .keyInventory .getKeyCode ()) {
@@ -450,6 +456,26 @@ public void keyPressed(char eventCharacter, int eventKey, int mx, int my) {
450456 mc .displayScreen (s );
451457 }
452458
459+ if (eventKey == ((IKeybinds ) mc .gameSettings ).toomanyblocks$getKeyFillRecipe ().getKeyCode ()){
460+ Screen s = getParentScreen ();
461+ while (s instanceof ScreenTMBRecipe ) {
462+ s = s .getParentScreen ();
463+ }
464+ if (s instanceof ISupportsRecipeFilling ){
465+ for (int i = 0 ; i < drawnIngredients .size (); i ++) {
466+ Pair <ITypedIngredient <?>, Pair <Integer , Integer >> drawn = drawnIngredients .get (i );
467+ RecipeIngredient recipeIngredient = recipeIngredients .get (i );
468+ if (mx >= drawn .getRight ().getLeft () && my >= drawn .getRight ().getRight () && mx < drawn .getRight ().getLeft () + 16 && my < drawn .getRight ().getRight () + 16 ) {
469+ if (recipeIngredient .recipe != null ) {
470+ mc .displayScreen (s );
471+ ((ISupportsRecipeFilling ) s ).fillRecipe (recipeIngredient .recipe );
472+ break ;
473+ }
474+ }
475+ }
476+ }
477+ }
478+
453479 if (eventKey == ((IKeybinds )mc .gameSettings ).toomanyblocks$getKeyShowRecipeTree ().getKeyCode ()){
454480 for (int i = 0 ; i < drawnIngredients .size (); i ++) {
455481 Pair <ITypedIngredient <?>, Pair <Integer , Integer >> drawn = drawnIngredients .get (i );
@@ -511,8 +537,10 @@ public void keyPressed(char eventCharacter, int eventKey, int mx, int my) {
511537 Pair <ITypedIngredient <?>, Pair <Integer , Integer >> drawn = drawnIngredients .get (i );
512538 if (mx >= drawn .getRight ().getLeft () && my >= drawn .getRight ().getRight () && mx < drawn .getRight ().getLeft () + 16 && my < drawn .getRight ().getRight () + 16 ) {
513539 if (eventKey == mc .gameSettings .keyShowUsage .getKeyCode ()) {
540+ debounce = 10 ;
514541 TMB .getRuntime ().showRecipe (drawn .getLeft (), RecipeIngredientRole .INPUT );
515542 } else {
543+ debounce = 10 ;
516544 TMB .getRuntime ().showRecipe (drawn .getLeft (), RecipeIngredientRole .OUTPUT );
517545 }
518546 break ;
0 commit comments