BelowOrAboveWidgetTooltipPositioner.java
net.minecraft.client.gui.screens.inventory.tooltip.BelowOrAboveWidgetTooltipPositioner
信息
- 全限定名:net.minecraft.client.gui.screens.inventory.tooltip.BelowOrAboveWidgetTooltipPositioner
- 类型:public class
- 包:net.minecraft.client.gui.screens.inventory.tooltip
- 源码路径:src/main/java/net/minecraft/client/gui/screens/inventory/tooltip/BelowOrAboveWidgetTooltipPositioner.java
- 起始行号:L10
- 实现:ClientTooltipPositioner
- 职责:
TODO
字段/常量
screenRectangle- 类型:
ScreenRectangle - 修饰符:
private final - 源码定位:
L11 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public BelowOrAboveWidgetTooltipPositioner(ScreenRectangle screenRectangle) @ L13
- 构造器名:BelowOrAboveWidgetTooltipPositioner
- 源码定位:L13
- 修饰符:public
参数:
- screenRectangle: ScreenRectangle
说明:
TODO
方法
下面的方法块按源码顺序生成。
public Vector2ic positionTooltip(int screenWidth, int screenHeight, int x, int y, int tooltipWidth, int tooltipHeight) @ L17
- 方法名:positionTooltip
- 源码定位:L17
- 返回类型:Vector2ic
- 修饰符:public
参数:
- screenWidth: int
- screenHeight: int
- x: int
- y: int
- tooltipWidth: int
- tooltipHeight: int
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class BelowOrAboveWidgetTooltipPositioner implements ClientTooltipPositioner {
private final ScreenRectangle screenRectangle;
public BelowOrAboveWidgetTooltipPositioner(ScreenRectangle screenRectangle) {
this.screenRectangle = screenRectangle;
}
@Override
public Vector2ic positionTooltip(int screenWidth, int screenHeight, int x, int y, int tooltipWidth, int tooltipHeight) {
Vector2i result = new Vector2i();
result.x = this.screenRectangle.left() + 3;
result.y = this.screenRectangle.bottom() + 3 + 1;
if (result.y + tooltipHeight + 3 > screenHeight) {
result.y = this.screenRectangle.top() - tooltipHeight - 3 - 1;
}
if (result.x + tooltipWidth > screenWidth) {
result.x = Math.max(this.screenRectangle.right() - tooltipWidth - 3, 4);
}
return result;
}
}引用的其他类
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
实现
- 引用位置: