zh_cn:tutorial:blockentityrenderers
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
zh_cn:tutorial:blockentityrenderers [2019/12/19 10:08] – lightcolour | zh_cn:tutorial:blockentityrenderers [2019/12/19 10:13] – lightcolour | ||
---|---|---|---|
Line 69: | Line 69: | ||
} | } | ||
</ | </ | ||
- | We then perform the movement of the jukebox (matrices.translate) and rotation (matrices.multiply). | + | 然后,我们执行自动点唱机的移动(matrices.translate)和旋转(matrices.multiply)。 |
- | There are two parts to the translation: | + | 转换分为两部分:将其转换为高于块中心的0.5、1.25和0.5。 |
- | The second part is the part that changes: the offset in the y value. The offset is the height of the item for any given frame. | + | 第二部分是更改的部分:y值的偏移量。 偏移量是任何给定框架的项目高度。 |
- | We recalculate this each time because we want it to be animating bouncing up and down. We calculate this by: | + | 每次我们都要重新计算,因为我们希望它可以动画上下跳跃。 我们通过以下方式计算: |
- | * Getting the current world time, which changes over time. | + | |
- | * Adding the partial ticks. (The partial ticks is a fractional value representing the amount of time that’s passed between the last full tick and now. We use this because otherwise the animation would be jittery because there are fewer ticks per second than frames per second.) | + | |
- | * Dividing that by 8 to slow the movement down. | + | |
- | * Taking the sine of that to produce a value that ranges between | + | |
- | * Dividing that by 4 to compress the sine wave vertically so the item doesn’t move up and down as much. | + | |
<code java> | <code java> | ||
public void render(DemoBlockEntity blockEntity, | public void render(DemoBlockEntity blockEntity, | ||
Line 90: | Line 90: | ||
} | } | ||
</ | </ | ||
- | Finally, we will get the Minecraft ' | + | 最后,我们将获得Minecraft的'' |
- | We also pass '' | + | 我们还将'' |
- | an item lying on the ground. Try experimenting with this value and see what happens (it's an enum). | + | 躺在地上的物品。 尝试尝试使用此值,看看会发生什么(这是一个枚举)。 |
- | We also need to call '' | + | 在这些GL调用之后,我们还需要调用'' |
<code java> | <code java> | ||
public void render(DemoBlockEntity blockEntity, | public void render(DemoBlockEntity blockEntity, | ||
Line 104: | Line 104: | ||
</ | </ | ||
- | You can try your newly created block entity renderer right now. | + | 您可以立即尝试新创建的块实体渲染器。 |
- | However, if you didn't make your block transparent, | + | 但是,如果您没有使块透明,您会发现有些不对劲-浮动块,点唱机是黑色的! |
- | This is because by default, | + | 这是因为默认情况下,无论您在方块实体中进行渲染的任何内容,都将接收光线,就好像它与块实体//处于同一位置一样。 |
- | So the floating block receives light from //inside// our opaque block, which means it receives no light! | + | 因此,浮动块从不透明的块中接收inside的光,这意味着它没有接收到光! |
- | To fix this, we will tell Minecraft | + | 为了解决这个问题,我们将告诉Minecraft从上方的一个方块方块实体的位置接收光。 |
- | To get the light, we call '' | + | 要获取灯光,我们在块实体上方的位置调用'' |
- | and to use the light we use it in '' | + | 并使用灯光,我们在'' |
<code java> | <code java> | ||
@Override | @Override | ||
Line 124: | Line 124: | ||
</ | </ | ||
- | The jukebox should now have the proper lighting. | + | 点唱机现在应具有适当的照明。 |
zh_cn/tutorial/blockentityrenderers.txt · Last modified: 2023/08/29 10:31 by wjz_p