Bladeren bron

Better Recipe Tooltips

Unknown 6 jaren geleden
bovenliggende
commit
f4473fd6c4

+ 1 - 1
build.gradle

@@ -6,7 +6,7 @@ sourceCompatibility = 1.8
 targetCompatibility = 1.8
 
 archivesBaseName = "RoughlyEnoughItems"
-version = "2.0.0.35"
+version = "2.0.0.36"
 
 minecraft {
 }

+ 6 - 2
src/main/java/me/shedaniel/rei/gui/widget/ItemSlotWidget.java

@@ -1,7 +1,6 @@
 package me.shedaniel.rei.gui.widget;
 
 import com.google.common.collect.Lists;
-import me.shedaniel.rei.RoughlyEnoughItemsCore;
 import me.shedaniel.rei.client.ClientHelper;
 import me.shedaniel.rei.client.GuiHelper;
 import me.shedaniel.rei.listeners.IMixinContainerGui;
@@ -92,10 +91,15 @@ public class ItemSlotWidget extends Drawable implements HighlightableWidget {
         if (containerGui != null)
             toolTip = containerGui.getContainerGui().getStackTooltip(itemStack).stream().filter(s -> !s.equals(modString)).collect(Collectors.toList());
         else toolTip.add(itemStack.getDisplayName().getFormattedText());
-        toolTip.add("§9§o" + ClientHelper.getModFromItemStack(itemStack));
+        toolTip.addAll(getExtraToolTips(itemStack));
+        toolTip.add(modString);
         return toolTip;
     }
     
+    protected List<String> getExtraToolTips(ItemStack stack) {
+        return Lists.newArrayList();
+    }
+    
     protected String getItemCountOverlay(ItemStack currentStack) {
         return "";
     }

+ 8 - 11
src/main/java/me/shedaniel/rei/mixin/MixinBrewingRecipeRegistry.java

@@ -22,24 +22,21 @@ import java.util.List;
 @Mixin(BrewingRecipeRegistry.class)
 public class MixinBrewingRecipeRegistry {
     
-    private static final List<BrewingRecipe> ITEM_RECIPES = Lists.newArrayList();
+    private static final List<BrewingRecipe> SELF_ITEM_RECIPES = Lists.newArrayList();
     private static final List<Potion> REGISTERED_POTION_TYPES = Lists.newArrayList();
-    private static final List<Ingredient> POTION_TYPES = Lists.newArrayList();
+    private static final List<Ingredient> SELF_POTION_TYPES = Lists.newArrayList();
     
     @Inject(method = "method_8080", at = @At("RETURN"))
     private static void method_8080(Item item_1, CallbackInfo ci) {
-        if (!(item_1 instanceof PotionItem)) {
-        } else {
-            POTION_TYPES.add(Ingredient.ofItems(new ItemProvider[]{item_1}));
+        if (item_1 instanceof PotionItem) {
+            SELF_POTION_TYPES.add(Ingredient.ofItems(new ItemProvider[]{item_1}));
         }
     }
     
     @Inject(method = "method_8071", at = @At("RETURN"))
     private static void method_8071(Item item_1, Item item_2, Item item_3, CallbackInfo ci) {
-        if (!(item_1 instanceof PotionItem)) {
-        } else if (!(item_3 instanceof PotionItem)) {
-        } else {
-            ITEM_RECIPES.add(new BrewingRecipe(item_1, Ingredient.ofItems(new ItemProvider[]{item_2}), item_3));
+        if (item_1 instanceof PotionItem && item_3 instanceof PotionItem) {
+            SELF_ITEM_RECIPES.add(new BrewingRecipe(item_1, Ingredient.ofItems(new ItemProvider[]{item_2}), item_3));
         }
     }
     
@@ -49,7 +46,7 @@ public class MixinBrewingRecipeRegistry {
             registerPotionType(potion_1);
         if (!REGISTERED_POTION_TYPES.contains(potion_2))
             registerPotionType(potion_2);
-        POTION_TYPES.forEach(ingredient -> {
+        SELF_POTION_TYPES.forEach(ingredient -> {
             for(ItemStack stack : ingredient.getStackArray()) {
                 DefaultPlugin.registerBrewingDisplay(new DefaultBrewingDisplay(PotionUtil.setPotion(stack.copy(), potion_1), Ingredient.ofItems(new ItemProvider[]{item_1}),
                         PotionUtil.setPotion(stack.copy(), potion_2)));
@@ -59,7 +56,7 @@ public class MixinBrewingRecipeRegistry {
     
     private static void registerPotionType(Potion potion) {
         REGISTERED_POTION_TYPES.add(potion);
-        ITEM_RECIPES.forEach(recipe -> {
+        SELF_ITEM_RECIPES.forEach(recipe -> {
             DefaultPlugin.registerBrewingDisplay(new DefaultBrewingDisplay(PotionUtil.setPotion(recipe.input.getDefaultStack(), potion), recipe.ingredient,
                     PotionUtil.setPotion(recipe.output.getDefaultStack(), potion)));
         });

+ 1 - 0
src/main/java/me/shedaniel/rei/plugin/BrewingRecipe.java

@@ -14,4 +14,5 @@ public class BrewingRecipe {
         this.ingredient = ingredient_1;
         this.output = object_2;
     }
+    
 }

+ 6 - 1
src/main/java/me/shedaniel/rei/plugin/DefaultBlastingCategory.java

@@ -57,7 +57,12 @@ public class DefaultBlastingCategory implements IRecipeCategory<DefaultBlastingD
         }));
         List<List<ItemStack>> input = recipeDisplay.getInput();
         widgets.add(new ItemSlotWidget(startPoint.x + 1, startPoint.y + 1, input.get(0), true, true, containerGui, true));
-        widgets.add(new ItemSlotWidget(startPoint.x + 1, startPoint.y + 37, recipeDisplay.getFuel(), true, true, containerGui, true));
+        widgets.add(new ItemSlotWidget(startPoint.x + 1, startPoint.y + 37, recipeDisplay.getFuel(), true, true, containerGui, true) {
+            @Override
+            protected List<String> getExtraToolTips(ItemStack stack) {
+                return Arrays.asList(I18n.translate("category.rei.smelting.fuel"));
+            }
+        });
         widgets.add(new ItemSlotWidget(startPoint.x + 61, startPoint.y + 19, recipeDisplay.getOutput(), false, true, containerGui, true));
         return widgets;
     }

+ 30 - 5
src/main/java/me/shedaniel/rei/plugin/DefaultBrewingCategory.java

@@ -55,11 +55,36 @@ public class DefaultBrewingCategory implements IRecipeCategory<DefaultBrewingDis
             }
         }));
         widgets.add(new ItemSlotWidget(startPoint.x + 1, startPoint.y + 1, Arrays.asList(new ItemStack(Items.BLAZE_POWDER)), false, true, containerGui, true));
-        widgets.add(new ItemSlotWidget(startPoint.x + 63, startPoint.y + 1, recipeDisplay.getInput().get(0), false, true, containerGui, true));
-        widgets.add(new ItemSlotWidget(startPoint.x + 40, startPoint.y + 1, recipeDisplay.getInput().get(1), false, true, containerGui, true));
-        widgets.add(new ItemSlotWidget(startPoint.x + 40, startPoint.y + 35, recipeDisplay.getOutput(0), false, true, containerGui, true));
-        widgets.add(new ItemSlotWidget(startPoint.x + 63, startPoint.y + 42, recipeDisplay.getOutput(1), false, true, containerGui, true));
-        widgets.add(new ItemSlotWidget(startPoint.x + 86, startPoint.y + 35, recipeDisplay.getOutput(2), false, true, containerGui, true));
+        widgets.add(new ItemSlotWidget(startPoint.x + 63, startPoint.y + 1, recipeDisplay.getInput().get(0), false, true, containerGui, true) {
+            @Override
+            protected List<String> getExtraToolTips(ItemStack stack) {
+                return Arrays.asList(I18n.translate("category.rei.brewing.input"));
+            }
+        });
+        widgets.add(new ItemSlotWidget(startPoint.x + 40, startPoint.y + 1, recipeDisplay.getInput().get(1), false, true, containerGui, true) {
+            @Override
+            protected List<String> getExtraToolTips(ItemStack stack) {
+                return Arrays.asList(I18n.translate("category.rei.brewing.reactant"));
+            }
+        });
+        widgets.add(new ItemSlotWidget(startPoint.x + 40, startPoint.y + 35, recipeDisplay.getOutput(0), false, true, containerGui, true) {
+            @Override
+            protected List<String> getExtraToolTips(ItemStack stack) {
+                return Arrays.asList(I18n.translate("category.rei.brewing.result"));
+            }
+        });
+        widgets.add(new ItemSlotWidget(startPoint.x + 63, startPoint.y + 42, recipeDisplay.getOutput(1), false, true, containerGui, true) {
+            @Override
+            protected List<String> getExtraToolTips(ItemStack stack) {
+                return Arrays.asList(I18n.translate("category.rei.brewing.result"));
+            }
+        });
+        widgets.add(new ItemSlotWidget(startPoint.x + 86, startPoint.y + 35, recipeDisplay.getOutput(2), false, true, containerGui, true) {
+            @Override
+            protected List<String> getExtraToolTips(ItemStack stack) {
+                return Arrays.asList(I18n.translate("category.rei.brewing.result"));
+            }
+        });
         return widgets;
     }
     

+ 6 - 1
src/main/java/me/shedaniel/rei/plugin/DefaultSmeltingCategory.java

@@ -57,7 +57,12 @@ public class DefaultSmeltingCategory implements IRecipeCategory<DefaultSmeltingD
         }));
         List<List<ItemStack>> input = recipeDisplay.getInput();
         widgets.add(new ItemSlotWidget(startPoint.x + 1, startPoint.y + 1, input.get(0), true, true, containerGui, true));
