aboutsummaryrefslogtreecommitdiff
path: root/forge/src/main/java/me
diff options
context:
space:
mode:
Diffstat (limited to 'forge/src/main/java/me')
-rw-r--r--forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java2
-rw-r--r--forge/src/main/java/me/shedaniel/rei/forge/REIPlugin.java2
-rw-r--r--forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java2
-rw-r--r--forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java2
-rw-r--r--forge/src/main/java/me/shedaniel/rei/plugin/common/forge/DefaultPluginImpl.java58
5 files changed, 62 insertions, 4 deletions
diff --git a/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java b/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java
index 7f31c7670..d4e48f9b8 100644
--- a/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java
+++ b/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java
@@ -1,6 +1,6 @@
/*
* This file is licensed under the MIT License, part of Roughly Enough Items.
- * Copyright (c) 2018, 2019, 2020 shedaniel
+ * 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
diff --git a/forge/src/main/java/me/shedaniel/rei/forge/REIPlugin.java b/forge/src/main/java/me/shedaniel/rei/forge/REIPlugin.java
index 03c40897d..b24487bb1 100644
--- a/forge/src/main/java/me/shedaniel/rei/forge/REIPlugin.java
+++ b/forge/src/main/java/me/shedaniel/rei/forge/REIPlugin.java
@@ -1,6 +1,6 @@
/*
* This file is licensed under the MIT License, part of Roughly Enough Items.
- * Copyright (c) 2018, 2019, 2020 shedaniel
+ * 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
diff --git a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java
index 8aea48ca0..61593fd84 100644
--- a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java
+++ b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java
@@ -1,6 +1,6 @@
/*
* This file is licensed under the MIT License, part of Roughly Enough Items.
- * Copyright (c) 2018, 2019, 2020 shedaniel
+ * 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
diff --git a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java
index a433c87a5..45b4e39a7 100644
--- a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java
+++ b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java
@@ -1,6 +1,6 @@
/*
* This file is licensed under the MIT License, part of Roughly Enough Items.
- * Copyright (c) 2018, 2019, 2020 shedaniel
+ * 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
diff --git a/forge/src/main/java/me/shedaniel/rei/plugin/common/forge/DefaultPluginImpl.java b/forge/src/main/java/me/shedaniel/rei/plugin/common/forge/DefaultPluginImpl.java
new file mode 100644
index 000000000..eccbc9e63
--- /dev/null
+++ b/forge/src/main/java/me/shedaniel/rei/plugin/common/forge/DefaultPluginImpl.java
@@ -0,0 +1,58 @@
+/*
+ * 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.common.forge;
+
+import com.google.common.base.Predicates;
+import me.shedaniel.architectury.hooks.forge.FluidStackHooksForge;
+import me.shedaniel.rei.api.common.fluid.FluidSupportProvider;
+import me.shedaniel.rei.api.common.util.EntryStacks;
+import net.minecraft.world.InteractionResultHolder;
+import net.minecraft.world.item.ItemStack;
+import net.minecraftforge.common.util.LazyOptional;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.FluidUtil;
+import net.minecraftforge.fluids.capability.IFluidHandlerItem;
+
+import java.util.stream.IntStream;
+
+public class DefaultPluginImpl {
+ public static void registerForgeFluidSupport(FluidSupportProvider support) {
+ support.register(stack -> {
+ ItemStack itemStack = stack.getValue();
+ LazyOptional<IFluidHandlerItem> handlerOptional = FluidUtil.getFluidHandler(itemStack);
+ if (handlerOptional.isPresent()) {
+ IFluidHandlerItem handler = handlerOptional.orElse(null);
+ if (handler.getTanks() > 0) {
+ return InteractionResultHolder.success(IntStream.range(0, handler.getTanks())
+ .mapToObj(handler::getFluidInTank)
+ .filter(Predicates.not(FluidStack::isEmpty))
+ .map(FluidStackHooksForge::fromForge)
+ .map(EntryStacks::of));
+ }
+ }
+
+ return InteractionResultHolder.pass(null);
+ });
+ }
+}