Java Code Examples for net.minecraftforge.event.entity.living.LivingEvent#LivingJumpEvent

The following examples show how to use net.minecraftforge.event.entity.living.LivingEvent#LivingJumpEvent . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PotionLowGrav.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void jump(LivingEvent.LivingJumpEvent event) {
	EntityLivingBase entity = event.getEntityLiving();
	if (!entity.isPotionActive(this)) return;

	PotionEffect effect = entity.getActivePotionEffect(this);
	if (effect == null) return;

	entity.motionY = effect.getAmplifier() / 3.0;
}
 
Example 2
Source File: CommonHandler.java    From GokiStats with MIT License 5 votes vote down vote up
@SubscribeEvent
public void playerJump(LivingEvent.LivingJumpEvent event) {
    if ((event.getEntityLiving() instanceof EntityPlayer)) {
        EntityPlayer player = (EntityPlayer) event.getEntityLiving();
        if (player.isSprinting()) {
            player.motionY *= 1.0F + Stats.LEAPER_V.getBonus(player);
            player.motionX *= 1.0F + Stats.LEAPER_H.getBonus(player);
            player.motionZ *= 1.0F + Stats.LEAPER_H.getBonus(player);
        }
    }
}
 
Example 3
Source File: ItemElectricBootsTraveller.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onPlayerJump(LivingEvent.LivingJumpEvent event) {
    if (event.entityLiving instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.entityLiving;
        boolean hasArmor = player.getCurrentArmor(0) != null && player.getCurrentArmor(0).getItem() == this;

        if (hasArmor)
            player.motionY += jumpBonus;
    }
}
 
Example 4
Source File: PotionTimeSlow.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onEntityJump(LivingEvent.LivingJumpEvent event) {
	stopEvent(event);
}
 
Example 5
Source File: ItemLegUpgrade.java    From Cyberware with MIT License 4 votes vote down vote up
@SubscribeEvent
public void playerJumps(LivingEvent.LivingJumpEvent event)
{
	EntityLivingBase e = event.getEntityLiving();
	
	ItemStack test = new ItemStack(this, 1, 0);
	if (CyberwareAPI.isCyberwareInstalled(e, test))
	{
		int numLegs = 0;
		if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(CyberwareContent.cyberlimbs, 1, 2)))
		{
			numLegs++;
		}
		if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(CyberwareContent.cyberlimbs, 1, 3)))
		{
			numLegs++;
		}
		ICyberwareUserData ware = CyberwareAPI.getCapability(e);
		if (ware.usePower(test, this.getPowerConsumption(test)))
		{
			if (e.isSneaking())
			{
				Vec3d vector = e.getLook(0.5F);
				double total = Math.abs(vector.zCoord + vector.xCoord);
				double jump = 0;
				if (jump >= 1)
				{
					jump = (jump + 2D) / 4D;
				}

				double y = vector.yCoord < total ? total : vector.yCoord;

				e.motionY += (numLegs * ((jump + 1) * y)) / 3F;
				e.motionZ += (jump + 1) * vector.zCoord * numLegs;
				e.motionX += (jump + 1) * vector.xCoord * numLegs;
			}
			else
			{
				e.motionY += numLegs * (0.2750000059604645D / 2D);
			}
		}
	}
}