aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me
diff options
context:
space:
mode:
authorDanielshe <shekwancheung0528@gmail.com>2019-11-03 00:10:19 +0800
committerDanielshe <shekwancheung0528@gmail.com>2019-11-03 00:10:19 +0800
commiteb075596d26ad53c63adbec75bae8da4ff1e9851 (patch)
tree33d14ed1d07a3e89a9d0cbc2d562889f58b75729 /src/main/java/me
parent8856ab0fd0c103da1a495525884db5f4d34dcaee (diff)
downloadRoughlyEnoughItems-eb075596d26ad53c63adbec75bae8da4ff1e9851.tar.gz
RoughlyEnoughItems-eb075596d26ad53c63adbec75bae8da4ff1e9851.tar.bz2
RoughlyEnoughItems-eb075596d26ad53c63adbec75bae8da4ff1e9851.zip
3.2
Diffstat (limited to 'src/main/java/me')
-rw-r--r--src/main/java/me/shedaniel/rei/api/ClientHelper.java24
-rw-r--r--src/main/java/me/shedaniel/rei/api/Entry.java11
-rw-r--r--src/main/java/me/shedaniel/rei/api/EntryRegistry.java76
-rw-r--r--src/main/java/me/shedaniel/rei/api/EntryStack.java148
-rw-r--r--src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java4
-rw-r--r--src/main/java/me/shedaniel/rei/api/ObjectHolder.java17
-rw-r--r--src/main/java/me/shedaniel/rei/api/RecipeCategory.java16
-rw-r--r--src/main/java/me/shedaniel/rei/api/RecipeDisplay.java36
-rw-r--r--src/main/java/me/shedaniel/rei/api/RecipeHelper.java35
-rw-r--r--src/main/java/me/shedaniel/rei/api/Renderer.java17
-rw-r--r--src/main/java/me/shedaniel/rei/api/TransferRecipeDisplay.java26
-rw-r--r--src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java7
-rw-r--r--src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java2
-rw-r--r--src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.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/EntryListWidget.java194
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java186
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/SlotWidget.java23
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/TabWidget.java20
-rw-r--r--src/main/java/me/shedaniel/rei/impl/AbstractEntryStack.java73
-rw-r--r--src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java18
-rw-r--r--src/main/java/me/shedaniel/rei/impl/EmptyEntryStack.java91
-rw-r--r--src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java30
-rw-r--r--src/main/java/me/shedaniel/rei/impl/FluidEntry.java3
-rw-r--r--src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java181
-rw-r--r--src/main/java/me/shedaniel/rei/impl/ItemEntryStack.java153
-rw-r--r--src/main/java/me/shedaniel/rei/impl/ItemStackEntry.java5
-rw-r--r--src/main/java/me/shedaniel/rei/impl/ObjectHolderImpl.java46
-rw-r--r--src/main/java/me/shedaniel/rei/impl/RecipeHelperImpl.java49
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java52
-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.java67
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingCategory.java17
-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.java15
-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.java28
-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)78
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/cooking/DefaultCookingDisplay.java79
-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.java28
-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.java67
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/smoking/DefaultSmokingDisplay.java68
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/stonecutting/DefaultStoneCuttingCategory.java6
-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
53 files changed, 1686 insertions, 860 deletions
diff --git a/src/main/java/me/shedaniel/rei/api/ClientHelper.java b/src/main/java/me/shedaniel/rei/api/ClientHelper.java
index 160777fee..b72e86ea0 100644
--- a/src/main/java/me/shedaniel/rei/api/ClientHelper.java
+++ b/src/main/java/me/shedaniel/rei/api/ClientHelper.java
@@ -55,39 +55,39 @@ public interface ClientHelper {
void registerFabricKeyBinds();
/**
- * Tries to cheat entry using either packets or commands.
+ * Tries to cheat stack using either packets or commands.
*
- * @param stack the entry to cheat in
+ * @param stack the stack to cheat in
* @return whether it failed
*/
- boolean tryCheatingEntry(Entry entry);
+ boolean tryCheatingEntry(EntryStack stack);
default boolean tryCheatingStack(ItemStack stack) {
- return tryCheatingEntry(Entry.create(stack));
+ return tryCheatingEntry(EntryStack.create(stack));
}
/**
- * Finds recipe for the entry and opens the recipe screen.
+ * Finds recipe for the stack and opens the recipe screen.
*
- * @param entry the entry to find recipe for
+ * @param stack the stack to find recipe for
* @return whether the stack has any recipes to show
*/
- boolean executeRecipeKeyBind(Entry entry);
+ boolean executeRecipeKeyBind(EntryStack stack);
default boolean executeRecipeKeyBind(ItemStack stack) {
- return executeRecipeKeyBind(Entry.create(stack));
+ return executeRecipeKeyBind(EntryStack.create(stack));
}
/**
- * Finds usage for the entry and opens the recipe screen.
+ * Finds usage for the stack and opens the recipe screen.
*
- * @param entry the entry to find usage for
+ * @param stack the stack to find usage for
* @return whether the stack has any usages to show
*/
- boolean executeUsageKeyBind(Entry entry);
+ boolean executeUsageKeyBind(EntryStack stack);
default boolean executeUsageKeyBind(ItemStack stack) {
- return executeUsageKeyBind(Entry.create(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 9c494558b..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,6 +13,8 @@ import net.minecraft.item.ItemStack;
import javax.annotation.Nullable;
+@Deprecated
+@ToBeRemoved
public interface Entry extends Cloneable {
@SuppressWarnings("deprecation")
static Entry create(ItemStack itemStack) {
@@ -33,6 +36,14 @@ public interface Entry extends Cloneable {
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 {
diff --git a/src/main/java/me/shedaniel/rei/api/EntryRegistry.java b/src/main/java/me/shedaniel/rei/api/EntryRegistry.java
index effd1c8a4..dfa320bc9 100644
--- a/src/main/java/me/shedaniel/rei/api/EntryRegistry.java
+++ b/src/main/java/me/shedaniel/rei/api/EntryRegistry.java
@@ -5,11 +5,14 @@
package me.shedaniel.rei.api;
+import me.shedaniel.rei.api.annotations.ToBeRemoved;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+import java.util.Collections;
import java.util.List;
+import java.util.stream.Collectors;
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 getStacksList().stream().map(EntryStack::toEntry).collect(Collectors.toList());
+ }
/**
* 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 getStacksList().stream().anyMatch(entry -> stack.equalsAll(entry));
}
}
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..ef145a2d8
--- /dev/null
+++ b/src/main/java/me/shedaniel/rei/api/EntryStack.java
@@ -0,0 +1,148 @@
+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));
+ }
+
+ static EntryStack create(Block block) {
+ return new ItemEntryStack(new ItemStack(block));
+ }
+
+ Optional<Identifier> getIdentifier();
+
+ EntryStack.Type getType();
+
+ int getAmount();
+
+ void setAmount(int amount);
+
+ boolean isEmpty();
+
+ @ToBeRemoved
+ @Deprecated
+ Entry toEntry();
+
+ EntryStack copy();
+
+ Object getObject();
+
+ boolean equals(EntryStack stack, boolean ignoreTags, boolean ignoreAmount);
+
+ boolean equalsIgnoreTagsAndAmount(EntryStack stack);
+
+ boolean equalsIgnoreTags(EntryStack stack);
+
+ boolean equalsIgnoreAmount(EntryStack stack);
+
+ boolean equalsAll(EntryStack stack);
+
+ int getZ();
+
+ void setZ(int z);
+
+ default ItemStack getItemStack() {
+ if (getType() == Type.ITEM)
+ return (ItemStack) getObject();
+ return null;
+ }
+
+ default Item getItem() {
+ if (getType() == Type.ITEM)
+ return ((ItemStack) getObject()).getItem();
+ return null;
+ }
+
+ default Fluid getFluid() {
+ if (getType() == Type.FLUID)
+ return (Fluid) getObject();
+ return null;
+ }
+
+ <T> EntryStack setting(Settings<T> settings, T value);
+
+ <T> EntryStack removeSetting(Settings<T> settings);
+
+ EntryStack clearSettings();
+
+ default <T> EntryStack addSetting(Settings<T> settings, T value) {
+ return setting(settings, value);
+ }
+
+ <T> ObjectHolder<T> getSetting(Settings<T> settings);
+
+ @Nullable
+ QueuedTooltip getTooltip(int mouseX, int mouseY);
+
+ void render(Rectangle bounds, int mouseX, int mouseY, float delta);
+
+ public static enum Type {
+ ITEM, FLUID, EMPTY
+ }
+
+ public static class Settings<T> {
+ public static final Supplier<Boolean> TRUE = () -> true;
+ public static final Supplier<Boolean> FALSE = () -> false;
+ public static final Settings<Supplier<Boolean>> RENDER = new Settings(TRUE);
+ public static final Settings<Supplier<Boolean>> CHECK_TAGS = new Settings(FALSE);
+ public static final Settings<Supplier<Boolean>> TOOLTIP_ENABLED = new Settings(TRUE);
+ public static final Settings<Supplier<Boolean>> TOOLTIP_APPEND_MOD = new Settings(TRUE);
+ public static final Settings<Supplier<Boolean>> RENDER_COUNTS = new Settings(TRUE);
+ public static final Settings<Function<EntryStack, List<String>>> TOOLTIP_APPEND_EXTRA = new Settings<Function<EntryStack, List<String>>>(stack -> Collections.emptyList());
+ public static final Settings<Function<EntryStack, String>> COUNTS = new Settings<Function<EntryStack, String>>(stack -> null);
+
+ private T defaultValue;
+
+ public Settings(T defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ public T getDefaultValue() {
+ return defaultValue;
+ }
+
+ public static class Item {
+ public static final Settings<Supplier<Boolean>> RENDER_OVERLAY = new Settings(TRUE);
+
+ private Item() {
+ }
+ }
+ }
+}
diff --git a/src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java b/src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java
index 3d197f1cf..8200fcdc0 100644
--- a/src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java
+++ b/src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java
@@ -20,7 +20,7 @@ public interface LiveRecipeGenerator<T extends RecipeDisplay> {
return Optional.empty();
}
- default Optional<List<T>> getRecipeFor(Entry entry) {
+ default Optional<List<T>> getRecipeFor(EntryStack entry) {
return Optional.empty();
}
@@ -29,7 +29,7 @@ public interface LiveRecipeGenerator<T extends RecipeDisplay> {
return Optional.empty();
}
- default Optional<List<T>> getUsageFor(Entry entry) {
+ default Optional<List<T>> getUsageFor(EntryStack entry) {
return Optional.empty();
}
diff --git a/src/main/java/me/shedaniel/rei/api/ObjectHolder.java b/src/main/java/me/shedaniel/rei/api/ObjectHolder.java
new file mode 100644
index 000000000..f77fde6b9
--- /dev/null
+++ b/src/main/java/me/shedaniel/rei/api/ObjectHolder.java
@@ -0,0 +1,17 @@
+package me.shedaniel.rei.api;
+
+public interface ObjectHolder<T> {
+ int intValue();
+
+ long longValue();
+
+ boolean booleanValue();
+
+ float floatValue();
+
+ double doubleValue();
+
+ String stringValue();
+
+ T value();
+} \ No newline at end of file
diff --git a/src/main/java/me/shedaniel/rei/api/RecipeCategory.java b/src/main/java/me/shedaniel/rei/api/RecipeCategory.java
index 233cf4553..4cecb6fce 100644
--- a/src/main/java/me/shedaniel/rei/api/RecipeCategory.java
+++ b/src/main/java/me/shedaniel/rei/api/RecipeCategory.java
@@ -6,6 +6,7 @@
package me.shedaniel.rei.api;
import me.shedaniel.math.api.Rectangle;
+import me.shedaniel.rei.api.annotations.ToBeRemoved;
import me.shedaniel.rei.gui.RecipeViewingScreen;
import me.shedaniel.rei.gui.renderers.RecipeRenderer;
import me.shedaniel.rei.gui.widget.CategoryBaseWidget;
@@ -32,9 +33,18 @@ public interface RecipeCategory<T extends RecipeDisplay> {
/**
* Gets the renderer of the icon, allowing developers to render things other than items
*
+ * @see RecipeCategory#getLogo()
* @return the renderer of the icon
*/
- Renderer getIcon();
+ @ToBeRemoved
+ @Deprecated
+ default Renderer getIcon() {
+ return Renderer.empty();
+ }
+
+ default EntryStack getLogo() {
+ return getIcon().getEntry();
+ }
/**
* Gets the category name
@@ -51,7 +61,7 @@ public interface RecipeCategory<T extends RecipeDisplay> {
*/
@SuppressWarnings("unchecked")
default RecipeRenderer getSimpleRenderer(T recipe) {
- re