aboutsummaryrefslogtreecommitdiff
path: root/fabric
diff options
context:
space:
mode:
Diffstat (limited to 'fabric')
-rw-r--r--fabric/build.gradle41
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java2
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/impl/common/compat/FabricFluidAPISupportPlugin.java62
3 files changed, 84 insertions, 21 deletions
diff --git a/fabric/build.gradle b/fabric/build.gradle
index c182229c0..6d42ecee2 100644
--- a/fabric/build.gradle
+++ b/fabric/build.gradle
@@ -2,15 +2,19 @@ plugins {
id "com.github.johnrengelman.shadow" version "7.0.0"
}
-configurations {
- shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
-}
-
architectury {
platformSetupLoomIde()
fabric()
}
+configurations {
+ common
+ shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
+ compileClasspath.extendsFrom common
+ runtimeClasspath.extendsFrom common
+ developmentFabric.extendsFrom common
+}
+
processResources {
filesMatching("fabric.mod.json") {
expand "version": project.version
@@ -19,26 +23,23 @@ processResources {
}
loom {
- accessWidener = file("src/main/resources/roughlyenoughitems.accessWidener")
+ accessWidenerPath = file("src/main/resources/roughlyenoughitems.accessWidener")
}
def depProjects = [":api", ":runtime", ":default-plugin"]
dependencies {
modApi("net.fabricmc:fabric-loader:${project.fabricloader_version}")
- modRuntime("net.fabricmc.fabric-api:fabric-api:${project.fabric_api}")
+ modApi("net.fabricmc.fabric-api:fabric-api:${project.fabric_api}")
modApi("me.shedaniel.cloth:cloth-config-fabric:${cloth_config_version}") {
exclude(module: "fabric-api")
}
- modRuntime("com.terraformersmc:modmenu:${modmenu_version}") {
- transitive(false)
- }
+ modRuntime("com.terraformersmc:modmenu:${modmenu_version}") { transitive false }
modApi("dev.architectury:architectury-fabric:${architectury_version}")
depProjects.forEach {
- implementation(project(path: it)) { transitive = false }
- developmentFabric(project(path: it)) { transitive = false }
- shadowCommon(project(path: it, configuration: "transformProductionFabric")) { transitive = false }
+ common(project(path: it, configuration: "dev")) { transitive false }
+ shadowCommon(project(path: it, configuration: "transformProductionFabric")) { transitive false }
}
}
@@ -50,7 +51,7 @@ shadowJar {
remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
- classifier "fabric"
+ classifier null
}
jar {
@@ -71,17 +72,17 @@ sourcesJar {
}
}
+components.java {
+ withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
+ skip()
+ }
+}
+
publishing {
publications {
mavenFabric(MavenPublication) {
artifactId = rootProject.name + "-" + project.name
- artifact(remapJar) { classifier null }
- afterEvaluate {
- artifact(remapSourcesJar.output) {
- builtBy remapSourcesJar
- classifier "sources"
- }
- }
+ from components.java
}
["api", "default-plugin", "runtime"].forEach { projectName ->
create(projectName + "Fabric", MavenPublication.class) { publication ->
diff --git a/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java b/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java
index fae947dae..c44ae6a06 100644
--- a/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java
+++ b/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java
@@ -100,7 +100,7 @@ public class PluginDetectorImpl {
loadPlugin(REIServerPlugin.class, ((PluginView<REIServerPlugin>) PluginManager.getServerInstance())::registerPlugin);
if (FabricLoader.getInstance().isModLoaded("libblockattributes-fluids")) {
try {
- PluginView.getServerInstance().registerPlugin((REIServerPlugin) Class.forName("me.shedaniel.rei.impl.common.compat.LBASupportPlugin").getConstructor().newInstance());
+ PluginView.getServerInstance().registerPlugin((REIServerPlugin) Class.forName("me.shedaniel.rei.impl.common.compat.FabricFluidAPISupportPlugin").getConstructor().newInstance());
} catch (Throwable throwable) {
throwable.printStackTrace();
}
diff --git a/fabric/src/main/java/me/shedaniel/rei/impl/common/compat/FabricFluidAPISupportPlugin.java b/fabric/src/main/java/me/shedaniel/rei/impl/common/compat/FabricFluidAPISupportPlugin.java
new file mode 100644
index 000000000..651ff2821
--- /dev/null
+++ b/fabric/src/main/java/me/shedaniel/rei/impl/common/compat/FabricFluidAPISupportPlugin.java
@@ -0,0 +1,62 @@
+/*
+ * 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.impl.common.compat;
+
+import dev.architectury.event.CompoundEventResult;
+import dev.architectury.fluid.FluidStack;
+import me.shedaniel.rei.api.common.entry.EntryStack;
+import me.shedaniel.rei.api.common.fluid.FluidSupportProvider;
+import me.shedaniel.rei.api.common.plugins.REIServerPlugin;
+import me.shedaniel.rei.api.common.util.EntryStacks;
+import net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext;
+import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorage;
+import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
+import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
+import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction;
+import net.minecraft.world.item.ItemStack;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
+
+public class FabricFluidAPISupportPlugin implements REIServerPlugin {
+ @Override
+ public void registerFluidSupport(FluidSupportProvider support) {
+ support.register(entry -> {
+ ItemStack stack = entry.getValue().copy();
+ Storage<FluidVariant> storage = FluidStorage.ITEM.find(stack, ContainerItemContext.withInitial(stack));
+ List<EntryStack<FluidStack>> result;
+ try (Transaction transaction = Transaction.openOuter()) {
+ result = StreamSupport.stream(storage.iterable(transaction).spliterator(), false)
+ .filter(view -> !view.isResourceBlank() && !view.getResource().isBlank())
+ .map(view -> EntryStacks.of(FluidStack.create(view.getResource().getFluid(), view.getAmount(), view.getResource().getNbt())))
+ .collect(Collectors.toList());
+ }
+ if (!result.isEmpty()) {
+ return CompoundEventResult.interruptTrue(result.stream());
+ }
+ return CompoundEventResult.pass();
+ });
+ }
+}