dev.polymodloader.api.content.block.entity
이 페이지는 소스의 Javadoc에서 ./gradlew apiReference로 만든 것입니다. 설명은 코드에 적힌 영어 그대로입니다. 직접 고치지 말고 소스의 주석을 고친 뒤 다시 만드세요.
| 형식 | 종류 | 설명 |
|---|---|---|
BlockEntityDefinition | 레코드 | Gives a mod block per-position state that is saved with the world: a DataTree, an optional inventory, and an optional server tick. |
BlockEntityDefinition.Builder | 클래스 | Builds a BlockEntityDefinition. |
BlockEntityTicker | 함수형 인터페이스 | Server-side code run every tick for each loaded block entity. |
BlockEntityView | 인터페이스 | A mod block entity. |
MenuLayout | 레코드 | The menu of a block entity with its own slot positions, like a furnace. |
MenuLayout.Builder | 클래스 | Builds a MenuLayout. |
MenuLayout.MenuSlot | 레코드 | One slot. |
MenuLayout.ProgressBar | 레코드 | A bar filled in proportion to data().getInt(valueKey) / data().getInt(maxKey) of the block entity. |
MenuLayout.ProgressStyle | 열거형 | Looks of a ProgressBar, taken from the game's furnace. |
BlockEntityDefinition
레코드 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public record BlockEntityDefinition(int inventoryRows, String menuTitle, Optional<BlockEntityTicker> ticker, boolean syncToClients, Optional<MenuLayout> menu, int dataVersion, Optional<DataMigration> migration)
Gives a mod block per-position state that is saved with the world: a DataTree, an optional inventory, and an optional server tick.
| 구성 요소 | 타입 | 설명 |
|---|---|---|
inventoryRows | int | rows of 9 slots (1–6), or 0 for no inventory. Blocks with an inventory open the game's chest-style menu when used (unless the block behaviour returns something other than PASS), drop their contents when broken, and work with hoppers. |
menuTitle | String | translation key or plain text shown above the menu |
ticker | Optional<BlockEntityTicker> | server-side code run every tick, or empty |
syncToClients | boolean | whether data changes reach clients (for rendering or client logic); the inventory is synchronised through the menu either way |
menu | Optional<MenuLayout> | a menu with its own slot layout, or empty; when present the inventory has one slot per layout slot and inventoryRows is 0 |
dataVersion | int | the current version of the data tree; older saved data runs migration |
migration | Optional<DataMigration> | upgrades older data, if any |
inventorySize()
public int inventorySize()
추가된 버전 0.1.0-alpha.4 또는 그 이전
Number of inventory slots: from the layout, or rows × 9.
반환 int
builder()
public static BlockEntityDefinition.Builder builder()
추가된 버전 0.1.0-alpha.4 또는 그 이전
A builder for a block entity with data only.
반환 BlockEntityDefinition.Builder
BlockEntityDefinition.Builder
클래스 · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public static final class Builder
Builds a BlockEntityDefinition.
inventory(int, String)
public BlockEntityDefinition.Builder inventory(int rows, String title)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Adds an inventory of rows × 9 slots with a menu titled title.
| 인자 | 타입 | 설명 |
|---|---|---|
rows | int | — |
title | String | — |
반환 BlockEntityDefinition.Builder
menu(MenuLayout, String)
public BlockEntityDefinition.Builder menu(MenuLayout layout, String title)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Adds an inventory with one slot per layout slot, shown in a menu with that layout.
| 인자 | 타입 | 설명 |
|---|---|---|
layout | MenuLayout | — |
title | String | — |
반환 BlockEntityDefinition.Builder
dataVersion(int, DataMigration)
public BlockEntityDefinition.Builder dataVersion(int version, DataMigration upgrade)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Sets the data version; block entities saved with an older one run upgrade on load.
| 인자 | 타입 | 설명 |
|---|---|---|
version | int | — |
upgrade | DataMigration | — |
반환 BlockEntityDefinition.Builder
ticker(BlockEntityTicker)
public BlockEntityDefinition.Builder ticker(BlockEntityTicker ticker)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Runs ticker on the server every tick.
| 인자 | 타입 | 설명 |
|---|---|---|
ticker | BlockEntityTicker | — |
반환 BlockEntityDefinition.Builder
syncToClients()
public BlockEntityDefinition.Builder syncToClients()
추가된 버전 0.1.0-alpha.4 또는 그 이전
Sends data changes to clients when BlockEntityView.markChanged() is called.
반환 BlockEntityDefinition.Builder
build()
public BlockEntityDefinition build()
추가된 버전 0.1.0-alpha.4 또는 그 이전
Creates the definition.
반환 BlockEntityDefinition
BlockEntityTicker
함수형 인터페이스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public interface BlockEntityTicker
Server-side code run every tick for each loaded block entity. Keep it cheap.
tick(BlockEntityView)
void tick(BlockEntityView entity)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Called on the server thread; entity is valid only during the call.
| 인자 | 타입 | 설명 |
|---|---|---|
entity | BlockEntityView | — |
BlockEntityView
인터페이스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public interface BlockEntityView
A mod block entity. The data tree and inventory live as long as the block; the view itself is valid only during the callback that handed it out.
world()
WorldView world()
추가된 버전 0.1.0-alpha.4 또는 그 이전
The world it is in.
반환 WorldView
pos()
BlockPos pos()
추가된 버전 0.1.0-alpha.4 또는 그 이전
Its position.
반환 BlockPos
data()
DataTree data()
추가된 버전 0.1.0-alpha.4 또는 그 이전
Its saved data; call markChanged() after changing it.
반환 DataTree
inventory()
Optional<InventoryView> inventory()
추가된 버전 0.1.0-alpha.4 또는 그 이전
Its inventory, when the definition has one.
반환 Optional<InventoryView>
markChanged()
void markChanged()
추가된 버전 0.1.0-alpha.4 또는 그 이전
Marks the data for saving and, for synchronised block entities, sends it to clients.
MenuLayout
레코드 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public record MenuLayout(int width, int height, List<MenuLayout.MenuSlot> slots, int inventoryX, int inventoryY, Optional<ResourceId> background, List<MenuLayout.ProgressBar> progressBars)
The menu of a block entity with its own slot positions, like a furnace. Coordinates are GUI pixels from the menu's top-left corner; a slot is 16×16 with its frame one pixel outside. The player's inventory (27 + 9 slots) is placed at inventoryX, inventoryY.
Without a background texture Poly Mod Loader draws a plain panel with slot frames. With one, the texture (<namespace>:textures/gui/...png, 256×256 canvas) is drawn as is and must include the slot frames.
| 구성 요소 | 타입 | 설명 |
|---|---|---|
width | int | menu width (176 for the game's menus) |
height | int | menu height (166 for the game's menus) |
slots | List<MenuLayout.MenuSlot> | the block entity's slots, in inventory order |
inventoryX | int | left of the player's inventory |
inventoryY | int | top of the player's inventory |
background | Optional<ResourceId> | texture, or empty for the plain panel |
progressBars | List<MenuLayout.ProgressBar> | bars filled from block entity data |
builder(int, int)
public static MenuLayout.Builder builder(int width, int height)
추가된 버전 0.1.0-alpha.4 또는 그 이전
A builder for a width × height menu with the inventory at the game's usual place.
| 인자 | 타입 | 설명 |
|---|---|---|
width | int | — |
height | int | — |
반환 MenuLayout.Builder
MenuLayout.Builder
클래스 · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public static final class Builder
Builds a MenuLayout.
slot(int, int)
public MenuLayout.Builder slot(int x, int y)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Adds a slot.
| 인자 | 타입 | 설명 |
|---|---|---|
x | int | — |
y | int | — |
반환 MenuLayout.Builder
outputSlot(int, int)
public MenuLayout.Builder outputSlot(int x, int y)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Adds a slot players can only take from.
| 인자 | 타입 | 설명 |
|---|---|---|
x | int | — |
y | int | — |
반환 MenuLayout.Builder
grid(int, int, int, int)
public MenuLayout.Builder grid(int x, int y, int columns, int rows)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Adds a columns × rows grid of slots with 18-pixel spacing.
| 인자 | 타입 | 설명 |
|---|---|---|
x | int | — |
y | int | — |
columns | int | — |
rows | int | — |
반환 MenuLayout.Builder
playerInventory(int, int)
public MenuLayout.Builder playerInventory(int x, int y)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Moves the player's inventory (default 8, height - 82).
| 인자 | 타입 | 설명 |
|---|---|---|
x | int | — |
y | int | — |
반환 MenuLayout.Builder
background(ResourceId)
public MenuLayout.Builder background(ResourceId texture)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Draws texture instead of the plain panel.
| 인자 | 타입 | 설명 |
|---|---|---|
texture | ResourceId | — |
반환 MenuLayout.Builder
progressBar(int, int, MenuLayout.ProgressStyle, String, String)
public MenuLayout.Builder progressBar(int x, int y, MenuLayout.ProgressStyle style, String valueKey, String maxKey)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Adds a progress bar.
| 인자 | 타입 | 설명 |
|---|---|---|
x | int | — |
y | int | — |
style | MenuLayout.ProgressStyle | — |
valueKey | String | — |
maxKey | String | — |
반환 MenuLayout.Builder
build()
public MenuLayout build()
추가된 버전 0.1.0-alpha.4 또는 그 이전
Creates the layout; invalid values throw IllegalArgumentException.
반환 MenuLayout
MenuLayout.MenuSlot
레코드 · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public static record MenuSlot(int x, int y, boolean outputOnly)
One slot.
| 구성 요소 | 타입 | 설명 |
|---|---|---|
x | int | left of the 16×16 item area |
y | int | top of the item area |
outputOnly | boolean | players can take items out but not put them in |
MenuLayout.ProgressBar
레코드 · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public static record ProgressBar(int x, int y, MenuLayout.ProgressStyle style, String valueKey, String maxKey)
A bar filled in proportion to data().getInt(valueKey) / data().getInt(maxKey) of the block entity. Values reach the client while the menu is open; they must fit in -32768..32767.
| 구성 요소 | 타입 | 설명 |
|---|---|---|
x | int | left |
y | int | top |
style | MenuLayout.ProgressStyle | how it looks |
valueKey | String | data key of the current value |
maxKey | String | data key of the full value; the bar is empty while it is 0 |
MenuLayout.ProgressStyle
열거형 · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public static enum ProgressStyle
Looks of a ProgressBar, taken from the game's furnace.
| 상수 | 설명 |
|---|---|
ARROW | 24×16 arrow filling left to right. |
FLAME | 14×14 flame filling bottom to top. |