User Tools

Site Tools


zh_cn:tutorial:blockappearance

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
zh_cn:tutorial:blockappearance [2022/12/16 02:19] – [使方块透明] solidblockzh_cn:tutorial:blockappearance [2022/12/16 02:20] – [使方块不可见] solidblock
Line 22: Line 22:
  
 ===== 使方块不可见 ===== ===== 使方块不可见 =====
-首先,我们需要使该方块看起来不可见。 +首先,我们需要使该方块看起来不可见。为此,我们在方块类中重写 ''<yarn method_9604>'' 并返回 ''<yarn class_2464>.<yarn field_11455>'': 
-为此,我们在方块类中重写''getRenderType''并返回''BlockRenderType.INVISIBLE'': +<yarncode java>
-<code java>+
     @Override     @Override
-    public BlockRenderType getRenderType(BlockState blockState) { +    public class_2464 method_9604(class_2680 state) { 
-        return BlockRenderType.INVISIBLE;+        return class_2464.field_11455;
     }     }
-</code+</yarncode> 
-然后,我们需要通过使其''outlineShape''不存在来使我们的方块不能被选中。 + 
-因此,覆盖''getOutlineShape''并返回一个空的''VoxelShape'': +然后,我们需要通过使其 ''outlineShape'' 不存在来使我们的方块不能被选中。因此,覆盖 ''<yarn method_9530>'' 并返回一个空的 ''<yarn class_265>'' 
-<code java>+ 
 +<yarncode java>
     @Override     @Override
-    public VoxelShape getOutlineShape(BlockState blockStateBlockView blockView, BlockPos blockPosEntityContext entityContext) { +    public class_265 method_9530(class_2680 stateclass_1922 blockView, class_2338 posclass_3726 context) { 
-       return VoxelShapes.empty();+       return class_259.method_1073();
     }     }
-</code>+</yarncode>
zh_cn/tutorial/blockappearance.txt · Last modified: 2023/11/18 08:40 by solidblock