9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-31 12:56:28 +00:00

Improve Recipe system

This commit is contained in:
XiaoMoMi
2025-02-13 03:15:13 +08:00
parent b53b86065d
commit 7cf9a22916
8 changed files with 479 additions and 60 deletions

View File

@@ -25,6 +25,10 @@ public class CustomShapedRecipe<T> extends CraftingTableRecipe<T> {
this.result = result;
}
public ParsedPattern<T> parsedPattern() {
return parsedPattern;
}
@SuppressWarnings("unchecked")
@Override
public boolean matches(RecipeInput input) {
@@ -72,6 +76,10 @@ public class CustomShapedRecipe<T> extends CraftingTableRecipe<T> {
this.ingredients = ingredients;
}
public List<Optional<Ingredient<T>>> ingredients() {
return ingredients;
}
public int width() {
return width;
}

View File

@@ -27,4 +27,11 @@ public class OptimizedIDItem<T> {
public boolean isEmpty() {
return idHolder == null;
}
@Override
public String toString() {
return "OptimizedIDItem{" +
"idHolder=" + idHolder +
'}';
}
}

View File

@@ -8,6 +8,7 @@ import net.momirealms.craftengine.core.util.Key;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.concurrent.CompletableFuture;
public interface RecipeManager<T> extends Reloadable, ConfigSectionParser {
String CONFIG_SECTION_NAME = "recipes";
@@ -25,7 +26,7 @@ public interface RecipeManager<T> extends Reloadable, ConfigSectionParser {
@Nullable
Recipe<T> getRecipe(Key type, RecipeInput input);
void delayedLoad();
CompletableFuture<Void> delayedLoad();
default int loadingSequence() {
return LoadingSequence.RECIPE;

View File

@@ -80,11 +80,9 @@ public abstract class CraftEngine implements Plugin {
this.worldManager.reload();
this.packManager.reload();
this.blockManager.delayedLoad();
this.recipeManager.delayedLoad();
this.scheduler.async().execute(() -> {
this.recipeManager.delayedLoad().thenRunAsync(() -> {
this.packManager.generateResourcePack();
});
}, this.scheduler.async());
}
@Override