From 3f520ad2161158d31e8784fbd47f35102978d4a3 Mon Sep 17 00:00:00 2001 From: Jab125 <67534807+Jab125@users.noreply.github.com> Date: Mon, 29 Apr 2024 16:27:57 +1000 Subject: [PATCH 1/9] initial implementation of hooks --- .../net/fabricmc/loader/api/FabricLoader.java | 6 +++ .../api/info/EntrypointInfoReceiver.java | 5 ++ .../api/info/EntrypointInvocationSession.java | 15 ++++++ .../net/fabricmc/loader/api/info/Message.java | 11 +++++ .../loader/api/info/ModMessageSession.java | 7 +++ .../fabricmc/loader/api/info/ProgressBar.java | 17 +++++++ .../loader/impl/FabricLoaderImpl.java | 39 +++++++++++++-- .../net/fabricmc/test/ProgressBarTest.java | 49 +++++++++++++++++++ 8 files changed, 146 insertions(+), 3 deletions(-) create mode 100644 src/main/java/net/fabricmc/loader/api/info/EntrypointInfoReceiver.java create mode 100644 src/main/java/net/fabricmc/loader/api/info/EntrypointInvocationSession.java create mode 100644 src/main/java/net/fabricmc/loader/api/info/Message.java create mode 100644 src/main/java/net/fabricmc/loader/api/info/ModMessageSession.java create mode 100644 src/main/java/net/fabricmc/loader/api/info/ProgressBar.java create mode 100644 src/test/java/net/fabricmc/test/ProgressBarTest.java diff --git a/src/main/java/net/fabricmc/loader/api/FabricLoader.java b/src/main/java/net/fabricmc/loader/api/FabricLoader.java index e83b54033..d5753c543 100644 --- a/src/main/java/net/fabricmc/loader/api/FabricLoader.java +++ b/src/main/java/net/fabricmc/loader/api/FabricLoader.java @@ -25,6 +25,9 @@ import net.fabricmc.api.EnvType; import net.fabricmc.loader.api.entrypoint.EntrypointContainer; +import net.fabricmc.loader.api.info.EntrypointInfoReceiver; +import net.fabricmc.loader.api.info.EntrypointInvocationSession; +import net.fabricmc.loader.api.info.ModMessageSession; import net.fabricmc.loader.impl.FabricLoaderImpl; /** @@ -236,4 +239,7 @@ static FabricLoader getInstance() { * @return the launch arguments for the game */ String[] getLaunchArguments(boolean sanitize); + + List getEntrypointInfoReceivers(); + ModMessageSession getModMessageSession(); } diff --git a/src/main/java/net/fabricmc/loader/api/info/EntrypointInfoReceiver.java b/src/main/java/net/fabricmc/loader/api/info/EntrypointInfoReceiver.java new file mode 100644 index 000000000..8e3a040b2 --- /dev/null +++ b/src/main/java/net/fabricmc/loader/api/info/EntrypointInfoReceiver.java @@ -0,0 +1,5 @@ +package net.fabricmc.loader.api.info; + +public interface EntrypointInfoReceiver { + EntrypointInvocationSession createEntrypointInvocationSession(String entrypointName, int size); +} diff --git a/src/main/java/net/fabricmc/loader/api/info/EntrypointInvocationSession.java b/src/main/java/net/fabricmc/loader/api/info/EntrypointInvocationSession.java new file mode 100644 index 000000000..23cd64119 --- /dev/null +++ b/src/main/java/net/fabricmc/loader/api/info/EntrypointInvocationSession.java @@ -0,0 +1,15 @@ +package net.fabricmc.loader.api.info; + +import net.fabricmc.loader.api.ModContainer; + +import java.io.Closeable; + +public interface EntrypointInvocationSession extends Closeable { + /** + * Called before an entrypoint is invoked. + */ + void preInvoke(ModContainer mod, int index, int size); + Throwable error(ModContainer mod, Throwable throwable, int index, int size); + @Override + void close(); +} diff --git a/src/main/java/net/fabricmc/loader/api/info/Message.java b/src/main/java/net/fabricmc/loader/api/info/Message.java new file mode 100644 index 000000000..0d1523c8b --- /dev/null +++ b/src/main/java/net/fabricmc/loader/api/info/Message.java @@ -0,0 +1,11 @@ +package net.fabricmc.loader.api.info; + +public interface Message { + void pin(); + void unpin(); + + /** + * Sets a new message. Should only be used when pinned. + */ + void title(String message); +} diff --git a/src/main/java/net/fabricmc/loader/api/info/ModMessageSession.java b/src/main/java/net/fabricmc/loader/api/info/ModMessageSession.java new file mode 100644 index 000000000..55193fa58 --- /dev/null +++ b/src/main/java/net/fabricmc/loader/api/info/ModMessageSession.java @@ -0,0 +1,7 @@ +package net.fabricmc.loader.api.info; + +public interface ModMessageSession { + Message message(String string); + + ProgressBar progressBar(String name, int steps); +} diff --git a/src/main/java/net/fabricmc/loader/api/info/ProgressBar.java b/src/main/java/net/fabricmc/loader/api/info/ProgressBar.java new file mode 100644 index 000000000..81c8858d9 --- /dev/null +++ b/src/main/java/net/fabricmc/loader/api/info/ProgressBar.java @@ -0,0 +1,17 @@ +package net.fabricmc.loader.api.info; + +import java.io.Closeable; + +/** + * A progress bar with 0 is an indeterminate progress bar which can only be completed. + */ +public interface ProgressBar extends Closeable { + void increment(); + float progress(); + + void set(int steps); + String title(); + void title(String title); + @Override + void close(); +} diff --git a/src/main/java/net/fabricmc/loader/impl/FabricLoaderImpl.java b/src/main/java/net/fabricmc/loader/impl/FabricLoaderImpl.java index 9ab01efd3..43e39c1db 100644 --- a/src/main/java/net/fabricmc/loader/impl/FabricLoaderImpl.java +++ b/src/main/java/net/fabricmc/loader/impl/FabricLoaderImpl.java @@ -35,6 +35,10 @@ import java.util.function.Consumer; import java.util.stream.Collectors; +import net.fabricmc.loader.api.info.EntrypointInfoReceiver; +import net.fabricmc.loader.api.info.EntrypointInvocationSession; +import net.fabricmc.loader.api.info.ModMessageSession; + import org.objectweb.asm.Opcodes; import net.fabricmc.accesswidener.AccessWidener; @@ -369,20 +373,35 @@ public List> getEntrypointContainers(String key, Clas @Override public void invokeEntrypoints(String key, Class type, Consumer invoker) { + RuntimeException exception = null; + Collection> entrypoints = FabricLoaderImpl.INSTANCE.getEntrypointContainers(key, type); + List sessions = new ArrayList<>(); + int size = entrypoints.size(); + for (EntrypointInfoReceiver entrypointInfoReceiver : FabricLoaderImpl.INSTANCE.getEntrypointInfoReceivers()) { + sessions.add(entrypointInfoReceiver.createEntrypointInvocationSession(key, size)); + } + if (!hasEntrypoints(key)) { Log.debug(LogCategory.ENTRYPOINT, "No subscribers for entrypoint '%s'", key); return; } - RuntimeException exception = null; - Collection> entrypoints = FabricLoaderImpl.INSTANCE.getEntrypointContainers(key, type); - Log.debug(LogCategory.ENTRYPOINT, "Iterating over entrypoint '%s'", key); + int index = 0; for (EntrypointContainer container : entrypoints) { + index++; + for (EntrypointInvocationSession session : sessions) { + session.preInvoke(container.getProvider(), index, size); + } try { invoker.accept(container.getEntrypoint()); } catch (Throwable t) { + for (EntrypointInvocationSession session : sessions) { + //noinspection ReassignedVariable,AssignmentToCatchBlockParameter + t = session.error(container.getProvider(), t, index, size); + } + if (t == null) continue; exception = ExceptionUtil.gatherExceptions(t, exception, exc -> new RuntimeException(String.format("Could not execute entrypoint stage '%s' due to errors, provided by '%s'!", @@ -391,6 +410,10 @@ public void invokeEntrypoints(String key, Class type, Consumer } } + for (EntrypointInvocationSession session : sessions) { + session.close(); + } + if (exception != null) { throw exception; } @@ -595,6 +618,16 @@ public String[] getLaunchArguments(boolean sanitize) { return getGameProvider().getLaunchArguments(sanitize); } + @Override + public List getEntrypointInfoReceivers() { + return null; + } + + @Override + public ModMessageSession getModMessageSession() { + return null; + } + @Override protected Path getModsDirectory0() { String directory = System.getProperty(SystemProperties.MODS_FOLDER); diff --git a/src/test/java/net/fabricmc/test/ProgressBarTest.java b/src/test/java/net/fabricmc/test/ProgressBarTest.java new file mode 100644 index 000000000..b79eb1d92 --- /dev/null +++ b/src/test/java/net/fabricmc/test/ProgressBarTest.java @@ -0,0 +1,49 @@ +package net.fabricmc.test; + +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.ModContainer; +import net.fabricmc.loader.api.info.EntrypointInfoReceiver; +import net.fabricmc.loader.api.info.EntrypointInvocationSession; +import net.fabricmc.loader.api.info.Message; +import net.fabricmc.loader.api.info.ModMessageSession; +import net.fabricmc.loader.api.info.ProgressBar; + +public class ProgressBarTest { + public void progressBarTest() { + ModMessageSession modMessageSession = FabricLoader.getInstance().getModMessageSession(); + Message message = modMessageSession.message("0/2"); + message.pin(); + message.title("1/2"); + message.title("2/2"); + message.unpin(); + + ProgressBar progressBar = modMessageSession.progressBar("Progress Bar", 100); + for (int i = 0; i < 100; i++) { + progressBar.increment(); + } + progressBar.close(); + } + + // Specified in `fabric.mod.json` + class EntrypointSession implements EntrypointInfoReceiver { + + @Override + public EntrypointInvocationSession createEntrypointInvocationSession(String entrypointName, int size) { + return new EntrypointInvocationSession() { + ProgressBar progressBar; + @Override + public void preInvoke(ModContainer mod, int index, int size) { + if (progressBar == null) { + progressBar = FabricLoader.getInstance().getModMessageSession().progressBar(entrypointName, size); + } + progressBar.set(index); + } + + @Override + public void close() { + + } + }; + } + } +} From 49ee80ac1da8050ee30d4e71b175ca6ff488c115 Mon Sep 17 00:00:00 2001 From: Jab125 <67534807+Jab125@users.noreply.github.com> Date: Mon, 29 Apr 2024 16:32:47 +1000 Subject: [PATCH 2/9] Update ProgressBarTest.java --- src/test/java/net/fabricmc/test/ProgressBarTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/java/net/fabricmc/test/ProgressBarTest.java b/src/test/java/net/fabricmc/test/ProgressBarTest.java index b79eb1d92..91f4d7849 100644 --- a/src/test/java/net/fabricmc/test/ProgressBarTest.java +++ b/src/test/java/net/fabricmc/test/ProgressBarTest.java @@ -39,6 +39,11 @@ public void preInvoke(ModContainer mod, int index, int size) { progressBar.set(index); } + @Override + public Throwable error(ModContainer mod, Throwable throwable, int index, int size) { + return throwable; + } + @Override public void close() { From 3951dd840802df5fc82ee183190f35deb5c14d6e Mon Sep 17 00:00:00 2001 From: Jab125 <67534807+Jab125@users.noreply.github.com> Date: Mon, 29 Apr 2024 16:39:24 +1000 Subject: [PATCH 3/9] Update ProgressBarTest.java --- src/test/java/net/fabricmc/test/ProgressBarTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/fabricmc/test/ProgressBarTest.java b/src/test/java/net/fabricmc/test/ProgressBarTest.java index 91f4d7849..953012ebf 100644 --- a/src/test/java/net/fabricmc/test/ProgressBarTest.java +++ b/src/test/java/net/fabricmc/test/ProgressBarTest.java @@ -46,7 +46,7 @@ public Throwable error(ModContainer mod, Throwable throwable, int index, int siz @Override public void close() { - + progressBar.close(); } }; } From 0e9fdde88b5ebd68defda062ca6387026500fd7b Mon Sep 17 00:00:00 2001 From: Jab125 <67534807+Jab125@users.noreply.github.com> Date: Mon, 29 Apr 2024 23:14:46 +1000 Subject: [PATCH 4/9] update api --- .../net/fabricmc/loader/api/FabricLoader.java | 5 +- .../net/fabricmc/loader/api/info/Message.java | 9 ++- .../loader/api/info/ModMessageReceiver.java | 6 ++ ...sageSession.java => ModMessageSender.java} | 2 +- .../fabricmc/loader/api/info/ProgressBar.java | 9 ++- .../loader/impl/FabricLoaderImpl.java | 10 +-- .../loader/impl/info/MessageImpl.java | 36 +++++++++++ .../impl/info/ModMessageSenderImpl.java | 24 +++++++ .../loader/impl/info/ProgressBarImpl.java | 63 +++++++++++++++++++ 9 files changed, 152 insertions(+), 12 deletions(-) create mode 100644 src/main/java/net/fabricmc/loader/api/info/ModMessageReceiver.java rename src/main/java/net/fabricmc/loader/api/info/{ModMessageSession.java => ModMessageSender.java} (77%) create mode 100644 src/main/java/net/fabricmc/loader/impl/info/MessageImpl.java create mode 100644 src/main/java/net/fabricmc/loader/impl/info/ModMessageSenderImpl.java create mode 100644 src/main/java/net/fabricmc/loader/impl/info/ProgressBarImpl.java diff --git a/src/main/java/net/fabricmc/loader/api/FabricLoader.java b/src/main/java/net/fabricmc/loader/api/FabricLoader.java index d5753c543..d6655934b 100644 --- a/src/main/java/net/fabricmc/loader/api/FabricLoader.java +++ b/src/main/java/net/fabricmc/loader/api/FabricLoader.java @@ -26,8 +26,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.loader.api.entrypoint.EntrypointContainer; import net.fabricmc.loader.api.info.EntrypointInfoReceiver; -import net.fabricmc.loader.api.info.EntrypointInvocationSession; -import net.fabricmc.loader.api.info.ModMessageSession; +import net.fabricmc.loader.api.info.ModMessageSender; import net.fabricmc.loader.impl.FabricLoaderImpl; /** @@ -241,5 +240,5 @@ static FabricLoader getInstance() { String[] getLaunchArguments(boolean sanitize); List getEntrypointInfoReceivers(); - ModMessageSession getModMessageSession(); + ModMessageSender getModMessageSession(); } diff --git a/src/main/java/net/fabricmc/loader/api/info/Message.java b/src/main/java/net/fabricmc/loader/api/info/Message.java index 0d1523c8b..b96140fa5 100644 --- a/src/main/java/net/fabricmc/loader/api/info/Message.java +++ b/src/main/java/net/fabricmc/loader/api/info/Message.java @@ -1,11 +1,14 @@ package net.fabricmc.loader.api.info; -public interface Message { - void pin(); - void unpin(); +import java.io.Closeable; +public interface Message extends Closeable { + boolean pinned(); /** * Sets a new message. Should only be used when pinned. */ void title(String message); + String title(); + @Override + void close(); } diff --git a/src/main/java/net/fabricmc/loader/api/info/ModMessageReceiver.java b/src/main/java/net/fabricmc/loader/api/info/ModMessageReceiver.java new file mode 100644 index 000000000..550257889 --- /dev/null +++ b/src/main/java/net/fabricmc/loader/api/info/ModMessageReceiver.java @@ -0,0 +1,6 @@ +package net.fabricmc.loader.api.info; + +public interface ModMessageReceiver { + void progressBar(ProgressBar progressBar); + void message(Message message); +} diff --git a/src/main/java/net/fabricmc/loader/api/info/ModMessageSession.java b/src/main/java/net/fabricmc/loader/api/info/ModMessageSender.java similarity index 77% rename from src/main/java/net/fabricmc/loader/api/info/ModMessageSession.java rename to src/main/java/net/fabricmc/loader/api/info/ModMessageSender.java index 55193fa58..81474ed97 100644 --- a/src/main/java/net/fabricmc/loader/api/info/ModMessageSession.java +++ b/src/main/java/net/fabricmc/loader/api/info/ModMessageSender.java @@ -1,6 +1,6 @@ package net.fabricmc.loader.api.info; -public interface ModMessageSession { +public interface ModMessageSender { Message message(String string); ProgressBar progressBar(String name, int steps); diff --git a/src/main/java/net/fabricmc/loader/api/info/ProgressBar.java b/src/main/java/net/fabricmc/loader/api/info/ProgressBar.java index 81c8858d9..9d15d0cdd 100644 --- a/src/main/java/net/fabricmc/loader/api/info/ProgressBar.java +++ b/src/main/java/net/fabricmc/loader/api/info/ProgressBar.java @@ -7,11 +7,18 @@ */ public interface ProgressBar extends Closeable { void increment(); - float progress(); + float percentage(); + int progress(); + /** + * @return The total amount of steps the progress bar has. + */ + int steps(); void set(int steps); String title(); void title(String title); @Override void close(); + + boolean isCompleted(); } diff --git a/src/main/java/net/fabricmc/loader/impl/FabricLoaderImpl.java b/src/main/java/net/fabricmc/loader/impl/FabricLoaderImpl.java index 43e39c1db..dbc0cb5d8 100644 --- a/src/main/java/net/fabricmc/loader/impl/FabricLoaderImpl.java +++ b/src/main/java/net/fabricmc/loader/impl/FabricLoaderImpl.java @@ -37,7 +37,9 @@ import net.fabricmc.loader.api.info.EntrypointInfoReceiver; import net.fabricmc.loader.api.info.EntrypointInvocationSession; -import net.fabricmc.loader.api.info.ModMessageSession; +import net.fabricmc.loader.api.info.ModMessageSender; + +import net.fabricmc.loader.impl.info.ModMessageSenderImpl; import org.objectweb.asm.Opcodes; @@ -620,12 +622,12 @@ public String[] getLaunchArguments(boolean sanitize) { @Override public List getEntrypointInfoReceivers() { - return null; + return getEntrypoints("entrypointReceiver", EntrypointInfoReceiver.class); } @Override - public ModMessageSession getModMessageSession() { - return null; + public ModMessageSender getModMessageSession() { + return new ModMessageSenderImpl(); } @Override diff --git a/src/main/java/net/fabricmc/loader/impl/info/MessageImpl.java b/src/main/java/net/fabricmc/loader/impl/info/MessageImpl.java new file mode 100644 index 000000000..e2fc35714 --- /dev/null +++ b/src/main/java/net/fabricmc/loader/impl/info/MessageImpl.java @@ -0,0 +1,36 @@ +package net.fabricmc.loader.impl.info; + +import net.fabricmc.loader.api.info.Message; + +import java.io.Serializable; + +class MessageImpl implements Message, Serializable { + private boolean closed; + private String title; + + MessageImpl(String title) { + this.title = title; + } + + @Override + public boolean pinned() { + return !closed; + } + + @Override + public void title(String message) { + if (closed) throw new IllegalStateException("Already closed!"); + title = message; + } + + @Override + public String title() { + return title; + } + + @Override + public void close() { + if (closed) throw new IllegalStateException("Already closed!"); + closed = true; + } +} diff --git a/src/main/java/net/fabricmc/loader/impl/info/ModMessageSenderImpl.java b/src/main/java/net/fabricmc/loader/impl/info/ModMessageSenderImpl.java new file mode 100644 index 000000000..9d0906060 --- /dev/null +++ b/src/main/java/net/fabricmc/loader/impl/info/ModMessageSenderImpl.java @@ -0,0 +1,24 @@ +package net.fabricmc.loader.impl.info; + +import net.fabricmc.loader.api.info.Message; +import net.fabricmc.loader.api.info.ModMessageReceiver; +import net.fabricmc.loader.api.info.ModMessageSender; +import net.fabricmc.loader.api.info.ProgressBar; +import net.fabricmc.loader.impl.FabricLoaderImpl; + +public class ModMessageSenderImpl implements ModMessageSender { + + @Override + public Message message(String title) { + MessageImpl message = new MessageImpl(title); + FabricLoaderImpl.INSTANCE.getEntrypoints("modMessageReceiver", ModMessageReceiver.class).forEach(entrypoint -> entrypoint.message(message)); + return message; + } + + @Override + public ProgressBar progressBar(String name, int steps) { + ProgressBarImpl progressBar = new ProgressBarImpl(name, steps); + FabricLoaderImpl.INSTANCE.getEntrypoints("modMessageReceiver", ModMessageReceiver.class).forEach(entrypoint -> entrypoint.progressBar(progressBar)); + return progressBar; + } +} diff --git a/src/main/java/net/fabricmc/loader/impl/info/ProgressBarImpl.java b/src/main/java/net/fabricmc/loader/impl/info/ProgressBarImpl.java new file mode 100644 index 000000000..dbdbd009f --- /dev/null +++ b/src/main/java/net/fabricmc/loader/impl/info/ProgressBarImpl.java @@ -0,0 +1,63 @@ +package net.fabricmc.loader.impl.info; + +import net.fabricmc.loader.api.info.ProgressBar; + +import java.io.Serializable; + +public class ProgressBarImpl implements ProgressBar, Serializable { + private String title; + private int progress; + private int steps; + private boolean completed; + ProgressBarImpl(String title, int steps) { + this.title = title; + this.steps = steps; + } + @Override + public void increment() { + if (this.completed) throw new IllegalStateException("Already closed!"); + progress++; + } + + @Override + public float percentage() { + return (float) progress / steps; + } + + @Override + public int steps() { + return steps; + } + + @Override + public int progress() { + return progress; + } + + @Override + public void set(int steps) { + if (this.completed) throw new IllegalStateException("Already closed!"); + this.progress = steps; + } + + @Override + public String title() { + return title; + } + + @Override + public void title(String title) { + if (this.completed) throw new IllegalStateException("Already closed!"); + this.title = title; + } + + @Override + public void close() { + this.completed = true; + } + + @Override + public boolean isCompleted() { + return completed; + } +} From 97d90896e20be0b0298fa3cbbd8d76d605566249 Mon Sep 17 00:00:00 2001 From: Jab125 <67534807+Jab125@users.noreply.github.com> Date: Mon, 29 Apr 2024 23:14:53 +1000 Subject: [PATCH 5/9] remove progress bar test --- .../net/fabricmc/test/ProgressBarTest.java | 54 ------------------- 1 file changed, 54 deletions(-) delete mode 100644 src/test/java/net/fabricmc/test/ProgressBarTest.java diff --git a/src/test/java/net/fabricmc/test/ProgressBarTest.java b/src/test/java/net/fabricmc/test/ProgressBarTest.java deleted file mode 100644 index 953012ebf..000000000 --- a/src/test/java/net/fabricmc/test/ProgressBarTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package net.fabricmc.test; - -import net.fabricmc.loader.api.FabricLoader; -import net.fabricmc.loader.api.ModContainer; -import net.fabricmc.loader.api.info.EntrypointInfoReceiver; -import net.fabricmc.loader.api.info.EntrypointInvocationSession; -import net.fabricmc.loader.api.info.Message; -import net.fabricmc.loader.api.info.ModMessageSession; -import net.fabricmc.loader.api.info.ProgressBar; - -public class ProgressBarTest { - public void progressBarTest() { - ModMessageSession modMessageSession = FabricLoader.getInstance().getModMessageSession(); - Message message = modMessageSession.message("0/2"); - message.pin(); - message.title("1/2"); - message.title("2/2"); - message.unpin(); - - ProgressBar progressBar = modMessageSession.progressBar("Progress Bar", 100); - for (int i = 0; i < 100; i++) { - progressBar.increment(); - } - progressBar.close(); - } - - // Specified in `fabric.mod.json` - class EntrypointSession implements EntrypointInfoReceiver { - - @Override - public EntrypointInvocationSession createEntrypointInvocationSession(String entrypointName, int size) { - return new EntrypointInvocationSession() { - ProgressBar progressBar; - @Override - public void preInvoke(ModContainer mod, int index, int size) { - if (progressBar == null) { - progressBar = FabricLoader.getInstance().getModMessageSession().progressBar(entrypointName, size); - } - progressBar.set(index); - } - - @Override - public Throwable error(ModContainer mod, Throwable throwable, int index, int size) { - return throwable; - } - - @Override - public void close() { - progressBar.close(); - } - }; - } - } -} From 762f90242e9562df88276847cd13ee13b1c51efe Mon Sep 17 00:00:00 2001 From: Jab125 <67534807+Jab125@users.noreply.github.com> Date: Mon, 29 Apr 2024 23:15:07 +1000 Subject: [PATCH 6/9] Add early display test --- .../minecraft/test/info/DisplayRemote.java | 10 ++ .../test/info/DisplayRemoteObject.java | 70 ++++++++ .../test/info/EarlyDisplayEntrypoint.java | 150 ++++++++++++++++++ .../minecraft/test/info/EarlyDisplayInit.java | 12 ++ .../minecraft/test/info/TestEntrypoint.java | 12 ++ .../src/main/resources/fabric.mod.json | 34 ++++ 6 files changed, 288 insertions(+) create mode 100644 minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/DisplayRemote.java create mode 100644 minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/DisplayRemoteObject.java create mode 100644 minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/EarlyDisplayEntrypoint.java create mode 100644 minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/EarlyDisplayInit.java create mode 100644 minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/TestEntrypoint.java diff --git a/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/DisplayRemote.java b/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/DisplayRemote.java new file mode 100644 index 000000000..7e3e62d9b --- /dev/null +++ b/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/DisplayRemote.java @@ -0,0 +1,10 @@ +package net.fabricmc.minecraft.test.info; + +import net.fabricmc.loader.api.info.ProgressBar; + +import java.rmi.Remote; +import java.rmi.RemoteException; + +public interface DisplayRemote extends Remote { + void progressBars(ProgressBar[] progressBars) throws RemoteException; +} diff --git a/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/DisplayRemoteObject.java b/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/DisplayRemoteObject.java new file mode 100644 index 000000000..b323cad95 --- /dev/null +++ b/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/DisplayRemoteObject.java @@ -0,0 +1,70 @@ +package net.fabricmc.minecraft.test.info; + +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.info.ProgressBar; + +import javax.swing.*; + +import java.rmi.RemoteException; +import java.rmi.server.UnicastRemoteObject; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class DisplayRemoteObject extends UnicastRemoteObject implements DisplayRemote { + private ProgressBar[] progressBars = new ProgressBar[0]; + protected DisplayRemoteObject() throws RemoteException { + new Thread(() -> { + JFrame frame = new JFrame(); + frame.setVisible(false); + System.setProperty("apple.awt.application.appearance", "system"); + System.setProperty("apple.awt.application.name", "Loading Window"); + + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | + UnsupportedLookAndFeelException e) { + throw new RuntimeException(e); + } + JLabel modMessages = new JLabel("Mod Messages"); + frame.add(modMessages); + frame.setSize(480, 300); + frame.setVisible(true); + ConcurrentHashMap cache = new ConcurrentHashMap<>(); + try { + while (true) { + int i = 0; + for (ProgressBar progressBar : progressBars) { + JProgressBar jProgressBar = cache.computeIfAbsent(progressBar.title(), f -> { + JProgressBar bar = progressBar.steps() == 0 ? new JProgressBar(0, 1) : new JProgressBar(0, progressBar.steps()); + frame.add(bar); + return bar; + }); + jProgressBar.setStringPainted(true); + if (progressBar.steps() == 0) jProgressBar.setValue(1); + jProgressBar.setString(progressBar.title() + " (" + progressBar.progress() + "/" + progressBar.steps() + ")"); + jProgressBar.setBounds(10, 30 + i * 10, 300, 30 * 10); + if (progressBar.steps() != 0) jProgressBar.setValue(progressBar.progress()); + i++; + } + frame.repaint(); + cache.forEach((s, jProgressBar) -> { + if (Arrays.stream(progressBars).map(ProgressBar::title).noneMatch(s::equals)) { + frame.remove(jProgressBar); + cache.remove(s); + } + }); + } + } catch (Throwable t) { + t.printStackTrace(); + } + }).start(); + } + + @Override + public void progressBars(ProgressBar[] progressBars) { + this.progressBars = progressBars; + } +} diff --git a/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/EarlyDisplayEntrypoint.java b/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/EarlyDisplayEntrypoint.java new file mode 100644 index 000000000..2dee46be1 --- /dev/null +++ b/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/EarlyDisplayEntrypoint.java @@ -0,0 +1,150 @@ +package net.fabricmc.minecraft.test.info; + +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.ModContainer; +import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint; +import net.fabricmc.loader.api.info.EntrypointInfoReceiver; +import net.fabricmc.loader.api.info.EntrypointInvocationSession; +import net.fabricmc.loader.api.info.Message; +import net.fabricmc.loader.api.info.ModMessageReceiver; +import net.fabricmc.loader.api.info.ProgressBar; +import net.fabricmc.loader.impl.gui.FabricGuiEntry; +import net.fabricmc.loader.impl.util.LoaderUtil; +import net.fabricmc.loader.impl.util.UrlUtil; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.rmi.NotBoundException; +import java.rmi.RemoteException; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; +import java.util.Arrays; +import java.util.concurrent.ConcurrentLinkedDeque; + +public class EarlyDisplayEntrypoint implements PreLaunchEntrypoint, Runnable, EntrypointInfoReceiver, ModMessageReceiver { + + private DisplayRemote remote; + + @Override + public void onPreLaunch() { + try { + openForked(); + Thread.sleep(1000); + Registry registry = LocateRegistry.getRegistry(null, 1099); + System.out.println(Arrays.toString(registry.list())); + remote = (DisplayRemote) registry.lookup("Remote"); + } catch (NotBoundException | InterruptedException | IOException e) { + throw new RuntimeException(e); + } + new Thread(this).start(); + + new Thread(() -> { + ProgressBar progressBar = FabricLoader.getInstance().getModMessageSession().progressBar("Test Progress Bar", 1000); + for (int i = 0; i < 1000; i++) { + progressBar.increment(); + try { + Thread.sleep(10); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + progressBar.close(); + }).start(); + FabricLoader.getInstance().invokeEntrypoints("test", Runnable.class, Runnable::run); + } + + private static void openForked() throws IOException, InterruptedException { + Path javaBinDir = LoaderUtil.normalizePath(Paths.get(System.getProperty("java.home"), "bin")); + String[] executables = { "javaw.exe", "java.exe", "java" }; + Path javaPath = null; + + for (String executable : executables) { + Path path = javaBinDir.resolve(executable); + + if (Files.isRegularFile(path)) { + javaPath = path; + break; + } + } + + if (javaPath == null) throw new RuntimeException("can't find java executable in "+javaBinDir); + System.out.println(javaPath.toString() + " -Xmx1G" + " -cp " + UrlUtil.getCodeSource(EarlyDisplayInit.class).toString() + ":" + UrlUtil.LOADER_CODE_SOURCE.toString() + " " + FabricGuiEntry.class.getName()); + Process process = new ProcessBuilder(javaPath.toString(), "-Xmx1G", "-cp", UrlUtil.getCodeSource(EarlyDisplayInit.class).toString() + ":" + UrlUtil.LOADER_CODE_SOURCE.toString(), EarlyDisplayInit.class.getName()) + .redirectOutput(ProcessBuilder.Redirect.INHERIT) + .redirectError(ProcessBuilder.Redirect.INHERIT) + .start(); + + final Thread shutdownHook = new Thread(process::destroy); + + Runtime.getRuntime().addShutdownHook(shutdownHook); + + +// int rVal = process.waitFor(); +// +// Runtime.getRuntime().removeShutdownHook(shutdownHook); +// +// if (rVal != 0) throw new IOException("subprocess exited with code "+rVal); + } + + private static final ConcurrentLinkedDeque progressBars = new ConcurrentLinkedDeque<>(); + private static final ConcurrentLinkedDeque pinnedMessages = new ConcurrentLinkedDeque<>(); + private static final ConcurrentLinkedDeque messages = new ConcurrentLinkedDeque<>(); + + @Override + public void run() { + while (true) { + progressBars.removeIf(ProgressBar::isCompleted); + try { + remote.progressBars(progressBars.toArray(new ProgressBar[0])); + } catch (RemoteException e) { + throw new RuntimeException(e); + } + } + } + + @Override + public EntrypointInvocationSession createEntrypointInvocationSession(String entrypointName, int size) { + MyEntrypointInvocationSession myEntrypointInvocationSession = new MyEntrypointInvocationSession(); + myEntrypointInvocationSession.name = entrypointName; + myEntrypointInvocationSession.size = size; + myEntrypointInvocationSession.progressBar = FabricLoader.getInstance().getModMessageSession().progressBar(entrypointName, size); + return myEntrypointInvocationSession; + } + + @Override + public void progressBar(ProgressBar progressBar) { + synchronized (progressBars) { + progressBars.add(progressBar); + } + } + + @Override + public void message(Message message) { + synchronized (pinnedMessages) { + pinnedMessages.add(message); + } + } + + private static class MyEntrypointInvocationSession implements EntrypointInvocationSession { + private String name; + private int size; + private ProgressBar progressBar; + + @Override + public void preInvoke(ModContainer mod, int index, int size) { + progressBar.set(index); + } + + @Override + public Throwable error(ModContainer mod, Throwable throwable, int index, int size) { + return throwable; + } + + @Override + public void close() { + progressBar.close(); + } + } +} diff --git a/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/EarlyDisplayInit.java b/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/EarlyDisplayInit.java new file mode 100644 index 000000000..ef9871901 --- /dev/null +++ b/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/EarlyDisplayInit.java @@ -0,0 +1,12 @@ +package net.fabricmc.minecraft.test.info; + +import java.rmi.RemoteException; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; + +public class EarlyDisplayInit { + public static void main(String[] args) throws RemoteException { + Registry registry = LocateRegistry.createRegistry(1099); + registry.rebind("Remote", new DisplayRemoteObject()); + } +} diff --git a/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/TestEntrypoint.java b/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/TestEntrypoint.java new file mode 100644 index 000000000..1fcf63cad --- /dev/null +++ b/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/TestEntrypoint.java @@ -0,0 +1,12 @@ +package net.fabricmc.minecraft.test.info; + +public class TestEntrypoint implements Runnable { + @Override + public void run() { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } +} diff --git a/minecraft/minecraft-test/src/main/resources/fabric.mod.json b/minecraft/minecraft-test/src/main/resources/fabric.mod.json index 2a07a0ee6..1529c6b0e 100644 --- a/minecraft/minecraft-test/src/main/resources/fabric.mod.json +++ b/minecraft/minecraft-test/src/main/resources/fabric.mod.json @@ -12,6 +12,40 @@ "entrypoints": { "main": [ "net.fabricmc.minecraft.test.TestEntrypoint" + ], + "preLaunch": [ + "net.fabricmc.minecraft.test.info.EarlyDisplayEntrypoint" + ], + "entrypointReceiver": [ + "net.fabricmc.minecraft.test.info.EarlyDisplayEntrypoint" + ], + "modMessageReceiver": [ + "net.fabricmc.minecraft.test.info.EarlyDisplayEntrypoint" + ], + "test": [ + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint", + "net.fabricmc.minecraft.test.info.TestEntrypoint" ] } } From 645e9df54cdf6da0074bb4fd4bf0f2c35c6ecf84 Mon Sep 17 00:00:00 2001 From: Jab125 <67534807+Jab125@users.noreply.github.com> Date: Mon, 29 Apr 2024 23:17:31 +1000 Subject: [PATCH 7/9] edit test --- .../test/info/DisplayRemoteObject.java | 12 ++++------ .../test/info/EarlyDisplayEntrypoint.java | 24 +++++-------------- .../minecraft/test/info/TestEntrypoint.java | 2 +- 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/DisplayRemoteObject.java b/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/DisplayRemoteObject.java index b323cad95..9b142df3f 100644 --- a/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/DisplayRemoteObject.java +++ b/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/DisplayRemoteObject.java @@ -1,16 +1,16 @@ package net.fabricmc.minecraft.test.info; -import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.info.ProgressBar; -import javax.swing.*; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JProgressBar; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class DisplayRemoteObject extends UnicastRemoteObject implements DisplayRemote { @@ -28,8 +28,6 @@ protected DisplayRemoteObject() throws RemoteException { UnsupportedLookAndFeelException e) { throw new RuntimeException(e); } - JLabel modMessages = new JLabel("Mod Messages"); - frame.add(modMessages); frame.setSize(480, 300); frame.setVisible(true); ConcurrentHashMap cache = new ConcurrentHashMap<>(); diff --git a/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/EarlyDisplayEntrypoint.java b/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/EarlyDisplayEntrypoint.java index 2dee46be1..d7695b36c 100644 --- a/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/EarlyDisplayEntrypoint.java +++ b/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/EarlyDisplayEntrypoint.java @@ -8,7 +8,6 @@ import net.fabricmc.loader.api.info.Message; import net.fabricmc.loader.api.info.ModMessageReceiver; import net.fabricmc.loader.api.info.ProgressBar; -import net.fabricmc.loader.impl.gui.FabricGuiEntry; import net.fabricmc.loader.impl.util.LoaderUtil; import net.fabricmc.loader.impl.util.UrlUtil; @@ -23,6 +22,7 @@ import java.util.Arrays; import java.util.concurrent.ConcurrentLinkedDeque; +@SuppressWarnings("InfiniteLoopStatement") public class EarlyDisplayEntrypoint implements PreLaunchEntrypoint, Runnable, EntrypointInfoReceiver, ModMessageReceiver { private DisplayRemote remote; @@ -69,8 +69,7 @@ private static void openForked() throws IOException, InterruptedException { } } - if (javaPath == null) throw new RuntimeException("can't find java executable in "+javaBinDir); - System.out.println(javaPath.toString() + " -Xmx1G" + " -cp " + UrlUtil.getCodeSource(EarlyDisplayInit.class).toString() + ":" + UrlUtil.LOADER_CODE_SOURCE.toString() + " " + FabricGuiEntry.class.getName()); + if (javaPath == null) throw new RuntimeException("can't find java executable in " + javaBinDir); Process process = new ProcessBuilder(javaPath.toString(), "-Xmx1G", "-cp", UrlUtil.getCodeSource(EarlyDisplayInit.class).toString() + ":" + UrlUtil.LOADER_CODE_SOURCE.toString(), EarlyDisplayInit.class.getName()) .redirectOutput(ProcessBuilder.Redirect.INHERIT) .redirectError(ProcessBuilder.Redirect.INHERIT) @@ -79,13 +78,6 @@ private static void openForked() throws IOException, InterruptedException { final Thread shutdownHook = new Thread(process::destroy); Runtime.getRuntime().addShutdownHook(shutdownHook); - - -// int rVal = process.waitFor(); -// -// Runtime.getRuntime().removeShutdownHook(shutdownHook); -// -// if (rVal != 0) throw new IOException("subprocess exited with code "+rVal); } private static final ConcurrentLinkedDeque progressBars = new ConcurrentLinkedDeque<>(); @@ -106,11 +98,9 @@ public void run() { @Override public EntrypointInvocationSession createEntrypointInvocationSession(String entrypointName, int size) { - MyEntrypointInvocationSession myEntrypointInvocationSession = new MyEntrypointInvocationSession(); - myEntrypointInvocationSession.name = entrypointName; - myEntrypointInvocationSession.size = size; - myEntrypointInvocationSession.progressBar = FabricLoader.getInstance().getModMessageSession().progressBar(entrypointName, size); - return myEntrypointInvocationSession; + TestEntrypointInvocationSession testEntrypointInvocationSession = new TestEntrypointInvocationSession(); + testEntrypointInvocationSession.progressBar = FabricLoader.getInstance().getModMessageSession().progressBar(entrypointName, size); + return testEntrypointInvocationSession; } @Override @@ -127,9 +117,7 @@ public void message(Message message) { } } - private static class MyEntrypointInvocationSession implements EntrypointInvocationSession { - private String name; - private int size; + private static class TestEntrypointInvocationSession implements EntrypointInvocationSession { private ProgressBar progressBar; @Override diff --git a/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/TestEntrypoint.java b/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/TestEntrypoint.java index 1fcf63cad..feadd440d 100644 --- a/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/TestEntrypoint.java +++ b/minecraft/minecraft-test/src/main/java/net/fabricmc/minecraft/test/info/TestEntrypoint.java @@ -4,7 +4,7 @@ public class TestEntrypoint implements Runnable { @Override public void run() { try { - Thread.sleep(1000); + Thread.sleep(100); } catch (InterruptedException e) { throw new RuntimeException(e); } From 97e21444c37c7ee2da46cbec88786675d5f0e256 Mon Sep 17 00:00:00 2001 From: Jab125 <67534807+Jab125@users.noreply.github.com> Date: Mon, 29 Apr 2024 23:29:55 +1000 Subject: [PATCH 8/9] add child progress bars --- .../fabricmc/loader/api/info/ProgressBar.java | 10 ++++++++ .../loader/impl/info/ProgressBarImpl.java | 24 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/main/java/net/fabricmc/loader/api/info/ProgressBar.java b/src/main/java/net/fabricmc/loader/api/info/ProgressBar.java index 9d15d0cdd..a0483d209 100644 --- a/src/main/java/net/fabricmc/loader/api/info/ProgressBar.java +++ b/src/main/java/net/fabricmc/loader/api/info/ProgressBar.java @@ -1,5 +1,7 @@ package net.fabricmc.loader.api.info; +import org.jetbrains.annotations.Nullable; + import java.io.Closeable; /** @@ -21,4 +23,12 @@ public interface ProgressBar extends Closeable { void close(); boolean isCompleted(); + + /** + * Create a child progress bar. + */ + ProgressBar progressBar(String name, int steps); + + @Nullable + ProgressBar getParent(); } diff --git a/src/main/java/net/fabricmc/loader/impl/info/ProgressBarImpl.java b/src/main/java/net/fabricmc/loader/impl/info/ProgressBarImpl.java index dbdbd009f..c32d8fa5d 100644 --- a/src/main/java/net/fabricmc/loader/impl/info/ProgressBarImpl.java +++ b/src/main/java/net/fabricmc/loader/impl/info/ProgressBarImpl.java @@ -2,13 +2,20 @@ import net.fabricmc.loader.api.info.ProgressBar; +import org.jetbrains.annotations.Nullable; + import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; public class ProgressBarImpl implements ProgressBar, Serializable { private String title; private int progress; private int steps; private boolean completed; + private ProgressBarImpl parent; + // TODO: Are there any concurrency issues? + private List children = new ArrayList<>(); ProgressBarImpl(String title, int steps) { this.title = title; this.steps = steps; @@ -53,11 +60,28 @@ public void title(String title) { @Override public void close() { + if (this.completed) throw new IllegalStateException("Already closed!"); this.completed = true; + this.children.forEach(progressBar -> { + if (!progressBar.isCompleted()) progressBar.close(); + }); } @Override public boolean isCompleted() { return completed; } + + @Override + public ProgressBar progressBar(String name, int steps) { + ProgressBarImpl progressBar = new ProgressBarImpl(name, steps); + progressBar.parent = this; + this.children.add(progressBar); + return progressBar; + } + + @Override + public @Nullable ProgressBar getParent() { + return parent; + } } From 48a2590eebd8c449e058ce43551c43e7a3f38ccd Mon Sep 17 00:00:00 2001 From: Jab125 <67534807+Jab125@users.noreply.github.com> Date: Mon, 29 Apr 2024 23:30:57 +1000 Subject: [PATCH 9/9] fire entrypoint when creating a child progress bar --- .../java/net/fabricmc/loader/impl/info/ProgressBarImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/net/fabricmc/loader/impl/info/ProgressBarImpl.java b/src/main/java/net/fabricmc/loader/impl/info/ProgressBarImpl.java index c32d8fa5d..85dc2bbb7 100644 --- a/src/main/java/net/fabricmc/loader/impl/info/ProgressBarImpl.java +++ b/src/main/java/net/fabricmc/loader/impl/info/ProgressBarImpl.java @@ -1,7 +1,10 @@ package net.fabricmc.loader.impl.info; +import net.fabricmc.loader.api.info.ModMessageReceiver; import net.fabricmc.loader.api.info.ProgressBar; +import net.fabricmc.loader.impl.FabricLoaderImpl; + import org.jetbrains.annotations.Nullable; import java.io.Serializable; @@ -77,6 +80,7 @@ public ProgressBar progressBar(String name, int steps) { ProgressBarImpl progressBar = new ProgressBarImpl(name, steps); progressBar.parent = this; this.children.add(progressBar); + FabricLoaderImpl.INSTANCE.getEntrypoints("modMessageReceiver", ModMessageReceiver.class).forEach(entrypoint -> entrypoint.progressBar(progressBar)); return progressBar; }