hytale-custom-blocks
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreating Custom Hytale Blocks
为Hytale创建自定义方块
Complete guide for defining custom block types with all available properties and configurations.
本指南完整介绍了如何定义带有所有可用属性和配置的自定义方块类型。
When to use this skill
何时使用本技能
Use this skill when:
- Creating new block types
- Configuring block rendering (textures, models)
- Setting up block physics (support, bouncy, climbable)
- Making blocks farmable with growth stages
- Adding crafting benches
- Defining block interactions
- Setting up block sounds and particles
- Managing block states
在以下场景使用本技能:
- 创建新的方块类型
- 配置方块渲染(纹理、模型)
- 设置方块物理特性(支撑、弹性、可攀爬)
- 制作带有生长阶段的可种植方块
- 添加工作台
- 定义方块交互
- 设置方块音效与粒子效果
- 管理方块状态
Block Asset Structure
方块资源结构
Blocks are defined as JSON assets in your plugin's asset pack:
my-plugin/
└── assets/
└── Server/
└── Content/
└── BlockTypes/
├── my_custom_block.blocktype
├── my_crop.blocktype
└── my_bench.blocktype方块在插件资源包中以JSON资源的形式定义:
my-plugin/
└── assets/
└── Server/
└── Content/
└── BlockTypes/
├── my_custom_block.blocktype
├── my_crop.blocktype
└── my_bench.blocktypeBasic Block Definition
基础方块定义
File:
my_custom_block.blocktypejson
{
"DisplayName": {
"en-US": "Custom Block"
},
"Description": {
"en-US": "A custom block with special properties"
},
"DrawType": "Cube",
"Texture": "MyPlugin/Textures/custom_block",
"Material": "Stone",
"Tags": {
"Category": ["Building", "Decorative"]
}
}文件:
my_custom_block.blocktypejson
{
"DisplayName": {
"en-US": "Custom Block"
},
"Description": {
"en-US": "A custom block with special properties"
},
"DrawType": "Cube",
"Texture": "MyPlugin/Textures/custom_block",
"Material": "Stone",
"Tags": {
"Category": ["Building", "Decorative"]
}
}Block Properties Reference
方块属性参考
Core Properties
核心属性
| Property | Type | Description |
|---|---|---|
| LocalizedString | Localized display name |
| LocalizedString | Localized description |
| String | Inherit from another block type |
| Object | Category tags for filtering |
| 属性 | 类型 | 说明 |
|---|---|---|
| LocalizedString | 多语言显示名称 |
| LocalizedString | 多语言描述 |
| String | 继承自其他方块类型 |
| Object | 用于筛选的分类标签 |
Rendering Properties
渲染属性
| Property | Type | Default | Description |
|---|---|---|---|
| Enum | | |
| String | - | Texture path for cube rendering |
| String | - | Top face texture |
| String | - | Side faces texture |
| String | - | Bottom face texture |
| String | - | Model asset for DrawType=Model |
| String | - | Custom shader |
| Float | 1.0 | Block opacity (0-1) |
| Boolean | false | Enable alpha blending |
| Boolean | false | Random Y rotation on place |
| Enum | - | Rotation variant mode |
| Enum | - | Random flipping mode |
| Float | 0 | Rotation offset in degrees |
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| Enum | | 可选值: |
| String | - | 立方体渲染的纹理路径 |
| String | - | 顶面纹理 |
| String | - | 侧面纹理 |
| String | - | 底面纹理 |
| String | - | 当DrawType=Model时使用的模型资源 |
| String | - | 自定义着色器 |
| Float | 1.0 | 方块透明度(0-1) |
| Boolean | false | 是否启用透明度混合 |
| Boolean | false | 放置时随机Y轴旋转 |
| Enum | - | 旋转变体模式 |
| Enum | - | 随机翻转模式 |
| Float | 0 | 旋转偏移角度(度) |
Physics Properties
物理属性
| Property | Type | Default | Description |
|---|---|---|---|
| String | - | Physics material type |
| Boolean | true | Collision enabled |
| Boolean | false | Can be replaced when placing |
| Boolean | false | Falls like sand |
| Object | - | Support provided to neighbors |
| Object | - | Support needed from neighbors |
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| String | - | 物理材质类型 |
| Boolean | true | 是否启用碰撞 |
| Boolean | false | 放置时是否可被替换 |
| Boolean | false | 是否像沙子一样下落 |
| Object | - | 向相邻方块提供的支撑 |
| Object | - | 自身需要从相邻方块获得的支撑 |
Movement Properties
移动属性
| Property | Type | Default | Description |
|---|---|---|---|
| Boolean | false | Can be climbed (ladders) |
| Float | 0 | Bounce factor (0-1) |
| Float | 0 | Movement drag |
| Float | 1 | Surface friction |
| Float | 1 | Walk speed multiplier |
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| Boolean | false | 是否可攀爬(如梯子) |
| Float | 0 | 弹跳系数(0-1) |
| Float | 0 | 移动阻力 |
| Float | 1 | 表面摩擦力 |
| Float | 1 | 行走速度倍率 |
Behavior Properties
行为属性
| Property | Type | Default | Description |
|---|---|---|---|
| Boolean | false | Right-click interaction |
| Boolean | true | Can be placed adjacent |
| String | - | Item dropped when broken |
| Integer | 0 | Light emission (0-15) |
| Color | white | Light color |
| Boolean | false | Can catch fire |
| Integer | 0 | Fire spread rate |
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| Boolean | false | 是否支持右键交互 |
| Boolean | true | 是否可相邻放置 |
| String | - | 破坏后掉落的物品ID |
| Integer | 0 | 发光等级(0-15) |
| Color | white | 发光颜色 |
| Boolean | false | 是否可燃 |
| Integer | 0 | 火焰传播速度 |
Draw Types
渲染类型
Cube (Default)
Cube(默认)
Standard voxel block with 6-sided textures:
json
{
"DrawType": "Cube",
"Texture": "MyPlugin/Textures/stone",
"TextureTop": "MyPlugin/Textures/stone_top"
}标准体素方块,支持6面纹理:
json
{
"DrawType": "Cube",
"Texture": "MyPlugin/Textures/stone",
"TextureTop": "MyPlugin/Textures/stone_top"
}Model
Model
Custom 3D model:
json
{
"DrawType": "Model",
"Model": "MyPlugin/Models/custom_model",
"BoundingBox": "MyPlugin/BoundingBoxes/custom_box"
}自定义3D模型:
json
{
"DrawType": "Model",
"Model": "MyPlugin/Models/custom_model",
"BoundingBox": "MyPlugin/BoundingBoxes/custom_box"
}Empty
Empty
Invisible block (air-like, for logic):
json
{
"DrawType": "Empty",
"IsSolid": false
}不可见方块(类似空气,用于逻辑实现):
json
{
"DrawType": "Empty",
"IsSolid": false
}Block Physics System
方块物理系统
Block Face Support
方块面支撑
Define which faces provide support:
json
{
"BlockFaceSupport": {
"Top": {
"Type": "Full",
"SupportStrength": 100
},
"Bottom": {
"Type": "Full",
"SupportStrength": 100
},
"North": { "Type": "Full" },
"South": { "Type": "Full" },
"East": { "Type": "Full" },
"West": { "Type": "Full" }
}
}Support Types: , , ,
FullPartialNoneCenter定义方块各面可提供的支撑:
json
{
"BlockFaceSupport": {
"Top": {
"Type": "Full",
"SupportStrength": 100
},
"Bottom": {
"Type": "Full",
"SupportStrength": 100
},
"North": { "Type": "Full" },
"South": { "Type": "Full" },
"East": { "Type": "Full" },
"West": { "Type": "Full" }
}
}支撑类型:、、、
FullPartialNoneCenterRequired Support
所需支撑
Define what support the block needs:
json
{
"RequiredBlockFaceSupport": {
"Bottom": [
{
"Type": "Full",
"Match": "REQUIRED"
}
]
}
}Match Types:
- - Must have this support
REQUIRED - - Don't care
IGNORED - - Must NOT have this support
DISALLOWED
定义方块自身需要的支撑:
json
{
"RequiredBlockFaceSupport": {
"Bottom": [
{
"Type": "Full",
"Match": "REQUIRED"
}
]
}
}匹配类型:
- - 必须具备该支撑
REQUIRED - - 无要求
IGNORED - - 必须不具备该支撑
DISALLOWED
Gravity Blocks
受重力影响的方块
json
{
"HasGravity": true,
"GravityDelay": 5,
"PhysicsDrop": {
"GatherType": "Shovel",
"Drops": [
{
"Item": "minecraft:sand",
"Quantity": 1
}
]
}
}json
{
"HasGravity": true,
"GravityDelay": 5,
"PhysicsDrop": {
"GatherType": "Shovel",
"Drops": [
{
"Item": "minecraft:sand",
"Quantity": 1
}
]
}
}Block Gathering/Breaking
方块采集/破坏
Breaking Configuration
破坏配置
json
{
"Gathering": {
"Breaking": {
"GatherType": "Pickaxe",
"Power": 2,
"Quality": 1,
"Drops": [
{
"Item": "my_plugin:custom_ore",
"Quantity": {
"Min": 1,
"Max": 3
},
"Chance": 1.0
}
]
},
"Harvest": {
"GatherType": "Hoe",
"Quality": 1,
"Drops": [
{
"Item": "my_plugin:seeds",
"Quantity": 1
}
]
},
"SoftBlock": {
"Enabled": true,
"Drops": [
{
"Item": "my_plugin:dust",
"Quantity": 1
}
]
}
}
}Gather Types: , , , , ,
HandPickaxeAxeShovelHoeSwordjson
{
"Gathering": {
"Breaking": {
"GatherType": "Pickaxe",
"Power": 2,
"Quality": 1,
"Drops": [
{
"Item": "my_plugin:custom_ore",
"Quantity": {
"Min": 1,
"Max": 3
},
"Chance": 1.0
}
]
},
"Harvest": {
"GatherType": "Hoe",
"Quality": 1,
"Drops": [
{
"Item": "my_plugin:seeds",
"Quantity": 1
}
]
},
"SoftBlock": {
"Enabled": true,
"Drops": [
{
"Item": "my_plugin:dust",
"Quantity": 1
}
]
}
}
}采集工具类型:、、、、、
HandPickaxeAxeShovelHoeSwordBlock States
方块状态
Define different visual/behavioral states:
json
{
"States": {
"powered": {
"Values": ["true", "false"],
"Default": "false"
},
"facing": {
"Values": ["north", "south", "east", "west"],
"Default": "north"
}
},
"StateData": {
"powered=true,facing=north": {
"Model": "MyPlugin/Models/powered_north"
},
"powered=true,facing=south": {
"Model": "MyPlugin/Models/powered_south"
},
"powered=false": {
"Model": "MyPlugin/Models/unpowered"
}
}
}定义不同的视觉/行为状态:
json
{
"States": {
"powered": {
"Values": ["true", "false"],
"Default": "false"
},
"facing": {
"Values": ["north", "south", "east", "west"],
"Default": "north"
}
},
"StateData": {
"powered=true,facing=north": {
"Model": "MyPlugin/Models/powered_north"
},
"powered=true,facing=south": {
"Model": "MyPlugin/Models/powered_south"
},
"powered=false": {
"Model": "MyPlugin/Models/unpowered"
}
}
}Farming Blocks
可种植方块
Create crops with growth stages:
json
{
"DisplayName": { "en-US": "Wheat" },
"DrawType": "Model",
"FarmingData": {
"Stages": [
{
"Model": "Hytale/Models/Crops/wheat_stage_0",
"GrowthTime": 300,
"LightRequired": 8
},
{
"Model": "Hytale/Models/Crops/wheat_stage_1",
"GrowthTime": 300,
"LightRequired": 8
},
{
"Model": "Hytale/Models/Crops/wheat_stage_2",
"GrowthTime": 300,
"LightRequired": 8
},
{
"Model": "Hytale/Models/Crops/wheat_stage_3",
"GrowthTime": 0,
"LightRequired": 0,
"IsFinalStage": true
}
],
"Modifiers": {
"Biome": {
"Plains": 1.2,
"Desert": 0.5
},
"Weather": {
"Rain": 1.3
}
},
"SpreadSettings": {
"Enabled": true,
"Chance": 0.1,
"Radius": 2
},
"RequiredSoil": ["Hytale:Farmland", "Hytale:Dirt"]
}
}创建带有生长阶段的农作物:
json
{
"DisplayName": { "en-US": "Wheat" },
"DrawType": "Model",
"FarmingData": {
"Stages": [
{
"Model": "Hytale/Models/Crops/wheat_stage_0",
"GrowthTime": 300,
"LightRequired": 8
},
{
"Model": "Hytale/Models/Crops/wheat_stage_1",
"GrowthTime": 300,
"LightRequired": 8
},
{
"Model": "Hytale/Models/Crops/wheat_stage_2",
"GrowthTime": 300,
"LightRequired": 8
},
{
"Model": "Hytale/Models/Crops/wheat_stage_3",
"GrowthTime": 0,
"LightRequired": 0,
"IsFinalStage": true
}
],
"Modifiers": {
"Biome": {
"Plains": 1.2,
"Desert": 0.5
},
"Weather": {
"Rain": 1.3
}
},
"SpreadSettings": {
"Enabled": true,
"Chance": 0.1,
"Radius": 2
},
"RequiredSoil": ["Hytale:Farmland", "Hytale:Dirt"]
}
}Crafting Benches
工作台
Create blocks that open crafting interfaces:
创建可打开 crafting 界面的方块:
Standard Crafting Bench
标准工作台
json
{
"DisplayName": { "en-US": "Workbench" },
"DrawType": "Model",
"Model": "MyPlugin/Models/workbench",
"IsUsable": true,
"Bench": {
"Type": "Crafting",
"Categories": ["MyPlugin:BasicCrafting", "MyPlugin:AdvancedCrafting"],
"GridSize": {
"Width": 3,
"Height": 3
},
"OutputSlots": 1
}
}json
{
"DisplayName": { "en-US": "Workbench" },
"DrawType": "Model",
"Model": "MyPlugin/Models/workbench",
"IsUsable": true,
"Bench": {
"Type": "Crafting",
"Categories": ["MyPlugin:BasicCrafting", "MyPlugin:AdvancedCrafting"],
"GridSize": {
"Width": 3,
"Height": 3
},
"OutputSlots": 1
}
}Processing Bench
加工工作台
json
{
"Bench": {
"Type": "Processing",
"Categories": ["MyPlugin:Smelting"],
"InputSlots": 1,
"FuelSlots": 1,
"OutputSlots": 1,
"ProcessingTime": 200,
"FuelTypes": ["Hytale:Coal", "Hytale:Charcoal"]
}
}json
{
"Bench": {
"Type": "Processing",
"Categories": ["MyPlugin:Smelting"],
"InputSlots": 1,
"FuelSlots": 1,
"OutputSlots": 1,
"ProcessingTime": 200,
"FuelTypes": ["Hytale:Coal", "Hytale:Charcoal"]
}
}Diagram Crafting Bench
蓝图工作台
json
{
"Bench": {
"Type": "DiagramCrafting",
"Categories": ["MyPlugin:BlueprintCrafting"],
"DiagramSlot": true,
"MaterialSlots": 6,
"OutputSlots": 1
}
}json
{
"Bench": {
"Type": "DiagramCrafting",
"Categories": ["MyPlugin:BlueprintCrafting"],
"DiagramSlot": true,
"MaterialSlots": 6,
"OutputSlots": 1
}
}Block Sounds
方块音效
json
{
"BlockSound": "MyPlugin/BlockSounds/metal",
"AmbientSound": {
"Sound": "MyPlugin/Sounds/machine_hum",
"Volume": 0.5,
"Radius": 8
}
}Standard BlockSound sets: , , , , , , , , ,
StoneWoodMetalGlassDirtSandGrassGravelSnowWooljson
{
"BlockSound": "MyPlugin/BlockSounds/metal",
"AmbientSound": {
"Sound": "MyPlugin/Sounds/machine_hum",
"Volume": 0.5,
"Radius": 8
}
}标准BlockSound集合:、、、、、、、、、
StoneWoodMetalGlassDirtSandGrassGravelSnowWoolBlock Particles
方块粒子效果
json
{
"BreakParticle": "MyPlugin/Particles/stone_break",
"AmbientParticle": {
"Particle": "MyPlugin/Particles/sparkle",
"SpawnRate": 2,
"Radius": 0.5
},
"FootstepParticle": "MyPlugin/Particles/dust"
}json
{
"BreakParticle": "MyPlugin/Particles/stone_break",
"AmbientParticle": {
"Particle": "MyPlugin/Particles/sparkle",
"SpawnRate": 2,
"Radius": 0.5
},
"FootstepParticle": "MyPlugin/Particles/dust"
}Block Interactions
方块交互
Define custom interactions via the Interaction system:
json
{
"Interactions": {
"Use": "MyPlugin:MyBlockInteraction",
"Attack": "MyPlugin:MyBlockAttackInteraction"
}
}通过交互系统定义自定义交互:
json
{
"Interactions": {
"Use": "MyPlugin:MyBlockInteraction",
"Attack": "MyPlugin:MyBlockAttackInteraction"
}
}Interaction Types
交互类型
| Type | Trigger |
|---|---|
| Right-click |
| Left-click |
| Look at block |
| Walk into block |
| 类型 | 触发条件 |
|---|---|
| 右键点击 |
| 左键点击 |
| 注视方块 |
| 走进方块 |
Complete Example: Custom Ore
完整示例:自定义矿石
json
{
"DisplayName": {
"en-US": "Mythril Ore"
},
"Description": {
"en-US": "A rare ore found deep underground"
},
"DrawType": "Cube",
"Texture": "MyPlugin/Textures/mythril_ore",
"Material": "Stone",
"LightLevel": 3,
"LightColor": { "R": 0.5, "G": 0.8, "B": 1.0 },
"Tags": {
"Category": ["Ore", "Mining"]
},
"Gathering": {
"Breaking": {
"GatherType": "Pickaxe",
"Power": 4,
"Quality": 3,
"Drops": [
{
"Item": "MyPlugin:RawMythril",
"Quantity": { "Min": 1, "Max": 2 }
}
]
}
},
"BlockFaceSupport": {
"Top": { "Type": "Full" },
"Bottom": { "Type": "Full" },
"North": { "Type": "Full" },
"South": { "Type": "Full" },
"East": { "Type": "Full" },
"West": { "Type": "Full" }
},
"BlockSound": "Hytale/BlockSounds/Stone",
"BreakParticle": "MyPlugin/Particles/mythril_break",
"AmbientParticle": {
"Particle": "MyPlugin/Particles/mythril_sparkle",
"SpawnRate": 0.5
}
}json
{
"DisplayName": {
"en-US": "Mythril Ore"
},
"Description": {
"en-US": "A rare ore found deep underground"
},
"DrawType": "Cube",
"Texture": "MyPlugin/Textures/mythril_ore",
"Material": "Stone",
"LightLevel": 3,
"LightColor": { "R": 0.5, "G": 0.8, "B": 1.0 },
"Tags": {
"Category": ["Ore", "Mining"]
},
"Gathering": {
"Breaking": {
"GatherType": "Pickaxe",
"Power": 4,
"Quality": 3,
"Drops": [
{
"Item": "MyPlugin:RawMythril",
"Quantity": { "Min": 1, "Max": 2 }
}
]
}
},
"BlockFaceSupport": {
"Top": { "Type": "Full" },
"Bottom": { "Type": "Full" },
"North": { "Type": "Full" },
"South": { "Type": "Full" },
"East": { "Type": "Full" },
"West": { "Type": "Full" }
},
"BlockSound": "Hytale/BlockSounds/Stone",
"BreakParticle": "MyPlugin/Particles/mythril_break",
"AmbientParticle": {
"Particle": "MyPlugin/Particles/mythril_sparkle",
"SpawnRate": 0.5
}
}Complete Example: Door Block
完整示例:门方块
json
{
"DisplayName": { "en-US": "Wooden Door" },
"DrawType": "Model",
"Material": "Wood",
"IsUsable": true,
"States": {
"open": {
"Values": ["true", "false"],
"Default": "false"
},
"facing": {
"Values": ["north", "south", "east", "west"],
"Default": "north"
},
"half": {
"Values": ["upper", "lower"],
"Default": "lower"
}
},
"StateData": {
"open=false,facing=north,half=lower": {
"Model": "MyPlugin/Models/door_closed_lower_n"
},
"open=true,facing=north,half=lower": {
"Model": "MyPlugin/Models/door_open_lower_n"
}
},
"IsSolid": false,
"Interactions": {
"Use": "MyPlugin:DoorInteraction"
},
"PlacementSettings": {
"RotationMode": "PlayerFacing",
"MultiBlock": {
"Pattern": [
{ "Offset": [0, 1, 0], "State": "half=upper" }
]
}
},
"BlockSound": "Hytale/BlockSounds/Wood",
"RequiredBlockFaceSupport": {
"Bottom": [
{ "Type": "Full", "Match": "REQUIRED" }
]
}
}json
{
"DisplayName": { "en-US": "Wooden Door" },
"DrawType": "Model",
"Material": "Wood",
"IsUsable": true,
"States": {
"open": {
"Values": ["true", "false"],
"Default": "false"
},
"facing": {
"Values": ["north", "south", "east", "west"],
"Default": "north"
},
"half": {
"Values": ["upper", "lower"],
"Default": "lower"
}
},
"StateData": {
"open=false,facing=north,half=lower": {
"Model": "MyPlugin/Models/door_closed_lower_n"
},
"open=true,facing=north,half=lower": {
"Model": "MyPlugin/Models/door_open_lower_n"
}
},
"IsSolid": false,
"Interactions": {
"Use": "MyPlugin:DoorInteraction"
},
"PlacementSettings": {
"RotationMode": "PlayerFacing",
"MultiBlock": {
"Pattern": [
{ "Offset": [0, 1, 0], "State": "half=upper" }
]
}
},
"BlockSound": "Hytale/BlockSounds/Wood",
"RequiredBlockFaceSupport": {
"Bottom": [
{ "Type": "Full", "Match": "REQUIRED" }
]
}
}Registering Blocks from Plugin Code
从插件代码注册方块
For dynamic block registration:
java
@Override
protected void setup() {
// Listen for block type loading
getEventRegistry().register(
LoadedAssetsEvent.class,
BlockType.class,
this::onBlockTypesLoaded
);
}
private void onBlockTypesLoaded(LoadedAssetsEvent<BlockType> event) {
// Access loaded block types
BlockType myBlock = event.getAssetStore().get("MyPlugin:my_custom_block");
if (myBlock != null) {
getLogger().atInfo().log("Custom block loaded: %s", myBlock.getDisplayName());
}
}动态注册方块的方法:
java
@Override
protected void setup() {
// 监听方块类型加载事件
getEventRegistry().register(
LoadedAssetsEvent.class,
BlockType.class,
this::onBlockTypesLoaded
);
}
private void onBlockTypesLoaded(LoadedAssetsEvent<BlockType> event) {
// 获取已加载的方块类型
BlockType myBlock = event.getAssetStore().get("MyPlugin:my_custom_block");
if (myBlock != null) {
getLogger().atInfo().log("Custom block loaded: %s", myBlock.getDisplayName());
}
}Block Events
方块事件
Handle block-related events:
java
@Override
protected void setup() {
// Block break event
getEntityStoreRegistry().registerSystem(new BreakBlockHandler());
// Block place event
getEntityStoreRegistry().registerSystem(new PlaceBlockHandler());
// Block use event
getEntityStoreRegistry().registerSystem(new UseBlockHandler());
}
public class BreakBlockHandler extends EntityEventSystem<EntityStore, BreakBlockEvent> {
public BreakBlockHandler() {
super(BreakBlockEvent.class);
}
@Override
public void handle(int index, ArchetypeChunk<EntityStore> chunk,
Store<EntityStore> store, CommandBuffer<EntityStore> buffer,
BreakBlockEvent event) {
BlockType blockType = event.getBlockType();
Vector3i position = event.getPosition();
// Custom logic here
if (blockType.getId().equals("MyPlugin:protected_block")) {
event.setCancelled(true);
}
}
}处理与方块相关的事件:
java
@Override
protected void setup() {
// 方块破坏事件
getEntityStoreRegistry().registerSystem(new BreakBlockHandler());
// 方块放置事件
getEntityStoreRegistry().registerSystem(new PlaceBlockHandler());
// 方块使用事件
getEntityStoreRegistry().registerSystem(new UseBlockHandler());
}
public class BreakBlockHandler extends EntityEventSystem<EntityStore, BreakBlockEvent> {
public BreakBlockHandler() {
super(BreakBlockEvent.class);
}
@Override
public void handle(int index, ArchetypeChunk<EntityStore> chunk,
Store<EntityStore> store, CommandBuffer<EntityStore> buffer,
BreakBlockEvent event) {
BlockType blockType = event.getBlockType();
Vector3i position = event.getPosition();
// 自定义逻辑
if (blockType.getId().equals("MyPlugin:protected_block")) {
event.setCancelled(true);
}
}
}Troubleshooting
故障排除
Block Not Rendering
方块无法渲染
- Verify is correct
DrawType - Check texture path exists
- Ensure asset pack is registered in manifest
- 确认设置正确
DrawType - 检查纹理路径是否存在
- 确保资源包已在清单中注册
Block Breaking Instantly
方块被瞬间破坏
- Check property
Material - Verify and
GatherTypesettingsPower - Ensure tool requirements are set
- 检查属性设置
Material - 验证和
GatherType配置Power - 确保工具要求已正确设置
查看获取材质属性详情。
查看获取高级状态管理指南。
references/block-materials.mdreferences/block-states.mdPhysics Not Working
—
- Verify configuration
BlockFaceSupport - Check matches
RequiredBlockFaceSupport - Ensure is true
IsSolid
See for material properties.
See for advanced state management.
references/block-materials.mdreferences/block-states.md—