diff options
| author | shedaniel <daniel@shedaniel.me> | 2021-05-16 17:45:22 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2021-05-16 17:45:22 +0800 |
| commit | b657842bcddcb65fb658d4cd9835e7fa15e1c236 (patch) | |
| tree | f42511d9bb3ac413c03245391f26cfa6b0496c72 /forge/src/main/java | |
| parent | 4b55e2af04551f7b01047c9b47822e3a184e6362 (diff) | |
| download | RoughlyEnoughItems-b657842bcddcb65fb658d4cd9835e7fa15e1c236.tar.gz RoughlyEnoughItems-b657842bcddcb65fb658d4cd9835e7fa15e1c236.tar.bz2 RoughlyEnoughItems-b657842bcddcb65fb658d4cd9835e7fa15e1c236.zip | |
Update JEI API to 7.6.4 & Fix #520
Diffstat (limited to 'forge/src/main/java')
| -rw-r--r-- | forge/src/main/java/me/shedaniel/rei/plugin/client/forge/DefaultClientPluginImpl.java | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/forge/src/main/java/me/shedaniel/rei/plugin/client/forge/DefaultClientPluginImpl.java b/forge/src/main/java/me/shedaniel/rei/plugin/client/forge/DefaultClientPluginImpl.java new file mode 100644 index 000000000..7c47d1c84 --- /dev/null +++ b/forge/src/main/java/me/shedaniel/rei/plugin/client/forge/DefaultClientPluginImpl.java @@ -0,0 +1,71 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 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.plugin.client.forge; + +import com.google.common.collect.Sets; +import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; +import me.shedaniel.rei.plugin.client.BuiltinClientPlugin; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.alchemy.Potion; +import net.minecraft.world.item.alchemy.PotionBrewing; +import net.minecraft.world.item.alchemy.PotionUtils; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraftforge.registries.IRegistryDelegate; + +import java.util.Arrays; +import java.util.Set; + +public class DefaultClientPluginImpl { + public static void registerForgePotions(DisplayRegistry registry, BuiltinClientPlugin clientPlugin) { + Set<Potion> potions = Sets.newLinkedHashSet(); + for (Ingredient container : PotionBrewing.ALLOWED_CONTAINERS) { + for (PotionBrewing.Mix<Potion> mix : PotionBrewing.POTION_MIXES) { + IRegistryDelegate<Potion> from = mix.from; + Ingredient ingredient = mix.ingredient; + IRegistryDelegate<Potion> to = mix.to; + Ingredient base = Ingredient.of(Arrays.stream(container.getItems()) + .map(ItemStack::copy) + .map(stack -> PotionUtils.setPotion(stack, from.get()))); + ItemStack output = Arrays.stream(container.getItems()) + .map(ItemStack::copy) + .map(stack -> PotionUtils.setPotion(stack, to.get())) + .findFirst().orElse(ItemStack.EMPTY); + clientPlugin.registerBrewingRecipe(base, ingredient, output); + potions.add(from.get()); + potions.add(to.get()); + } + } + for (Potion potion : potions) { + for (PotionBrewing.Mix<Item> mix : PotionBrewing.CONTAINER_MIXES) { + IRegistryDelegate<Item> from = mix.from; + Ingredient ingredient = mix.ingredient; + IRegistryDelegate<Item> to = mix.to; + Ingredient base = Ingredient.of(PotionUtils.setPotion(new ItemStack(from.get()), potion)); + ItemStack output = PotionUtils.setPotion(new ItemStack(to.get()), potion); + clientPlugin.registerBrewingRecipe(base, ingredient, output); + } + } + } +} |
