diff options
| author | shedaniel <daniel@shedaniel.me> | 2025-02-25 19:20:09 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2025-02-25 19:20:09 +0800 |
| commit | f5408ce8c85dda2bccbe78d8d2a505acc69aa9a0 (patch) | |
| tree | d69fd8db7da7e00f451c29b91b581c133d4f56a8 /fabric/src | |
| parent | ce2de8d07e696b5ef75f2decbd6961286d88fb4f (diff) | |
| download | RoughlyEnoughItems-f5408ce8c85dda2bccbe78d8d2a505acc69aa9a0.tar.gz RoughlyEnoughItems-f5408ce8c85dda2bccbe78d8d2a505acc69aa9a0.tar.bz2 RoughlyEnoughItems-f5408ce8c85dda2bccbe78d8d2a505acc69aa9a0.zip | |
Fix custom ingredients
Diffstat (limited to 'fabric/src')
| -rw-r--r-- | fabric/src/main/java/me/shedaniel/rei/fabric/PlatformAdapterImpl.java | 50 | ||||
| -rw-r--r-- | fabric/src/main/resources/META-INF/services/me.shedaniel.rei.impl.init.PlatformAdapter | 1 |
2 files changed, 51 insertions, 0 deletions
diff --git a/fabric/src/main/java/me/shedaniel/rei/fabric/PlatformAdapterImpl.java b/fabric/src/main/java/me/shedaniel/rei/fabric/PlatformAdapterImpl.java new file mode 100644 index 000000000..7a5ceef59 --- /dev/null +++ b/fabric/src/main/java/me/shedaniel/rei/fabric/PlatformAdapterImpl.java @@ -0,0 +1,50 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023 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.fabric; + +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.util.EntryIngredients; +import me.shedaniel.rei.api.common.util.EntryStacks; +import me.shedaniel.rei.impl.init.PlatformAdapter; +import net.minecraft.world.item.crafting.Ingredient; + +public class PlatformAdapterImpl implements PlatformAdapter { + @Override + public EntryIngredient fromIngredient(Ingredient ingredient) { + if (ingredient.isEmpty()) return EntryIngredient.empty(); + if (ingredient.getCustomIngredient() != null) { + EntryIngredient.Builder result = EntryIngredient.builder(); + ingredient.items().forEach(item -> { + EntryStack<?> stack = EntryStacks.ofItemHolder(item); + if (!stack.isEmpty()) { + result.add(stack); + } + }); + return result.build(); + } else { + return EntryIngredients.ofItemsHolderSet(ingredient.values); + } + } +} diff --git a/fabric/src/main/resources/META-INF/services/me.shedaniel.rei.impl.init.PlatformAdapter b/fabric/src/main/resources/META-INF/services/me.shedaniel.rei.impl.init.PlatformAdapter new file mode 100644 index 000000000..e34e1dded --- /dev/null +++ b/fabric/src/main/resources/META-INF/services/me.shedaniel.rei.impl.init.PlatformAdapter @@ -0,0 +1 @@ +me.shedaniel.rei.fabric.PlatformAdapterImpl
\ No newline at end of file |
