9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-30 12:29:15 +00:00

refactor recipes

This commit is contained in:
XiaoMoMi
2025-04-04 03:21:35 +08:00
parent 6cadf524e4
commit 30588d86eb
19 changed files with 828 additions and 820 deletions

View File

@@ -10,6 +10,7 @@ public class CraftEngineReloadEvent extends Event {
private final BukkitCraftEngine plugin;
public CraftEngineReloadEvent(BukkitCraftEngine plugin) {
super(true);
this.plugin = plugin;
}

View File

@@ -0,0 +1,10 @@
package net.momirealms.craftengine.bukkit.item.recipe;
import net.momirealms.craftengine.core.item.recipe.Recipe;
import net.momirealms.craftengine.core.util.Key;
import org.bukkit.inventory.ItemStack;
public interface BukkitRecipeConvertor<T extends Recipe<ItemStack>> {
Runnable convert(Key id, T recipe);
}

View File

@@ -82,12 +82,12 @@ public class CrafterEventListener implements Listener {
return;
}
Recipe<ItemStack> ceRecipe = this.recipeManager.getRecipe(RecipeTypes.SHAPELESS, input);
Recipe<ItemStack> ceRecipe = this.recipeManager.recipeByInput(RecipeTypes.SHAPELESS, input);
if (ceRecipe != null) {
event.setResult(ceRecipe.result(ItemBuildContext.EMPTY));
return;
}
ceRecipe = this.recipeManager.getRecipe(RecipeTypes.SHAPED, input);
ceRecipe = this.recipeManager.recipeByInput(RecipeTypes.SHAPED, input);
if (ceRecipe != null) {
event.setResult(ceRecipe.result(ItemBuildContext.EMPTY));
return;

View File

@@ -85,7 +85,7 @@ public class RecipeEventListener implements Listener {
recipeType = RecipeTypes.SMOKING;
}
Recipe<ItemStack> ceRecipe = recipeManager.getRecipe(recipeType, input);
Recipe<ItemStack> ceRecipe = recipeManager.recipeByInput(recipeType, input);
// The item is an ingredient, we should never consider it as fuel firstly
if (ceRecipe != null) return;
@@ -345,7 +345,7 @@ public class RecipeEventListener implements Listener {
try {
@SuppressWarnings("unchecked")
Optional<Object> optionalMCRecipe = (Optional<Object>) Reflections.method$RecipeManager$getRecipeFor1.invoke(
BukkitRecipeManager.minecraftRecipeManager(),
BukkitRecipeManager.nmsRecipeManager(),
Reflections.instance$RecipeType$CAMPFIRE_COOKING,
Reflections.constructor$SingleRecipeInput.newInstance(Reflections.method$CraftItemStack$asNMSCopy.invoke(null, itemStack)),
FastNMS.INSTANCE.field$CraftWorld$ServerLevel(event.getPlayer().getWorld()),
@@ -360,7 +360,7 @@ public class RecipeEventListener implements Listener {
return;
}
SingleItemInput<ItemStack> input = new SingleItemInput<>(new OptimizedIDItem<>(idHolder.get(), itemStack));
CustomCampfireRecipe<ItemStack> ceRecipe = (CustomCampfireRecipe<ItemStack>) this.recipeManager.getRecipe(RecipeTypes.CAMPFIRE_COOKING, input);
CustomCampfireRecipe<ItemStack> ceRecipe = (CustomCampfireRecipe<ItemStack>) this.recipeManager.recipeByInput(RecipeTypes.CAMPFIRE_COOKING, input);
if (ceRecipe == null) {
event.setCancelled(true);
}
@@ -392,7 +392,7 @@ public class RecipeEventListener implements Listener {
}
SingleItemInput<ItemStack> input = new SingleItemInput<>(new OptimizedIDItem<>(idHolder.get(), itemStack));
CustomCampfireRecipe<ItemStack> ceRecipe = (CustomCampfireRecipe<ItemStack>) this.recipeManager.getRecipe(RecipeTypes.CAMPFIRE_COOKING, input);
CustomCampfireRecipe<ItemStack> ceRecipe = (CustomCampfireRecipe<ItemStack>) this.recipeManager.recipeByInput(RecipeTypes.CAMPFIRE_COOKING, input);
if (ceRecipe == null) {
event.setTotalCookTime(Integer.MAX_VALUE);
return;
@@ -427,7 +427,7 @@ public class RecipeEventListener implements Listener {
}
SingleItemInput<ItemStack> input = new SingleItemInput<>(new OptimizedIDItem<>(idHolder.get(), itemStack));
CustomCampfireRecipe<ItemStack> ceRecipe = (CustomCampfireRecipe<ItemStack>) this.recipeManager.getRecipe(RecipeTypes.CAMPFIRE_COOKING, input);
CustomCampfireRecipe<ItemStack> ceRecipe = (CustomCampfireRecipe<ItemStack>) this.recipeManager.recipeByInput(RecipeTypes.CAMPFIRE_COOKING, input);
if (ceRecipe == null) {
event.setCancelled(true);
return;
@@ -802,14 +802,14 @@ public class RecipeEventListener implements Listener {
BukkitServerPlayer serverPlayer = this.plugin.adapt(player);
Key lastRecipe = serverPlayer.lastUsedRecipe();
Recipe<ItemStack> ceRecipe = this.recipeManager.getRecipe(RecipeTypes.SHAPELESS, input, lastRecipe);
Recipe<ItemStack> ceRecipe = this.recipeManager.recipeByInput(RecipeTypes.SHAPELESS, input, lastRecipe);
if (ceRecipe != null) {
inventory.setResult(ceRecipe.result(new ItemBuildContext(serverPlayer, ContextHolder.EMPTY)));
serverPlayer.setLastUsedRecipe(ceRecipe.id());
correctCraftingRecipeUsed(inventory, ceRecipe);
return;
}
ceRecipe = this.recipeManager.getRecipe(RecipeTypes.SHAPED, input, lastRecipe);
ceRecipe = this.recipeManager.recipeByInput(RecipeTypes.SHAPED, input, lastRecipe);
if (ceRecipe != null) {
inventory.setResult(ceRecipe.result(new ItemBuildContext(serverPlayer, ContextHolder.EMPTY)));
serverPlayer.setLastUsedRecipe(ceRecipe.id());
@@ -821,7 +821,7 @@ public class RecipeEventListener implements Listener {
}
private void correctCraftingRecipeUsed(CraftingInventory inventory, Recipe<ItemStack> recipe) {
Object holderOrRecipe = recipeManager.getRecipeHolderByRecipe(recipe);
Object holderOrRecipe = recipeManager.nmsRecipeHolderByRecipe(recipe);
if (holderOrRecipe == null) {
// it's a vanilla recipe but not injected
return;
@@ -857,7 +857,7 @@ public class RecipeEventListener implements Listener {
getOptimizedIDItem(addition)
);
Recipe<ItemStack> ceRecipe = this.recipeManager.getRecipe(RecipeTypes.SMITHING_TRANSFORM, input);
Recipe<ItemStack> ceRecipe = this.recipeManager.recipeByInput(RecipeTypes.SMITHING_TRANSFORM, input);
if (ceRecipe == null) {
event.setResult(null);
return;
@@ -878,7 +878,7 @@ public class RecipeEventListener implements Listener {
}
private void correctSmithingRecipeUsed(SmithingInventory inventory, Recipe<ItemStack> recipe) {
Object holderOrRecipe = recipeManager.getRecipeHolderByRecipe(recipe);
Object holderOrRecipe = recipeManager.nmsRecipeHolderByRecipe(recipe);
if (holderOrRecipe == null) {
// it's a vanilla recipe but not injected
return;

View File

@@ -200,8 +200,10 @@ public class BukkitCraftEngine extends CraftEngine {
@Override
public void reload() {
super.reload();
CraftEngineReloadEvent event = new CraftEngineReloadEvent(this);
EventUtils.fireAndForget(event);
scheduler.async().execute(() -> {
CraftEngineReloadEvent event = new CraftEngineReloadEvent(this);
EventUtils.fireAndForget(event);
});
}
@Override
@@ -211,32 +213,6 @@ public class BukkitCraftEngine extends CraftEngine {
}
}
@Override
protected void registerParsers() {
// register template parser
this.packManager.registerConfigSectionParser(this.templateManager);
// register font parser
this.packManager.registerConfigSectionParsers(this.fontManager.parsers());
// register item parser
this.packManager.registerConfigSectionParser(this.itemManager);
// register furniture parser
this.packManager.registerConfigSectionParser(this.furnitureManager);
// register block parser
this.packManager.registerConfigSectionParser(this.blockManager);
// register recipe parser
this.packManager.registerConfigSectionParser(this.recipeManager);
// register category parser
this.packManager.registerConfigSectionParser(this.itemBrowserManager);
// register translation parser
this.packManager.registerConfigSectionParser(this.translationManager);
this.packManager.registerConfigSectionParser(this.translationManager.clientLangManager());
// register sound parser
this.packManager.registerConfigSectionParser(this.soundManager);
this.packManager.registerConfigSectionParser(this.soundManager.jukeboxSongManager());
// register vanilla loot parser
this.packManager.registerConfigSectionParser(this.vanillaLootManager);
}
@Override
public InputStream resourceStream(String filePath) {
return bootstrap.getResource(filePath.replace("\\", "/"));

View File

@@ -34,16 +34,18 @@ public class ReloadCommand extends BukkitCommandFeature<CommandSender> {
argument = optional.get();
}
if (argument == ReloadArgument.CONFIG) {
try {
RELOAD_PACK_FLAG = true;
long time1 = System.currentTimeMillis();
plugin().reload();
long time2 = System.currentTimeMillis();
handleFeedback(context, MessageConstants.COMMAND_RELOAD_CONFIG_SUCCESS, Component.text(time2 - time1));
} catch (Exception e) {
handleFeedback(context, MessageConstants.COMMAND_RELOAD_CONFIG_FAILURE);
plugin().logger().warn("Failed to reload config", e);
}
plugin().scheduler().executeAsync(() -> {
try {
RELOAD_PACK_FLAG = true;
long time1 = System.currentTimeMillis();
plugin().reload();
long time2 = System.currentTimeMillis();
handleFeedback(context, MessageConstants.COMMAND_RELOAD_CONFIG_SUCCESS, Component.text(time2 - time1));
} catch (Exception e) {
handleFeedback(context, MessageConstants.COMMAND_RELOAD_CONFIG_FAILURE);
plugin().logger().warn("Failed to reload config", e);
}
});
} else if (argument == ReloadArgument.PACK) {
plugin().scheduler().executeAsync(() -> {
try {
@@ -57,23 +59,18 @@ public class ReloadCommand extends BukkitCommandFeature<CommandSender> {
}
});
} else if (argument == ReloadArgument.ALL) {
long time1 = System.currentTimeMillis();
try {
plugin().scheduler().executeAsync(() -> {
long time1 = System.currentTimeMillis();
plugin().reload();
plugin().scheduler().executeAsync(() -> {
try {
plugin().packManager().generateResourcePack();
long time2 = System.currentTimeMillis();
handleFeedback(context, MessageConstants.COMMAND_RELOAD_ALL_SUCCESS, Component.text(time2 - time1));
} catch (Exception e) {
handleFeedback(context, MessageConstants.COMMAND_RELOAD_ALL_FAILURE);
plugin().logger().warn("Failed to generate resource pack", e);
}
});
} catch (Exception e) {
handleFeedback(context, MessageConstants.COMMAND_RELOAD_ALL_FAILURE);
plugin().logger().warn("Failed to reload config", e);
}
try {
plugin().packManager().generateResourcePack();
long time2 = System.currentTimeMillis();
handleFeedback(context, MessageConstants.COMMAND_RELOAD_ALL_SUCCESS, Component.text(time2 - time1));
} catch (Exception e) {
handleFeedback(context, MessageConstants.COMMAND_RELOAD_ALL_FAILURE);
plugin().logger().warn("Failed to generate resource pack", e);
}
});
}
});
}

View File

@@ -47,7 +47,7 @@ public class SearchRecipeAdminCommand extends BukkitCommandFeature<CommandSender
for (Player player : players) {
BukkitServerPlayer serverPlayer = plugin().adapt(player);
Key itemId = Key.of(namespacedKey.namespace(), namespacedKey.value());
List<Recipe<Object>> inRecipes = plugin().recipeManager().getRecipeByResult(itemId);
List<Recipe<Object>> inRecipes = plugin().recipeManager().recipeByResult(itemId);
if (!inRecipes.isEmpty()) {
plugin().itemBrowserManager().openRecipePage(serverPlayer, null, inRecipes, 0, 0, false);
}

View File

@@ -35,7 +35,7 @@ public class SearchRecipePlayerCommand extends BukkitCommandFeature<CommandSende
return;
}
Key itemId = item.id();
List<Recipe<Object>> inRecipes = plugin().recipeManager().getRecipeByResult(itemId);
List<Recipe<Object>> inRecipes = plugin().recipeManager().recipeByResult(itemId);
if (!inRecipes.isEmpty()) {
plugin().itemBrowserManager().openRecipePage(serverPlayer, null, inRecipes, 0, 0, false);
} else {

View File

@@ -47,7 +47,7 @@ public class SearchUsageAdminCommand extends BukkitCommandFeature<CommandSender>
for (Player player : players) {
BukkitServerPlayer serverPlayer = plugin().adapt(player);
Key itemId = Key.of(namespacedKey.namespace(), namespacedKey.value());
List<Recipe<Object>> inRecipes = plugin().recipeManager().getRecipeByIngredient(itemId);
List<Recipe<Object>> inRecipes = plugin().recipeManager().recipeByIngredient(itemId);
if (!inRecipes.isEmpty()) {
plugin().itemBrowserManager().openRecipePage(serverPlayer, null, inRecipes, 0, 0, false);
}

View File

@@ -35,7 +35,7 @@ public class SearchUsagePlayerCommand extends BukkitCommandFeature<CommandSender
return;
}
Key itemId = item.id();
List<Recipe<Object>> inRecipes = plugin().recipeManager().getRecipeByIngredient(itemId);
List<Recipe<Object>> inRecipes = plugin().recipeManager().recipeByIngredient(itemId);
if (!inRecipes.isEmpty()) {
plugin().itemBrowserManager().openRecipePage(serverPlayer, null, inRecipes, 0, 0, false);
} else {

View File

@@ -357,7 +357,7 @@ public class BukkitInjector {
@SuppressWarnings("unchecked")
@RuntimeType
public Object intercept(@This Object thisObj, @AllArguments Object[] args) throws Exception {
Object mcRecipeManager = BukkitRecipeManager.minecraftRecipeManager();
Object mcRecipeManager = BukkitRecipeManager.nmsRecipeManager();
InjectedCacheCheck injectedCacheCheck = (InjectedCacheCheck) thisObj;
Object type = injectedCacheCheck.recipeType();
Object lastRecipe = injectedCacheCheck.lastRecipe();
@@ -394,13 +394,13 @@ public class BukkitInjector {
CustomCookingRecipe<ItemStack> ceRecipe;
Key lastCustomRecipe = injectedCacheCheck.lastCustomRecipe();
if (type == Reflections.instance$RecipeType$SMELTING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.SMELTING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.SMELTING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$BLASTING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.BLASTING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.BLASTING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$SMOKING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.SMOKING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.SMOKING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$CAMPFIRE_COOKING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.CAMPFIRE_COOKING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.CAMPFIRE_COOKING, input, lastCustomRecipe);
} else {
return Optional.empty();
}
@@ -412,7 +412,7 @@ public class BukkitInjector {
injectedCacheCheck.lastCustomRecipe(ceRecipe.id());
// It doesn't matter at all
injectedCacheCheck.lastRecipe(resourceLocation);
return Optional.of(Optional.ofNullable(recipeManager.getRecipeHolderByRecipe(ceRecipe)).orElse(pair.getSecond()));
return Optional.of(Optional.ofNullable(recipeManager.nmsRecipeHolderByRecipe(ceRecipe)).orElse(pair.getSecond()));
} else {
return Optional.empty();
}
@@ -425,7 +425,7 @@ public class BukkitInjector {
@SuppressWarnings("unchecked")
@RuntimeType
public Object intercept(@This Object thisObj, @AllArguments Object[] args) throws Exception {
Object mcRecipeManager = BukkitRecipeManager.minecraftRecipeManager();
Object mcRecipeManager = BukkitRecipeManager.nmsRecipeManager();
InjectedCacheCheck injectedCacheCheck = (InjectedCacheCheck) thisObj;
Object type = injectedCacheCheck.recipeType();
Object lastRecipe = injectedCacheCheck.lastRecipe();
@@ -462,13 +462,13 @@ public class BukkitInjector {
CustomCookingRecipe<ItemStack> ceRecipe;
Key lastCustomRecipe = injectedCacheCheck.lastCustomRecipe();
if (type == Reflections.instance$RecipeType$SMELTING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.SMELTING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.SMELTING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$BLASTING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.BLASTING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.BLASTING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$SMOKING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.SMOKING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.SMOKING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$CAMPFIRE_COOKING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.CAMPFIRE_COOKING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.CAMPFIRE_COOKING, input, lastCustomRecipe);
} else {
return Optional.empty();
}
@@ -480,7 +480,7 @@ public class BukkitInjector {
injectedCacheCheck.lastCustomRecipe(ceRecipe.id());
// It doesn't matter at all
injectedCacheCheck.lastRecipe(id);
return Optional.of(Optional.ofNullable(recipeManager.getRecipeHolderByRecipe(ceRecipe)).orElse(holder));
return Optional.of(Optional.ofNullable(recipeManager.nmsRecipeHolderByRecipe(ceRecipe)).orElse(holder));
} else {
return Optional.empty();
}
@@ -493,7 +493,7 @@ public class BukkitInjector {
@SuppressWarnings("unchecked")
@RuntimeType
public Object intercept(@This Object thisObj, @AllArguments Object[] args) throws Exception {
Object mcRecipeManager = BukkitRecipeManager.minecraftRecipeManager();
Object mcRecipeManager = BukkitRecipeManager.nmsRecipeManager();
InjectedCacheCheck injectedCacheCheck = (InjectedCacheCheck) thisObj;
Object type = injectedCacheCheck.recipeType();
Object lastRecipe = injectedCacheCheck.lastRecipe();
@@ -522,13 +522,13 @@ public class BukkitInjector {
CustomCookingRecipe<ItemStack> ceRecipe;
Key lastCustomRecipe = injectedCacheCheck.lastCustomRecipe();
if (type == Reflections.instance$RecipeType$SMELTING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.SMELTING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.SMELTING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$BLASTING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.BLASTING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.BLASTING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$SMOKING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.SMOKING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.SMOKING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$CAMPFIRE_COOKING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.CAMPFIRE_COOKING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.CAMPFIRE_COOKING, input, lastCustomRecipe);
} else {
return Optional.empty();
}
@@ -540,7 +540,7 @@ public class BukkitInjector {
injectedCacheCheck.lastCustomRecipe(ceRecipe.id());
// It doesn't matter at all
injectedCacheCheck.lastRecipe(id);
return Optional.of(Optional.ofNullable(recipeManager.getRecipeHolderByRecipe(ceRecipe)).orElse(holder));
return Optional.of(Optional.ofNullable(recipeManager.nmsRecipeHolderByRecipe(ceRecipe)).orElse(holder));
} else {
return Optional.empty();
}
@@ -553,7 +553,7 @@ public class BukkitInjector {
@SuppressWarnings("unchecked")
@RuntimeType
public Object intercept(@This Object thisObj, @AllArguments Object[] args) throws Exception {
Object mcRecipeManager = BukkitRecipeManager.minecraftRecipeManager();
Object mcRecipeManager = BukkitRecipeManager.nmsRecipeManager();
InjectedCacheCheck injectedCacheCheck = (InjectedCacheCheck) thisObj;
Object type = injectedCacheCheck.recipeType();
Object lastRecipe = injectedCacheCheck.lastRecipe();
@@ -583,11 +583,11 @@ public class BukkitInjector {
CustomCookingRecipe<ItemStack> ceRecipe;
Key lastCustomRecipe = injectedCacheCheck.lastCustomRecipe();
if (type == Reflections.instance$RecipeType$SMELTING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.SMELTING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.SMELTING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$BLASTING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.BLASTING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.BLASTING, input, lastCustomRecipe);
} else if (type == Reflections.instance$RecipeType$SMOKING) {
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.getRecipe(RecipeTypes.SMOKING, input, lastCustomRecipe);
ceRecipe = (CustomCookingRecipe<ItemStack>) recipeManager.recipeByInput(RecipeTypes.SMOKING, input, lastCustomRecipe);
} else {
return Optional.empty();
}
@@ -599,7 +599,7 @@ public class BukkitInjector {
injectedCacheCheck.lastCustomRecipe(ceRecipe.id());
// It doesn't matter at all
injectedCacheCheck.lastRecipe(id);
return Optional.of(Optional.ofNullable(recipeManager.getRecipeHolderByRecipe(ceRecipe)).orElse(holder));
return Optional.of(Optional.ofNullable(recipeManager.nmsRecipeHolderByRecipe(ceRecipe)).orElse(holder));
} else {
return Optional.empty();
}

View File

@@ -79,14 +79,14 @@ public class InteractUtils {
register(BlockKeys.SOUL_CAMPFIRE, (player, item, blockState, result) -> {
if (!ConfigManager.enableRecipeSystem()) return false;
Optional<Holder.Reference<Key>> optional = BuiltInRegistries.OPTIMIZED_ITEM_ID.get(item.id());
return optional.filter(keyReference -> BukkitRecipeManager.instance().getRecipe(RecipeTypes.CAMPFIRE_COOKING, new SingleItemInput<>(new OptimizedIDItem<>(
return optional.filter(keyReference -> BukkitRecipeManager.instance().recipeByInput(RecipeTypes.CAMPFIRE_COOKING, new SingleItemInput<>(new OptimizedIDItem<>(
keyReference, item.getItem()
))) != null).isPresent();
});
register(BlockKeys.CAMPFIRE, (player, item, blockState, result) -> {
if (!ConfigManager.enableRecipeSystem()) return false;
Optional<Holder.Reference<Key>> optional = BuiltInRegistries.OPTIMIZED_ITEM_ID.get(item.id());
return optional.filter(keyReference -> BukkitRecipeManager.instance().getRecipe(RecipeTypes.CAMPFIRE_COOKING, new SingleItemInput<>(new OptimizedIDItem<>(
return optional.filter(keyReference -> BukkitRecipeManager.instance().recipeByInput(RecipeTypes.CAMPFIRE_COOKING, new SingleItemInput<>(new OptimizedIDItem<>(
keyReference, item.getItem()
))) != null).isPresent();
});