zh_cn:tutorial:model_predicate_providers
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
zh_cn:tutorial:model_predicate_providers [2022/06/01 11:51] – external edit 127.0.0.1 | zh_cn:tutorial:model_predicate_providers [2024/08/23 14:05] (current) – 更新翻译 solidblock | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== 模型谓词提供器 ======= | ====== 模型谓词提供器 ======= | ||
- | ==== 介绍 ==== | + | ===== 介绍 |
模型谓词提供器用于给予 '' | 模型谓词提供器用于给予 '' | ||
- | ==== 可行示例 ==== | + | ===== 可行示例 |
- | 在此例中,我们假定有了自定义的弓,叫做 '' | + | 在此例中,我们假定有了自定义的弓,叫做 '' |
在其方法中,使用其物品和一个 '' | 在其方法中,使用其物品和一个 '' | ||
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
+ | @Environment(EnvType.CLIENT) | ||
+ | public class ExampleModClient implements ClientModInitializer { | ||
+ | public static void registerModelPredicateProviders() { | ||
+ | //对于 1.21 之前的版本,将 ' | ||
+ | ModelPredicateProviderRegistry.register(EXAMPLE_BOW, | ||
+ | if (livingEntity == null) { | ||
+ | return 0.0F; | ||
+ | } | ||
+ | return livingEntity.getActiveItem() != itemStack ? 0.0F : (itemStack.getMaxUseTime(livingEntity) - livingEntity.getItemUseTimeLeft()) / 20.0F; | ||
+ | }); | ||
- | ModelPredicateProviderRegistry.register(EXAMPLE_BOW, | + | |
- | if (livingEntity == null) { | + | if (livingEntity == null) { |
- | return 0.0F; | + | return 0.0F; |
- | } | + | } |
- | return livingEntity.getActiveItem() | + | return |
- | }); | + | }); |
+ | } | ||
+ | |||
+ | @Override | ||
+ | public void onInitializeClient() { | ||
+ | // ... | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | </ | ||
- | ModelPredicateProviderRegistry.register(EXAMPLE_BOW, | ||
- | if (livingEntity == null) { | ||
- | return 0.0F; | ||
- | } | ||
- | return livingEntity.isUsingItem() && livingEntity.getActiveItem() == itemStack ? 1.0F : 0.0F; | ||
- | }); | ||
- | </ | ||
- | 可 | ||
如果 '' | 如果 '' | ||
Line 34: | Line 45: | ||
所有的 '' | 所有的 '' | ||
- | 仔细看看 '' | + | 仔细看看 '' |
所有这些都是有用的,但为了让我们的物品改变其模型,我们只需要实现其一部分的特性。 | 所有这些都是有用的,但为了让我们的物品改变其模型,我们只需要实现其一部分的特性。 | ||
- | <code json [enable_line_numbers=" | + | < |
- | " | + | { |
- | { | + | // [...] |
- | " | + | " |
- | " | + | { |
- | }, | + | " |
- | " | + | " |
- | }, | + | }, |
- | { | + | " |
- | " | + | |
- | " | + | |
- | " | + | |
}, | }, | ||
- | | + | { |
- | }, | + | " |
- | | + | " |
- | " | + | " |
- | " | + | }, |
- | " | + | " |
}, | }, | ||
- | " | + | |
- | } | + | " |
- | ] | + | " |
+ | " | ||
+ | }, | ||
+ | | ||
+ | } | ||
+ | ] | ||
+ | } | ||
</ | </ | ||
Minecraft 运作的方式是,在指定的值中,检查模型大于等于的值的最后一个值。所以拉伸值为 '' | Minecraft 运作的方式是,在指定的值中,检查模型大于等于的值的最后一个值。所以拉伸值为 '' |
zh_cn/tutorial/model_predicate_providers.1654084316.txt.gz · Last modified: 2022/06/01 11:51 by 127.0.0.1