RecipeBookTabButton.java
net.minecraft.client.gui.screens.recipebook.RecipeBookTabButton
信息
- 全限定名:net.minecraft.client.gui.screens.recipebook.RecipeBookTabButton
- 类型:public class
- 包:net.minecraft.client.gui.screens.recipebook
- 源码路径:src/main/java/net/minecraft/client/gui/screens/recipebook/RecipeBookTabButton.java
- 起始行号:L17
- 继承:ImageButton
- 职责:
TODO
字段/常量
-
SPRITES- 类型:
WidgetSprites - 修饰符:
private static final - 源码定位:
L18 - 说明:
TODO
- 类型:
-
WIDTH- 类型:
int - 修饰符:
public static final - 源码定位:
L21 - 说明:
TODO
- 类型:
-
HEIGHT- 类型:
int - 修饰符:
public static final - 源码定位:
L22 - 说明:
TODO
- 类型:
-
tabInfo- 类型:
RecipeBookComponent.TabInfo - 修饰符:
private final - 源码定位:
L23 - 说明:
TODO
- 类型:
-
ANIMATION_TIME- 类型:
float - 修饰符:
private static final - 源码定位:
L24 - 说明:
TODO
- 类型:
-
animationTime- 类型:
float - 修饰符:
private - 源码定位:
L25 - 说明:
TODO
- 类型:
-
selected- 类型:
boolean - 修饰符:
private - 源码定位:
L26 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public RecipeBookTabButton(int x, int y, RecipeBookComponent.TabInfo tabInfo, Button.OnPress onPress) @ L28
- 构造器名:RecipeBookTabButton
- 源码定位:L28
- 修饰符:public
参数:
- x: int
- y: int
- tabInfo: RecipeBookComponent.TabInfo
- onPress: Button.OnPress
说明:
TODO
方法
下面的方法块按源码顺序生成。
public void startAnimation(ClientRecipeBook recipeBook, boolean isFiltering) @ L33
- 方法名:startAnimation
- 源码定位:L33
- 返回类型:void
- 修饰符:public
参数:
- recipeBook: ClientRecipeBook
- isFiltering: boolean
说明:
TODO
public void extractContents(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L46
- 方法名:extractContents
- 源码定位:L46
- 返回类型:void
- 修饰符:public
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
- a: float
说明:
TODO
protected void handleCursor(GuiGraphicsExtractor graphics) @ L70
- 方法名:handleCursor
- 源码定位:L70
- 返回类型:void
- 修饰符:protected
参数:
- graphics: GuiGraphicsExtractor
说明:
TODO
private void extractIcon(GuiGraphicsExtractor graphics) @ L77
- 方法名:extractIcon
- 源码定位:L77
- 返回类型:void
- 修饰符:private
参数:
- graphics: GuiGraphicsExtractor
说明:
TODO
public ExtendedRecipeBookCategory getCategory() @ L87
- 方法名:getCategory
- 源码定位:L87
- 返回类型:ExtendedRecipeBookCategory
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean updateVisibility(ClientRecipeBook book) @ L91
- 方法名:updateVisibility
- 源码定位:L91
- 返回类型:boolean
- 修饰符:public
参数:
- book: ClientRecipeBook
说明:
TODO
public void select() @ L105
- 方法名:select
- 源码定位:L105
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void unselect() @ L109
- 方法名:unselect
- 源码定位:L109
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class RecipeBookTabButton extends ImageButton {
private static final WidgetSprites SPRITES = new WidgetSprites(
Identifier.withDefaultNamespace("recipe_book/tab"), Identifier.withDefaultNamespace("recipe_book/tab_selected")
);
public static final int WIDTH = 35;
public static final int HEIGHT = 27;
private final RecipeBookComponent.TabInfo tabInfo;
private static final float ANIMATION_TIME = 15.0F;
private float animationTime;
private boolean selected = false;
public RecipeBookTabButton(int x, int y, RecipeBookComponent.TabInfo tabInfo, Button.OnPress onPress) {
super(x, y, 35, 27, SPRITES, onPress);
this.tabInfo = tabInfo;
}
public void startAnimation(ClientRecipeBook recipeBook, boolean isFiltering) {
RecipeCollection.CraftableStatus recipesToShow = isFiltering ? RecipeCollection.CraftableStatus.CRAFTABLE : RecipeCollection.CraftableStatus.ANY;
for (RecipeCollection recipeCollection : recipeBook.getCollection(this.tabInfo.category())) {
for (RecipeDisplayEntry recipe : recipeCollection.getSelectedRecipes(recipesToShow)) {
if (recipeBook.willHighlight(recipe.id())) {
this.animationTime = 15.0F;
return;
}
}
}
}
@Override
public void extractContents(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
if (this.animationTime > 0.0F) {
float squeeze = 1.0F + 0.1F * (float)Math.sin(this.animationTime / 15.0F * (float) Math.PI);
graphics.pose().pushMatrix();
graphics.pose().translate(this.getX() + 8, this.getY() + 12);
graphics.pose().scale(1.0F, squeeze);
graphics.pose().translate(-(this.getX() + 8), -(this.getY() + 12));
}
Identifier sprite = this.sprites.get(true, this.selected);
int xPos = this.getX();
if (this.selected) {
xPos -= 2;
}
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, sprite, xPos, this.getY(), this.width, this.height);
this.extractIcon(graphics);
if (this.animationTime > 0.0F) {
graphics.pose().popMatrix();
this.animationTime -= a;
}
}
@Override
protected void handleCursor(GuiGraphicsExtractor graphics) {
if (!this.selected) {
super.handleCursor(graphics);
}
}
private void extractIcon(GuiGraphicsExtractor graphics) {
int moveLeft = this.selected ? -2 : 0;
if (this.tabInfo.secondaryIcon().isPresent()) {
graphics.fakeItem(this.tabInfo.primaryIcon(), this.getX() + 3 + moveLeft, this.getY() + 5);
graphics.fakeItem(this.tabInfo.secondaryIcon().get(), this.getX() + 14 + moveLeft, this.getY() + 5);
} else {
graphics.fakeItem(this.tabInfo.primaryIcon(), this.getX() + 9 + moveLeft, this.getY() + 5);
}
}
public ExtendedRecipeBookCategory getCategory() {
return this.tabInfo.category();
}
public boolean updateVisibility(ClientRecipeBook book) {
List<RecipeCollection> collections = book.getCollection(this.tabInfo.category());
this.visible = false;
for (RecipeCollection collection : collections) {
if (collection.hasAnySelected()) {
this.visible = true;
break;
}
}
return this.visible;
}
public void select() {
this.selected = true;
}
public void unselect() {
this.selected = false;
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
WidgetSprites()
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Identifier.withDefaultNamespace()
- 引用位置:
-
- 引用位置:
返回值
- 引用位置: