aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorUnknown <shekwancheung0528@gmail.com>2019-01-13 00:25:30 +0800
committerUnknown <shekwancheung0528@gmail.com>2019-01-13 00:25:30 +0800
commitf4473fd6c4142e071e498094490f44692dfbbdf3 (patch)
treee1c226a7fb13f8e30d642ebd019d10600378904a /src/main/java
parentaee1137515d4f74f54c8ea70e71e742661213bf2 (diff)
downloadRoughlyEnoughItems-f4473fd6c4142e071e498094490f44692dfbbdf3.tar.gz
RoughlyEnoughItems-f4473fd6c4142e071e498094490f44692dfbbdf3.tar.bz2
RoughlyEnoughItems-f4473fd6c4142e071e498094490f44692dfbbdf3.zip
Better Recipe Tooltips
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/ItemSlotWidget.java8
-rw-r--r--src/main/java/me/shedaniel/rei/mixin/MixinBrewingRecipeRegistry.java19
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/BrewingRecipe.java1
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultBlastingCategory.java7
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultBrewingCategory.java35
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultSmeltingCategory.java7
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultSmokingCategory.java7
7 files changed, 63 insertions, 21 deletions
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/ItemSlotWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/ItemSlotWidget.java
index bf3897c47..3aa94c8fc 100644
--- a/src/main/java/me/shedaniel/rei/gui/widget/ItemSlotWidget.java
+++ b/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 "";
}
diff --git a/src/main/java/me/shedaniel/rei/mixin/MixinBrewingRecipeRegistry.java b/src/main/java/me/shedaniel/rei/mixin/MixinBrewingRecipeRegistry.java
index 5813a42b3..15ea467dc 100644
--- a/src/main/java/me/shedaniel/rei/mixin/MixinBrewingRecipeRegistry.java
+++ b/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)));
});
diff --git a/src/main/java/me/shedaniel/rei/plugin/BrewingRecipe.java b/src/main/java/me/shedaniel/rei/plugin/BrewingRecipe.java
index b4bcdb39a..0d501105f 100644
--- a/src/main/java/me/shedaniel/rei/plugin/BrewingRecipe.java
+++ b/src/main/java/me/shedaniel/rei/plugin/BrewingRecipe.java
@@ -14,4 +14,5 @@ public class BrewingRecipe {
this.ingredient = ingredient_1;
this.output = object_2;
}
+
} \ No newline at end of file
diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultBlastingCategory.java b/src/main/java/me/shedaniel/rei/plugin/DefaultBlastingCategory.java
index 9e4855267..75c35407c 100644
--- a/src/main/java/me/shedaniel/rei/plugin/DefaultBlastingCategory.java
+++ b/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;
}
diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultBrewingCategory.java b/src/main/java/me/shedaniel/rei/plugin/DefaultBrewingCategory.java
index 1f28e1ce1..41cfcab83 100644
--- a/src/main/java/me/shedaniel/rei/plugin/DefaultBrewingCategory.java
+++ b/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;
}
diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultSmeltingCategory.java b/src/main/java/me/shedaniel/rei/plugin/DefaultSmeltingCategory.java
index 3bd10f472..63fbbd164 100644
--- a/src/main/java/me/shedaniel/rei/plugin/DefaultSmeltingCategory.java
+++ b/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;
}
diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultSmokingCategory.java b/src/main/java/me/shedaniel/rei/plugin/DefaultSmokingCategory.java
index dda60ba4b..eedce2977 100644
--- a/src/main/java/me/shedaniel/rei/plugin/DefaultSmokingCategory.java
+++ b/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;
}