-        widgets.add(new ItemSlotWidget(startPoint.x + 1, startPoint.y + 37, recipeDisplay.getFuel(), true, true, containerGui, true));
+        widgets.add(new ItemSlotWidget(startPoint.x + 1, startPoint.y + 37, recipeDisplay.getFuel(), true, true, containerGui, true) {
+            @Override
+            protected List<String> getExtraToolTips(ItemStack stack) {
+                return Arrays.asList(I18n.translate("category.rei.smelting.fuel"));
+            }
+        });
         widgets.add(new ItemSlotWidget(startPoint.x + 61, startPoint.y + 19, recipeDisplay.getOutput(), false, true, containerGui, true));
         return widgets;
     }

+ 6 - 1
src/main/java/me/shedaniel/rei/plugin/DefaultSmokingCategory.java

@@ -57,7 +57,12 @@ public class DefaultSmokingCategory implements IRecipeCategory<DefaultSmokingDis
         }));
         List<List<ItemStack>> input = recipeDisplay.getInput();
         widgets.add(new ItemSlotWidget(startPoint.x + 1, startPoint.y + 1, input.get(0), true, true, containerGui, true));
-        widgets.add(new ItemSlotWidget(startPoint.x + 1, startPoint.y + 37, recipeDisplay.getFuel(), true, true, containerGui, true));
+        widgets.add(new ItemSlotWidget(startPoint.x + 1, startPoint.y + 37, recipeDisplay.getFuel(), true, true, containerGui, true) {
+            @Override
+            protected List<String> getExtraToolTips(ItemStack stack) {
+                return Arrays.asList(I18n.translate("category.rei.smelting.fuel"));
+            }
+        });
         widgets.add(new ItemSlotWidget(startPoint.x + 61, startPoint.y + 19, recipeDisplay.getOutput(), false, true, containerGui, true));
         return widgets;
     }

+ 1 - 1
src/main/resources/fabric.mod.json

@@ -2,7 +2,7 @@
   "id": "roughlyenoughitems",
   "name": "RoughlyEnoughItems",
   "description": "To allow players to view items and recipes.",
-  "version": "2.0.0.35",
+  "version": "2.0.0.36",
   "side": "client",
   "authors": [
     "Danielshe"