noriokun4649 / TorchBowMod

松明を弓で打てるようになるMinecraftのModです。累計DL数:220万回
https://minecraft.curseforge.com/projects/torchbowmod
MIT License
6 stars 5 forks source link

Item animation on Forge 1.16.X #6

Closed Gonzales555 closed 4 years ago

Gonzales555 commented 4 years ago

Hello, i was looking for an idea to realize the item animation on my bow item for 1.16.X. So i get your great mod. I saw you have the same problem. I have the solution for you that i found in the Source. All you need is to register the Properties on the ClientSetupEvent, but see below. Have fun and Greetings from Germany

public static void doClientStuff(FMLClientSetupEvent event) {

ItemModelsProperties.func_239418_a_(ModItems.EXAMPLE_BOW, new ResourceLocation(References.MODID, "pulling"),
        (stack, world, entity) ->{
            if (entity == null) {
                return 0.0F;
            } else {
                return entity != null && entity.isHandActive() && entity.getActiveItemStack() == stack ? 1.0F : 0.0F;
            }
        });

ItemModelsProperties.func_239418_a_(ModItems.EXAMPLE_BOW, new ResourceLocation(References.MODID, "pull"), 
        (stack, world, entity) ->{
      if (entity == null) {
         return 0.0F;
      } else {
         return entity.getActiveItemStack() != stack ? 0.0F : (float)(stack.getUseDuration() - entity.getItemInUseCount()) / 20.0F;
      }
   });

}

noriokun4649 commented 4 years ago

I'm so glad to see that my problems have been solved. Thank you so much from Japan.