zh_cn:tutorial:blockappearance
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
zh_cn:tutorial:blockappearance [2019/12/19 05:39] – created lightcolour | zh_cn:tutorial:blockappearance [2024/08/27 04:22] (current) – solidblock | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
- | ===== Making a block transparent | + | // |
- | You may have noticed that even if your block' | + | ===== 使方块透明或半透明 |
- | To fix this, override '' | + | 你可能已经注意到,即使方块的纹理是透明或半透明的,看起来仍是不透明的。如需解决,请将方块的渲染层设为 cutout 或 transparent。 |
- | <code java> | + | |
- | class MyBlock extends Block { | + | 在[[zh_cn:documentation: |
- | @Override | + | <yarncode |
- | public | + | @Environment(EnvType.CLIENT) |
- | | + | public |
+ | public | ||
+ | | ||
+ | BlockRenderLayerMap.INSTANCE.putBlock(TutorialBlocks.MY_BLOCK, | ||
+ | |||
+ | // 如果方块一些部分是半透明的(例如冰、染色玻璃、传送门): | ||
+ | BlockRenderLayerMap.INSTANCE.putBlock(TutorialBlocks.MY_BLOCK, | ||
} | } | ||
- | |||
- | [...] | ||
} | } | ||
+ | </ | ||
- | </code> | + | 您可能还想使方块非不透明。为此,可在方块设置中使用 '' |
- | You probably also want to make your block transparent. To do that, use the '' | + | <yarncode |
- | <code java> | + | public |
- | class MyBlock extends Block { | + | </yarncode> |
- | private | + | |
- | MaterialColor.AIR, // | + | |
- | | + | |
- | false, // isSolid, | + | |
- | true, // blocksMovement, | + | |
- | false,// blocksLight, | + | |
- | true,// !requiresTool, | + | |
- | false, // burnable, | + | |
- | false,// | + | |
- | PistonBehavior.NORMAL// | + | |
- | ); | + | |
- | public MyBlock() { | + | 如果你不像这样把方块标记为非不透明的,则方块后面的面不会渲染,你将会“看穿”整个世界(到虚空或渲染范围之外之类的)。 |
- | super(Settings.of(myMaterial); | + | |
- | } | + | |
- | | + | 确保在 [[documentation: |
+ | <code javascript> | ||
+ | { | ||
+ | [...] | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | ] | ||
+ | }, | ||
+ | | ||
} | } | ||
- | |||
</ | </ | ||
+ | 注意:对于不透明但不完整的方块,你可能需要覆盖 ''< | ||
- | ===== Making a block invisible | + | ===== 使方块不可见 |
- | First we need to make the block appear invisible. | + | 首先,我们需要使该方块看起来不可见。为此,我们在方块类中重写 |
- | To do this we override | + | <yarncode |
- | <code java> | + | |
@Override | @Override | ||
- | public | + | public |
- | return | + | return |
} | } | ||
- | </code> | + | </yarncode> |
- | We then need to make our block unselectable by making its `outlineShape` be non-existent. | + | |
- | So override | + | 然后,我们需要通过使其形状不存在,从而使方块不能被选中。因此,覆盖 |
- | <code java> | + | |
+ | <yarncode | ||
@Override | @Override | ||
- | public | + | public |
- | | + | |
} | } | ||
- | </code> | + | </yarncode> |
zh_cn/tutorial/blockappearance.1576733995.txt.gz · Last modified: 2019/12/19 05:39 by lightcolour