Add bowModelPredicateProvider

This commit is contained in:
RyanTLG
2022-04-30 13:46:37 +02:00
parent c97fad41f6
commit e6d5c373f9
5 changed files with 43 additions and 3 deletions

View File

@@ -0,0 +1,31 @@
package net.arcmods.ryantlg.utils;
import net.arcmods.ryantlg.items.bows.strongBow;
import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry;
import net.minecraft.item.Item;
import net.minecraft.util.Identifier;
public class bowModelPredicateProvider {
public static void registerBowModels() {
registerBow(strongBow.STRONG_BOW);
}
private static void registerBow(Item bow) {
FabricModelPredicateProviderRegistry.register(bow, new Identifier("pull"),
(stack, world, entity, seed) -> {
if (entity == null) {
return 0.0f;
}
if (entity.getActiveItem() != stack) {
return 0.0f;
}
return (float)(stack.getMaxUseTime() - entity.getItemUseTimeLeft()) / 20.0f;
});
FabricModelPredicateProviderRegistry.register(bow, new Identifier("pulling"),
(stack, world, entity, seed) -> entity != null && entity.isUsingItem()
&& entity.getActiveItem() == stack ? 1.0f : 0.0f);
}
}