aboutsummaryrefslogtreecommitdiff
path: root/runtime/src/main/java/me/shedaniel/rei/plugin/common
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2021-06-22 01:47:32 +0800
committershedaniel <daniel@shedaniel.me>2021-06-22 01:47:32 +0800
commit927a4af76ec3c74dc83c38b5b46d105a933bb48a (patch)
treecffa99dbeb9b56d53e0dfeacdcb857b2368a391d /runtime/src/main/java/me/shedaniel/rei/plugin/common
parent0d1886cd3a85e7829646b666c36b35cf3321f1b0 (diff)
downloadRoughlyEnoughItems-927a4af76ec3c74dc83c38b5b46d105a933bb48a.tar.gz
RoughlyEnoughItems-927a4af76ec3c74dc83c38b5b46d105a933bb48a.tar.bz2
RoughlyEnoughItems-927a4af76ec3c74dc83c38b5b46d105a933bb48a.zip
Fix #558
Diffstat (limited to 'runtime/src/main/java/me/shedaniel/rei/plugin/common')
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/plugin/common/DefaultRuntimePlugin.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/plugin/common/DefaultRuntimePlugin.java b/runtime/src/main/java/me/shedaniel/rei/plugin/common/DefaultRuntimePlugin.java
new file mode 100644
index 000000000..103da1937
--- /dev/null
+++ b/runtime/src/main/java/me/shedaniel/rei/plugin/common/DefaultRuntimePlugin.java
@@ -0,0 +1,60 @@
+/*
+ * 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;
+
+import dev.architectury.event.CompoundEventResult;
+import dev.architectury.fluid.FluidStack;
+import me.shedaniel.rei.api.common.entry.EntryStack;
+import me.shedaniel.rei.api.common.entry.type.EntryTypeRegistry;
+import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes;
+import me.shedaniel.rei.api.common.fluid.FluidSupportProvider;
+import me.shedaniel.rei.api.common.plugins.REIServerPlugin;
+import me.shedaniel.rei.plugin.client.entry.FluidEntryDefinition;
+import me.shedaniel.rei.plugin.client.entry.ItemEntryDefinition;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.minecraft.resources.ResourceLocation;
+import org.jetbrains.annotations.ApiStatus;
+
+import java.util.Optional;
+import java.util.stream.Stream;
+
+@ApiStatus.Internal
+public class DefaultRuntimePlugin implements REIServerPlugin {
+ public static final ResourceLocation PLUGIN = new ResourceLocation("roughlyenoughitems", "default_runtime_plugin");
+
+ @Override
+ public void registerEntryTypes(EntryTypeRegistry registry) {
+ registry.register(VanillaEntryTypes.ITEM, new ItemEntryDefinition());
+ registry.register(VanillaEntryTypes.FLUID, new FluidEntryDefinition());
+
+ registry.registerBridge(VanillaEntryTypes.ITEM, VanillaEntryTypes.FLUID, input -> {
+ Optional<Stream<EntryStack<FluidStack>>> stream = FluidSupportProvider.getInstance().itemToFluids(input);
+ if (!stream.isPresent()) {
+ return CompoundEventResult.pass();
+ }
+ return CompoundEventResult.interruptTrue(stream.get());
+ });
+ }
+}