Post init API
This commit is contained in:
parent
4e9fda44f8
commit
50ccbace6d
3 changed files with 33 additions and 10 deletions
29
src/main/java/ru/bclib/api/PostInitAPI.java
Normal file
29
src/main/java/ru/bclib/api/PostInitAPI.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
package ru.bclib.api;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.core.Registry;
|
||||
import ru.bclib.interfaces.PostInitable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class PostInitAPI {
|
||||
private static List<Consumer<Void>> postInitFunctions = Lists.newArrayList();
|
||||
|
||||
public static void register(Consumer<Void> function) {
|
||||
postInitFunctions.add(function);
|
||||
}
|
||||
|
||||
public static void postInit() {
|
||||
if (postInitFunctions == null) {
|
||||
return;
|
||||
}
|
||||
postInitFunctions.forEach(function -> function.accept(null));
|
||||
Registry.BLOCK.forEach(block -> {
|
||||
if (block instanceof PostInitable) {
|
||||
((PostInitable) block).postInit();
|
||||
}
|
||||
});
|
||||
postInitFunctions = null;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue