Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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;
		}
	}
}

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.

  • 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.