zh_cn:tutorial:model_predicate_providers
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| zh_cn:tutorial:model_predicate_providers [2021/07/25 01:57] – [介绍] solidblock | zh_cn:tutorial:model_predicate_providers [2025/04/02 04:19] (current) – solidblock | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== 模型谓词提供器 ======= | + | ====== 模型谓词提供器(1.21.4 之前) |
| - | ==== 介绍 ==== | + | :!: 模型谓词提供器从 1.21.4 开始就移除了。从 1.21.4 开始,请使用物品模型映射。详见 [[https:// |
| - | 模型谓词提供器用于给予'' | + | ===== 介绍 ===== |
| - | ==== 可行示例 ==== | + | 模型谓词提供器用于给予 '' |
| - | 在此例中,我们假定有了自定义的弓,叫做'' | + | ===== 可行示例 ===== |
| - | 在其方法中,使用其物品和一个'' | + | 在此例中,我们假定有了自定义的弓,叫做 '' |
| + | |||
| + | 在其方法中,使用其物品和一个 '' | ||
| <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; | ||
| + | }); | ||
| - | FabricModelPredicateProviderRegistry.register(EXAMPLE_BOW, | + | ModelPredicateProviderRegistry.register(EXAMPLE_BOW, |
| - | if (livingEntity == null) { | + | if (livingEntity == null) { |
| - | return 0.0F; | + | return 0.0F; |
| - | } | + | } |
| - | return livingEntity.getActiveItem() | + | return |
| - | }); | + | }); |
| - | + | } | |
| - | FabricModelPredicateProviderRegistry.register(EXAMPLE_BOW, | + | |
| - | if (livingEntity == null) { | + | |
| - | return 0.0F; | + | public void onInitializeClient() { |
| - | } | + | // |
| - | return livingEntity.isUsingItem() && livingEntity.getActiveItem() == itemStack ? 1.0F : 0.0F; | + | registerModelPredicateProviders(); |
| - | }); | + | } |
| + | } | ||
| </ | </ | ||
| - | '' | + | 如果 |
| - | 所有的'' | + | '' |
| - | 仔细看看'' | + | 所有的 '' |
| + | |||
| + | 仔细看看 '' | ||
| 所有这些都是有用的,但为了让我们的物品改变其模型,我们只需要实现其一部分的特性。 | 所有这些都是有用的,但为了让我们的物品改变其模型,我们只需要实现其一部分的特性。 | ||
| - | <code json [enable_line_numbers=" | + | < |
| - | " | + | { |
| - | { | + | // [...] |
| - | " | + | " |
| - | " | + | { |
| - | }, | + | " |
| - | " | + | " |
| - | }, | + | }, |
| - | { | + | " |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| }, | }, | ||
| - | | + | { |
| - | }, | + | " |
| - | | + | " |
| - | " | + | " |
| - | " | + | }, |
| - | " | + | " |
| }, | }, | ||
| - | " | + | |
| - | } | + | " |
| - | ] | + | " |
| + | " | ||
| + | }, | ||
| + | | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| </ | </ | ||
| - | Minecraft运作的方式是,在指定的值中,检查模型大于等于的值的最后一个值。所以拉伸值为'' | + | Minecraft 运作的方式是,在指定的值中,检查模型大于等于的值的最后一个值。所以拉伸值为 '' |
zh_cn/tutorial/model_predicate_providers.1627178236.txt.gz · Last modified: 2021/07/25 01:57 by solidblock