zh_cn:tutorial:blockstate
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Last revisionBoth sides next revision | ||
zh_cn:tutorial:blockstate [2022/12/16 01:43] – solidblock | zh_cn:tutorial:blockstate [2022/12/16 01:52] – [赋予方块状态] solidblock | ||
---|---|---|---|
Line 4: | Line 4: | ||
这就是 '' | 这就是 '' | ||
| | ||
- | 首先,我们定义方块的布尔值属性——是否充能(小心不要导入错误的BooleanProperty!): | + | 首先,我们定义方块的布尔值属性——是否充能(小心不要导入错误的 |
+ | |||
+ | 事实上你也可以使用原版已有的属性,可以在 '' | ||
<code java> | <code java> | ||
public class ChargeableBlock extends Block { | public class ChargeableBlock extends Block { | ||
public static final BooleanProperty CHARGED = BooleanProperty.of(" | public static final BooleanProperty CHARGED = BooleanProperty.of(" | ||
- | // 方块实例。可以放在任何地方。 | + | // 方块实例。可以放在任何地方。确保这个类已经初始化。 |
- | public static final ChargeableBlock CHARGEABLE_BLOCK = Registry.register( | + | public static final ChargeableBlock CHARGEABLE_BLOCK = new ChargeableBlock(FabricBlockSettings.copyOf(Blocks.STONE)); |
- | Registries.BLOCK, | + | } |
- | | + | </ |
- | new ChargeableBlock( | + | <code java> |
+ | public class ExampleMod implements ModInitializer { | ||
+ | @Override | ||
+ | public void onInitialize() { | ||
+ | | ||
+ | | ||
+ | } | ||
} | } | ||
</ | </ |
zh_cn/tutorial/blockstate.txt · Last modified: 2023/11/18 08:13 by solidblock