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/api | |
| 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/api')
14 files changed, 492 insertions, 32 deletions
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)); + } + + 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 2e331b1df..8200fcdc0 100644 --- a/src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java +++ b/src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java @@ -15,8 +15,22 @@ public interface LiveRecipeGenerator<T extends RecipeDisplay> { Identifier getCategoryIdentifier(); - Optional<List<T>> getRecipeFor(ItemStack stack); + @Deprecated + default Optional<List<T>> getRecipeFor(ItemStack stack) { + return Optional.empty(); + } - Optional<List<T>> getUsageFor(ItemStack stack); + default Optional<List<T>> getRecipeFor(EntryStack entry) { + return Optional.empty(); + } + + @Deprecated + default Optional<List<T>> getUsageFor(ItemStack stack) { + return Optional.empty(); + } + + 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..d3b6189b1 --- /dev/null +++ b/src/main/java/me/shedaniel/rei/api/ObjectHolder.java @@ -0,0 +1,22 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + +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) { - return Renderer.fromRecipe(recipe::getInput, recipe::getOutput); + return Renderer.fromRecipeEntries(recipe::getInputEntries, recipe::getOutputEntries); } /** @@ -126,7 +136,9 @@ public interface RecipeCategory<T extends RecipeDisplay> { * Gets whether the category will check tags, useful for potions * * @return whether the category will check tags + * @deprecated no longer used */ + @Deprecated default boolean checkTags() { return false; } diff --git a/src/main/java/me/shedaniel/rei/api/RecipeDisplay.java b/src/main/java/me/shedaniel/rei/api/RecipeDisplay.java index 693712fc6..dd563f01a 100644 --- a/src/main/java/me/shedaniel/rei/api/RecipeDisplay.java +++ b/src/main/java/me/shedaniel/rei/api/RecipeDisplay.java @@ -5,10 +5,12 @@ package me.shedaniel.rei.api; -import com.google.common.collect.Lists; +import me.shedaniel.rei.api.annotations.ToBeRemoved; import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Optional; @@ -16,21 +18,79 @@ public interface RecipeDisplay { /** * @return a list of items + * @see RecipeDisplay#getInputStacks() */ - List<List<ItemStack>> getInput(); + @ToBeRemoved + @Deprecated + default List<List<ItemStack>> getInput() { + return Collections.emptyList(); + } + + /** + * @return a list of inputs + */ + default List<List<EntryStack>> getInputEntries() { + List<List<ItemStack>> input = getInput(); + if (input.isEmpty()) + return Collections.emptyList(); + List<List<EntryStack>> list = new ArrayList<>(); + for (List<ItemStack> stacks : input) { + List<EntryStack> entries = new ArrayList<>(); + for (ItemStack stack : stacks) { + entries.add(EntryStack.create(stack)); + } + list.add(entries); + } + return list; + } /** * @return a list of outputs */ - List<ItemStack> getOutput(); + @ToBeRemoved + @Deprecated + default List<ItemStack> getOutput() { + return Collections.emptyList(); + } + + /** + * @return a list of outputs + */ + default List<EntryStack> getOutputEntries() { + List<ItemStack> input = getOutput(); + if (input.isEmpty()) + return Collections.emptyList(); + List<EntryStack> entries = new ArrayList<>(); + for (ItemStack stack : input) { + entries.add(EntryStack.create(stack)); + } + return entries; + } /** * Gets the required items used in craftable filters * * @return the list of required items */ + default List<List<EntryStack>> getRequiredEntries() { + List<List<ItemStack>> input = getRequiredItems(); + if (input.isEmpty()) + return Collections.emptyList(); + List<List<EntryStack>> list = new ArrayList<>(); + for (List<ItemStack> stacks : input) { + List<EntryStack> entries = new ArrayList<>(); + for (ItemStack stack : stacks) { + entries.add(EntryStack.create(stack)); + } + list.add(entries); + } + return list; + } + + @ToBeRemoved + @Deprecated default List<List<ItemStack>> getRequiredItems() { - return Lists.newArrayList(); + return Collections.emptyList(); } /** diff --git a/src/main/java/me/shedaniel/rei/api/RecipeHelper.java b/src/main/java/me/shedaniel/rei/api/RecipeHelper.java index 3ef78f603..9c66a6eb4 100644 --- a/src/main/java/me/shedaniel/rei/api/RecipeHelper.java +++ b/src/main/java/me/shedaniel/rei/api/RecipeHelper.java @@ -7,12 +7,14 @@ package me.shedaniel.rei.api; import me.shedaniel.math.api.Rectangle; import me.shedaniel.rei.RoughlyEnoughItemsCore; +import me.shedaniel.rei.api.annotations.ToBeRemoved; import net.minecraft.client.gui.screen.ingame.AbstractContainerScreen; import net.minecraft.item.ItemStack; import net.minecraft.recipe.Recipe; import net.minecraft.recipe.RecipeManager; import net.minecraft.util.Identifier; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; @@ -50,7 +52,22 @@ public interface RecipeHelper { * @param inventoryItems the materials * @return the list of craftable items */ - List<ItemStack> findCraftableByItems(List<ItemStack> inventoryItems); + default List<ItemStack> findCraftableByItems(List<ItemStack> inventoryItems) { + List<ItemStack> itemStacks = new ArrayList<>(); + for (EntryStack item : findCraftableEntriesByItems(inventoryItems)) { + if (item.getItemStack() != null) + itemStacks.add(item.getItemStack()); + } + return itemStacks; + } + + /** + * Gets all craftable items from materials. + * + * @param inventoryItems the materials + * @return the list of craftable entries + */ + List<EntryStack> findCraftableEntriesByItems(List<ItemStack> inventoryItems); /** * Registers a category @@ -91,7 +108,13 @@ public interface RecipeHelper { * @param stack the stack to be crafted * @return the map of recipes */ - Map<RecipeCategory<?>, List<RecipeDisplay>> getRecipesFor(ItemStack stack); + Map<RecipeCategory<?>, List<RecipeDisplay>> getRecipesFor(EntryStack stack); + + @ToBeRemoved + @Deprecated + default Map<RecipeCategory<?>, List<RecipeDisplay>> getRecipesFor(ItemStack stack) { + return getRecipesFor(EntryStack.create(stack)); + } RecipeCategory getCategory(Identifier identifier); @@ -115,7 +138,13 @@ public interface RecipeHelper { * @param stack the stack to be used * @return the map of recipes */ - Map<RecipeCategory<?>, List<RecipeDisplay>> getUsagesFor(ItemStack stack); + Map<RecipeCategory<?>, List<RecipeDisplay>> getUsagesFor(EntryStack stack); + + @ToBeRemoved + @Deprecated + default Map<RecipeCategory<?>, List<RecipeDisplay>> getUsagesFor(ItemStack stack) { + return getUsagesFor(EntryStack.create(stack)); + } /** * Gets the optional of the speed crafting button area from a category diff --git a/src/main/java/me/shedaniel/rei/api/Renderer.java b/src/main/java/me/shedaniel/rei/api/Renderer.java index c2b6b133c..823a9ceb5 100644 --- a/src/main/java/me/shedaniel/rei/api/Renderer.java +++ b/src/main/java/me/shedaniel/rei/api/Renderer.java @@ -5,6 +5,7 @@ package me.shedaniel.rei.api; +import me.shedaniel.rei.api.annotations.ToBeRemoved; import me.shedaniel.rei.gui.renderers.EmptyRenderer; import me.shedaniel.rei.gui.renderers.FluidRenderer; import me.shedaniel.rei.gui.renderers.ItemStackRenderer; @@ -14,14 +15,17 @@ import net.minecraft.client.gui.DrawableHelper; import net.minecraft.fluid.Fluid; import net.minecraft.item.ItemStack; import net.minecraft.util.math.MathHelper; +import org.jetbrains.annotations.NotNull; 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; import java.util.stream.Collectors; +@Deprecated public abstract class Renderer extends DrawableHelper { /** * Gets an item stack renderer by an item stack supplier @@ -102,10 +106,16 @@ public abstract class Renderer extends DrawableHelper { * @param output the list of output items * @return the recipe renderer */ + @ToBeRemoved + @Deprecated public static SimpleRecipeRenderer fromRecipe(Supplier<List<List<ItemStack>>> input, Supplier<List<ItemStack>> output) { return new SimpleRecipeRenderer(input, output); } + public static SimpleRecipeRenderer fromRecipeEntries(Supplier<List<List<EntryStack>>> input, Supplier<List<EntryStack>> output) { + return new SimpleRecipeRenderer(input, output, 0); + } + public static ItemStackRenderer fromItemStacks(List<ItemStack> stacks) { return fromItemStacks(() -> stacks, true, null); } @@ -185,6 +195,14 @@ public abstract class Renderer extends DrawableHelper { */ public abstract void render(int x, int y, double mouseX, double mouseY, float delta); + public EntryStack getEntry() { + if (this instanceof ItemStackRenderer) + return EntryStack.create(((ItemStackRenderer) this).getItemStack()); + if (this instanceof FluidRenderer) + return EntryStack.create(((FluidRenderer) this).getFluid()); + return EntryStack.empty(); + } + @Nullable public QueuedTooltip getQueuedTooltip(float delta) { return null; diff --git a/src/main/java/me/shedaniel/rei/api/TransferRecipeDisplay.java b/src/main/java/me/shedaniel/rei/api/TransferRecipeDisplay.java index 3e7ed1bc8..f7d509f17 100644 --- a/src/main/java/me/shedaniel/rei/api/TransferRecipeDisplay.java +++ b/src/main/java/me/shedaniel/rei/api/TransferRecipeDisplay.java @@ -5,10 +5,13 @@ package me.shedaniel.rei.api; +import com.google.common.collect.Lists; import me.shedaniel.rei.server.ContainerInfo; import net.minecraft.container.Container; import net.minecraft.item.ItemStack; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; public interface TransferRecipeDisplay extends RecipeDisplay { @@ -17,6 +20,27 @@ public interface TransferRecipeDisplay extends RecipeDisplay { int getHeight(); - List<List<ItemStack>> getOrganisedInput(ContainerInfo<Container> containerInfo, Container container); + default List<List<ItemStack>> getOrganisedInput(ContainerInfo<Container> containerInfo, Container container) { + List<List<ItemStack>> list = Lists.newArrayListWithCapacity(containerInfo.getCraftingWidth(container) * containerInfo.getCraftingHeight(container)); + for (int i = 0; i < containerInfo.getCraftingWidth(container) * containerInfo.getCraftingHeight(container); i++) { + list.add(Lists.newArrayList()); + } + return list; + } + + default List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<Container> containerInfo, Container container) { + List<List<ItemStack>> input = getOrganisedInput(containerInfo, container); + if (input.isEmpty()) + return Collections.emptyList(); + List<List<EntryStack>> list = new ArrayList<>(); + for (List<ItemStack> stacks : input) { + List<EntryStack> entries = new ArrayList<>(); + for (ItemStack stack : stacks) { + entries.add(EntryStack.create(stack)); + } + list.add(entries); + } + return list; + } } diff --git a/src/main/java/me/shedaniel/rei/api/annotations/Experimental.java b/src/main/java/me/shedaniel/rei/api/annotations/Experimental.java new file mode 100644 index 000000000..043b0daae --- /dev/null +++ b/src/main/java/me/shedaniel/rei/api/annotations/Experimental.java @@ -0,0 +1,17 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + +package me.shedaniel.rei.api.annotations; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.*; + +@Retention(RetentionPolicy.RUNTIME) +@Target(value = {CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, PARAMETER, TYPE}) +public @interface Experimental { +} diff --git a/src/main/java/me/shedaniel/rei/api/annotations/Internal.java b/src/main/java/me/shedaniel/rei/api/annotations/Internal.java new file mode 100644 index 000000000..4b120c1de --- /dev/null +++ b/src/main/java/me/shedaniel/rei/api/annotations/Internal.java @@ -0,0 +1,17 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + +package me.shedaniel.rei.api.annotations; + |
