aboutsummaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2021-10-20 18:41:27 +0800
committershedaniel <daniel@shedaniel.me>2021-10-22 01:41:12 +0800
commit843a29c5fcf8d20f7073438d9fbed7039dead719 (patch)
treecfe93852c0ba236dfa7989470bab7e63c602d7a2 /api
parenta95ce0972205bff98687c7d2bb1654e331c7e41f (diff)
downloadRoughlyEnoughItems-843a29c5fcf8d20f7073438d9fbed7039dead719.tar.gz
RoughlyEnoughItems-843a29c5fcf8d20f7073438d9fbed7039dead719.tar.bz2
RoughlyEnoughItems-843a29c5fcf8d20f7073438d9fbed7039dead719.zip
Fix modifying stacks at runtime, fixes support for JEITweaker
Diffstat (limited to 'api')
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/plugins/PluginView.java13
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPlugin.java20
2 files changed, 27 insertions, 6 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/plugins/PluginView.java b/api/src/main/java/me/shedaniel/rei/api/common/plugins/PluginView.java
index ddd74a367..be1d3ab26 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/plugins/PluginView.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/plugins/PluginView.java
@@ -24,6 +24,7 @@
package me.shedaniel.rei.api.common.plugins;
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
+import me.shedaniel.rei.api.common.registry.ReloadStage;
import me.shedaniel.rei.impl.ClientInternals;
import me.shedaniel.rei.impl.Internals;
import net.fabricmc.api.EnvType;
@@ -61,18 +62,18 @@ public interface PluginView<P extends REIPlugin<?>> {
}
@Override
- public void pre() {
- PluginView.this.pre();
+ public void pre(ReloadStage stage) {
+ PluginView.this.pre(stage);
}
@Override
- public void post() {
- PluginView.this.post();
+ public void post(ReloadStage stage) {
+ PluginView.this.post(stage);
}
};
}
- void pre();
+ void pre(ReloadStage stage);
- void post();
+ void post(ReloadStage stage);
}
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPlugin.java b/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPlugin.java
index 2599281e8..ef4444661 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPlugin.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPlugin.java
@@ -29,11 +29,13 @@ import me.shedaniel.rei.api.common.entry.comparison.FluidComparatorRegistry;
import me.shedaniel.rei.api.common.entry.comparison.ItemComparatorRegistry;
import me.shedaniel.rei.api.common.entry.type.EntryTypeRegistry;
import me.shedaniel.rei.api.common.fluid.FluidSupportProvider;
+import me.shedaniel.rei.api.common.registry.ReloadStage;
import me.shedaniel.rei.api.common.registry.Reloadable;
import org.jetbrains.annotations.ApiStatus;
import java.util.Collection;
import java.util.Collections;
+import java.util.Objects;
/**
* Base interface for a REI plugin.
@@ -97,13 +99,31 @@ public interface REIPlugin<P extends REIPlugin<?>> extends Comparable<REIPlugin<
}
@ApiStatus.OverrideOnly
+ @Deprecated
+ @ApiStatus.ScheduledForRemoval
default void preRegister() {
}
@ApiStatus.OverrideOnly
+ default void preStage(PluginManager<P> manager, ReloadStage stage) {
+ if (stage == ReloadStage.START && Objects.equals(manager, PluginManager.getInstance())) {
+ preRegister();
+ }
+ }
+
+ @ApiStatus.OverrideOnly
+ @Deprecated
+ @ApiStatus.ScheduledForRemoval
default void postRegister() {
}
+ @ApiStatus.OverrideOnly
+ default void postStage(PluginManager<P> manager, ReloadStage stage) {
+ if (stage == ReloadStage.END && (this instanceof REIServerPlugin ? Objects.equals(manager, PluginManager.getServerInstance()) : !Objects.equals(manager, PluginManager.getInstance()))) {
+ preRegister();
+ }
+ }
+
@Override
default Collection<P> provide() {
return Collections.singletonList((P) this);