AbstractRecipeBookScreen.java
net.minecraft.client.gui.screens.inventory.AbstractRecipeBookScreen
信息
- 全限定名:net.minecraft.client.gui.screens.inventory.AbstractRecipeBookScreen
- 类型:public abstract class
- 包:net.minecraft.client.gui.screens.inventory
- 源码路径:src/main/java/net/minecraft/client/gui/screens/inventory/AbstractRecipeBookScreen.java
- 起始行号:L21
- 继承:AbstractContainerScreen
- 实现:RecipeUpdateListener
- 职责:
TODO
字段/常量
-
recipeBookComponent- 类型:
RecipeBookComponent<?> - 修饰符:
private final - 源码定位:
L22 - 说明:
TODO
- 类型:
-
widthTooNarrow- 类型:
boolean - 修饰符:
private - 源码定位:
L23 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public AbstractRecipeBookScreen(T menu, RecipeBookComponent<?> recipeBookComponent, Inventory inventory, Component title) @ L25
- 构造器名:AbstractRecipeBookScreen
- 源码定位:L25
- 修饰符:public
参数:
- menu: T
- recipeBookComponent: RecipeBookComponent<?>
- inventory: Inventory
- title: Component
说明:
TODO
方法
下面的方法块按源码顺序生成。
protected void init() @ L30
- 方法名:init
- 源码定位:L30
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
protected abstract ScreenPosition getRecipeBookButtonPosition() @ L39
- 方法名:getRecipeBookButtonPosition
- 源码定位:L39
- 返回类型:ScreenPosition
- 修饰符:protected abstract
参数:
- 无
说明:
TODO
private void initButton() @ L41
- 方法名:initButton
- 源码定位:L41
- 返回类型:void
- 修饰符:private
参数:
- 无
说明:
TODO
protected void onRecipeBookButtonClick() @ L53
- 方法名:onRecipeBookButtonClick
- 源码定位:L53
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L56
- 方法名:extractRenderState
- 源码定位:L56
- 返回类型:void
- 修饰符:public
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
- a: float
说明:
TODO
protected void extractSlots(GuiGraphicsExtractor graphics, int mouseX, int mouseY) @ L73
- 方法名:extractSlots
- 源码定位:L73
- 返回类型:void
- 修饰符:protected
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
说明:
TODO
protected boolean isBiggerResultSlot() @ L79
- 方法名:isBiggerResultSlot
- 源码定位:L79
- 返回类型:boolean
- 修饰符:protected
参数:
- 无
说明:
TODO
public boolean charTyped(CharacterEvent event) @ L83
- 方法名:charTyped
- 源码定位:L83
- 返回类型:boolean
- 修饰符:public
参数:
- event: CharacterEvent
说明:
TODO
public boolean keyPressed(KeyEvent event) @ L88
- 方法名:keyPressed
- 源码定位:L88
- 返回类型:boolean
- 修饰符:public
参数:
- event: KeyEvent
说明:
TODO
public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) @ L93
- 方法名:mouseClicked
- 源码定位:L93
- 返回类型:boolean
- 修饰符:public
参数:
- event: MouseButtonEvent
- doubleClick: boolean
说明:
TODO
public boolean mouseDragged(MouseButtonEvent event, double dx, double dy) @ L103
- 方法名:mouseDragged
- 源码定位:L103
- 返回类型:boolean
- 修饰符:public
参数:
- event: MouseButtonEvent
- dx: double
- dy: double
说明:
TODO
protected boolean isHovering(int left, int top, int w, int h, double xm, double ym) @ L108
- 方法名:isHovering
- 源码定位:L108
- 返回类型:boolean
- 修饰符:protected
参数:
- left: int
- top: int
- w: int
- h: int
- xm: double
- ym: double
说明:
TODO
protected boolean hasClickedOutside(double mx, double my, int xo, int yo) @ L113
- 方法名:hasClickedOutside
- 源码定位:L113
- 返回类型:boolean
- 修饰符:protected
参数:
- mx: double
- my: double
- xo: int
- yo: int
说明:
TODO
protected void slotClicked(Slot slot, int slotId, int buttonNum, ContainerInput containerInput) @ L119
- 方法名:slotClicked
- 源码定位:L119
- 返回类型:void
- 修饰符:protected
参数:
- slot: Slot
- slotId: int
- buttonNum: int
- containerInput: ContainerInput
说明:
TODO
public void containerTick() @ L125
- 方法名:containerTick
- 源码定位:L125
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void recipesUpdated() @ L131
- 方法名:recipesUpdated
- 源码定位:L131
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void fillGhostRecipe(RecipeDisplay display) @ L136
- 方法名:fillGhostRecipe
- 源码定位:L136
- 返回类型:void
- 修饰符:public
参数:
- display: RecipeDisplay
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public abstract class AbstractRecipeBookScreen<T extends RecipeBookMenu> extends AbstractContainerScreen<T> implements RecipeUpdateListener {
private final RecipeBookComponent<?> recipeBookComponent;
private boolean widthTooNarrow;
public AbstractRecipeBookScreen(T menu, RecipeBookComponent<?> recipeBookComponent, Inventory inventory, Component title) {
super(menu, inventory, title);
this.recipeBookComponent = recipeBookComponent;
}
@Override
protected void init() {
super.init();
this.widthTooNarrow = this.width < 379;
this.recipeBookComponent.init(this.width, this.height, this.minecraft, this.widthTooNarrow);
this.leftPos = this.recipeBookComponent.updateScreenPosition(this.width, this.imageWidth);
this.initButton();
}
protected abstract ScreenPosition getRecipeBookButtonPosition();
private void initButton() {
ScreenPosition buttonPos = this.getRecipeBookButtonPosition();
this.addRenderableWidget(new ImageButton(buttonPos.x(), buttonPos.y(), 20, 18, RecipeBookComponent.RECIPE_BUTTON_SPRITES, button -> {
this.recipeBookComponent.toggleVisibility();
this.leftPos = this.recipeBookComponent.updateScreenPosition(this.width, this.imageWidth);
ScreenPosition updatedButtonPos = this.getRecipeBookButtonPosition();
button.setPosition(updatedButtonPos.x(), updatedButtonPos.y());
this.onRecipeBookButtonClick();
}));
this.addWidget(this.recipeBookComponent);
}
protected void onRecipeBookButtonClick() {
}
@Override
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
if (this.recipeBookComponent.isVisible() && this.widthTooNarrow) {
this.extractBackground(graphics, mouseX, mouseY, a);
} else {
super.extractContents(graphics, mouseX, mouseY, a);
}
graphics.nextStratum();
this.recipeBookComponent.extractRenderState(graphics, mouseX, mouseY, a);
graphics.nextStratum();
this.extractCarriedItem(graphics, mouseX, mouseY);
this.extractSnapbackItem(graphics);
this.extractTooltip(graphics, mouseX, mouseY);
this.recipeBookComponent.extractTooltip(graphics, mouseX, mouseY, this.hoveredSlot);
}
@Override
protected void extractSlots(GuiGraphicsExtractor graphics, int mouseX, int mouseY) {
super.extractSlots(graphics, mouseX, mouseY);
this.recipeBookComponent.extractGhostRecipe(graphics, this.isBiggerResultSlot());
}
protected boolean isBiggerResultSlot() {
return true;
}
@Override
public boolean charTyped(CharacterEvent event) {
return this.recipeBookComponent.charTyped(event) ? true : super.charTyped(event);
}
@Override
public boolean keyPressed(KeyEvent event) {
return this.recipeBookComponent.keyPressed(event) ? true : super.keyPressed(event);
}
@Override
public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) {
if (this.recipeBookComponent.mouseClicked(event, doubleClick)) {
this.setFocused(this.recipeBookComponent);
return true;
} else {
return this.widthTooNarrow && this.recipeBookComponent.isVisible() ? true : super.mouseClicked(event, doubleClick);
}
}
@Override
public boolean mouseDragged(MouseButtonEvent event, double dx, double dy) {
return this.recipeBookComponent.mouseDragged(event, dx, dy) ? true : super.mouseDragged(event, dx, dy);
}
@Override
protected boolean isHovering(int left, int top, int w, int h, double xm, double ym) {
return (!this.widthTooNarrow || !this.recipeBookComponent.isVisible()) && super.isHovering(left, top, w, h, xm, ym);
}
@Override
protected boolean hasClickedOutside(double mx, double my, int xo, int yo) {
boolean clickedOutside = mx < xo || my < yo || mx >= xo + this.imageWidth || my >= yo + this.imageHeight;
return this.recipeBookComponent.hasClickedOutside(mx, my, this.leftPos, this.topPos, this.imageWidth, this.imageHeight) && clickedOutside;
}
@Override
protected void slotClicked(Slot slot, int slotId, int buttonNum, ContainerInput containerInput) {
super.slotClicked(slot, slotId, buttonNum, containerInput);
this.recipeBookComponent.slotClicked(slot);
}
@Override
public void containerTick() {
super.containerTick();
this.recipeBookComponent.tick();
}
@Override
public void recipesUpdated() {
this.recipeBookComponent.recipesUpdated();
}
@Override
public void fillGhostRecipe(RecipeDisplay display) {
this.recipeBookComponent.fillGhostRecipe(display);
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
ImageButton()
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: