aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/plugin
diff options
context:
space:
mode:
authorDanielshe <shekwancheung0528@gmail.com>2019-08-29 23:24:43 +0800
committerDanielshe <shekwancheung0528@gmail.com>2019-08-29 23:24:43 +0800
commit47ce58d320feedce57182ae0b88196bce518a57a (patch)
treed5ea5b0e4d5aa6590929e2a3c37c9d642f831aba /src/main/java/me/shedaniel/rei/plugin
parentb960e33306056c126c3816ec471c58c3b5a7be7f (diff)
downloadRoughlyEnoughItems-47ce58d320feedce57182ae0b88196bce518a57a.tar.gz
RoughlyEnoughItems-47ce58d320feedce57182ae0b88196bce518a57a.tar.bz2
RoughlyEnoughItems-47ce58d320feedce57182ae0b88196bce518a57a.zip
We are out of beta
- Fix #149 - Close #148 - SlotWidget API improvement
Diffstat (limited to 'src/main/java/me/shedaniel/rei/plugin')
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultCategoryHandler.java2
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingCategory.java7
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingCategory.java35
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/composting/DefaultCompostingCategory.java25
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingDisplay.java2
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/smelting/DefaultSmeltingCategory.java7
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/smoking/DefaultSmokingCategory.java7
7 files changed, 22 insertions, 63 deletions
diff --git a/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultCategoryHandler.java b/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultCategoryHandler.java
index 97bfc42af..5df184dad 100644
--- a/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultCategoryHandler.java
+++ b/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultCategoryHandler.java
@@ -81,7 +81,7 @@ public class DefaultCategoryHandler implements AutoTransferHandler {
public IntList hasItems(List<List<ItemStack>> inputs) {
// Create a clone of player's inventory, and count
- DefaultedList<ItemStack> copyMain = DefaultedList.create();
+ DefaultedList<ItemStack> copyMain = DefaultedList.of();
for (ItemStack stack : MinecraftClient.getInstance().player.inventory.main) {
copyMain.add(stack.copy());
}
diff --git a/src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingCategory.java b/src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingCategory.java
index b7652e0ab..b6561c438 100644
--- a/src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingCategory.java
+++ b/src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingCategory.java
@@ -74,12 +74,7 @@ public class DefaultBlastingCategory implements TransferRecipeCategory<DefaultBl
widgets.add(new RecipeArrowWidget(startPoint.x + 24, startPoint.y + 18, true));
List<List<ItemStack>> input = recipeDisplay.getInput();
widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 1, Renderer.fromItemStacks(input.get(0)), true, true, true));
- widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 37, Renderer.fromItemStacks(recipeDisplay.getFuel()), true, true, true) {
- @Override
- protected List<String> getExtraItemToolTips(ItemStack stack) {
- return Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.smelting.fuel"));
- }
- });
+ widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 37, Renderer.fromItemStacks(() -> recipeDisplay.getFuel(), true, stack -> Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.smelting.fuel"))), true, true, true));
widgets.add(new SlotWidget(startPoint.x + 61, startPoint.y + 19, Renderer.fromItemStacks(recipeDisplay.getOutput()), false, true, true));
return widgets;
}
diff --git a/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingCategory.java b/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingCategory.java
index 69f93557d..31c193d5d 100644
--- a/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingCategory.java
+++ b/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingCategory.java
@@ -64,36 +64,11 @@ public class DefaultBrewingCategory implements RecipeCategory<DefaultBrewingDisp
}
}));
widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 1, Renderer.fromItemStack(new ItemStack(Items.BLAZE_POWDER)), false, true, true));
- widgets.add(new SlotWidget(startPoint.x + 40, startPoint.y + 1, Renderer.fromItemStacks(recipeDisplay.getInput().get(0)), false, true, true) {
- @Override
- protected List<String> getExtraItemToolTips(ItemStack stack) {
- return Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.brewing.input"));
- }
- });
- widgets.add(new SlotWidget(startPoint.x + 63, startPoint.y + 1, Renderer.fromItemStacks(recipeDisplay.getInput().get(1)), false, true, true) {
- @Override
- protected List<String> getExtraItemToolTips(ItemStack stack) {
- return Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.brewing.reactant"));
- }
- });
- widgets.add(new SlotWidget(startPoint.x + 40, startPoint.y + 35, Renderer.fromItemStacks(recipeDisplay.getOutput(0)), false, true, true) {
- @Override
- protected List<String> getExtraItemToolTips(ItemStack stack) {
- return Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.brewing.result"));
- }
- });
- widgets.add(new SlotWidget(startPoint.x + 63, startPoint.y + 42, Renderer.fromItemStacks(recipeDisplay.getOutput(1)), false, true, true) {
- @Override
- protected List<String> getExtraItemToolTips(ItemStack stack) {
- return Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.brewing.result"));
- }
- });
- widgets.add(new SlotWidget(startPoint.x + 86, startPoint.y + 35, Renderer.fromItemStacks(recipeDisplay.getOutput(2)), false, true, true) {
- @Override
- protected List<String> getExtraItemToolTips(ItemStack stack) {
- return Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.brewing.result"));
- }
- });
+ widgets.add(new SlotWidget(startPoint.x + 40, startPoint.y + 1, Renderer.fromItemStacks(() -> recipeDisplay.getInput().get(0), true, stack -> Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.brewing.input"))), false, true, true));
+ widgets.add(new SlotWidget(startPoint.x + 63, startPoint.y + 1, Renderer.fromItemStacks(() -> recipeDisplay.getInput().get(1), true, stack -> Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.brewing.reactant"))), false, true, true));
+ widgets.add(new SlotWidget(startPoint.x + 40, startPoint.y + 35, Renderer.fromItemStacks(() -> recipeDisplay.getOutput(0), true, stack -> Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.brewing.result"))), false, true, true));
+ widgets.add(new SlotWidget(startPoint.x + 63, startPoint.y + 42, Renderer.fromItemStacks(() -> recipeDisplay.getOutput(1), true, stack -> Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.brewing.result"))), false, true, true));
+ widgets.add(new SlotWidget(startPoint.x + 86, startPoint.y + 35, Renderer.fromItemStacks(() -> recipeDisplay.getOutput(2), true, stack -> Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.brewing.result"))), false, true, true));
return widgets;
}
diff --git a/src/main/java/me/shedaniel/rei/plugin/composting/DefaultCompostingCategory.java b/src/main/java/me/shedaniel/rei/plugin/composting/DefaultCompostingCategory.java
index 8e049ba94..632fa623d 100644
--- a/src/main/java/me/shedaniel/rei/plugin/composting/DefaultCompostingCategory.java
+++ b/src/main/java/me/shedaniel/rei/plugin/composting/DefaultCompostingCategory.java
@@ -26,6 +26,7 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import java.util.Arrays;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.function.Supplier;
@@ -79,19 +80,17 @@ public class DefaultCompostingCategory implements RecipeCategory<DefaultComposti
int i = 0;
for (int y = 0; y < 6; y++)
for (int x = 0; x < 8; x++) {
- widgets.add(new SlotWidget(bounds.getCenterX() - 72 + x * 18, bounds.y + y * 18, stacks.size() > i ? Renderer.fromItemStack(stacks.get(i).asItem().getStackForRender()) : Renderer.empty(), true, true, true) {
- @Override
- protected List<String> getExtraItemToolTips(ItemStack stack) {
- final List<String>[] thing = new List[]{null};
- recipeDisplaySupplier.get().getInputMap().forEach((itemProvider, aFloat) -> {
- if (itemProvider.asItem().equals(stack.getItem()))
- thing[0] = Arrays.asList(I18n.translate("text.rei.composting.chance", MathHelper.fastFloor(aFloat * 100)));
- });
- if (thing[0] != null)
- return thing[0];
- return super.getExtraItemToolTips(stack);
- }
- });
+ int finalI = i;
+ widgets.add(new SlotWidget(bounds.getCenterX() - 72 + x * 18, bounds.y + y * 18, stacks.size() > i ? Renderer.fromItemStacks(() -> Collections.singletonList(new ItemStack(stacks.get(finalI))), true, stack -> {
+ final List<String>[] thing = new List[]{null};
+ recipeDisplaySupplier.get().getInputMap().forEach((itemProvider, aFloat) -> {
+ if (itemProvider.asItem().equals(stack.getItem()))
+ thing[0] = Arrays.asList(I18n.translate("text.rei.composting.chance", MathHelper.fastFloor(aFloat * 100)));
+ });
+ if (thing[0] != null)
+ return thing[0];
+ return null;
+ }) : Renderer.empty(), true, true, true));
i++;
}
widgets.add(new SlotWidget(startingPoint.x + 34, startingPoint.y + 5, Renderer.fromItemStacks(recipeDisplaySupplier.get().getOutput()), false, true, true));
diff --git a/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingDisplay.java b/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingDisplay.java
index 701b9347d..7a0bbba84 100644
--- a/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingDisplay.java
+++ b/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingDisplay.java
@@ -44,7 +44,7 @@ public interface DefaultCraftingDisplay extends TransferRecipeDisplay {
}
for (int i = 0; i < getInput().size(); i++) {
List<ItemStack> stacks = getInput().get(i);
- list.set(i, stacks);
+ list.set(DefaultCraftingCategory.getSlotWithSize(this, i), stacks);
}
return list;
}
diff --git a/src/main/java/me/shedaniel/rei/plugin/smelting/DefaultSmeltingCategory.java b/src/main/java/me/shedaniel/rei/plugin/smelting/DefaultSmeltingCategory.java
index a98cf0ecd..38ba8e5aa 100644
--- a/src/main/java/me/shedaniel/rei/plugin/smelting/DefaultSmeltingCategory.java
+++ b/src/main/java/me/shedaniel/rei/plugin/smelting/DefaultSmeltingCategory.java
@@ -73,12 +73,7 @@ public class DefaultSmeltingCategory implements TransferRecipeCategory<DefaultSm
widgets.add(new RecipeArrowWidget(startPoint.x + 24, startPoint.y + 18, true));
List<List<ItemStack>> input = recipeDisplaySupplier.get().getInput();
widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 1, Renderer.fromItemStacks(input.get(0)), true, true, true));
- widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 37, Renderer.fromItemStacks(recipeDisplaySupplier.get().getFuel()), true, true, true) {
- @Override
- protected List<String> getExtraItemToolTips(ItemStack stack) {
- return Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.smelting.fuel"));
- }
- });
+ widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 37, Renderer.fromItemStacks(() -> recipeDisplaySupplier.get().getFuel(), true, stack -> Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.smelting.fuel"))), true, true, true));
widgets.add(new SlotWidget(startPoint.x + 61, startPoint.y + 19, Renderer.fromItemStacks(recipeDisplaySupplier.get().getOutput()), false, true, true));
return widgets;
}
diff --git a/src/main/java/me/shedaniel/rei/plugin/smoking/DefaultSmokingCategory.java b/src/main/java/me/shedaniel/rei/plugin/smoking/DefaultSmokingCategory.java
index 128bc62c1..d15044f23 100644
--- a/src/main/java/me/shedaniel/rei/plugin/smoking/DefaultSmokingCategory.java
+++ b/src/main/java/me/shedaniel/rei/plugin/smoking/DefaultSmokingCategory.java
@@ -73,12 +73,7 @@ public class DefaultSmokingCategory implements TransferRecipeCategory<DefaultSmo
widgets.add(new RecipeArrowWidget(startPoint.x + 24, startPoint.y + 18, true));
List<List<ItemStack>> input = recipeDisplaySupplier.get().getInput();
widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 1, Renderer.fromItemStacks(input.get(0)), true, true, true));
- widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 37, Renderer.fromItemStacks(recipeDisplaySupplier.get().getFuel()), true, true, true) {
- @Override
- protected List<String> getExtraItemToolTips(ItemStack stack) {
- return Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.smelting.fuel"));
- }
- });
+ widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 37, Renderer.fromItemStacks(() -> recipeDisplaySupplier.get().getFuel(), true, stack -> Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.smelting.fuel"))), true, true, true));
widgets.add(new SlotWidget(startPoint.x + 61, startPoint.y + 19, Renderer.fromItemStacks(recipeDisplaySupplier.get().getOutput()), false, true, true));
return widgets;
}