9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-27 19:09:08 +00:00

修复bug

This commit is contained in:
XiaoMoMi
2025-07-11 04:19:55 +08:00
parent 18c67d34e0
commit f4906abe0d
6 changed files with 28 additions and 17 deletions

View File

@@ -43,8 +43,10 @@ public interface ItemManager<T> extends Manageable, ModelGenerator {
@Nullable
T buildItemStack(Key id, @Nullable Player player);
@Nullable
Item<T> createCustomWrappedItem(Key id, @Nullable Player player);
@Nullable
Item<T> createWrappedItem(Key id, @Nullable Player player);
@NotNull

View File

@@ -173,6 +173,8 @@ public abstract class AbstractRecipeManager<T> implements RecipeManager<T> {
markAsCustomRecipe(id);
registerInternalRecipe(id, recipe);
registerPlatformRecipe(id, recipe);
} catch (LocalizedResourceConfigException e) {
throw e;
} catch (Exception e) {
CraftEngine.instance().logger().warn("Failed to register custom recipe " + id, e);
}

View File

@@ -157,7 +157,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
List<ItemWithAction> iconList = this.categoryOnMainPage.stream().map(it -> {
Item<?> item = this.plugin.itemManager().createWrappedItem(it.icon(), player);
if (item == null) {
if (ItemUtils.isEmpty(item)) {
this.plugin.logger().warn("Can't not find item " + it.icon() + " for category icon");
return null;
}
@@ -242,7 +242,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
Category subCategory = this.byId.get(Key.of(subCategoryId));
if (subCategory == null) return null;
Item<?> item = this.plugin.itemManager().createWrappedItem(subCategory.icon(), player);
if (item == null) {
if (ItemUtils.isEmpty(item)) {
if (!subCategory.icon().equals(ItemKeys.AIR)) {
item = this.plugin.itemManager().createWrappedItem(ItemKeys.BARRIER, player);
item.customNameJson(AdventureHelper.componentToJson(AdventureHelper.miniMessage().deserialize(subCategory.displayName(), ItemBuildContext.EMPTY.tagResolvers())));
@@ -261,7 +261,7 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
Key itemId = Key.of(it);
Item<?> item = this.plugin.itemManager().createWrappedItem(itemId, player);
boolean canGoFurther;
if (item == null) {
if (ItemUtils.isEmpty(item)) {
if (!itemId.equals(ItemKeys.AIR)) {
item = this.plugin.itemManager().createWrappedItem(ItemKeys.BARRIER, player);
item.customNameJson(AdventureHelper.componentToJson(Component.text(it).decoration(TextDecoration.ITALIC, TextDecoration.State.FALSE).color(NamedTextColor.RED)));
@@ -499,7 +499,6 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
}
}));
List<Item<?>> templates = new ArrayList<>();
Optional.ofNullable(recipe.template()).ifPresent(it -> {
for (UniqueKey in : it.items()) {