Jump to content

getItemInUseDuration() : No replacement in EntityLivingBase ?


Recommended Posts

Posted

Hi again,

 

First of all, here's the code I'm updating right now :

/**
 * Cancel the FOV decrease caused by the decreasing speed due to player penalties.
 * @param event
 */
@SubscribeEvent
public void onFOVUpdate(FOVUpdateEvent event) {
	EntityPlayer player = event.getEntity();
	PenaltyManager penalty = new PenaltyManager(player);//It's just a set of methods that give info about the player, not important
	float f = 1.0F;

	if (player.capabilities.isFlying) {
		f *= 1.1F;
	}

	IAttributeInstance iattributeinstance = player
			.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
	f = (float) ((double) f * (((iattributeinstance.getAttributeValue() / penalty
			.getHealthAndExhaustionModifier())
			/ (double) player.capabilities.getWalkSpeed() + 1.0D) / 2.0D));

	if (player.capabilities.getWalkSpeed() == 0.0F || Float.isNaN(f)
			|| Float.isInfinite(f)) {
		f = 1.0F;
	}

	if (player.isHandActive()
			&& player.getActiveItemStack().getItem() == Items.BOW) {
		int i = player.getItemInUseDuration();// FIXME Does not exist anymore ?
		float f1 = (float) i / 20.0F;

		if (f1 > 1.0F) {
			f1 = 1.0F;
		} else {
			f1 *= f1;
		}

		f *= 1.0F - f1 * 0.15F;
	}
	event.setNewfov(f);
}

 

Since 1.9 I believe, all EntityLivingBase can use items, so I naturally searched through it to find replacements for my methods. I found some, but not for getItemInUseDuration(). I used it to know for how long the bow is being used.

 

If anyone has a workaround or found a replacement, I would be very grateful.

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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