RecipeCollection.java
net.minecraft.client.gui.screens.recipebook.RecipeCollection
信息
- 全限定名:net.minecraft.client.gui.screens.recipebook.RecipeCollection
- 类型:public class
- 包:net.minecraft.client.gui.screens.recipebook
- 源码路径:src/main/java/net/minecraft/client/gui/screens/recipebook/RecipeCollection.java
- 起始行号:L16
- 职责:
TODO
字段/常量
-
EMPTY- 类型:
RecipeCollection - 修饰符:
public static final - 源码定位:
L17 - 说明:
TODO
- 类型:
-
entries- 类型:
List<RecipeDisplayEntry> - 修饰符:
private final - 源码定位:
L18 - 说明:
TODO
- 类型:
-
craftable- 类型:
Set<RecipeDisplayId> - 修饰符:
private final - 源码定位:
L19 - 说明:
TODO
- 类型:
-
selected- 类型:
Set<RecipeDisplayId> - 修饰符:
private final - 源码定位:
L20 - 说明:
TODO
- 类型:
内部类/嵌套类型
net.minecraft.client.gui.screens.recipebook.RecipeCollection.CraftableStatus- 类型:
enum - 修饰符:
public static - 源码定位:
L77 - 说明:
TODO
- 类型:
构造器
public RecipeCollection(List<RecipeDisplayEntry> recipes) @ L22
- 构造器名:RecipeCollection
- 源码定位:L22
- 修饰符:public
参数:
- recipes: List
说明:
TODO
方法
下面的方法块按源码顺序生成。
public void selectRecipes(StackedItemContents stackedContents, Predicate<RecipeDisplay> selector) @ L26
- 方法名:selectRecipes
- 源码定位:L26
- 返回类型:void
- 修饰符:public
参数:
- stackedContents: StackedItemContents
- selector: Predicate
说明:
TODO
public boolean isCraftable(RecipeDisplayId recipe) @ L43
- 方法名:isCraftable
- 源码定位:L43
- 返回类型:boolean
- 修饰符:public
参数:
- recipe: RecipeDisplayId
说明:
TODO
public boolean hasCraftable() @ L47
- 方法名:hasCraftable
- 源码定位:L47
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean hasAnySelected() @ L51
- 方法名:hasAnySelected
- 源码定位:L51
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public List<RecipeDisplayEntry> getRecipes() @ L55
- 方法名:getRecipes
- 源码定位:L55
- 返回类型:List
- 修饰符:public
参数:
- 无
说明:
TODO
public List<RecipeDisplayEntry> getSelectedRecipes(RecipeCollection.CraftableStatus selector) @ L59
- 方法名:getSelectedRecipes
- 源码定位:L59
- 返回类型:List
- 修饰符:public
参数:
- selector: RecipeCollection.CraftableStatus
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class RecipeCollection {
public static final RecipeCollection EMPTY = new RecipeCollection(List.of());
private final List<RecipeDisplayEntry> entries;
private final Set<RecipeDisplayId> craftable = new HashSet<>();
private final Set<RecipeDisplayId> selected = new HashSet<>();
public RecipeCollection(List<RecipeDisplayEntry> recipes) {
this.entries = recipes;
}
public void selectRecipes(StackedItemContents stackedContents, Predicate<RecipeDisplay> selector) {
for (RecipeDisplayEntry entry : this.entries) {
boolean isSelected = selector.test(entry.display());
if (isSelected) {
this.selected.add(entry.id());
} else {
this.selected.remove(entry.id());
}
if (isSelected && entry.canCraft(stackedContents)) {
this.craftable.add(entry.id());
} else {
this.craftable.remove(entry.id());
}
}
}
public boolean isCraftable(RecipeDisplayId recipe) {
return this.craftable.contains(recipe);
}
public boolean hasCraftable() {
return !this.craftable.isEmpty();
}
public boolean hasAnySelected() {
return !this.selected.isEmpty();
}
public List<RecipeDisplayEntry> getRecipes() {
return this.entries;
}
public List<RecipeDisplayEntry> getSelectedRecipes(RecipeCollection.CraftableStatus selector) {
Predicate<RecipeDisplayId> predicate = switch (selector) {
case ANY -> this.selected::contains;
case CRAFTABLE -> this.craftable::contains;
case NOT_CRAFTABLE -> recipe -> this.selected.contains(recipe) && !this.craftable.contains(recipe);
};
List<RecipeDisplayEntry> result = new ArrayList<>();
for (RecipeDisplayEntry entries : this.entries) {
if (predicate.test(entries.id())) {
result.add(entries);
}
}
return result;
}
@OnlyIn(Dist.CLIENT)
public static enum CraftableStatus {
ANY,
CRAFTABLE,
NOT_CRAFTABLE;
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/字段/返回值
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置: