Posted December 25, 20213 yr I have an item that activates while holding right-click button. I want it to show my own third-person player animation while it is active. Since vanilla animations are specified in UseAction class, which is enum, i can't create my own instance of it. What i did is subscribed to RenderPlayerEvent.Pre and changed player position values there, but it didn't work at all. Any ideas how i can implement this? My code is below: @EventBusSubscriber(modid=ElderNorseGods.MOD_ID, bus=EventBusSubscriber.Bus.FORGE, value=Dist.CLIENT) public class HealingStaffItem extends Item implements IVanishable { public static final String ID="healing_staff"; public HealingStaffItem(Rarity rarity, int durability) { super(new Item.Properties().rarity(rarity).durability(durability).tab(ENGTabs.COMBAT)); } @Override public int getUseDuration(ItemStack itemStack) { return 72000; } @Override public UseAction getUseAnimation(ItemStack itemStack) { return UseAction.BOW; } @Override public boolean isValidRepairItem(ItemStack itemStack, ItemStack repairStack) { return false; } @Override public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) { player.startUsingItem(hand); return ActionResult.consume(player.getItemInHand(hand)); } @SubscribeEvent public static void renderArmsPoses(RenderPlayerEvent.Pre event) { if(event.getPlayer().getUseItem().getItem()==ENGItems.HEALING_STAFF.get()) { PlayerModel<AbstractClientPlayerEntity> model=event.getRenderer().getModel(); model.rightArm.xRot=model.rightArm.xRot*0.5F-(float)Math.PI; model.rightArm.yRot=0.0F; model.leftArm.xRot=model.leftArm.xRot*0.5F-(float)Math.PI; model.leftArm.yRot=0.0F; } } }
December 26, 20213 yr You're updating the model itself, which only controls how the base model looks like. The rendering itself is done by the renderer, so changes should be done at this level to actually affect the rendering result.
December 26, 20213 yr Author 10 hours ago, LocusAzzurro said: You're updating the model itself, which only controls how the base model looks like. The rendering itself is done by the renderer, so changes should be done at this level to actually affect the rendering result. What method should i use in that case? I tried PlayerRenderer#render, but it throws an "net.minecraft.crash.ReportedException: Rendering entity in world". How do i fix it?
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.