aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/zeitheron/hammercore/client/utils/Scissors.java52
-rw-r--r--src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java7
-rw-r--r--src/main/java/me/shedaniel/rei/api/ClientHelper.java24
-rw-r--r--src/main/java/me/shedaniel/rei/api/Entry.java17
-rw-r--r--src/main/java/me/shedaniel/rei/api/EntryRegistry.java76
-rw-r--r--src/main/java/me/shedaniel/rei/api/EntryStack.java153
-rw-r--r--src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java18
-rw-r--r--src/main/java/me/shedaniel/rei/api/ObjectHolder.java22
-rw-r--r--src/main/java/me/shedaniel/rei/api/RecipeCategory.java16
-rw-r--r--src/main/java/me/shedaniel/rei/api/RecipeDisplay.java68
-rw-r--r--src/main/java/me/shedaniel/rei/api/RecipeHelper.java35
-rw-r--r--src/main/java/me/shedaniel/rei/api/Renderer.java18
-rw-r--r--src/main/java/me/shedaniel/rei/api/TransferRecipeDisplay.java26
-rw-r--r--src/main/java/me/shedaniel/rei/api/annotations/Experimental.java17
-rw-r--r--src/main/java/me/shedaniel/rei/api/annotations/Internal.java17
-rw-r--r--src/main/java/me/shedaniel/rei/api/annotations/ToBeRemoved.java17
-rw-r--r--src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java19
-rw-r--r--src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java (renamed from src/main/java/me/shedaniel/rei/gui/widget/SearchFieldWidget.java)17
-rw-r--r--src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java16
-rw-r--r--src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java19
-rw-r--r--src/main/java/me/shedaniel/rei/gui/credits/CreditsScreen.java2
-rw-r--r--src/main/java/me/shedaniel/rei/gui/renderers/SimpleRecipeRenderer.java94
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/CategoryBaseWidget.java2
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/ClickableLabelWidget.java14
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/DetailedButtonWidget.java3
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java323
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java195
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java25
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/PanelWidget.java111
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java71
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/SlotBaseWidget.java2
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/SlotWidget.java78
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/TabWidget.java20
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/Widget.java8
-rw-r--r--src/main/java/me/shedaniel/rei/impl/AbstractEntryStack.java78
-rw-r--r--src/main/java/me/shedaniel/rei/impl/BaseBoundsHandlerImpl.java30
-rw-r--r--src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java20
-rw-r--r--src/main/java/me/shedaniel/rei/impl/DisplayHelperImpl.java22
-rw-r--r--src/main/java/me/shedaniel/rei/impl/EmptyEntryStack.java96
-rw-r--r--src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java30
-rw-r--r--src/main/java/me/shedaniel/rei/impl/FluidEntry.java15
-rw-r--r--src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java186
-rw-r--r--src/main/java/me/shedaniel/rei/impl/ItemEntryStack.java158
-rw-r--r--src/main/java/me/shedaniel/rei/impl/ItemStackEntry.java15
-rw-r--r--src/main/java/me/shedaniel/rei/impl/ObjectHolderImpl.java51
-rw-r--r--src/main/java/me/shedaniel/rei/impl/RecipeHelperImpl.java49
-rw-r--r--src/main/java/me/shedaniel/rei/impl/ScreenHelper.java17
-rw-r--r--src/main/java/me/shedaniel/rei/mixin/MixinBrewingRecipeRegistry.java14
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java80
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultCategoryHandler.java22
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingCategory.java92
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingDisplay.java68
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingCategory.java23
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingDisplay.java45
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/campfire/DefaultCampfireCategory.java13
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/campfire/DefaultCampfireDisplay.java31
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/composting/DefaultCompostingCategory.java34
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/composting/DefaultCompostingDisplay.java32
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/cooking/DefaultCookingCategory.java (renamed from src/main/java/me/shedaniel/rei/plugin/smoking/DefaultSmokingCategory.java)77
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/cooking/DefaultCookingDisplay.java84
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingCategory.java14
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingDisplay.java10
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCustomDisplay.java20
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/crafting/DefaultShapedDisplay.java28
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/crafting/DefaultShapelessDisplay.java28
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/smelting/DefaultSmeltingCategory.java91
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/smelting/DefaultSmeltingDisplay.java68
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/smoking/DefaultSmokingDisplay.java69
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/stonecutting/DefaultStoneCuttingCategory.java11
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/stonecutting/DefaultStoneCuttingDisplay.java28
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/stripping/DefaultStrippingCategory.java13
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/stripping/DefaultStrippingDisplay.java20
-rw-r--r--src/main/java/me/shedaniel/rei/utils/CollectionUtils.java161
73 files changed, 2423 insertions, 1122 deletions
diff --git a/src/main/java/com/zeitheron/hammercore/client/utils/Scissors.java b/src/main/java/com/zeitheron/hammercore/client/utils/Scissors.java
deleted file mode 100644
index c32053447..000000000
--- a/src/main/java/com/zeitheron/hammercore/client/utils/Scissors.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.zeitheron.hammercore.client.utils;
-
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.util.Window;
-import org.lwjgl.opengl.GL11;
-
-/**
- * This is originally the part of Hammer Lib, repacked in REI with permission.
- * Adapted GL scissor for minecraft pixel resolution and adjusts (0;0) as left-top corner.
- *
- * @author Zeitheron
- */
-public class Scissors {
- /**
- * Starts the scissor test
- */
- public static void begin() {
- GL11.glEnable(GL11.GL_SCISSOR_TEST);
- }
-
- /**
- * Setup the scissor bounds
- *
- * @param x the top left x coordinates
- * @param y the top left y coordinates
- * @param width the width of the bounds
- * @param height the height of the bounds
- */
- public static void scissor(int x, int y, int width, int height) {
- Window window = MinecraftClient.getInstance().getWindow();
-
- int sw = window.getWidth();
- int sh = window.getHeight();
- float dw = window.getScaledWidth();
- float dh = window.getScaledHeight();
-
- x = Math.round(sw * (x / dw));
- y = Math.round(sh * (y / dh));
-
- width = Math.round(sw * (width / dw));
- height = Math.round(sh * (height / dh));
-
- GL11.glScissor(x, sh - height - y, width, height);
- }
-
- /**
- * Stops the scissor test
- */
- public static void end() {
- GL11.glDisable(GL11.GL_SCISSOR_TEST);
- }
-} \ No newline at end of file
diff --git a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
index 1b6d91e5b..dc65ed688 100644
--- a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
+++ b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
@@ -136,9 +136,10 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer {
registerClothEvents();
discoverPluginEntries();
- FabricLoader.getInstance().getAllMods().stream().map(ModContainer::getMetadata).filter(metadata -> metadata.containsCustomValue("roughlyenoughitems:plugins")).forEach(modMetadata -> {
- RoughlyEnoughItemsCore.LOGGER.error("[REI] REI plugin from " + modMetadata.getId() + " is not loaded because it is too old!");
- });
+ for (ModContainer modContainer : FabricLoader.getInstance().getAllMods()) {
+ if (modContainer.getMetadata().containsCustomValue("roughlyenoughitems:plugins"))
+ RoughlyEnoughItemsCore.LOGGER.error("[REI] REI plugin from " + modContainer.getMetadata().getId() + " is not loaded because it is too old!");
+ }
ClientSidePacketRegistry.INSTANCE.register(RoughlyEnoughItemsNetwork.CREATE_ITEMS_MESSAGE_PACKET, (packetContext, packetByteBuf) -> {
ItemStack stack = packetByteBuf.readItemStack();
diff --git a/src/main/java/me/shedaniel/rei/api/ClientHelper.java b/src/main/java/me/shedaniel/rei/api/ClientHelper.java
index 458379457..b72e86ea0 100644
--- a/src/main/java/me/shedaniel/rei/api/ClientHelper.java
+++ b/src/main/java/me/shedaniel/rei/api/ClientHelper.java
@@ -55,28 +55,40 @@ public interface ClientHelper {
void registerFabricKeyBinds();
/**
- * Tries to cheat items using either packets or commands.
+ * Tries to cheat stack using either packets or commands.
*
* @param stack the stack to cheat in
* @return whether it failed
*/
- boolean tryCheatingStack(ItemStack stack);
+ boolean tryCheatingEntry(EntryStack stack);
+
+ default boolean tryCheatingStack(ItemStack stack) {
+ return tryCheatingEntry(EntryStack.create(stack));
+ }
/**
- * Finds recipe for the item and opens the recipe screen.
+ * Finds recipe for the stack and opens the recipe screen.
*
* @param stack the stack to find recipe for
* @return whether the stack has any recipes to show
*/
- boolean executeRecipeKeyBind(ItemStack stack);
+ boolean executeRecipeKeyBind(EntryStack stack);
+
+ default boolean executeRecipeKeyBind(ItemStack stack) {
+ return executeRecipeKeyBind(EntryStack.create(stack));
+ }
/**
- * Finds usage for the item and opens the recipe screen.
+ * Finds usage for the stack and opens the recipe screen.
*
* @param stack the stack to find usage for
* @return whether the stack has any usages to show
*/
- boolean executeUsageKeyBind(ItemStack stack);
+ boolean executeUsageKeyBind(EntryStack stack);
+
+ default boolean executeUsageKeyBind(ItemStack stack) {
+ return executeUsageKeyBind(EntryStack.create(stack));
+ }
FabricKeyBinding getFocusSearchFieldKeyBinding();
diff --git a/src/main/java/me/shedaniel/rei/api/Entry.java b/src/main/java/me/shedaniel/rei/api/Entry.java
index fca8f9fd2..c0eb609bb 100644
--- a/src/main/java/me/shedaniel/rei/api/Entry.java
+++ b/src/main/java/me/shedaniel/rei/api/Entry.java
@@ -5,6 +5,7 @@
package me.shedaniel.rei.api;
+import me.shedaniel.rei.api.annotations.ToBeRemoved;
import me.shedaniel.rei.impl.FluidEntry;
import me.shedaniel.rei.impl.ItemStackEntry;
import net.minecraft.fluid.Fluid;
@@ -12,7 +13,9 @@ import net.minecraft.item.ItemStack;
import javax.annotation.Nullable;
-public interface Entry {
+@Deprecated
+@ToBeRemoved
+public interface Entry extends Cloneable {
@SuppressWarnings("deprecation")
static Entry create(ItemStack itemStack) {
return new ItemStackEntry(itemStack);
@@ -31,6 +34,18 @@ public interface Entry {
@Nullable
Fluid getFluid();
+ Entry clone();
+
+ default EntryStack toEntryStack() {
+ if (getEntryType() == Type.ITEM)
+ return EntryStack.create(getItemStack());
+ if (getEntryType() == Type.FLUID)
+ return EntryStack.create(getFluid());
+ return EntryStack.empty();
+ }
+
+ boolean equalsEntry(Entry other, boolean checkTags);
+
public static enum Type {
ITEM, FLUID
}
diff --git a/src/main/java/me/shedaniel/rei/api/EntryRegistry.java b/src/main/java/me/shedaniel/rei/api/EntryRegistry.java
index effd1c8a4..9a811a127 100644
--- a/src/main/java/me/shedaniel/rei/api/EntryRegistry.java
+++ b/src/main/java/me/shedaniel/rei/api/EntryRegistry.java
@@ -5,10 +5,13 @@
package me.shedaniel.rei.api;
+import me.shedaniel.rei.api.annotations.ToBeRemoved;
+import me.shedaniel.rei.utils.CollectionUtils;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+import java.util.Collections;
import java.util.List;
public interface EntryRegistry {
@@ -18,7 +21,17 @@ public interface EntryRegistry {
*
* @return an unmodifiable item list
*/
- List<Entry> getEntryList();
+ @Deprecated
+ default List<Entry> getEntryList() {
+ return Collections.unmodifiableList(getModifiableEntryList());
+ }
+
+ /**
+ * Gets the current modifiable stacks list
+ *
+ * @return a stacks list
+ */
+ List<EntryStack> getStacksList();
/**
* Gets the current modifiable item list
@@ -26,7 +39,9 @@ public interface EntryRegistry {
* @return an modifiable item list
*/
@Deprecated
- List<Entry> getModifiableEntryList();
+ default List<Entry> getModifiableEntryList() {
+ return CollectionUtils.map(getStacksList(), EntryStack::toEntry);
+ }
/**
* Gets all possible stacks from an item
@@ -42,31 +57,66 @@ public interface EntryRegistry {
* @param afterItem the stack to put after
* @param stack the stack to register
*/
- void registerItemStack(Item afterItem, ItemStack stack);
+ @Deprecated
+ default void registerItemStack(Item afterItem, ItemStack stack) {
+ registerEntryAfter(EntryStack.create(afterItem), EntryStack.create(stack));
+ }
- void registerFluid(Fluid fluid);
+ @Deprecated
+ default void registerFluid(Fluid fluid) {
+ registerEntry(EntryStack.create(fluid));
+ }
+
+ default void registerEntry(EntryStack stack) {
+ registerEntryAfter(null, stack);
+ }
+
+ void registerEntryAfter(EntryStack afterEntry, EntryStack stack);
+
+ @ToBeRemoved
+ @Deprecated
+ default void registerItemStack(Item afterItem, ItemStack... stacks) {
+ EntryStack afterStack = EntryStack.create(afterItem);
+ for (int i = stacks.length - 1; i >= 0; i--) {
+ ItemStack stack = stacks[i];
+ if (stack != null && !stack.isEmpty())
+ registerEntryAfter(afterStack, EntryStack.create(stack));
+ }
+ }
/**
* Registers multiple stacks to the item list
*
- * @param afterItem the stack to put after
- * @param stacks the stacks to register
+ * @param afterStack the stack to put after
+ * @param stacks the stacks to register
*/
- default void registerItemStack(Item afterItem, ItemStack... stacks) {
+ default void registerEntriesAfter(EntryStack afterStack, EntryStack... stacks) {
for (int i = stacks.length - 1; i >= 0; i--) {
- ItemStack stack = stacks[i];
+ EntryStack stack = stacks[i];
if (stack != null && !stack.isEmpty())
- registerItemStack(afterItem, stack);
+ registerEntryAfter(afterStack, stack);
}
}
+ @ToBeRemoved
+ @Deprecated
+ default void registerItemStack(ItemStack... stacks) {
+ registerItemStack(null, stacks);
+ }
+
/**
* Registers multiple stacks to the item list
*
* @param stacks the stacks to register
*/
- default void registerItemStack(ItemStack... stacks) {
- registerItemStack(null, stacks);
+ default void registerEntries(EntryStack... stacks) {
+ registerEntriesAfter(null, stacks);
+ }
+
+ @ToBeRemoved
+ @Deprecated
+ default boolean alreadyContain(ItemStack stack) {
+ return alreadyContain(EntryStack.create(stack));
}
/**
@@ -75,8 +125,8 @@ public interface EntryRegistry {
* @param stack the stack to check
* @return whether the stack has been registered
*/
- default boolean alreadyContain(ItemStack stack) {
- return getEntryList().stream().filter(entry -> entry.getEntryType() == Entry.Type.ITEM).anyMatch(entry -> ItemStack.areEqualIgnoreDamage(stack, entry.getItemStack()));
+ default boolean alreadyContain(EntryStack stack) {
+ return CollectionUtils.anyMatchEqualsAll(getStacksList(), stack);
}
}
diff --git a/src/main/java/me/shedaniel/rei/api/EntryStack.java b/src/main/java/me/shedaniel/rei/api/EntryStack.java
new file mode 100644
index 000000000..3baa4e5e0
--- /dev/null
+++ b/src/main/java/me/shedaniel/rei/api/EntryStack.java
@@ -0,0 +1,153 @@
+/*
+ * Roughly Enough Items by Danielshe.
+ * Licensed under the MIT License.
+ */
+
+package me.shedaniel.rei.api;
+
+import me.shedaniel.math.api.Rectangle;
+import me.shedaniel.rei.api.annotations.ToBeRemoved;
+import me.shedaniel.rei.gui.widget.QueuedTooltip;
+import me.shedaniel.rei.impl.EmptyEntryStack;
+import me.shedaniel.rei.impl.FluidEntryStack;
+import me.shedaniel.rei.impl.ItemEntryStack;
+import net.minecraft.block.Block;
+import net.minecraft.fluid.Fluid;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemConvertible;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.Identifier;
+
+import javax.annotation.Nullable;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import java.util.function.Function;
+import java.util.function.Supplier;
+
+public interface EntryStack {
+
+ static EntryStack empty() {
+ return EmptyEntryStack.EMPTY;
+ }
+
+ static EntryStack create(Fluid fluid) {
+ return create(fluid, 1000);
+ }
+
+ static EntryStack create(Fluid fluid, int amount) {
+ return new FluidEntryStack(fluid, amount);
+ }
+
+ static EntryStack create(ItemStack stack) {
+ return new ItemEntryStack(stack);
+ }
+
+ static EntryStack create(ItemConvertible item) {
+ return new ItemEntryStack(new ItemStack(item));
+ }
+
+ st