CartographyTableScreen.java
net.minecraft.client.gui.screens.inventory.CartographyTableScreen
信息
- 全限定名:net.minecraft.client.gui.screens.inventory.CartographyTableScreen
- 类型:public class
- 包:net.minecraft.client.gui.screens.inventory
- 源码路径:src/main/java/net/minecraft/client/gui/screens/inventory/CartographyTableScreen.java
- 起始行号:L21
- 继承:AbstractContainerScreen
- 职责:
TODO
字段/常量
-
ERROR_SPRITE- 类型:
Identifier - 修饰符:
private static final - 源码定位:
L22 - 说明:
TODO
- 类型:
-
SCALED_MAP_SPRITE- 类型:
Identifier - 修饰符:
private static final - 源码定位:
L23 - 说明:
TODO
- 类型:
-
DUPLICATED_MAP_SPRITE- 类型:
Identifier - 修饰符:
private static final - 源码定位:
L24 - 说明:
TODO
- 类型:
-
MAP_SPRITE- 类型:
Identifier - 修饰符:
private static final - 源码定位:
L25 - 说明:
TODO
- 类型:
-
LOCKED_SPRITE- 类型:
Identifier - 修饰符:
private static final - 源码定位:
L26 - 说明:
TODO
- 类型:
-
BG_LOCATION- 类型:
Identifier - 修饰符:
private static final - 源码定位:
L27 - 说明:
TODO
- 类型:
-
mapRenderState- 类型:
MapRenderState - 修饰符:
private final - 源码定位:
L28 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public CartographyTableScreen(CartographyTableMenu menu, Inventory inventory, Component title) @ L30
- 构造器名:CartographyTableScreen
- 源码定位:L30
- 修饰符:public
参数:
- menu: CartographyTableMenu
- inventory: Inventory
- title: Component
说明:
TODO
方法
下面的方法块按源码顺序生成。
public void extractBackground(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L35
- 方法名:extractBackground
- 源码定位:L35
- 返回类型:void
- 修饰符:public
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
- a: float
说明:
TODO
private void extractResultingMap(GuiGraphicsExtractor graphics, MapId id, MapItemSavedData data, boolean isDuplication, boolean isScaling, boolean isLocking, boolean locked) @ L71
- 方法名:extractResultingMap
- 源码定位:L71
- 返回类型:void
- 修饰符:private
参数:
- graphics: GuiGraphicsExtractor
- id: MapId
- data: MapItemSavedData
- isDuplication: boolean
- isScaling: boolean
- isLocking: boolean
- locked: boolean
说明:
TODO
private void extractMap(GuiGraphicsExtractor graphics, MapId id, MapItemSavedData data, int x, int y, float scale) @ L101
- 方法名:extractMap
- 源码定位:L101
- 返回类型:void
- 修饰符:private
参数:
- graphics: GuiGraphicsExtractor
- id: MapId
- data: MapItemSavedData
- x: int
- y: int
- scale: float
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class CartographyTableScreen extends AbstractContainerScreen<CartographyTableMenu> {
private static final Identifier ERROR_SPRITE = Identifier.withDefaultNamespace("container/cartography_table/error");
private static final Identifier SCALED_MAP_SPRITE = Identifier.withDefaultNamespace("container/cartography_table/scaled_map");
private static final Identifier DUPLICATED_MAP_SPRITE = Identifier.withDefaultNamespace("container/cartography_table/duplicated_map");
private static final Identifier MAP_SPRITE = Identifier.withDefaultNamespace("container/cartography_table/map");
private static final Identifier LOCKED_SPRITE = Identifier.withDefaultNamespace("container/cartography_table/locked");
private static final Identifier BG_LOCATION = Identifier.withDefaultNamespace("textures/gui/container/cartography_table.png");
private final MapRenderState mapRenderState = new MapRenderState();
public CartographyTableScreen(CartographyTableMenu menu, Inventory inventory, Component title) {
super(menu, inventory, title);
this.titleLabelY -= 2;
}
@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, BG_LOCATION, xo, yo, 0.0F, 0.0F, this.imageWidth, this.imageHeight, 256, 256);
ItemStack additionalItem = this.menu.getSlot(1).getItem();
boolean isDuplication = additionalItem.is(Items.MAP);
boolean isScaling = additionalItem.is(Items.PAPER);
boolean isLocking = additionalItem.is(Items.GLASS_PANE);
ItemStack map = this.menu.getSlot(0).getItem();
MapId mapId = map.get(DataComponents.MAP_ID);
boolean locked = false;
MapItemSavedData mapData;
if (mapId != null) {
mapData = MapItem.getSavedData(mapId, this.minecraft.level);
if (mapData != null) {
if (mapData.locked) {
locked = true;
if (isScaling || isLocking) {
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, ERROR_SPRITE, xo + 35, yo + 31, 28, 21);
}
}
if (isScaling && mapData.scale >= 4) {
locked = true;
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, ERROR_SPRITE, xo + 35, yo + 31, 28, 21);
}
}
} else {
mapData = null;
}
this.extractResultingMap(graphics, mapId, mapData, isDuplication, isScaling, isLocking, locked);
}
private void extractResultingMap(
GuiGraphicsExtractor graphics,
@Nullable MapId id,
@Nullable MapItemSavedData data,
boolean isDuplication,
boolean isScaling,
boolean isLocking,
boolean locked
) {
int xo = this.leftPos;
int yo = this.topPos;
if (isScaling && !locked) {
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, SCALED_MAP_SPRITE, xo + 67, yo + 13, 66, 66);
this.extractMap(graphics, id, data, xo + 85, yo + 31, 0.226F);
} else if (isDuplication) {
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, DUPLICATED_MAP_SPRITE, xo + 67 + 16, yo + 13, 50, 66);
this.extractMap(graphics, id, data, xo + 86, yo + 16, 0.34F);
graphics.nextStratum();
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, DUPLICATED_MAP_SPRITE, xo + 67, yo + 13 + 16, 50, 66);
this.extractMap(graphics, id, data, xo + 70, yo + 32, 0.34F);
} else if (isLocking) {
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, MAP_SPRITE, xo + 67, yo + 13, 66, 66);
this.extractMap(graphics, id, data, xo + 71, yo + 17, 0.45F);
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, LOCKED_SPRITE, xo + 118, yo + 60, 10, 14);
} else {
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, MAP_SPRITE, xo + 67, yo + 13, 66, 66);
this.extractMap(graphics, id, data, xo + 71, yo + 17, 0.45F);
}
}
private void extractMap(GuiGraphicsExtractor graphics, @Nullable MapId id, @Nullable MapItemSavedData data, int x, int y, float scale) {
if (id != null && data != null) {
graphics.pose().pushMatrix();
graphics.pose().translate(x, y);
graphics.pose().scale(scale, scale);
this.minecraft.getMapRenderer().extractRenderState(id, data, this.mapRenderState);
graphics.map(this.mapRenderState);
graphics.pose().popMatrix();
}
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
MapRenderState()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Identifier.withDefaultNamespace()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
MapItem.getSavedData()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: