aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/plugin
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2020-03-10 02:03:11 +0800
committershedaniel <daniel@shedaniel.me>2020-03-10 02:03:11 +0800
commit9ce069457bca016c8793c73844e5cc984deac365 (patch)
tree367195b8ec8402638a2d9af267eb45c2dd08ae89 /src/main/java/me/shedaniel/rei/plugin
parentb31a280413f5ec916f44fbd96d0690f8ce1a9186 (diff)
downloadRoughlyEnoughItems-9ce069457bca016c8793c73844e5cc984deac365.tar.gz
RoughlyEnoughItems-9ce069457bca016c8793c73844e5cc984deac365.tar.bz2
RoughlyEnoughItems-9ce069457bca016c8793c73844e5cc984deac365.zip
new widget api
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'src/main/java/me/shedaniel/rei/plugin')
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/beacon/DefaultBeaconBaseCategory.java25
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingCategory.java42
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/campfire/DefaultCampfireCategory.java44
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/composting/DefaultCompostingCategory.java32
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/cooking/DefaultCookingCategory.java47
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingCategory.java39
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/fuel/DefaultFuelCategory.java49
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/information/DefaultInformationCategory.java31
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/stonecutting/DefaultStoneCuttingCategory.java29
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/stripping/DefaultStrippingCategory.java30
10 files changed, 149 insertions, 219 deletions
diff --git a/src/main/java/me/shedaniel/rei/plugin/beacon/DefaultBeaconBaseCategory.java b/src/main/java/me/shedaniel/rei/plugin/beacon/DefaultBeaconBaseCategory.java
index a6ae15169..a64720862 100644
--- a/src/main/java/me/shedaniel/rei/plugin/beacon/DefaultBeaconBaseCategory.java
+++ b/src/main/java/me/shedaniel/rei/plugin/beacon/DefaultBeaconBaseCategory.java
@@ -28,12 +28,17 @@ import com.mojang.blaze3d.systems.RenderSystem;
import me.shedaniel.clothconfig2.ClothConfigInitializer;
import me.shedaniel.clothconfig2.api.ScissorsHandler;
import me.shedaniel.clothconfig2.gui.widget.DynamicEntryListWidget;
-import me.shedaniel.math.api.Rectangle;
+import me.shedaniel.math.Point;
+import me.shedaniel.math.Rectangle;
import me.shedaniel.math.impl.PointHelper;
import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeCategory;
+import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.entries.RecipeEntry;
-import me.shedaniel.rei.gui.widget.*;
+import me.shedaniel.rei.gui.widget.EntryWidget;
+import me.shedaniel.rei.gui.widget.QueuedTooltip;
+import me.shedaniel.rei.gui.widget.Widget;
+import me.shedaniel.rei.gui.widget.WidgetWithBounds;
import me.shedaniel.rei.plugin.DefaultPlugin;
import me.shedaniel.rei.utils.CollectionUtils;
import net.minecraft.block.Blocks;
@@ -48,7 +53,6 @@ import net.minecraft.util.math.MathHelper;
import org.jetbrains.annotations.Nullable;
import java.util.List;
-import java.util.function.Supplier;
public class DefaultBeaconBaseCategory implements RecipeCategory<DefaultBeaconBaseDisplay> {
@Override
@@ -82,19 +86,18 @@ public class DefaultBeaconBaseCategory implements RecipeCategory<DefaultBeaconBa
}
@Override
- public void render(Rectangle rectangle, int mouseX, int mouseY, float delta) {
+ public void render(me.shedaniel.math.api.Rectangle rectangle, int mouseX, int mouseY, float delta) {
MinecraftClient.getInstance().textRenderer.draw(name, rectangle.x + 5, rectangle.y + 6, -1);
}
};
}
@Override
- public List<Widget> setupDisplay(Supplier<DefaultBeaconBaseDisplay> recipeDisplaySupplier, Rectangle bounds) {
- DefaultBeaconBaseDisplay display = recipeDisplaySupplier.get();
+ public List<Widget> setupDisplay(DefaultBeaconBaseDisplay display, Rectangle bounds) {
List<Widget> widgets = Lists.newArrayList();
- widgets.add(EntryWidget.create(bounds.getCenterX() - 8, bounds.y + 3).entry(getLogo()));
+ widgets.add(Widgets.createSlot(new Point(bounds.getCenterX() - 8, bounds.y + 3)).entry(getLogo()));
Rectangle rectangle = new Rectangle(bounds.getCenterX() - (bounds.width / 2) - 1, bounds.y + 23, bounds.width + 2, bounds.height - 28);
- widgets.add(new SlotBaseWidget(rectangle));
+ widgets.add(Widgets.createSlotBase(rectangle));
widgets.add(new ScrollableSlotsWidget(rectangle, CollectionUtils.map(display.getEntries(), t -> EntryWidget.create(0, 0).noBackground().entry(t))));
return widgets;
}
@@ -110,7 +113,7 @@ public class DefaultBeaconBaseCategory implements RecipeCategory<DefaultBeaconBa
}
private static class ScrollableSlotsWidget extends WidgetWithBounds {
- private Rectangle bounds;
+ private me.shedaniel.math.api.Rectangle bounds;
private List<EntryWidget> widgets;
private double target;
private double scroll;
@@ -118,7 +121,7 @@ public class DefaultBeaconBaseCategory implements RecipeCategory<DefaultBeaconBa
private long duration;
public ScrollableSlotsWidget(Rectangle bounds, List<EntryWidget> widgets) {
- this.bounds = bounds;
+ this.bounds = new me.shedaniel.math.api.Rectangle(bounds);
this.widgets = Lists.newArrayList(widgets);
}
@@ -166,7 +169,7 @@ public class DefaultBeaconBaseCategory implements RecipeCategory<DefaultBeaconBa
}
@Override
- public Rectangle getBounds() {
+ public me.shedaniel.math.api.Rectangle getBounds() {
return bounds;
}
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 049c31608..c758886e0 100644
--- a/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingCategory.java
+++ b/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingCategory.java
@@ -23,12 +23,12 @@
package me.shedaniel.rei.plugin.brewing;
-import me.shedaniel.math.api.Point;
-import me.shedaniel.math.api.Rectangle;
+import com.google.common.collect.Lists;
+import me.shedaniel.math.Point;
+import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeCategory;
-import me.shedaniel.rei.gui.widget.EntryWidget;
-import me.shedaniel.rei.gui.widget.RecipeBaseWidget;
+import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.Widget;
import me.shedaniel.rei.plugin.DefaultPlugin;
import net.minecraft.block.Blocks;
@@ -38,10 +38,7 @@ import net.minecraft.item.Items;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
-import java.util.Collections;
-import java.util.LinkedList;
import java.util.List;
-import java.util.function.Supplier;
public class DefaultBrewingCategory implements RecipeCategory<DefaultBrewingDisplay> {
@@ -61,25 +58,22 @@ public class DefaultBrewingCategory implements RecipeCategory<DefaultBrewingDisp
}
@Override
- public List<Widget> setupDisplay(Supplier<DefaultBrewingDisplay> recipeDisplaySupplier, Rectangle bounds) {
- final DefaultBrewingDisplay recipeDisplay = recipeDisplaySupplier.get();
+ public List<Widget> setupDisplay(DefaultBrewingDisplay display, Rectangle bounds) {
Point startPoint = new Point(bounds.getCenterX() - 52, bounds.getCenterY() - 29);
- List<Widget> widgets = new LinkedList<>(Collections.singletonList(new RecipeBaseWidget(bounds) {
- @Override
- public void render(int mouseX, int mouseY, float delta) {
- super.render(mouseX, mouseY, delta);
- MinecraftClient.getInstance().getTextureManager().bindTexture(DefaultPlugin.getDisplayTexture());
- blit(startPoint.x, startPoint.y, 0, 108, 103, 59);
- int width = MathHelper.ceil(System.currentTimeMillis() / 250d % 18d);
- blit(startPoint.x + 44, startPoint.y + 28, 103, 163, width, 4);
- }
+ List<Widget> widgets = Lists.newArrayList();
+ widgets.add(Widgets.createRecipeBase(bounds));
+ widgets.add(Widgets.createDrawableWidget((helper, mouseX, mouseY, delta) -> {
+ MinecraftClient.getInstance().getTextureManager().bindTexture(DefaultPlugin.getDisplayTexture());
+ helper.blit(startPoint.x, startPoint.y, 0, 108, 103, 59);
+ int width = MathHelper.ceil(System.currentTimeMillis() / 250d % 18d);
+ helper.blit(startPoint.x + 44, startPoint.y + 28, 103, 163, width, 4);
}));
- widgets.add(EntryWidget.create(startPoint.x + 1, startPoint.y + 1).entry(EntryStack.create(Items.BLAZE_POWDER)).noBackground().markIsInput());
- widgets.add(EntryWidget.create(startPoint.x + 40, startPoint.y + 1).entries(recipeDisplay.getInputEntries().get(0)).noBackground().markIsInput());
- widgets.add(EntryWidget.create(startPoint.x + 63, startPoint.y + 1).entries(recipeDisplay.getInputEntries().get(1)).noBackground().markIsInput());
- widgets.add(EntryWidget.create(startPoint.x + 40, startPoint.y + 35).entries(recipeDisplay.getOutput(0)).noBackground().markIsOutput());
- widgets.add(EntryWidget.create(startPoint.x + 63, startPoint.y + 42).entries(recipeDisplay.getOutput(1)).noBackground().markIsOutput());
- widgets.add(EntryWidget.create(startPoint.x + 86, startPoint.y + 35).entries(recipeDisplay.getOutput(2)).noBackground().markIsOutput());
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entry(EntryStack.create(Items.BLAZE_POWDER)).disableBackground().markInput());
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 40, startPoint.y + 1)).entries(display.getInputEntries().get(0)).disableBackground().markInput());
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 63, startPoint.y + 1)).entries(display.getInputEntries().get(1)).disableBackground().markInput());
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 40, startPoint.y + 35)).entries(display.getOutput(0)).disableBackground().markOutput());
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 63, startPoint.y + 42)).entries(display.getOutput(1)).disableBackground().markOutput());
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 86, startPoint.y + 35)).entries(display.getOutput(2)).disableBackground().markOutput());
return widgets;
}
diff --git a/src/main/java/me/shedaniel/rei/plugin/campfire/DefaultCampfireCategory.java b/src/main/java/me/shedaniel/rei/plugin/campfire/DefaultCampfireCategory.java
index b4b7835dc..80439cc2c 100644
--- a/src/main/java/me/shedaniel/rei/plugin/campfire/DefaultCampfireCategory.java
+++ b/src/main/java/me/shedaniel/rei/plugin/campfire/DefaultCampfireCategory.java
@@ -23,27 +23,20 @@
package me.shedaniel.rei.plugin.campfire;
-import me.shedaniel.math.api.Point;
-import me.shedaniel.math.api.Rectangle;
+import com.google.common.collect.Lists;
+import me.shedaniel.math.Point;
+import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.EntryStack;
-import me.shedaniel.rei.api.REIHelper;
import me.shedaniel.rei.api.RecipeCategory;
-import me.shedaniel.rei.gui.widget.EntryWidget;
-import me.shedaniel.rei.gui.widget.RecipeArrowWidget;
-import me.shedaniel.rei.gui.widget.RecipeBaseWidget;
+import me.shedaniel.rei.api.widgets.Widgets;
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.resource.language.I18n;
import net.minecraft.util.Identifier;
-import net.minecraft.util.math.MathHelper;
import java.text.DecimalFormat;
-import java.util.Collections;
-import java.util.LinkedList;
import java.util.List;
-import java.util.function.Supplier;
public class DefaultCampfireCategory implements RecipeCategory<DefaultCampfireDisplay> {
@@ -63,26 +56,19 @@ public class DefaultCampfireCategory implements RecipeCategory<DefaultCampfireDi
}
@Override
- public List<Widget> setupDisplay(Supplier<DefaultCampfireDisplay> recipeDisplaySupplier, Rectangle bounds) {
+ public List<Widget> setupDisplay(DefaultCampfireDisplay display, Rectangle bounds) {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10);
- final double cookingTime = recipeDisplaySupplier.get().getCookTime();
+ final double cookingTime = display.getCookTime();
DecimalFormat df = new DecimalFormat("###.##");
- List<Widget> widgets = new LinkedList<>(Collections.singletonList(new RecipeBaseWidget(bounds) {
- @Override
- public void render(int mouseX, int mouseY, float delta) {
- super.render(mouseX, mouseY, delta);
- MinecraftClient.getInstance().getTextureManager().bindTexture(DefaultPlugin.getDisplayTexture());
- blit(startPoint.x, startPoint.y, 0, 177, 82, 34);
- int height = 14 - MathHelper.ceil(System.currentTimeMillis() / 250d % 14d);
- blit(startPoint.x + 2, startPoint.y + 31 + (3 - height), 82, 77 + (14 - height), 14, height);
- String text = I18n.translate("category.rei.campfire.time", df.format(cookingTime / 20d));
- int length = MinecraftClient.getInstance().textRenderer.getStringWidth(text);
- MinecraftClient.getInstance().textRenderer.draw(text, bounds.x + bounds.width - length - 5, bounds.y + 5, REIHelper.getInstance().isDarkThemeEnabled() ? 0xFFBBBBBB : 0xFF404040);
- }
- }));
- widgets.add(RecipeArrowWidget.create(new Point(startPoint.x + 24, startPoint.y + 8), true).time(cookingTime * 50));
- widgets.add(EntryWidget.create(startPoint.x + 1, startPoint.y + 1).entries(recipeDisplaySupplier.get().getInputEntries().get(0)).markIsInput());
- widgets.add(EntryWidget.create(startPoint.x + 61, startPoint.y + 9).entries(recipeDisplaySupplier.get().getOutputEntries()).noBackground().markIsOutput());
+ List<Widget> widgets = Lists.newArrayList();
+ widgets.add(Widgets.createRecipeBase(bounds));
+ widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 61, startPoint.y + 9)));
+ widgets.add(Widgets.createBurningFire(new Point(startPoint.x + 1, startPoint.y + 20)).animationDurationMS(10000));
+ widgets.add(Widgets.createLabel(new Point(bounds.x + bounds.width - 5, bounds.y + 5),
+ I18n.translate("category.rei.campfire.time", df.format(cookingTime / 20d))).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB));
+ widgets.add(Widgets.createArrow(new Point(startPoint.x + 24, startPoint.y + 8)).animationDurationTicks(cookingTime));
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(display.getInputEntries().get(0)).markInput());
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 9)).entries(display.getOutputEntries()).disableBackground().markOutput());
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 911b58aae..a7a91a399 100644
--- a/src/main/java/me/shedaniel/rei/plugin/composting/DefaultCompostingCategory.java
+++ b/src/main/java/me/shedaniel/rei/plugin/composting/DefaultCompostingCategory.java
@@ -24,14 +24,14 @@
package me.shedaniel.rei.plugin.composting;
import com.google.common.collect.Lists;
-import me.shedaniel.math.api.Point;
-import me.shedaniel.math.api.Rectangle;
+import me.shedaniel.math.Point;
+import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.EntryStack;
+import me.shedaniel.rei.api.REIHelper;
import me.shedaniel.rei.api.RecipeCategory;
+import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.entries.RecipeEntry;
-import me.shedaniel.rei.gui.widget.EntryWidget;
import me.shedaniel.rei.gui.widget.QueuedTooltip;
-import me.shedaniel.rei.gui.widget.RecipeBaseWidget;
import me.shedaniel.rei.gui.widget.Widget;
import me.shedaniel.rei.plugin.DefaultPlugin;
import net.minecraft.block.Blocks;
@@ -46,7 +46,6 @@ import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.function.Supplier;
public class DefaultCompostingCategory implements RecipeCategory<DefaultCompostingDisplay> {
@@ -80,41 +79,36 @@ public class DefaultCompostingCategory implements RecipeCategory<DefaultComposti
}
@Override
- public void render(Rectangle rectangle, int mouseX, int mouseY, float delta) {
+ public void render(me.shedaniel.math.api.Rectangle rectangle, int mouseX, int mouseY, float delta) {
MinecraftClient.getInstance().textRenderer.draw(I18n.translate("text.rei.composting.page", recipe.getPage() + 1), rectangle.x + 5, rectangle.y + 6, -1);
}
};
}
@Override
- public List<Widget> setupDisplay(Supplier<DefaultCompostingDisplay> recipeDisplaySupplier, Rectangle bounds) {
+ public List<Widget> setupDisplay(DefaultCompostingDisplay display, Rectangle bounds) {
List<Widget> widgets = Lists.newArrayList();
Point startingPoint = new Point(bounds.x + bounds.width - 55, bounds.y + 110);
- widgets.add(new RecipeBaseWidget(bounds) {
- @Override
- public void render(int mouseX, int mouseY, float partialTicks) {
- fillGradient(getBounds().x, getBounds().y, getBounds().getMaxX(), getBounds().getMaxY(), getInnerColor(), getInnerColor());
- MinecraftClient.getInstance().getTextureManager().bindTexture(DefaultPlugin.getDisplayTexture());
- this.blit(startingPoint.x, startingPoint.y + 3, 28, 221, 55, 26);
- }
- });
- List<EntryStack> stacks = new LinkedList<>(recipeDisplaySupplier.get().getItemsByOrder());
+ widgets.add(Widgets.createFilledRectangle(bounds, REIHelper.getInstance().isDarkThemeEnabled() ? -13750738 : -3750202));
+ List<EntryStack> stacks = new LinkedList<>(display.getItemsByOrder());
int i = 0;
for (int y = 0; y < 6; y++)
for (int x = 0; x < 8; x++) {
int finalI = i;
EntryStack entryStack = stacks.size() > i ? stacks.get(finalI) : EntryStack.empty();
if (entryStack.getType() != EntryStack.Type.EMPTY)
- for (Map.Entry<ItemConvertible, Float> entry : recipeDisplaySupplier.get().getInputMap().entrySet()) {
+ for (Map.Entry<ItemConvertible, Float> entry : display.getInputMap().entrySet()) {
if (entry.getKey().asItem().equals(entryStack.getItem())) {
entryStack = entryStack.setting(EntryStack.Settings.TOOLTIP_APPEND_EXTRA, s -> Collections.singletonList(I18n.translate("text.rei.composting.chance", MathHelper.fastFloor(entry.getValue() * 100))));
break;
}
}
- widgets.add(EntryWidget.create(bounds.getCenterX() - 72 + x * 18, bounds.y + 3 + y * 18).entry(entryStack).markIsInput());
+ widgets.add(Widgets.createSlot(new Point(bounds.getCenterX() - 72 + x * 18, bounds.y + 3 + y * 18)).entry(entryStack).markInput());
i++;
}
- widgets.add(EntryWidget.create(startingPoint.x + 33, startingPoint.y + 8).entries(recipeDisplaySupplier.get().getOutputEntries()).noBackground().markIsOutput());
+ widgets.add(Widgets.createArrow(new Point(startingPoint.x - 1, startingPoint.y + 7)));
+ widgets.add(Widgets.createResultSlotBackground(new Point(startingPoint.x + 33, startingPoint.y + 8)));
+ widgets.add(Widgets.createSlot(new Point(startingPoint.x + 33, startingPoint.y + 8)).entries(display.getOutputEntries()).disableBackground().markOutput());
return widgets;
}
diff --git a/src/main/java/me/shedaniel/rei/plugin/cooking/DefaultCookingCategory.java b/src/main/java/me/shedaniel/rei/plugin/cooking/DefaultCookingCategory.java
index 56a19d3d4..f4d049f8f 100644
--- a/src/main/java/me/shedaniel/rei/plugin/cooking/DefaultCookingCategory.java
+++ b/src/main/java/me/shedaniel/rei/plugin/cooking/DefaultCookingCategory.java
@@ -23,31 +23,24 @@
package me.shedaniel.rei.plugin.cooking;
+import com.google.common.collect.Lists;
import com.mojang.blaze3d.systems.RenderSystem;
import it.unimi.dsi.fastutil.ints.IntList;
-import me.shedaniel.math.api.Point;
-import me.shedaniel.math.api.Rectangle;
+import me.shedaniel.math.Point;
+import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.EntryStack;
-import me.shedaniel.rei.api.REIHelper;
import me.shedaniel.rei.api.TransferRecipeCategory;
+import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.entries.RecipeEntry;
import me.shedaniel.rei.gui.entries.SimpleRecipeEntry;
-import me.shedaniel.rei.gui.widget.EntryWidget;
-import me.shedaniel.rei.gui.widget.RecipeArrowWidget;
-import me.shedaniel.rei.gui.widget.RecipeBaseWidget;
import me.shedaniel.rei.gui.widget.Widget;
-import me.shedaniel.rei.plugin.DefaultPlugin;
-import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.util.Identifier;
-import net.minecraft.util.math.MathHelper;
import java.text.DecimalFormat;
import java.util.Collections;
-import java.util.LinkedList;
import java.util.List;
-import java.util.function.Supplier;
public class DefaultCookingCategory implements TransferRecipeCategory<DefaultCookingDisplay> {
private Identifier identifier;
@@ -61,7 +54,7 @@ public class DefaultCookingCategory implements TransferRecipeCategory<DefaultCoo
}
@Override
- public void renderRedSlots(List<Widget> widgets, Rectangle bounds, DefaultCookingDisplay display, IntList redSlots) {
+ public void renderRedSlots(List<Widget> widgets, me.shedaniel.math.api.Rectangle bounds, DefaultCookingDisplay display, IntList redSlots) {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 27);
RenderSystem.translatef(0, 0, 400);
if (redSlots.contains(0)) {
@@ -71,27 +64,19 @@ public class DefaultCookingCategory implements TransferRecipeCategory<DefaultCoo
}
@Override
- public List<Widget> setupDisplay(Supplier<DefaultCookingDisplay> recipeDisplaySupplier, Rectangle bounds) {
+ public List<Widget> setupDisplay(DefaultCookingDisplay display, Rectangle bounds) {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10);
- double cookingTime = recipeDisplaySupplier.get().getCookingTime();
+ double cookingTime = display.getCookingTime();
DecimalFormat df = new DecimalFormat("###.##");
- List<Widget> widgets = new LinkedList<>(Collections.singletonList(new RecipeBaseWidget(bounds) {
- @Override
- public void render(int mouseX, int mouseY, float delta) {
- super.render(mouseX, mouseY, delta);
- MinecraftClient.getInstance().getTextureManager().bindTexture(DefaultPlugin.getDisplayTexture());
- blit(startPoint.x, startPoint.y, 0, 177, 82, 34);
- int height = 14 - MathHelper.ceil((System.currentTimeMillis() / 250d % 14d) / 1f);
- blit(startPoint.x + 2, startPoint.y + 31 + (3 - height), 82, 77 + (14 - height), 14, height);
- String text = I18n.translate("category.rei.cooking.time&xp", df.format(recipeDisplaySupplier.get().getXp()), df.format(cookingTime / 20d));
- int length = MinecraftClient.getInstance().textRenderer.getStringWidth(text);
- MinecraftClient.getInstance().textRenderer.draw(text, bounds.x + bounds.width - length - 5, bounds.y + 5, REIHelper.getInstance().isDarkThemeEnabled() ? 0xFFBBBBBB : 0xFF404040);
-
- }
- }));
- widgets.add(RecipeArrowWidget.create(new Point(startPoint.x + 24, startPoint.y + 8), true).time(cookingTime * 50));
- widgets.add(EntryWidget.create(startPoint.x + 1, startPoint.y + 1).entries(recipeDisplaySupplier.get().getInputEntries().get(0)).markIsInput());
- widgets.add(EntryWidget.create(startPoint.x + 61, startPoint.y + 9).entries(recipeDisplaySupplier.get().getOutputEntries()).noBackground().markIsOutput());
+ List<Widget> widgets = Lists.newArrayList();
+ widgets.add(Widgets.createRecipeBase(bounds));
+ widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 61, startPoint.y + 9)));
+ widgets.add(Widgets.createBurningFire(new Point(startPoint.x + 1, startPoint.y + 20)).animationDurationMS(10000));
+ widgets.add(Widgets.createLabel(new Point(bounds.x + bounds.width - 5, bounds.y + 5),
+ I18n.translate("category.rei.cooking.time&xp", df.format(display.getXp()), df.format(cookingTime / 20d))).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB));
+ widgets.add(Widgets.createArrow(new Point(startPoint.x + 24, startPoint.y + 8)).animationDurationTicks(cookingTime));
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(display.getInputEntries().get(0)).markInput());
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 9)).entries(display.getOutputEntries()).disableBackground().markOutput());
return widgets;
}
diff --git a/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingCategory.java b/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingCategory.java
index b0c24b652..4839a0355 100644
--- a/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingCategory.java
+++ b/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingCategory.java
@@ -26,28 +26,25 @@ package me.shedaniel.rei.plugin.crafting;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.systems.RenderSystem;
import it.unimi.dsi.fastutil.ints.IntList;
-import me.shedaniel.math.api.Point;
-import me.shedaniel.math.api.Rectangle;
+import me.shedaniel.math.Point;
+import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.TransferRecipeCategory;
-import me.shedaniel.rei.gui.widget.EntryWidget;
-import me.shedaniel.rei.gui.widget.RecipeBaseWidget;
+import me.shedaniel.rei.api.widgets.Slot;
+import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.Widget;
import me.shedaniel.rei.impl.ScreenHelper;
import me.shedaniel.rei.plugin.DefaultPlugin;
import me.shedaniel.rei.server.ContainerInfo;
import me.shedaniel.rei.server.ContainerInfoHandler;
import net.minecraft.block.Blocks;
-import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.container.Container;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
-import java.util.Collections;
import java.util.List;
-import java.util.function.Supplier;
public class DefaultCraftingCategory implements TransferRecipeCategory<DefaultCraftingDisplay> {
@@ -73,35 +70,31 @@ public class DefaultCraftingCategory implements TransferRecipeCategory<DefaultCr
}
@Override
- public List<Widget> setupDisplay(Supplier<DefaultCraftingDisplay> recipeDisplaySupplier, Rectangle bounds) {
+ public List<Widget> setupDisplay(DefaultCraftingDisplay display, Rectangle bounds) {
Point startPoint = new Point(bounds.getCenterX() - 58, bounds.getCenterY() - 27);
- List<Widget> widgets = Lists.newLinkedList(Collections.singletonList(new RecipeBaseWidget(bounds) {
- @Override
- public void render(int mouseX, int mouseY, float delta) {
- super.render(mouseX, mouseY, delta);
- MinecraftClient.getInstance().getTextureManager().bindTexture(DefaultPlugin.getDisplayTexture());
- blit(startPoint.x, startPoint.y, 0, 0, 116, 54);
- }
- }));
- List<List<EntryStack>> input = recipeDisplaySupplier.get().getInputEntries();
- List<EntryWidget> slots = Lists.newArrayList();
+ List<Widget> widgets = Lists.newArrayList();
+ widgets.add(Widgets.createRecipeBase(bounds));
+ widgets.add(Widgets.createArrow(new Point(startPoint.x + 60, startPoint.y + 18)));
+ widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 95, startPoint.y + 19)));
+ List<List<EntryStack>> input = display.getInputEntries();
+ List<Slot> slots = Lists.newArrayList();
for (int y = 0; y < 3; y++)
for (int x = 0; x < 3; x++)
- slots.add(EntryWidget.create(startPoint.x + 1 + x * 18, startPoint.y + 1 + y * 18).markIsInput());
+ slots.add(Widgets.createSlot(new Point(startPoint.x + 1 + x * 18, startPoint.y + 1 + y * 18)).markInput());
for (int i = 0; i < input.size(); i++) {
- if (recipeDisplaySupplier.get() instanceof DefaultShapedDisplay) {
+ if (display instanceof DefaultShapedDisplay) {
if (!input.get(i).isEmpty())
- slots.get(getSlotWithSize(recipeDisplaySupplier.get(), i, 3)).entries(input.get(i));
+ slots.get(getSlotWithSize(display, i, 3)).entries(input.get(i));
} else if (!input.get(i).isEmpty())
slots.get(i).entries(input.get(i));
}
widgets.addAll(slots);
- widgets.add(EntryWidget.create(startPoint.x + 95, startPoint.y + 19).entries(recipeDisplaySupplier.get().getOutputEntries()).noBackground().markIsOutput());
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 95, startPoint.y + 19)).entries(display.getOutputEntries()).disableBackground().markOutput());
return widgets;
}
@Override
- public void renderRedSlots(List<Widget> widgets, Rectangle bounds, DefaultCraftingDisplay display, IntList redSlots) {
+ public void renderRedSlots(List<Widget> widgets, me.shedaniel.math.api.Rectangle bounds, DefaultCraftingDisplay display, IntList redSlots) {
ContainerInfo<Container> info = (ContainerInfo<Container>) ContainerInfoHandler.getContainerInfo(getIdentifier(), ScreenHelper.getLastContainerScreen().getContainer().getClass());
if (info == null)
return;
diff --git a/src/main/java/me/shedaniel/rei/plugin/fuel/DefaultFuelCategory.java b/src/main/java/me/shedaniel/rei/plugin/fuel/DefaultFuelCategory.java
index dae6ceeaf..f0e6f9666 100644
--- a/src/main/java/me/shedaniel/rei/plugin/fuel/DefaultFuelCategory.java
+++ b/src/main/java/me/shedaniel/rei/plugin/fuel/DefaultFuelCategory.java
@@ -23,29 +23,24 @@
package me.shedaniel.rei.plugin.fuel;
-import me.shedaniel.math.api.Point;
-import me.shedaniel.math.api.Rectangle;
+import com.google.common.collect.Lists;
+import me.shedaniel.math.Point;
import me.shedaniel.rei.api.EntryStack;
-import me.shedaniel.rei.api.REIHelper;
import me.shedaniel.rei.api.RecipeCategory;
+import me.shedaniel.rei.api.widgets.Slot;
+import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.entries.RecipeEntry;
-import me.shedaniel.rei.gui.widget.EntryWidget;
import me.shedaniel.rei.gui.widget.QueuedTooltip;
-import me.shedaniel.rei.gui.widget.RecipeBaseWidget;
import me.shedaniel.rei.gui.widget.Widget;
import me.shedaniel.rei.plugin.DefaultPlugin;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.item.Items;
import net.minecraft.util.Identifier;
-import net.minecraft.util.math.MathHelper;
import org.jetbrains.annotations.Nullable;
import java.text.DecimalFormat;
-import java.util.Collections;
-import java.util.LinkedList;
import java.util.List;
-import java.util.function.Supplier;
public class DefaultFuelCategory implements RecipeCategory<DefaultFuelDisplay> {
@@ -72,27 +67,21 @@ public class DefaultFuelCategory implements RecipeCategory<DefaultFuelDisplay> {
}
@Override
- public List<Widget> setupDisplay(Supplier<DefaultFuelDisplay> recipeDisplaySupplier, Rectangle bounds) {
+ public List<Widget> setupDisplay(DefaultFuelDisplay recipeDisplay, me.shedaniel.math.Rectangle bounds) {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 17);
- String burnItems = DECIMAL_FORMAT.format(recipeDisplaySupplier.get().getFuelTime() / 200d);
- List<Widget> widgets = new LinkedList<>(Collections.singletonList(new RecipeBaseWidget(bounds) {
- @Override
- public void render(int mouseX, int mouseY, float delta) {
- super.render(mouseX, mouseY, delta);
- MinecraftClient.getInstance().getTextureManager().bindTexture(DefaultPlugin.getDisplayTexture());
- blit(bounds.x + 5, startPoint.y, 0, 73, 18, 34);
- int height = MathHelper.ceil(System.currentTimeMillis() / 250d % 14d);
- blit(bounds.x + 7, startPoint.y + 12 + (3 - height), 82, 77 + (14 - height), 14, height);
- minecraft.textRenderer.draw(I18n.translate("category.rei.fuel.time.items", burnItems), bounds.x + 26, bounds.getMaxY() - 15, REIHelper.getInstance().isDarkThemeEnabled() ? 0xFFBBBBBB : 0xFF404040);
- }
- }));
- widgets.add(EntryWidget.create(bounds.x + 6, startPoint.y + 18).entries(recipeDisplaySupplier.get().getInputEntries().get(0)).markIsInput());
+ String burnItems = DECIMAL_FORMAT.format(recipeDisplay.getFuelTime() / 200d);
+ List<Widget> widgets = Lists.newArrayList();
+ widgets.add(Widgets.createRecipeBase(bounds));
+ widgets.add(Widgets.createLabel(new Point(bounds.x + 26, bounds.getMaxY() - 15), I18n.translate("category.rei.fuel.time.items", burnItems))
+ .color(0xFF404040, 0xFFBBBBBB).noShadow().leftAligned());
+ widgets.add(Widgets.createBurningFire(new Point(bounds.x + 6, startPoint.y + 1)).animationDurationTicks(recipeDisplay.getFuelTime()));
+ widgets.add(Widgets.createSlot(new Point(bounds.x + 6, startPoint.y + 18)).entries(recipeDisplay.getInputEntries().get(0)).markInput());
return widgets;
}
@Override
public RecipeEntry getSimpleRenderer(DefaultFuelDisplay recipe) {
- EntryWidget widget = EntryWidget.create(0, 0).entries(recipe.getInputEntries().get(0)).noBackground().noHighlight();
+ Slot slot = Widgets.createSlot(new Point(0, 0)).entries(recipe.getInputEntries().get(0)).disableBackground().disableHighlight();
String burnItems = DECIMAL_FORMAT.format(recipe.getFuelTime() / 200d);
return new RecipeEntry() {
@Override
@@ -103,16 +92,16 @@ public class DefaultFuelCategory implements RecipeCategory<DefaultFuelDisplay> {
@Nullable
@Override
public QueuedTooltip getTooltip(int mouseX, int mouseY) {
- if (widget.containsMouse(mouseX, mouseY))
- return widget.getCurrentTooltip(mouseX, mouseY);
+ if (slot.containsMouse(mouseX, mouseY))
+ return slot.getCurrentTooltip(mouseX, mouseY);
return null;
}
@Override
- public void render(Rectangle bounds, int mouseX, int mouseY, float delta) {
- widget.setZ(getZ() + 50);
- widget.getBounds().setLocation(bounds.x + 4, bounds.y + 2);
- widget.render(mouseX, mouseY, delta);
+ public void render(me.shedaniel.math.api.Rectangle bounds, int mouseX, int mouseY, float delta) {
+ slot.setZ(getZ() + 50);
+ slot.getBounds().setLocation(bounds.x + 4, bounds.y + 2);
+ slot.render(mouseX, mouseY, delta);
MinecraftClient.getInstance().textRenderer.drawWithShadow(I18n.translate("category.rei.fuel.time_short.items", burnItems), bounds.x + 25, bounds.y + 8, -1);
}
};
diff --git a/src/main/java/me/shedaniel/rei/plugin/information/DefaultInformationCategory.java b/src/main/java/me/shedaniel/rei/plugin/information/DefaultInformationCategory.java
index a3972c385..7240e8dbe 100644
--- a/