InventoryScreen.java
net.minecraft.client.gui.screens.inventory.InventoryScreen
信息
- 全限定名:net.minecraft.client.gui.screens.inventory.InventoryScreen
- 类型:public class
- 包:net.minecraft.client.gui.screens.inventory
- 源码路径:src/main/java/net/minecraft/client/gui/screens/inventory/InventoryScreen.java
- 起始行号:L24
- 继承:AbstractRecipeBookScreen
- 职责:
TODO
字段/常量
-
xMouse- 类型:
float - 修饰符:
private - 源码定位:
L25 - 说明:
TODO
- 类型:
-
yMouse- 类型:
float - 修饰符:
private - 源码定位:
L26 - 说明:
TODO
- 类型:
-
buttonClicked- 类型:
boolean - 修饰符:
private - 源码定位:
L27 - 说明:
TODO
- 类型:
-
effects- 类型:
EffectsInInventory - 修饰符:
private final - 源码定位:
L28 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public InventoryScreen(Player player) @ L30
- 构造器名:InventoryScreen
- 源码定位:L30
- 修饰符:public
参数:
- player: Player
说明:
TODO
方法
下面的方法块按源码顺序生成。
public void containerTick() @ L36
- 方法名:containerTick
- 源码定位:L36
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
protected void init() @ L49
- 方法名:init
- 源码定位:L49
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
protected ScreenPosition getRecipeBookButtonPosition() @ L63
- 方法名:getRecipeBookButtonPosition
- 源码定位:L63
- 返回类型:ScreenPosition
- 修饰符:protected
参数:
- 无
说明:
TODO
protected void onRecipeBookButtonClick() @ L68
- 方法名:onRecipeBookButtonClick
- 源码定位:L68
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
protected void extractLabels(GuiGraphicsExtractor graphics, int xm, int ym) @ L73
- 方法名:extractLabels
- 源码定位:L73
- 返回类型:void
- 修饰符:protected
参数:
- graphics: GuiGraphicsExtractor
- xm: int
- ym: int
说明:
TODO
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L78
- 方法名:extractRenderState
- 源码定位:L78
- 返回类型:void
- 修饰符:public
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
- a: float
说明:
TODO
public boolean showsActiveEffects() @ L86
- 方法名:showsActiveEffects
- 源码定位:L86
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
protected boolean isBiggerResultSlot() @ L91
- 方法名:isBiggerResultSlot
- 源码定位:L91
- 返回类型:boolean
- 修饰符:protected
参数:
- 无
说明:
TODO
public void extractBackground(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L96
- 方法名:extractBackground
- 源码定位:L96
- 返回类型:void
- 修饰符:public
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
- a: float
说明:
TODO
public static void extractEntityInInventoryFollowsMouse(GuiGraphicsExtractor graphics, int x0, int y0, int x1, int y1, int size, float offsetY, float mouseX, float mouseY, LivingEntity entity) @ L105
- 方法名:extractEntityInInventoryFollowsMouse
- 源码定位:L105
- 返回类型:void
- 修饰符:public static
参数:
- graphics: GuiGraphicsExtractor
- x0: int
- y0: int
- x1: int
- y1: int
- size: int
- offsetY: float
- mouseX: float
- mouseY: float
- entity: LivingEntity
说明:
TODO
private static EntityRenderState extractRenderState(LivingEntity entity) @ L134
- 方法名:extractRenderState
- 源码定位:L134
- 返回类型:EntityRenderState
- 修饰符:private static
参数:
- entity: LivingEntity
说明:
TODO
public boolean mouseReleased(MouseButtonEvent event) @ L143
- 方法名:mouseReleased
- 源码定位:L143
- 返回类型:boolean
- 修饰符:public
参数:
- event: MouseButtonEvent
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class InventoryScreen extends AbstractRecipeBookScreen<InventoryMenu> {
private float xMouse;
private float yMouse;
private boolean buttonClicked;
private final EffectsInInventory effects;
public InventoryScreen(Player player) {
super(player.inventoryMenu, new CraftingRecipeBookComponent(player.inventoryMenu), player.getInventory(), Component.translatable("container.crafting"));
this.titleLabelX = 97;
this.effects = new EffectsInInventory(this);
}
@Override
public void containerTick() {
super.containerTick();
if (this.minecraft.player.hasInfiniteMaterials()) {
this.minecraft
.setScreen(
new CreativeModeInventoryScreen(
this.minecraft.player, this.minecraft.player.connection.enabledFeatures(), this.minecraft.options.operatorItemsTab().get()
)
);
}
}
@Override
protected void init() {
if (this.minecraft.player.hasInfiniteMaterials()) {
this.minecraft
.setScreen(
new CreativeModeInventoryScreen(
this.minecraft.player, this.minecraft.player.connection.enabledFeatures(), this.minecraft.options.operatorItemsTab().get()
)
);
} else {
super.init();
}
}
@Override
protected ScreenPosition getRecipeBookButtonPosition() {
return new ScreenPosition(this.leftPos + 104, this.height / 2 - 22);
}
@Override
protected void onRecipeBookButtonClick() {
this.buttonClicked = true;
}
@Override
protected void extractLabels(GuiGraphicsExtractor graphics, int xm, int ym) {
graphics.text(this.font, this.title, this.titleLabelX, this.titleLabelY, -12566464, false);
}
@Override
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
this.effects.extractRenderState(graphics, mouseX, mouseY);
super.extractRenderState(graphics, mouseX, mouseY, a);
this.xMouse = mouseX;
this.yMouse = mouseY;
}
@Override
public boolean showsActiveEffects() {
return this.effects.canSeeEffects();
}
@Override
protected boolean isBiggerResultSlot() {
return false;
}
@Override
public void extractBackground(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
super.extractBackground(graphics, mouseX, mouseY, a);
int xo = this.leftPos;
int yo = this.topPos;
graphics.blit(RenderPipelines.GUI_TEXTURED, INVENTORY_LOCATION, xo, yo, 0.0F, 0.0F, this.imageWidth, this.imageHeight, 256, 256);
extractEntityInInventoryFollowsMouse(graphics, xo + 26, yo + 8, xo + 75, yo + 78, 30, 0.0625F, this.xMouse, this.yMouse, this.minecraft.player);
}
public static void extractEntityInInventoryFollowsMouse(
GuiGraphicsExtractor graphics, int x0, int y0, int x1, int y1, int size, float offsetY, float mouseX, float mouseY, LivingEntity entity
) {
float centerX = (x0 + x1) / 2.0F;
float centerY = (y0 + y1) / 2.0F;
float xAngle = (float)Math.atan((centerX - mouseX) / 40.0F);
float yAngle = (float)Math.atan((centerY - mouseY) / 40.0F);
Quaternionf rotation = new Quaternionf().rotateZ((float) Math.PI);
Quaternionf xRotation = new Quaternionf().rotateX(yAngle * 20.0F * (float) (Math.PI / 180.0));
rotation.mul(xRotation);
EntityRenderState renderState = extractRenderState(entity);
if (renderState instanceof LivingEntityRenderState livingRenderState) {
livingRenderState.bodyRot = 180.0F + xAngle * 20.0F;
livingRenderState.yRot = xAngle * 20.0F;
if (livingRenderState.pose != Pose.FALL_FLYING) {
livingRenderState.xRot = -yAngle * 20.0F;
} else {
livingRenderState.xRot = 0.0F;
}
livingRenderState.boundingBoxWidth = livingRenderState.boundingBoxWidth / livingRenderState.scale;
livingRenderState.boundingBoxHeight = livingRenderState.boundingBoxHeight / livingRenderState.scale;
livingRenderState.scale = 1.0F;
}
Vector3f translation = new Vector3f(0.0F, renderState.boundingBoxHeight / 2.0F + offsetY, 0.0F);
graphics.entity(renderState, size, translation, rotation, xRotation, x0, y0, x1, y1);
}
private static EntityRenderState extractRenderState(LivingEntity entity) {
EntityRenderDispatcher entityRenderDispatcher = Minecraft.getInstance().getEntityRenderDispatcher();
EntityRenderer<? super LivingEntity, ?> renderer = entityRenderDispatcher.getRenderer(entity);
EntityRenderState renderState = renderer.createRenderState(entity, 1.0F);
renderState.shadowPieces.clear();
renderState.outlineColor = 0;
return renderState;
}
@Override
public boolean mouseReleased(MouseButtonEvent event) {
if (this.buttonClicked) {
this.buttonClicked = false;
return true;
} else {
return super.mouseReleased(event);
}
}
}引用的其他类
-
- 引用位置:
方法调用 - 关联成员:
Minecraft.getInstance()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
构造调用/返回值 - 关联成员:
ScreenPosition()
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
CreativeModeInventoryScreen()
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
EffectsInInventory()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
CraftingRecipeBookComponent()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Component.translatable()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: