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

dev.polymodloader.api.content.block

자동 생성

이 페이지는 소스의 Javadoc에서 ./gradlew apiReference로 만든 것입니다. 설명은 코드에 적힌 영어 그대로입니다. 직접 고치지 말고 소스의 주석을 고친 뒤 다시 만드세요.

형식종류설명
BlockBehavior인터페이스Code that runs when something happens to a mod block.
BlockDefinition레코드Properties of a mod block.
BlockDefinition.Builder클래스Builds a BlockDefinition.
BlockHandle인터페이스A declared block.
BlockShape레코드The solid part of a block: boxes in pixels, where a full block spans 0..16 on each axis, like the from/to of a block model element.
BlockShape.Box레코드A box from (minX, minY, minZ) to (maxX, maxY, maxZ) in pixels.
BlockSound열거형Sounds a block makes when placed, broken, and walked on; each maps to the game's sound type.
BlockUse레코드A player using (right-clicking) a block with an empty hand.

BlockBehavior​

인터페이스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전

public interface BlockBehavior

Code that runs when something happens to a mod block. Every method has a default that keeps the game's normal behaviour, so implement only what the block needs.

Thread: the world's thread. Callbacks run on both the client and the server copy of the world unless stated otherwise; check WorldView.isClientSide() before changing state. Failure: exceptions propagate into the game like exceptions from the game's own blocks.

onUse(BlockUse)​

default InteractionResult onUse(BlockUse use)

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

A player used the block with an empty hand.

인자타입설명
useBlockUse—

반환 InteractionResult

onSteppedOn(WorldView, BlockPos, EntityView)​

default void onSteppedOn(WorldView world, BlockPos pos, EntityView entity)

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

An entity walks on top of the block.

인자타입설명
worldWorldView—
posBlockPos—
entityEntityView—

onPlaced(WorldView, BlockPos, EntityView)​

default void onPlaced(WorldView world, BlockPos pos, EntityView placer)

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

The block was placed by an entity (server and client).

인자타입설명
worldWorldView—
posBlockPos—
placerEntityView—

onRandomTick(WorldView, BlockPos)​

default void onRandomTick(WorldView world, BlockPos pos)

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

A random tick reached the block (server only, about every 68 seconds per block at the default randomTickSpeed). Requires BlockDefinition.Builder.randomTicks().

인자타입설명
worldWorldView—
posBlockPos—

onNeighborChanged(WorldView, BlockPos)​

default void onNeighborChanged(WorldView world, BlockPos pos)

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

A neighbouring block changed (server and client); typical for redstone-like reactions.

인자타입설명
worldWorldView—
posBlockPos—

BlockDefinition​

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

public record BlockDefinition(float hardness, float explosionResistance, boolean requiresCorrectTool, BlockSound sound, int lightLevel, float friction, boolean collision, boolean occludes, BlockBehavior behavior, Optional<ItemDefinition> item, List<BlockProperty<?>> properties, Optional<BlockProperty.DirectionProperty> placementFacing, boolean randomTicks, Optional<BlockEntityDefinition> blockEntity, Optional<ToIntFunction<BlockStateView>> lightByState, Optional<Function<BlockStateView,BlockShape>> shape, Optional<Function<BlockStateView,BlockShape>> collisionShape)

Properties of a mod block. Created with builder(); immutable.

구성 요소타입설명
hardnessfloattime factor to break the block; -1 is unbreakable
explosionResistancefloatresistance to explosions
requiresCorrectToolbooleanwhether the block drops only when mined with the right tool (tool tags such as minecraft:mineable/pickaxe come from the mod's data pack)
soundBlockSoundsound type
lightLevelintemitted light, 0–15
frictionfloatslipperiness; the game's default is 0.6, ice is 0.98
collisionbooleanwhether entities collide with the block
occludesbooleanwhether the block hides the faces of its neighbours; turn off for see-through blocks
behaviorBlockBehaviorinteraction callbacks
itemOptional<ItemDefinition>the block item to declare with the same ID, or empty for no item
propertiesList<BlockProperty<?>>block state properties, in order
placementFacingOptional<BlockProperty.DirectionProperty>a horizontal direction property set on placement so the block faces the player, or empty
randomTicksbooleanwhether the block receives random ticks (BlockBehavior.onRandomTick)
blockEntityOptional<BlockEntityDefinition>per-position saved state, or empty
lightByStateOptional<ToIntFunction<BlockStateView>>emitted light computed from the state (0–15), overriding lightLevel; for example a lamp that glows only when lit=true
shapeOptional<Function<BlockStateView,BlockShape>>the outline the player aims at, by state, or empty for a full block
collisionShapeOptional<Function<BlockStateView,BlockShape>>what entities collide with, by state, or empty for the same as shape; ignored without collision

builder()​

public static BlockDefinition.Builder builder()

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

A builder with the game's defaults for a plain stone-like block that has a block item.

반환 BlockDefinition.Builder

BlockDefinition.Builder​

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

public static final class Builder

Builds a BlockDefinition.

strength(float, float)​

public BlockDefinition.Builder strength(float hardness, float explosionResistance)

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

Sets hardness and explosion resistance (stone is 1.5 / 6.0).

인자타입설명
hardnessfloat—
explosionResistancefloat—

반환 BlockDefinition.Builder

requiresCorrectTool()​

public BlockDefinition.Builder requiresCorrectTool()

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

The block drops only when mined with the correct tool.

반환 BlockDefinition.Builder

sound(BlockSound)​

public BlockDefinition.Builder sound(BlockSound sound)

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

Sets the sound type.

인자타입설명
soundBlockSound—

반환 BlockDefinition.Builder

lightLevel(int)​

public BlockDefinition.Builder lightLevel(int lightLevel)

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

Sets the emitted light level, 0–15.

인자타입설명
lightLevelint—

반환 BlockDefinition.Builder

lightLevel(ToIntFunction<BlockStateView>)​

public BlockDefinition.Builder lightLevel(ToIntFunction<BlockStateView> byState)

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

Computes the emitted light from each state, for example state -> state.get(LIT) ? 15 : 0. The game evaluates it once per state while the block is created; results outside 0–15 are clamped.

인자타입설명
byStateToIntFunction<BlockStateView>—

반환 BlockDefinition.Builder

friction(float)​

public BlockDefinition.Builder friction(float friction)

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

Sets the friction (0.6 default, 0.98 ice).

인자타입설명
frictionfloat—

반환 BlockDefinition.Builder

noCollision()​

public BlockDefinition.Builder noCollision()

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

Entities pass through the block.

반환 BlockDefinition.Builder

noOcclusion()​

public BlockDefinition.Builder noOcclusion()

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

The block does not hide its neighbours' faces (glass-like blocks).

반환 BlockDefinition.Builder

behavior(BlockBehavior)​

public BlockDefinition.Builder behavior(BlockBehavior behavior)

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

Sets the interaction callbacks.

인자타입설명
behaviorBlockBehavior—

반환 BlockDefinition.Builder

item(ItemDefinition)​

public BlockDefinition.Builder item(ItemDefinition item)

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

Sets the properties of the block item declared with the block.

인자타입설명
itemItemDefinition—

반환 BlockDefinition.Builder

noItem()​

public BlockDefinition.Builder noItem()

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

Declares no block item.

반환 BlockDefinition.Builder

properties(BlockProperty<?>[])​

public BlockDefinition.Builder properties(BlockProperty<?>... added)

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

Adds block state properties; their default values form the default state.

인자타입설명
addedBlockProperty<?>[]—

반환 BlockDefinition.Builder

facesPlayerWhenPlaced(BlockProperty.DirectionProperty)​

public BlockDefinition.Builder facesPlayerWhenPlaced(BlockProperty.DirectionProperty facing)

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

Adds facing as a property and sets it on placement so the block faces the player.

인자타입설명
facingBlockProperty.DirectionProperty—

반환 BlockDefinition.Builder

randomTicks()​

public BlockDefinition.Builder randomTicks()

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

The block receives random ticks.

반환 BlockDefinition.Builder

blockEntity(BlockEntityDefinition)​

public BlockDefinition.Builder blockEntity(BlockEntityDefinition definition)

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

Gives the block per-position saved state.

인자타입설명
definitionBlockEntityDefinition—

반환 BlockDefinition.Builder

shape(BlockShape)​

public BlockDefinition.Builder shape(BlockShape shape)

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

The block's outline and collision: a slab, a post, a pipe. The game also uses it to hide only the neighbour faces the shape covers. Block models are not changed; draw the model to match.

인자타입설명
shapeBlockShape—

반환 BlockDefinition.Builder

shape(Function<BlockStateView,BlockShape>)​

public BlockDefinition.Builder shape(Function<BlockStateView,BlockShape> byState)

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

The block's outline and collision computed from the state, for example turned with BlockShape.facing by a facing property. Called once per state when the game starts.

인자타입설명
byStateFunction<BlockStateView,BlockShape>—

반환 BlockDefinition.Builder

collisionShape(BlockShape)​

public BlockDefinition.Builder collisionShape(BlockShape shape)

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

What entities collide with, when it differs from shape: a low fence-like box, for example.

인자타입설명
shapeBlockShape—

반환 BlockDefinition.Builder

collisionShape(Function<BlockStateView,BlockShape>)​

public BlockDefinition.Builder collisionShape(Function<BlockStateView,BlockShape> byState)

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

What entities collide with, computed from the state. Called once per state when the game starts.

인자타입설명
byStateFunction<BlockStateView,BlockShape>—

반환 BlockDefinition.Builder

build()​

public BlockDefinition build()

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

Creates the definition; invalid values throw IllegalArgumentException.

반환 BlockDefinition

BlockHandle​

인터페이스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전

public interface BlockHandle extends ContentHandle

A declared block.

상위 형식: ContentHandle

BlockShape​

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

public record BlockShape(List<BlockShape.Box> boxes)

The solid part of a block: boxes in pixels, where a full block spans 0..16 on each axis, like the from/to of a block model element. Used for the outline the player aims at and for what entities collide with.

구성 요소타입설명
boxesList<BlockShape.Box>the boxes; empty for no shape at all
상수·필드타입설명
FULLBlockShapeThe whole block.
EMPTYBlockShapeNothing: the block cannot be aimed at or collided with.

box(double, double, double, double, double, double)​

public static BlockShape box(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)

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

One box, in pixels.

인자타입설명
minXdouble—
minYdouble—
minZdouble—
maxXdouble—
maxYdouble—
maxZdouble—

반환 BlockShape

or(BlockShape)​

public BlockShape or(BlockShape other)

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

This shape together with other.

인자타입설명
otherBlockShape—

반환 BlockShape

facing(Direction)​

public BlockShape facing(Direction facing)

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

This shape, drawn facing north, turned around the block's vertical axis to face facing. For example a box along the north edge ends up along the east edge for Direction.EAST.

인자타입설명
facingDirection—

반환 BlockShape

예외 IllegalArgumentException — if facing is up or down

BlockShape.Box​

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

public static record Box(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)

A box from (minX, minY, minZ) to (maxX, maxY, maxZ) in pixels.

구성 요소타입설명
minXdoublelowest x, 0..16
minYdoublelowest y
minZdoublelowest z (north side)
maxXdoublehighest x, greater than minX
maxYdoublehighest y
maxZdoublehighest z (south side)

BlockSound​

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

public enum BlockSound

Sounds a block makes when placed, broken, and walked on; each maps to the game's sound type.

상수설명
STONE—
WOOD—
GRAVEL—
GRASS—
METAL—
GLASS—
WOOL—
SAND—
COPPER—
AMETHYST—

BlockUse​

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

public record BlockUse(WorldView world, BlockPos pos, PlayerView player)

A player using (right-clicking) a block with an empty hand.

구성 요소타입설명
worldWorldViewthe world, client or server copy
posBlockPosthe block's position
playerPlayerViewthe player
Buy me a coffee