aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2020-08-28 20:03:35 +0800
committershedaniel <daniel@shedaniel.me>2020-08-28 20:03:35 +0800
commit89f7cc5fc35591655dfb849b318ebff69c23e5aa (patch)
tree32818c95da0af4ee2dd3bb5d5d8fdeb2fb1b29ca
parent614a8ef48584740ddbcd6ece4f7e7bbe139e755b (diff)
downloadRoughlyEnoughItems-89f7cc5fc35591655dfb849b318ebff69c23e5aa.tar.gz
RoughlyEnoughItems-89f7cc5fc35591655dfb849b318ebff69c23e5aa.tar.bz2
RoughlyEnoughItems-89f7cc5fc35591655dfb849b318ebff69c23e5aa.zip
Beacon Payment category (Close #406)
Signed-off-by: shedaniel <daniel@shedaniel.me>
-rw-r--r--RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/BuiltinPlugin.java1
-rw-r--r--RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java10
-rw-r--r--RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon_payment/DefaultBeaconPaymentCategory.java183
-rw-r--r--RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon_payment/DefaultBeaconPaymentDisplay.java67
-rwxr-xr-xsrc/main/resources/assets/roughlyenoughitems/lang/en_us.json1
5 files changed, 261 insertions, 1 deletions
diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/BuiltinPlugin.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/BuiltinPlugin.java
index 49a9b7746..ca9c60085 100644
--- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/BuiltinPlugin.java
+++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/BuiltinPlugin.java
@@ -47,6 +47,7 @@ public interface BuiltinPlugin {
ResourceLocation FUEL = new ResourceLocation("minecraft", "plugins/fuel");
ResourceLocation SMITHING = new ResourceLocation("minecraft", "plugins/smithing");
ResourceLocation BEACON = new ResourceLocation("minecraft", "plugins/beacon");
+ ResourceLocation BEACON_PAYMENT = new ResourceLocation("minecraft", "plugins/beacon_payment");
ResourceLocation TILLING = new ResourceLocation("minecraft", "plugins/tilling");
ResourceLocation PATHING = new ResourceLocation("minecraft", "plugins/pathing");
ResourceLocation INFO = new ResourceLocation("roughlyenoughitems", "plugins/information");
diff --git a/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java b/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java
index 51df3e7a3..0da32a6cc 100644
--- a/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java
+++ b/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java
@@ -33,6 +33,8 @@ import me.shedaniel.rei.api.plugins.REIPluginV0;
import me.shedaniel.rei.plugin.autocrafting.DefaultRecipeBookHandler;
import me.shedaniel.rei.plugin.beacon.DefaultBeaconBaseCategory;
import me.shedaniel.rei.plugin.beacon.DefaultBeaconBaseDisplay;
+import me.shedaniel.rei.plugin.beacon_payment.DefaultBeaconPaymentCategory;
+import me.shedaniel.rei.plugin.beacon_payment.DefaultBeaconPaymentDisplay;
import me.shedaniel.rei.plugin.blasting.DefaultBlastingDisplay;
import me.shedaniel.rei.plugin.brewing.DefaultBrewingCategory;
import me.shedaniel.rei.plugin.brewing.DefaultBrewingDisplay;
@@ -75,6 +77,7 @@ import net.minecraft.core.Registry;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
+import net.minecraft.tags.ItemTags;
import net.minecraft.tags.Tag;
import net.minecraft.util.LazyLoadedValue;
import net.minecraft.util.Mth;
@@ -113,6 +116,7 @@ public class DefaultPlugin implements REIPluginV0, BuiltinPlugin {
public static final ResourceLocation FUEL = BuiltinPlugin.FUEL;
public static final ResourceLocation SMITHING = BuiltinPlugin.SMITHING;
public static final ResourceLocation BEACON = BuiltinPlugin.BEACON;
+ public static final ResourceLocation BEACON_PAYMENT = BuiltinPlugin.BEACON_PAYMENT;
public static final ResourceLocation TILLING = BuiltinPlugin.TILLING;
public static final ResourceLocation PATHING = BuiltinPlugin.PATHING;
public static final ResourceLocation INFO = BuiltinPlugin.INFO;
@@ -210,6 +214,7 @@ public class DefaultPlugin implements REIPluginV0, BuiltinPlugin {
new DefaultStrippingCategory(),
new DefaultSmithingCategory(),
new DefaultBeaconBaseCategory(),
+ new DefaultBeaconPaymentCategory(),
new DefaultTillingCategory(),
new DefaultPathingCategory(),
new DefaultInformationCategory()
@@ -272,6 +277,7 @@ public class DefaultPlugin implements REIPluginV0, BuiltinPlugin {
recipeHelper.registerDisplay(new DefaultPathingDisplay(EntryStack.create(set.getKey()), EntryStack.create(set.getValue().getBlock())));
});
recipeHelper.registerDisplay(new DefaultBeaconBaseDisplay(CollectionUtils.map(Lists.newArrayList(BlockTags.BEACON_BASE_BLOCKS.getValues()), ItemStack::new)));
+ recipeHelper.registerDisplay(new DefaultBeaconPaymentDisplay(CollectionUtils.map(Lists.newArrayList(ItemTags.BEACON_PAYMENT_ITEMS.getValues()), ItemStack::new)));
}
@Override
@@ -327,13 +333,14 @@ public class DefaultPlugin implements REIPluginV0, BuiltinPlugin {
recipeHelper.registerWorkingStations(SMELTING, EntryStack.create(Items.FURNACE));
recipeHelper.registerWorkingStations(SMOKING, EntryStack.create(Items.SMOKER));
recipeHelper.registerWorkingStations(BLASTING, EntryStack.create(Items.BLAST_FURNACE));
- recipeHelper.registerWorkingStations(CAMPFIRE, EntryStack.create(Items.CAMPFIRE));
+ recipeHelper.registerWorkingStations(CAMPFIRE, EntryStack.create(Items.CAMPFIRE), EntryStack.create(Items.SOUL_CAMPFIRE));
recipeHelper.registerWorkingStations(FUEL, EntryStack.create(Items.FURNACE), EntryStack.create(Items.SMOKER), EntryStack.create(Items.BLAST_FURNACE));
recipeHelper.registerWorkingStations(BREWING, EntryStack.create(Items.BREWING_STAND));
recipeHelper.registerWorkingStations(STONE_CUTTING, EntryStack.create(Items.STONECUTTER));
recipeHelper.registerWorkingStations(COMPOSTING, EntryStack.create(Items.COMPOSTER));
recipeHelper.registerWorkingStations(SMITHING, EntryStack.create(Items.SMITHING_TABLE));
recipeHelper.registerWorkingStations(BEACON, EntryStack.create(Items.BEACON));
+ recipeHelper.registerWorkingStations(BEACON_PAYMENT, EntryStack.create(Items.BEACON));
Tag<Item> axes = Minecraft.getInstance().getConnection().getTags().getItems().getTag(new ResourceLocation("fabric", "axes"));
if (axes != null) {
for (Item item : axes.getValues()) {
@@ -355,6 +362,7 @@ public class DefaultPlugin implements REIPluginV0, BuiltinPlugin {
recipeHelper.removeAutoCraftButton(FUEL);
recipeHelper.removeAutoCraftButton(COMPOSTING);
recipeHelper.removeAutoCraftButton(BEACON);
+ recipeHelper.removeAutoCraftButton(BEACON_PAYMENT);
recipeHelper.removeAutoCraftButton(INFO);
recipeHelper.registerScreenClickArea(new Rectangle(88, 32, 28, 23), CraftingScreen.class, CRAFTING);
recipeHelper.registerScreenClickArea(new Rectangle(137, 29, 10, 13), InventoryScreen.class, CRAFTING);
diff --git a/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon_payment/DefaultBeaconPaymentCategory.java b/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon_payment/DefaultBeaconPaymentCategory.java
new file mode 100644
index 000000000..156f83915
--- /dev/null
+++ b/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon_payment/DefaultBeaconPaymentCategory.java
@@ -0,0 +1,183 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020 shedaniel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.shedaniel.rei.plugin.beacon_payment;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.client.resources.language.I18n;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.util.Mth;
+import net.minecraft.world.level.block.Blocks;
+import com.mojang.blaze3d.vertex.PoseStack;
+
+import me.shedaniel.clothconfig2.ClothConfigInitializer;
+import me.shedaniel.clothconfig2.api.ScissorsHandler;
+import me.shedaniel.clothconfig2.api.ScrollingContainer;
+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.Slot;
+import me.shedaniel.rei.api.widgets.Widgets;
+import me.shedaniel.rei.gui.entries.RecipeEntry;
+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 org.jetbrains.annotations.NotNull;
+
+import com.google.common.collect.Lists;
+import java.util.List;
+import java.util.Objects;
+
+public class DefaultBeaconPaymentCategory implements RecipeCategory<DefaultBeaconPaymentDisplay> {
+ @Override
+ public @NotNull ResourceLocation getIdentifier() {
+ return DefaultPlugin.BEACON_PAYMENT;
+ }
+
+ @Override
+ public @NotNull String getCategoryName() {
+ return I18n.get("category.rei.beacon_payment");
+ }
+
+ @Override
+ public @NotNull EntryStack getLogo() {
+ return EntryStack.create(Blocks.BEACON);
+ }
+
+ @Override
+ public @NotNull RecipeEntry getSimpleRenderer(DefaultBeaconPaymentDisplay recipe) {
+ String name = getCategoryName();
+ return new RecipeEntry() {
+ @Override
+ public int getHeight() {
+ return 10 + Minecraft.getInstance().font.lineHeight;
+ }
+
+ @Override
+ public void render(PoseStack matrices, Rectangle rectangle, int mouseX, int mouseY, float delta) {
+ Minecraft.getInstance().font.draw(matrices, name, rectangle.x + 5, rectangle.y + 6, -1);
+ }
+ };
+ }
+
+ @Override
+ public @NotNull List<Widget> setupDisplay(DefaultBeaconPaymentDisplay display, Rectangle bounds) {
+ List<Widget> widgets = Lists.newArrayList();
+ 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(Widgets.createSlotBase(rectangle));
+ widgets.add(new ScrollableSlotsWidget(rectangle, CollectionUtils.map(display.getEntries(), t -> Widgets.createSlot(new Point(0, 0)).disableBackground().entry(t))));
+ return widgets;
+ }
+
+ @Override
+ public int getDisplayHeight() {
+ return 140;
+ }
+
+ @Override
+ public int getFixedRecipesPerPage() {
+ return 1;
+ }
+
+ private static class ScrollableSlotsWidget extends WidgetWithBounds {
+ private Rectangle bounds;
+ private List<Slot> widgets;
+ private final ScrollingContainer scrolling = new ScrollingContainer() {
+ @Override
+ public Rectangle getBounds() {
+ Rectangle bounds = ScrollableSlotsWidget.this.getBounds();
+ return new Rectangle(bounds.x + 1, bounds.y + 1, bounds.width - 2, bounds.height - 2);
+ }
+
+ @Override
+ public int getMaxScrollHeight() {
+ return Mth.ceil(widgets.size() / 8f) * 18;
+ }
+ };
+
+ public ScrollableSlotsWidget(Rectangle bounds, List<Slot> widgets) {
+ this.bounds = Objects.requireNonNull(bounds);
+ this.widgets = Lists.newArrayList(widgets);
+ }
+
+ @Override
+ public boolean mouseScrolled(double double_1, double double_2, double double_3) {
+ if (containsMouse(double_1, double_2)) {
+ scrolling.offset(ClothConfigInitializer.getScrollStep() * -double_3, true);
+ return true;
+ }
+ return false;
+ }
+
+ @NotNull
+ @Override
+ public Rectangle getBounds() {
+ return bounds;
+ }
+
+ @Override
+ public boolean mouseClicked(double mouseX, double mouseY, int button) {
+ if (scrolling.updateDraggingState(mouseX, mouseY, button))
+ return true;
+ return super.mouseClicked(mouseX, mouseY, button);
+ }
+
+ @Override
+ public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
+ if (scrolling.mouseDragged(mouseX, mouseY, button, deltaX, deltaY))
+ return true;
+ return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
+ }
+
+ @Override
+ public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ scrolling.updatePosition(delta);
+ Rectangle innerBounds = scrolling.getScissorBounds();
+ ScissorsHandler.INSTANCE.scissor(innerBounds);
+ for (int y = 0; y < Mth.ceil(widgets.size() / 8f); y++) {
+ for (int x = 0; x < 8; x++) {
+ int index = y * 8 + x;
+ if (widgets.size() <= index)
+ break;
+ Slot widget = widgets.get(index);
+ widget.getBounds().setLocation(bounds.x + 1 + x * 18, (int) (bounds.y + 1 + y * 18 - scrolling.scrollAmount));
+ widget.render(matrices, mouseX, mouseY, delta);
+ }
+ }
+ ScissorsHandler.INSTANCE.removeLastScissor();
+ ScissorsHandler.INSTANCE.scissor(scrolling.getBounds());
+ scrolling.renderScrollBar(0xff000000, 1, REIHelper.getInstance().isDarkThemeEnabled() ? 0.8f : 1f);
+ ScissorsHandler.INSTANCE.removeLastScissor();
+ }
+
+ @Override
+ public List<? extends GuiEventListener> children() {
+ return widgets;
+ }
+ }
+}
diff --git a/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon_payment/DefaultBeaconPaymentDisplay.java b/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon_payment/DefaultBeaconPaymentDisplay.java
new file mode 100644
index 000000000..34eca7444
--- /dev/null
+++ b/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon_payment/DefaultBeaconPaymentDisplay.java
@@ -0,0 +1,67 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020 shedaniel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.shedaniel.rei.plugin.beacon_payment;
+
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.world.item.ItemStack;
+
+import me.shedaniel.rei.api.EntryStack;
+import me.shedaniel.rei.api.RecipeDisplay;
+import me.shedaniel.rei.plugin.DefaultPlugin;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Collections;
+import java.util.List;
+
+@Environment(EnvType.CLIENT)
+public class DefaultBeaconPaymentDisplay implements RecipeDisplay {
+
+ private List<EntryStack> entries;
+
+ public DefaultBeaconPaymentDisplay(List<ItemStack> entries) {
+ this.entries = EntryStack.ofItemStacks(entries);
+ }
+
+ @Override
+ public @NotNull List<List<EntryStack>> getInputEntries() {
+ return Collections.singletonList(entries);
+ }
+
+ public List<EntryStack> getEntries() {
+ return entries;
+ }
+
+ @Override
+ public @NotNull List<List<EntryStack>> getResultingEntries() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public @NotNull ResourceLocation getRecipeCategory() {
+ return DefaultPlugin.BEACON_PAYMENT;
+ }
+}
diff --git a/src/main/resources/assets/roughlyenoughitems/lang/en_us.json b/src/main/resources/assets/roughlyenoughitems/lang/en_us.json
index c673beb6b..008c51dfe 100755
--- a/src/main/resources/assets/roughlyenoughitems/lang/en_us.json
+++ b/src/main/resources/assets/roughlyenoughitems/lang/en_us.json
@@ -31,6 +31,7 @@
"category.rei.stripping": "Stripping",
"category.rei.smithing": "Smithing",
"category.rei.beacon_base": "Beacon Base",
+ "category.rei.beacon_payment": "Beacon Payment",
"category.rei.tilling": "Tilling",
"category.rei.pathing": "Pathing",
"category.rei.information": "Information",