diff options
| author | shedaniel <daniel@shedaniel.me> | 2021-05-03 17:23:48 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2021-05-03 17:23:48 +0800 |
| commit | 57ef08b02c2692063d8b3c14cc4f5a985c8a5a5e (patch) | |
| tree | c95984dd5343f5cfb788c9d78903418922c01c1a /forge/src/main/java | |
| parent | 3d2b1e760e56ea1ec6ab395d76029e2ae0b1e2d1 (diff) | |
| parent | 2ecc1d1dfe3ffa1261de82fee96d4943a3220bc1 (diff) | |
| download | RoughlyEnoughItems-57ef08b02c2692063d8b3c14cc4f5a985c8a5a5e.tar.gz RoughlyEnoughItems-57ef08b02c2692063d8b3c14cc4f5a985c8a5a5e.tar.bz2 RoughlyEnoughItems-57ef08b02c2692063d8b3c14cc4f5a985c8a5a5e.zip | |
Merge remote-tracking branch 'origin/6.x' into 6.x-1.17
# Conflicts:
# runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ContainerScreenOverlay.java
Diffstat (limited to 'forge/src/main/java')
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); + }); + } +} |
