diff options
| author | shedaniel <daniel@shedaniel.me> | 2020-07-14 11:19:19 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2020-07-14 11:19:29 +0800 |
| commit | e2c264a82dc10b8e29b08225cd5bc24e689fa332 (patch) | |
| tree | 4adf065ef2183d7cb22b684806543121f9fb4359 /src/main/java | |
| parent | 1a6a10596fd0d9cc7e35419ced6fe056d93d7604 (diff) | |
| download | RoughlyEnoughItems-e2c264a82dc10b8e29b08225cd5bc24e689fa332.tar.gz RoughlyEnoughItems-e2c264a82dc10b8e29b08225cd5bc24e689fa332.tar.bz2 RoughlyEnoughItems-e2c264a82dc10b8e29b08225cd5bc24e689fa332.zip | |
Optimised craftable filter and changed some api
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'src/main/java')
26 files changed, 150 insertions, 67 deletions
diff --git a/src/main/java/me/shedaniel/rei/api/EntryStack.java b/src/main/java/me/shedaniel/rei/api/EntryStack.java index a963f4274..972321995 100644 --- a/src/main/java/me/shedaniel/rei/api/EntryStack.java +++ b/src/main/java/me/shedaniel/rei/api/EntryStack.java @@ -50,11 +50,7 @@ import net.minecraft.util.registry.Registry; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Optional; +import java.util.*; import java.util.function.Function; import java.util.function.Supplier; @@ -81,20 +77,28 @@ public interface EntryStack extends TextRepresentable { static EntryStack create(ItemStack stack) { return new ItemEntryStack(stack); } - + static EntryStack create(ItemConvertible item) { return create(new ItemStack(item)); } - - static List<EntryStack> create(Collection<ItemStack> stacks) { + + static List<EntryStack> ofItems(Collection<ItemConvertible> stacks) { + List<EntryStack> result = new ArrayList<>(stacks.size()); + for (ItemConvertible stack : stacks) { + result.add(create(stack)); + } + return result; + } + + static List<EntryStack> ofItemStacks(Collection<ItemStack> stacks) { List<EntryStack> result = new ArrayList<>(stacks.size()); for (ItemStack stack : stacks) { result.add(create(stack)); } return result; } - - static List<EntryStack> create(Ingredient ingredient) { + + static List<EntryStack> ofIngredient(Ingredient ingredient) { ItemStack[] matchingStacks = ingredient.getMatchingStacksClient(); List<EntryStack> result = new ArrayList<>(matchingStacks.length); for (ItemStack matchingStack : matchingStacks) { @@ -102,15 +106,33 @@ public interface EntryStack extends TextRepresentable { } return result; } - - static List<List<EntryStack>> create(List<Ingredient> ingredients) { + + static List<List<EntryStack>> ofIngredients(List<Ingredient> ingredients) { List<List<EntryStack>> result = new ArrayList<>(ingredients.size()); for (Ingredient ingredient : ingredients) { - result.add(create(ingredient)); + result.add(ofIngredient(ingredient)); } return result; } - + + @Deprecated + @ApiStatus.ScheduledForRemoval + static List<EntryStack> create(Collection<ItemStack> stacks) { + return ofItemStacks(stacks); + } + + @Deprecated + @ApiStatus.ScheduledForRemoval + static List<EntryStack> create(Ingredient ingredient) { + return ofIngredient(ingredient); + } + + @Deprecated + @ApiStatus.ScheduledForRemoval + static List<List<EntryStack>> create(List<Ingredient> ingredients) { + return ofIngredients(ingredients); + } + @ApiStatus.Internal static EntryStack readFromJson(JsonElement jsonElement) { try { diff --git a/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java index 481c24adb..85f6e223a 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java @@ -24,6 +24,7 @@ package me.shedaniel.rei.gui.widget; import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import me.shedaniel.clothconfig2.ClothConfigInitializer; import me.shedaniel.clothconfig2.api.ScissorsHandler; import me.shedaniel.clothconfig2.api.ScrollingContainer; @@ -491,9 +492,9 @@ public class EntryListWidget extends WidgetWithBounds { this.lastSearchArguments = SearchArgument.processSearchTerm(searchTerm); List<EntryStack> list = Lists.newArrayList(); boolean checkCraftable = ConfigManager.getInstance().isCraftableOnlyEnabled() && !ScreenHelper.inventoryStacks.isEmpty(); - Set<EntryStack> workingItems = checkCraftable ? new TreeSet<>(Comparator.comparing(EntryStack::hashIgnoreAmount)) : null; + Set<Integer> workingItems = checkCraftable ? Sets.newHashSet() : null; if (checkCraftable) - workingItems.addAll(RecipeHelper.getInstance().findCraftableEntriesByItems(CollectionUtils.map(ScreenHelper.inventoryStacks, EntryStack::create))); + workingItems.addAll(CollectionUtils.map(RecipeHelper.getInstance().findCraftableEntriesByItems(CollectionUtils.map(ScreenHelper.inventoryStacks, EntryStack::create)), EntryStack::hashIgnoreAmount)); List<EntryStack> stacks = EntryRegistry.getInstance().getPreFilteredList(); if (stacks instanceof CopyOnWriteArrayList && !stacks.isEmpty()) { if (ConfigObject.getInstance().shouldAsyncSearch()) { @@ -507,7 +508,7 @@ public class EntryListWidget extends WidgetWithBounds { for (; start[0] < end; start[0]++) { EntryStack stack = stacks.get(start[0]); if (canLastSearchTermsBeAppliedTo(stack)) { - if (workingItems != null && workingItems.contains(stack)) + if (workingItems != null && !workingItems.contains(stack.hashIgnoreAmount())) continue; filtered.add(stack.copy().setting(EntryStack.Settings.RENDER_COUNTS, EntryStack.Settings.FALSE).setting(EntryStack.Settings.Item.RENDER_ENCHANTMENT_GLINT, RENDER_ENCHANTMENT_GLINT)); } diff --git a/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java index 16b5bb917..55b7d0051 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java @@ -24,6 +24,7 @@ package me.shedaniel.rei.gui.widget; import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import me.shedaniel.clothconfig2.ClothConfigInitializer; import me.shedaniel.clothconfig2.api.ScissorsHandler; import me.shedaniel.clothconfig2.api.ScrollingContainer; @@ -47,7 +48,9 @@ import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.Collections; +import java.util.List; +import java.util.Set; import static me.shedaniel.rei.gui.widget.EntryListWidget.*; @@ -187,12 +190,12 @@ public class FavoritesListWidget extends WidgetWithBounds { if (ConfigObject.getInstance().doSearchFavorites()) { List<EntryStack> list = Lists.newArrayList(); boolean checkCraftable = ConfigManager.getInstance().isCraftableOnlyEnabled() && !ScreenHelper.inventoryStacks.isEmpty(); - Set<EntryStack> workingItems = checkCraftable ? new TreeSet<>(Comparator.comparing(EntryStack::hashIgnoreAmount)) : null; + Set<Integer> workingItems = checkCraftable ? Sets.newHashSet() : null; if (checkCraftable) - workingItems.addAll(RecipeHelper.getInstance().findCraftableEntriesByItems(CollectionUtils.map(ScreenHelper.inventoryStacks, EntryStack::create))); + workingItems.addAll(CollectionUtils.map(RecipeHelper.getInstance().findCraftableEntriesByItems(CollectionUtils.map(ScreenHelper.inventoryStacks, EntryStack::create)), EntryStack::hashIgnoreAmount)); for (EntryStack stack : ConfigObject.getInstance().getFavorites()) { if (listWidget.canLastSearchTermsBeAppliedTo(stack)) { - if (checkCraftable && workingItems.contains(stack)) + if (checkCraftable && !workingItems.contains(stack.hashIgnoreAmount())) continue; list.add(stack.copy().setting(EntryStack.Settings.RENDER_COUNTS, EntryStack.Settings.FALSE).setting(EntryStack.Settings.Item.RENDER_ENCHANTMENT_GLINT, RENDER_ENCHANTMENT_GLINT)); } @@ -208,11 +211,11 @@ public class FavoritesListWidget extends WidgetWithBounds { } else { List<EntryStack> list = Lists.newArrayList(); boolean checkCraftable = ConfigManager.getInstance().isCraftableOnlyEnabled() && !ScreenHelper.inventoryStacks.isEmpty(); - Set<EntryStack> workingItems = checkCraftable ? new TreeSet<>(Comparator.comparing(EntryStack::hashIgnoreAmount)) : null; + Set<Integer> workingItems = checkCraftable ? Sets.newHashSet() : null; if (checkCraftable) - workingItems.addAll(RecipeHelper.getInstance().findCraftableEntriesByItems(CollectionUtils.map(ScreenHelper.inventoryStacks, EntryStack::create))); + workingItems.addAll(CollectionUtils.map(RecipeHelper.getInstance().findCraftableEntriesByItems(CollectionUtils.map(ScreenHelper.inventoryStacks, EntryStack::create)), EntryStack::hashIgnoreAmount)); for (EntryStack stack : ConfigObject.getInstance().getFavorites()) { - if (checkCraftable && workingItems.contains(stack)) + if (checkCraftable && !workingItems.contains(stack.hashIgnoreAmount())) continue; list.add(stack.copy().setting(EntryStack.Settings.RENDER_COUNTS, EntryStack.Settings.FALSE).setting(EntryStack.Settings.Item.RENDER_ENCHANTMENT_GLINT, RENDER_ENCHANTMENT_GLINT)); } diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultAutoCraftingPlugin.java b/src/main/java/me/shedaniel/rei/plugin/DefaultAutoCraftingPlugin.java index 6c33d3559..d7cc11ddf 100644 --- a/src/main/java/me/shedaniel/rei/plugin/DefaultAutoCraftingPlugin.java +++ b/src/main/java/me/shedaniel/rei/plugin/DefaultAutoCraftingPlugin.java @@ -28,8 +28,11 @@ import me.shedaniel.rei.api.RecipeHelper; import me.shedaniel.rei.api.plugins.REIPluginV0; import me.shedaniel.rei.plugin.autocrafting.DefaultCategoryHandler; import me.shedaniel.rei.plugin.autocrafting.DefaultRecipeBookHandler; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.util.Identifier; +@Environment(EnvType.CLIENT) public class DefaultAutoCraftingPlugin implements REIPluginV0 { public static final Identifier PLUGIN = new Identifier("roughlyenoughitems", "default_auto_crafting_plugin"); diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java b/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java index d852de324..f54bf8ba9 100644 --- a/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java +++ b/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java @@ -230,21 +230,19 @@ public class DefaultPlugin implements REIPluginV0 { recipeHelper.registerDisplay(new DefaultFuelDisplay(EntryStack.create(entry.getKey()), entry.getValue())); } List<EntryStack> arrowStack = Collections.singletonList(EntryStack.create(Items.ARROW)); - for (EntryStack entry : EntryRegistry.getInstance().getStacksList()) { - if (entry.getItem() == Items.LINGERING_POTION) { - List<List<EntryStack>> input = new ArrayList<>(); - for (int i = 0; i < 4; i++) - input.add(arrowStack); - input.add(Collections.singletonList(EntryStack.create(entry.getItemStack()))); - for (int i = 0; i < 4; i++) - input.add(arrowStack); - ItemStack outputStack = new ItemStack(Items.TIPPED_ARROW, 8); - PotionUtil.setPotion(outputStack, PotionUtil.getPotion(entry.getItemStack())); - PotionUtil.setCustomPotionEffects(outputStack, PotionUtil.getCustomPotionEffects(entry.getItemStack())); - List<EntryStack> output = Collections.singletonList(EntryStack.create(outputStack).addSetting(EntryStack.Settings.CHECK_TAGS, EntryStack.Settings.TRUE)); - recipeHelper.registerDisplay(new DefaultCustomDisplay(null, input, output)); - } - } + EntryRegistry.getInstance().getEntryStacks().filter(entry -> entry.getItem() == Items.LINGERING_POTION).forEach(entry -> { + List<List<EntryStack>> input = new ArrayList<>(); + for (int i = 0; i < 4; i++) + input.add(arrowStack); + input.add(Collections.singletonList(EntryStack.create(entry.getItemStack()))); + for (int i = 0; i < 4; i++) + input.add(arrowStack); + ItemStack outputStack = new ItemStack(Items.TIPPED_ARROW, 8); + PotionUtil.setPotion(outputStack, PotionUtil.getPotion(entry.getItemStack())); + PotionUtil.setCustomPotionEffects(outputStack, PotionUtil.getCustomPotionEffects(entry.getItemStack())); + List<EntryStack> output = Collections.singletonList(EntryStack.create(outputStack).addSetting(EntryStack.Settings.CHECK_TAGS, EntryStack.Settings.TRUE)); + recipeHelper.registerDisplay(new DefaultCustomDisplay(null, input, output)); + }); Map<ItemConvertible, Float> map = Maps.newLinkedHashMap(); if (ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.isEmpty()) ComposterBlock.registerDefaultCompostableItems(); @@ -274,8 +272,7 @@ public class DefaultPlugin implements REIPluginV0 { // TODO Turn this into an API // Sit tight! This will be a fast journey! long time = System.currentTimeMillis(); - for (EntryStack stack : EntryRegistry.getInstance().getStacksList()) - applyPotionTransformer(stack); + EntryRegistry.getInstance().getEntryStacks().forEach(this::applyPotionTransformer); for (List<RecipeDisplay> displays : RecipeHelper.getInstance().getAllRecipesNoHandlers().values()) { for (RecipeDisplay display : displays) { for (List<EntryStack> entries : display.getInputEntries()) diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultPotionEffectExclusionZones.java b/src/main/java/me/shedaniel/rei/plugin/DefaultPotionEffectExclusionZones.java index 0dbd2df61..79116da14 100644 --- a/src/main/java/me/shedaniel/rei/plugin/DefaultPotionEffectExclusionZones.java +++ b/src/main/java/me/shedaniel/rei/plugin/DefaultPotionEffectExclusionZones.java @@ -26,6 +26,8 @@ package me.shedaniel.rei.plugin; import com.google.common.collect.Ordering; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.REIHelper; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen; import net.minecraft.client.gui.screen.ingame.ContainerScreen; @@ -37,6 +39,7 @@ import java.util.Collections; import java.util.List; import java.util.function.Supplier; +@Environment(EnvType.CLIENT) public class DefaultPotionEffectExclusionZones implements Supplier<List<Rectangle>> { @Override public List<Rectangle> get() { diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultRecipeBookExclusionZones.java b/src/main/java/me/shedaniel/rei/plugin/DefaultRecipeBookExclusionZones.java index ff5a14025..87602364f 100644 --- a/src/main/java/me/shedaniel/rei/plugin/DefaultRecipeBookExclusionZones.java +++ b/src/main/java/me/shedaniel/rei/plugin/DefaultRecipeBookExclusionZones.java @@ -26,6 +26,8 @@ package me.shedaniel.rei.plugin; import com.google.common.collect.Lists; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.REIHelper; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.ingame.ContainerScreen; import net.minecraft.client.gui.screen.recipebook.RecipeBookProvider; @@ -36,6 +38,7 @@ import java.util.Collections; import java.util.List; import java.util.function.Supplier; +@Environment(EnvType.CLIENT) public class DefaultRecipeBookExclusionZones implements Supplier<List<Rectangle>> { @Override diff --git a/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultCategoryHandler.java b/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultCategoryHandler.java index 2dc9a4a32..a4b2f297d 100644 --- a/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultCategoryHandler.java +++ b/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultCategoryHandler.java @@ -32,6 +32,8 @@ import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.TransferRecipeDisplay; import me.shedaniel.rei.server.ContainerInfo; import me.shedaniel.rei.server.ContainerInfoHandler; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.network.ClientSidePacketRegistry; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.Screen; @@ -45,6 +47,7 @@ import net.minecraft.util.collection.DefaultedList; import java.util.List; +@Environment(EnvType.CLIENT) public class DefaultCategoryHandler implements AutoTransferHandler { public static boolean canUseMovePackets() { diff --git a/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultRecipeBookHandler.java b/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultRecipeBookHandler.java index b9f96a27d..5f300e731 100644 --- a/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultRecipeBookHandler.java +++ b/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultRecipeBookHandler.java @@ -29,6 +29,8 @@ import me.shedaniel.rei.api.TransferRecipeDisplay; import me.shedaniel.rei.impl.ScreenHelper; import me.shedaniel.rei.plugin.cooking.DefaultCookingDisplay; import me.shedaniel.rei.plugin.crafting.DefaultCraftingDisplay; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.recipebook.RecipeBookProvider; import net.minecraft.client.resource.language.I18n; @@ -37,6 +39,7 @@ import net.minecraft.container.CraftingTableContainer; import net.minecraft.container.PlayerContainer; import net.minecraft.recipe.Recipe; +@Environment(EnvType.CLIENT) public class DefaultRecipeBookHandler implements AutoTransferHandler { @Override public Result handle(Context context) { diff --git a/src/main/java/me/shedaniel/rei/plugin/beacon/DefaultBeaconBaseDisplay.java b/src/main/java/me/shedaniel/rei/plugin/beacon/DefaultBeaconBaseDisplay.java index 46941d320..6749a9f4a 100644 --- a/src/main/java/me/shedaniel/rei/plugin/beacon/DefaultBeaconBaseDisplay.java +++ b/src/main/java/me/shedaniel/rei/plugin/beacon/DefaultBeaconBaseDisplay.java @@ -26,19 +26,21 @@ package me.shedaniel.rei.plugin.beacon; import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.RecipeDisplay; import me.shedaniel.rei.plugin.DefaultPlugin; -import me.shedaniel.rei.utils.CollectionUtils; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; import java.util.Collections; import java.util.List; +@Environment(EnvType.CLIENT) public class DefaultBeaconBaseDisplay implements RecipeDisplay { private List<EntryStack> entries; public DefaultBeaconBaseDisplay(List<ItemStack> entries) { - this.entries = CollectionUtils.map(entries, EntryStack::create); + this.entries = EntryStack.ofItemStacks(entries); } @Override diff --git a/src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingDisplay.java b/src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingDisplay.java index 6286697f1..e34d580a7 100644 --- a/src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingDisplay.java +++ b/src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingDisplay.java @@ -25,9 +25,12 @@ package me.shedaniel.rei.plugin.blasting; import me.shedaniel.rei.plugin.DefaultPlugin; import me.shedaniel.rei.plugin.cooking.DefaultCookingDisplay; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.recipe.BlastingRecipe; import net.minecraft.util.Identifier; +@Environment(EnvType.CLIENT) public class DefaultBlastingDisplay extends DefaultCookingDisplay { public DefaultBlastingDisplay(BlastingRecipe recipe) { diff --git a/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingDisplay.java b/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingDisplay.java index 5ab1f94cb..2c81519e1 100644 --- a/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingDisplay.java +++ b/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingDisplay.java @@ -27,6 +27,8 @@ import com.google.common.collect.Lists; import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.RecipeDisplay; import me.shedaniel.rei.plugin.DefaultPlugin; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.item.ItemStack; import net.minecraft.recipe.Ingredient; import net.minecraft.text.TranslatableText; @@ -37,6 +39,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +@Environment(EnvType.CLIENT) public class DefaultBrewingDisplay implements RecipeDisplay { private EntryStack input, output; @@ -44,8 +47,9 @@ public class DefaultBrewingDisplay implements RecipeDisplay { public DefaultBrewingDisplay(ItemStack input, Ingredient reactant, ItemStack output) { this.input = EntryStack.create(input).setting(EntryStack.Settings.TOOLTIP_APPEND_EXTRA, stack -> Collections.singletonList(new TranslatableText("category.rei.brewing.input").formatted(Formatting.YELLOW))); - this.reactant = new ArrayList<>(); - for (ItemStack stack : reactant.getMatchingStacksClient()) { + ItemStack[] reactantStacks = reactant.getMatchingStacksClient(); + this.reactant = new ArrayList<>(reactantStacks.length); + for (ItemStack stack : reactantStacks) { EntryStack entryStack = EntryStack.create(stack); entryStack.setting(EntryStack.Settings.TOOLTIP_APPEND_EXTRA, s -> Collections.singletonList(new TranslatableText("category.rei.brewing.reactant").formatted(Formatting.YELLOW))); this.reactant.add(entryStack); diff --git a/src/main/java/me/shedaniel/rei/plugin/campfire/DefaultCampfireDisplay.java b/src/main/java/me/shedaniel/rei/plugin/campfire/DefaultCampfireDisplay.java index 9ae044f21..706a9d22b 100644 --- a/src/main/java/me/shedaniel/rei/plugin/campfire/DefaultCampfireDisplay.java +++ b/src/main/java/me/shedaniel/rei/plugin/campfire/DefaultCampfireDisplay.java @@ -26,6 +26,8 @@ package me.shedaniel.rei.plugin.campfire; import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.RecipeDisplay; import me.shedaniel.rei.plugin.DefaultPlugin; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.item.ItemStack; import net.minecraft.recipe.AbstractCookingRecipe; import net.minecraft.recipe.CampfireCookingRecipe; @@ -39,6 +41,7 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; +@Environment(EnvType.CLIENT) public class DefaultCampfireDisplay implements RecipeDisplay { private List<List<EntryStack>> inputs; @@ -52,7 +55,7 @@ public class DefaultCampfireDisplay implements RecipeDisplay { } public DefaultCampfireDisplay(DefaultedList<Ingredient> ingredients, ItemStack output, int cookTime) { - this.inputs = EntryStack.create(ingredients); + this.inputs = EntryStack.ofIngredients(ingredients); this.output = Collections.singletonList(EntryStack.create(output)); this.cookTime = cookTime; } diff --git a/src/main/java/me/shedaniel/rei/plugin/composting/DefaultCompostingDisplay.java b/src/main/java/me/shedaniel/rei/plugin/composting/DefaultCompostingDisplay.java index a3e9a98f8..c2bc3b22a 100644 --- a/src/main/java/me/shedaniel/rei/plugin/composting/DefaultCompostingDisplay.java +++ b/src/main/java/me/shedaniel/rei/plugin/composting/DefaultCompostingDisplay.java @@ -26,13 +26,15 @@ package me.shedaniel.rei.plugin.composting; import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.RecipeDisplay; import me.shedaniel.rei.plugin.DefaultPlugin; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.item.ItemConvertible; import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; import java.util.*; -import java.util.stream.Collectors; +@Environment(EnvType.CLIENT) public class DefaultCompostingDisplay implements RecipeDisplay { private List<EntryStack> order, allItems; @@ -42,10 +44,10 @@ public class DefaultCompostingDisplay implements RecipeDisplay { public DefaultCompostingDisplay(int page, List<ItemConvertible> order, Map<ItemConvertible, Float> inputMap, List<ItemConvertible> allItems, ItemStack[] output) { this.page = page; - this.order = order.stream().map(EntryStack::create).collect(Collectors.toList()); + this.order = EntryStack.ofItems(order); this.inputMap = inputMap; - this.output = Arrays.stream(output).map(EntryStack::create).collect(Collectors.toList()); - this.allItems = allItems.stream().map(EntryStack::create).collect(Collectors.toList()); + this.output = EntryStack.ofItemStacks(Arrays.asList(output)); + this.allItems = EntryStack.ofItems(allItems); } public int getPage() { diff --git a/src/main/java/me/shedaniel/rei/plugin/cooking/DefaultCookingDisplay.java b/src/main/java/me/shedaniel/rei/plugin/cooking/DefaultCookingDisplay.java index 5a501d9c9..b0bbeb783 100644 --- a/src/main/java/me/shedaniel/rei/plugin/cooking/DefaultCookingDisplay.java +++ b/src/main/java/me/shedaniel/rei/plugin/cooking/DefaultCookingDisplay.java @@ -26,7 +26,8 @@ package me.shedaniel.rei.plugin.cooking; import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.TransferRecipeDisplay; import me.shedaniel.rei.server.ContainerInfo; -import me.shedaniel.rei.utils.CollectionUtils; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.block.entity.FurnaceBlockEntity; import net.minecraft.container.Container; |
