From a7b0a0dd4b305eb8655b008ebcfdcd2f7b70079a Mon Sep 17 00:00:00 2001 From: shedaniel Date: Fri, 15 Oct 2021 02:43:07 +0800 Subject: Fix merge conflicts --- .../shedaniel/rei/impl/common/compat/FabricFluidAPISupportPlugin.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'fabric') 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 index 651ff2821..01b5f2a47 100644 --- 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 @@ -30,6 +30,7 @@ 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.FluidConstants; 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; @@ -50,7 +51,7 @@ public class FabricFluidAPISupportPlugin implements REIServerPlugin { 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()))) + .map(view -> EntryStacks.of(FluidStack.create(view.getResource().getFluid(), Fraction.of(view.getAmount(), FluidConstants.BUCKET), view.getResource().getNbt()))) .collect(Collectors.toList()); } if (!result.isEmpty()) { -- cgit From 1dcf535cdf25c808ee4c0827a27c5b0e50094fda Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 16 Oct 2021 00:59:29 +0800 Subject: Fix merge conflicts --- .../shedaniel/rei/impl/common/compat/FabricFluidAPISupportPlugin.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'fabric') 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 index 01b5f2a47..8847874c1 100644 --- 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 @@ -50,8 +50,8 @@ public class FabricFluidAPISupportPlugin implements REIServerPlugin { List> 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(), Fraction.of(view.getAmount(), FluidConstants.BUCKET), view.getResource().getNbt()))) + .filter(view -> !view.isResourceBlank()) + .map(view -> EntryStacks.of(FluidStack.create(view.getResource().getFluid(), view.getAmount(), view.getResource().getNbt()))) .collect(Collectors.toList()); } if (!result.isEmpty()) { -- cgit From 62045c9cc0416557e6b57b6f4101b98a0da02dde Mon Sep 17 00:00:00 2001 From: shedaniel Date: Thu, 21 Oct 2021 23:36:28 +0800 Subject: Fix most of the issues in #643 --- .../rei/impl/client/fabric/ErrorDisplayerImpl.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'fabric') diff --git a/fabric/src/main/java/me/shedaniel/rei/impl/client/fabric/ErrorDisplayerImpl.java b/fabric/src/main/java/me/shedaniel/rei/impl/client/fabric/ErrorDisplayerImpl.java index ae6a0f9f3..eeaf86492 100644 --- a/fabric/src/main/java/me/shedaniel/rei/impl/client/fabric/ErrorDisplayerImpl.java +++ b/fabric/src/main/java/me/shedaniel/rei/impl/client/fabric/ErrorDisplayerImpl.java @@ -23,16 +23,29 @@ package me.shedaniel.rei.impl.client.fabric; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; +import java.util.function.UnaryOperator; public class ErrorDisplayerImpl { public static List> consumerList = new ArrayList<>(); - public static void registerGuiInit(Consumer consumer) { - consumerList.add(consumer); + public static void registerGuiInit(UnaryOperator consumer) { + consumerList.add(screen -> { + Screen screen1 = consumer.apply(screen); + if (screen1 != null) { + Minecraft minecraft = Minecraft.getInstance(); + try { + if (minecraft.screen != null) minecraft.screen.removed(); + } catch (Throwable ignored) { + } + minecraft.screen = null; + minecraft.setScreen(screen1); + } + }); } } -- cgit From c8f1c10e6c661ecf949ab29e0e8efeaa13324670 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Fri, 22 Oct 2021 01:40:06 +0800 Subject: Add Performance Analysis --- fabric/build.gradle | 2 +- .../java/me/shedaniel/rei/fabric/PluginDetectorImpl.java | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'fabric') diff --git a/fabric/build.gradle b/fabric/build.gradle index 6d42ecee2..f91ffc538 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -34,7 +34,7 @@ dependencies { 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 { 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 c44ae6a06..711437449 100644 --- a/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java +++ b/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java @@ -80,7 +80,8 @@ public class PluginDetectorImpl { } catch (Throwable t) { Throwable throwable = t; while (throwable != null) { - if (throwable.getMessage() != null && throwable.getMessage().contains("environment type SERVER") && !RoughlyEnoughItemsInitializer.isClient()) continue out; + if (throwable.getMessage() != null && throwable.getMessage().contains("environment type SERVER") && !RoughlyEnoughItemsInitializer.isClient()) + continue out; throwable = throwable.getCause(); } String error = "Could not create REI Plugin [" + getSimpleName(pluginClass) + "] due to errors, provided by '" + container.getProvider().getMetadata().getId() + "'!"; @@ -98,12 +99,10 @@ public class PluginDetectorImpl { public static void detectServerPlugins() { loadPlugin(REIServerPlugin.class, ((PluginView) PluginManager.getServerInstance())::registerPlugin); - if (FabricLoader.getInstance().isModLoaded("libblockattributes-fluids")) { - try { - PluginView.getServerInstance().registerPlugin((REIServerPlugin) Class.forName("me.shedaniel.rei.impl.common.compat.FabricFluidAPISupportPlugin").getConstructor().newInstance()); - } catch (Throwable throwable) { - throwable.printStackTrace(); - } + try { + PluginView.getServerInstance().registerPlugin((REIServerPlugin) Class.forName("me.shedaniel.rei.impl.common.compat.FabricFluidAPISupportPlugin").getConstructor().newInstance()); + } catch (Throwable throwable) { + throwable.printStackTrace(); } } -- cgit From fc32ca29ab21871b339c6f55de83d1d4ba9932ec Mon Sep 17 00:00:00 2001 From: shedaniel Date: Fri, 22 Oct 2021 14:43:36 +0800 Subject: Fix #644 --- .../common/compat/FabricFluidAPISupportPlugin.java | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'fabric') 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 index 8847874c1..cb75eca9f 100644 --- 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 @@ -30,7 +30,6 @@ 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.FluidConstants; 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; @@ -47,15 +46,17 @@ public class FabricFluidAPISupportPlugin implements REIServerPlugin { support.register(entry -> { ItemStack stack = entry.getValue().copy(); Storage storage = FluidStorage.ITEM.find(stack, ContainerItemContext.withInitial(stack)); - List> result; - try (Transaction transaction = Transaction.openOuter()) { - result = StreamSupport.stream(storage.iterable(transaction).spliterator(), false) - .filter(view -> !view.isResourceBlank()) - .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()); + if (storage != null) { + List> result; + try (Transaction transaction = Transaction.openOuter()) { + result = StreamSupport.stream(storage.iterable(transaction).spliterator(), false) + .filter(view -> !view.isResourceBlank()) + .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(); }); -- cgit From 1f3c9837e3c3e7e2cae805aeb7e839db5c52fb1c Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 23 Oct 2021 19:24:20 +0800 Subject: Fix #640 --- .../rei/fabric/RoughlyEnoughItemsInitializerImpl.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'fabric') diff --git a/fabric/src/main/java/me/shedaniel/rei/fabric/RoughlyEnoughItemsInitializerImpl.java b/fabric/src/main/java/me/shedaniel/rei/fabric/RoughlyEnoughItemsInitializerImpl.java index 47f671dc0..6c02624ac 100644 --- a/fabric/src/main/java/me/shedaniel/rei/fabric/RoughlyEnoughItemsInitializerImpl.java +++ b/fabric/src/main/java/me/shedaniel/rei/fabric/RoughlyEnoughItemsInitializerImpl.java @@ -28,6 +28,7 @@ import me.shedaniel.rei.RoughlyEnoughItemsState; import net.fabricmc.api.EnvType; import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.SemanticVersion; +import net.fabricmc.loader.api.Version; import net.fabricmc.loader.api.VersionParsingException; public class RoughlyEnoughItemsInitializerImpl { @@ -59,6 +60,16 @@ public class RoughlyEnoughItemsInitializerImpl { } if (!FabricLoader.getInstance().isModLoaded("architectury")) { RoughlyEnoughItemsState.error("Architectury API is not installed!", "https://www.curseforge.com/minecraft/mc-mods/architectury-fabric/files/all"); + } else { + Version version = FabricLoader.getInstance().getModContainer("architectury").get().getMetadata().getVersion(); + + try { + if (version instanceof SemanticVersion && SemanticVersion.parse("2.6.0").compareTo((SemanticVersion) version) > 0) { + RoughlyEnoughItemsState.error("Architectury API is too old, please update!", "https://www.curseforge.com/minecraft/mc-mods/architectury-fabric/files/all"); + } + } catch (VersionParsingException e) { + e.printStackTrace(); + } } if (isClient()) { try { -- cgit