diff options
| author | Danielshe <shekwancheung0528@gmail.com> | 2019-11-03 14:44:52 +0800 |
|---|---|---|
| committer | Danielshe <shekwancheung0528@gmail.com> | 2019-11-03 14:44:59 +0800 |
| commit | 9f5a9eae9a7863412cc5eb433bf15e5ee71da616 (patch) | |
| tree | 0e6b0b94af061c5e9023b1ff19f339a6c30149be /src/main/java/me/shedaniel/rei/plugin/brewing | |
| parent | 3e3e25855b9f6df507a7d4c8a07c64b9a502fae2 (diff) | |
| download | RoughlyEnoughItems-9f5a9eae9a7863412cc5eb433bf15e5ee71da616.tar.gz RoughlyEnoughItems-9f5a9eae9a7863412cc5eb433bf15e5ee71da616.tar.bz2 RoughlyEnoughItems-9f5a9eae9a7863412cc5eb433bf15e5ee71da616.zip | |
3.2.1
Diffstat (limited to 'src/main/java/me/shedaniel/rei/plugin/brewing')
| -rw-r--r-- | src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingCategory.java | 23 | ||||
| -rw-r--r-- | src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingDisplay.java | 45 |
2 files changed, 39 insertions, 29 deletions
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 b17c0066d..466ab9c2c 100644 --- a/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingCategory.java +++ b/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingCategory.java @@ -8,24 +8,21 @@ package me.shedaniel.rei.plugin.brewing; import me.shedaniel.math.api.Point; import me.shedaniel.math.api.Rectangle; import com.mojang.blaze3d.systems.RenderSystem; +import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.RecipeCategory; -import me.shedaniel.rei.api.Renderer; +import me.shedaniel.rei.gui.widget.EntryWidget; import me.shedaniel.rei.gui.widget.RecipeBaseWidget; -import me.shedaniel.rei.gui.widget.SlotWidget; import me.shedaniel.rei.gui.widget.Widget; import me.shedaniel.rei.plugin.DefaultPlugin; import net.minecraft.block.Blocks; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.GuiLighting; import net.minecraft.client.resource.language.I18n; -import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import net.minecraft.util.Formatting; 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; @@ -38,8 +35,8 @@ public class DefaultBrewingCategory implements RecipeCategory<DefaultBrewingDisp } @Override - public Renderer getIcon() { - return Renderer.fromItemStack(new ItemStack(Blocks.BREWING_STAND)); + public EntryStack getLogo() { + return EntryStack.create(Blocks.BREWING_STAND); } @Override @@ -63,12 +60,12 @@ public class DefaultBrewingCategory implements RecipeCategory<DefaultBrewingDisp blit(startPoint.x + 44, startPoint.y + 28, 103, 163, width, 4); } })); - 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), 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)); + widgets.add(EntryWidget.create(startPoint.x + 1, startPoint.y + 1).entry(EntryStack.create(Items.BLAZE_POWDER)).noBackground()); + widgets.add(EntryWidget.create(startPoint.x + 40, startPoint.y + 1).entries(recipeDisplay.getInputEntries().get(0)).noBackground()); + widgets.add(EntryWidget.create(startPoint.x + 63, startPoint.y + 1).entries(recipeDisplay.getInputEntries().get(1)).noBackground()); + widgets.add(EntryWidget.create(startPoint.x + 40, startPoint.y + 35).entries(recipeDisplay.getOutput(0)).noBackground()); + widgets.add(EntryWidget.create(startPoint.x + 63, startPoint.y + 42).entries(recipeDisplay.getOutput(1)).noBackground()); + widgets.add(EntryWidget.create(startPoint.x + 86, startPoint.y + 35).entries(recipeDisplay.getOutput(2)).noBackground()); return widgets; } diff --git a/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingDisplay.java b/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingDisplay.java index 5a091e42b..3b8023779 100644 --- a/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingDisplay.java +++ b/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingDisplay.java @@ -6,36 +6,49 @@ package me.shedaniel.rei.plugin.brewing; import com.google.common.collect.Lists; +import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.RecipeDisplay; import me.shedaniel.rei.plugin.DefaultPlugin; -import net.minecraft.block.Blocks; +import net.minecraft.client.resource.language.I18n; import net.minecraft.item.ItemStack; +import net.minecraft.item.PotionItem; import net.minecraft.recipe.Ingredient; +import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; public class DefaultBrewingDisplay implements RecipeDisplay { - private ItemStack input, output; - private Ingredient reactant; + private EntryStack input, output; + private List<EntryStack> reactant; public DefaultBrewingDisplay(ItemStack input, Ingredient reactant, ItemStack output) { - this.input = input; - this.reactant = reactant; - this.output = output; + this.input = EntryStack.create(input).setting(EntryStack.Settings.TOOLTIP_APPEND_EXTRA, stack -> Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.brewing.input"))); + if (this.input.getItem() instanceof PotionItem) + this.input = this.input.setting(EntryStack.Settings.CHECK_TAGS, EntryStack.Settings.TRUE); + this.reactant = new ArrayList<>(); + for (ItemStack stack : reactant.getStackArray()) { + EntryStack entryStack = EntryStack.create(stack); + if (stack.getItem() instanceof PotionItem) + entryStack.setting(EntryStack.Settings.CHECK_TAGS, EntryStack.Settings.TRUE); + entryStack.setting(EntryStack.Settings.TOOLTIP_APPEND_EXTRA, s -> Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.brewing.reactant"))); + this.reactant.add(entryStack); + } + this.output = EntryStack.create(output).setting(EntryStack.Settings.TOOLTIP_APPEND_EXTRA, stack -> Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.brewing.result"))); + if (this.output.getItem() instanceof PotionItem) + this.output = this.output.setting(EntryStack.Settings.CHECK_TAGS, EntryStack.Settings.TRUE); } @Override - public List<List<ItemStack>> getInput() { - return Lists.newArrayList(Collections.singletonList(input), Arrays.asList(reactant.getMatchingStacksClient())); + public List<List<EntryStack>> getInputEntries() { + return Lists.newArrayList(Collections.singletonList(input), reactant); } @Override - public List<ItemStack> getOutput() { + public List<EntryStack> getOutputEntries() { return Collections.singletonList(output); } @@ -44,17 +57,17 @@ public class DefaultBrewingDisplay implements RecipeDisplay { return DefaultPlugin.BREWING; } - public List<ItemStack> getOutput(int slot) { - List<ItemStack> stack = new ArrayList<>(); + public List<EntryStack> getOutput(int slot) { + List<EntryStack> stack = new ArrayList<>(); for (int i = 0; i < slot * 2; i++) - stack.add(new ItemStack(Blocks.AIR)); + stack.add(EntryStack.empty()); for (int i = 0; i < 6 - slot * 2; i++) - stack.addAll(getOutput()); + stack.addAll(getOutputEntries()); return stack; } @Override - public List<List<ItemStack>> getRequiredItems() { - return Collections.singletonList(Collections.singletonList(ItemStack.EMPTY)); + public List<List<EntryStack>> getRequiredEntries() { + return getInputEntries(); } } |
