본문으로 건너뛰기
버전: Minecraft 26.2

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.

구성 요소타입설명
inventoryRowsintrows 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.
menuTitleStringtranslation key or plain text shown above the menu
tickerOptional<BlockEntityTicker>server-side code run every tick, or empty
syncToClientsbooleanwhether data changes reach clients (for rendering or client logic); the inventory is synchronised through the menu either way
menuOptional<MenuLayout>a menu with its own slot layout, or empty; when present the inventory has one slot per layout slot and inventoryRows is 0
dataVersionintthe current version of the data tree; older saved data runs migration
migrationOptional<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.

인자타입설명
rowsint—
titleString—

반환 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.

인자타입설명
layoutMenuLayout—
titleString—

반환 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.

인자타입설명
versionint—
upgradeDataMigration—

반환 BlockEntityDefinition.Builder

ticker(BlockEntityTicker)​

public BlockEntityDefinition.Builder ticker(BlockEntityTicker ticker)

추가된 버전 0.1.0-alpha.4 또는 그 이전

Runs ticker on the server every tick.

인자타입설명
tickerBlockEntityTicker—

반환 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.

인자타입설명
entityBlockEntityView—

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.

레코드 · 안정성 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.

구성 요소타입설명
widthintmenu width (176 for the game's menus)
heightintmenu height (166 for the game's menus)
slotsList<MenuLayout.MenuSlot>the block entity's slots, in inventory order
inventoryXintleft of the player's inventory
inventoryYinttop of the player's inventory
backgroundOptional<ResourceId>texture, or empty for the plain panel
progressBarsList<MenuLayout.ProgressBar>bars filled from block entity data
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.

인자타입설명
widthint—
heightint—

반환 MenuLayout.Builder

클래스 · 추가된 버전 0.1.0-alpha.4 또는 그 이전

public static final class Builder

Builds a MenuLayout.

public MenuLayout.Builder slot(int x, int y)

추가된 버전 0.1.0-alpha.4 또는 그 이전

Adds a slot.

인자타입설명
xint—
yint—

반환 MenuLayout.Builder

public MenuLayout.Builder outputSlot(int x, int y)

추가된 버전 0.1.0-alpha.4 또는 그 이전

Adds a slot players can only take from.

인자타입설명
xint—
yint—

반환 MenuLayout.Builder

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.

인자타입설명
xint—
yint—
columnsint—
rowsint—

반환 MenuLayout.Builder

public MenuLayout.Builder playerInventory(int x, int y)

추가된 버전 0.1.0-alpha.4 또는 그 이전

Moves the player's inventory (default 8, height - 82).

인자타입설명
xint—
yint—

반환 MenuLayout.Builder

public MenuLayout.Builder background(ResourceId texture)

추가된 버전 0.1.0-alpha.4 또는 그 이전

Draws texture instead of the plain panel.

인자타입설명
textureResourceId—

반환 MenuLayout.Builder

public MenuLayout.Builder progressBar(int x, int y, MenuLayout.ProgressStyle style, String valueKey, String maxKey)

추가된 버전 0.1.0-alpha.4 또는 그 이전

Adds a progress bar.

인자타입설명
xint—
yint—
styleMenuLayout.ProgressStyle—
valueKeyString—
maxKeyString—

반환 MenuLayout.Builder

public MenuLayout build()

추가된 버전 0.1.0-alpha.4 또는 그 이전

Creates the layout; invalid values throw IllegalArgumentException.

반환 MenuLayout

레코드 · 추가된 버전 0.1.0-alpha.4 또는 그 이전

public static record MenuSlot(int x, int y, boolean outputOnly)

One slot.

구성 요소타입설명
xintleft of the 16×16 item area
yinttop of the item area
outputOnlybooleanplayers can take items out but not put them in

레코드 · 추가된 버전 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.

구성 요소타입설명
xintleft
yinttop
styleMenuLayout.ProgressStylehow it looks
valueKeyStringdata key of the current value
maxKeyStringdata key of the full value; the bar is empty while it is 0

열거형 · 추가된 버전 0.1.0-alpha.4 또는 그 이전

public static enum ProgressStyle

Looks of a ProgressBar, taken from the game's furnace.

상수설명
ARROW24×16 arrow filling left to right.
FLAME14×14 flame filling bottom to top.
Buy me a coffee