aboutsummaryrefslogtreecommitdiff
path: root/default-plugin/src
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-12-18 20:50:56 +0800
committershedaniel <daniel@shedaniel.me>2024-04-16 00:38:17 +0900
commitffe21652b40a93a00f33a27a5ecf41479b48bcd9 (patch)
tree2861df1f563c35c78a1eda7477f6c201eed7ce56 /default-plugin/src
parente6687c01b254bf903d4895aa0bb631b1679d465c (diff)
downloadRoughlyEnoughItems-ffe21652b40a93a00f33a27a5ecf41479b48bcd9.tar.gz
RoughlyEnoughItems-ffe21652b40a93a00f33a27a5ecf41479b48bcd9.tar.bz2
RoughlyEnoughItems-ffe21652b40a93a00f33a27a5ecf41479b48bcd9.zip
Close #1131
Diffstat (limited to 'default-plugin/src')
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java23
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/TippedArrowRecipeFiller.java71
2 files changed, 74 insertions, 20 deletions
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
index bf1541003..50ffc35ef 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
@@ -29,6 +29,7 @@ import com.google.common.collect.Sets;
import dev.architectury.event.EventResult;
import dev.architectury.networking.NetworkManager;
import dev.architectury.platform.Platform;
+import it.unimi.dsi.fastutil.objects.Object2FloatMap;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import it.unimi.dsi.fastutil.objects.ReferenceSet;
import me.shedaniel.math.Rectangle;
@@ -55,6 +56,7 @@ import me.shedaniel.rei.plugin.client.categories.beacon.DefaultBeaconBaseCategor
import me.shedaniel.rei.plugin.client.categories.beacon.DefaultBeaconPaymentCategory;
import me.shedaniel.rei.plugin.client.categories.cooking.DefaultCookingCategory;
import me.shedaniel.rei.plugin.client.categories.crafting.DefaultCraftingCategory;
+import me.shedaniel.rei.plugin.client.categories.crafting.filler.TippedArrowRecipeFiller;
import me.shedaniel.rei.plugin.client.categories.tag.DefaultTagCategory;
import me.shedaniel.rei.plugin.client.exclusionzones.DefaultPotionEffectExclusionZones;
import me.shedaniel.rei.plugin.client.exclusionzones.DefaultRecipeBookExclusionZones;
@@ -73,7 +75,6 @@ import me.shedaniel.rei.plugin.common.displays.cooking.DefaultBlastingDisplay;
import me.shedaniel.rei.plugin.common.displays.cooking.DefaultSmeltingDisplay;
import me.shedaniel.rei.plugin.common.displays.cooking.DefaultSmokingDisplay;
import me.shedaniel.rei.plugin.common.displays.crafting.DefaultCraftingDisplay;
-import me.shedaniel.rei.plugin.common.displays.crafting.DefaultCustomDisplay;
import me.shedaniel.rei.plugin.common.displays.tag.DefaultTagDisplay;
import me.shedaniel.rei.plugin.common.displays.tag.TagNodes;
import net.fabricmc.api.EnvType;
@@ -253,25 +254,7 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin
for (Map.Entry<Item, Integer> entry : AbstractFurnaceBlockEntity.getFuel().entrySet()) {
registry.add(new DefaultFuelDisplay(Collections.singletonList(EntryIngredients.of(entry.getKey())), Collections.emptyList(), entry.getValue()));
}
- EntryIngredient arrowStack = EntryIngredient.of(EntryStacks.of(Items.ARROW));
- ReferenceSet<Potion> registeredPotions = new ReferenceOpenHashSet<>();
- EntryRegistry.getInstance().getEntryStacks().filter(entry -> entry.getValueType() == ItemStack.class && entry.<ItemStack>castValue().getItem() == Items.LINGERING_POTION).forEach(entry -> {
- ItemStack itemStack = (ItemStack) entry.getValue();
- Potion potion = PotionUtils.getPotion(itemStack);
- if (registeredPotions.add(potion)) {
- List<EntryIngredient> input = new ArrayList<>();
- for (int i = 0; i < 4; i++)
- input.add(arrowStack);
- input.add(EntryIngredients.of(itemStack));
- for (int i = 0; i < 4; i++)
- input.add(arrowStack);
- ItemStack outputStack = new ItemStack(Items.TIPPED_ARROW, 8);
- PotionUtils.setPotion(outputStack, potion);
- PotionUtils.setCustomEffects(outputStack, PotionUtils.getCustomEffects(itemStack));
- EntryIngredient output = EntryIngredients.of(outputStack);
- registry.add(new DefaultCustomDisplay(null, input, Collections.singletonList(output)));
- }
- });
+ registry.registerRecipesFiller(TippedArrowRecipe.class, RecipeType.CRAFTING, new TippedArrowRecipeFiller()::apply);
if (ComposterBlock.COMPOSTABLES.isEmpty()) {
ComposterBlock.bootStrap();
}
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/TippedArrowRecipeFiller.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/TippedArrowRecipeFiller.java
new file mode 100644
index 000000000..014799f6f
--- /dev/null
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/TippedArrowRecipeFiller.java
@@ -0,0 +1,71 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020, 2021, 2022 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.categories.crafting.filler;
+
+import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
+import it.unimi.dsi.fastutil.objects.ReferenceSet;
+import me.shedaniel.rei.api.client.registry.entry.EntryRegistry;
+import me.shedaniel.rei.api.common.display.Display;
+import me.shedaniel.rei.api.common.entry.EntryIngredient;
+import me.shedaniel.rei.api.common.util.EntryIngredients;
+import me.shedaniel.rei.api.common.util.EntryStacks;
+import me.shedaniel.rei.plugin.common.displays.crafting.DefaultCustomDisplay;
+import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.Items;
+import net.minecraft.world.item.alchemy.Potion;
+import net.minecraft.world.item.alchemy.PotionUtils;
+import net.minecraft.world.item.crafting.TippedArrowRecipe;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.function.Function;
+
+public class TippedArrowRecipeFiller implements Function<TippedArrowRecipe, Collection<Display>> {
+ @Override
+ public Collection<Display> apply(TippedArrowRecipe recipe) {
+ EntryIngredient arrowStack = EntryIngredient.of(EntryStacks.of(Items.ARROW));
+ ReferenceSet<Potion> registeredPotions = new ReferenceOpenHashSet<>();
+ List<Display> displays = new ArrayList<>();
+
+ EntryRegistry.getInstance().getEntryStacks().filter(entry -> entry.getValueType() == ItemStack.class && entry.<ItemStack>castValue().getItem() == Items.LINGERING_POTION).forEach(entry -> {
+ ItemStack itemStack = (ItemStack) entry.getValue();
+ Potion potion = PotionUtils.getPotion(itemStack);
+ if (registeredPotions.add(potion)) {
+ List<EntryIngredient> input = new ArrayList<>();
+ for (int i = 0; i < 4; i++)
+ input.add(arrowStack);
+ input.add(EntryIngredients.of(itemStack));
+ for (int i = 0; i < 4; i++)
+ input.add(arrowStack);
+ ItemStack outputStack = new ItemStack(Items.TIPPED_ARROW, 8);
+ PotionUtils.setPotion(outputStack, potion);
+ PotionUtils.setCustomEffects(outputStack, PotionUtils.getCustomEffects(itemStack));
+ displays.add(new DefaultCustomDisplay(recipe, input, List.of(EntryIngredients.of(outputStack))));
+ }
+ });
+
+ return displays;
+ }
+}