Java Code Examples for net.minecraft.entity.player.EntityPlayer#jump()

The following examples show how to use net.minecraft.entity.player.EntityPlayer#jump() . 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: GTEventOnLivingFall.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void onEntityFall(LivingFallEvent event) {
	if (event.getEntityLiving() instanceof EntityPlayer) {
		EntityPlayer player = (EntityPlayer) event.getEntityLiving();
		for (ItemStack armor : player.getEquipmentAndArmor()) {
			if (armor.getItem() instanceof GTItemSpringBoots) {
				float amount = event.getDistance();
				if (amount < 20) {
					event.setResult(Event.Result.DENY);
					event.setCanceled(true);
				} else {
					armor.damageItem(Math.round(amount), player);
					event.setDamageMultiplier(event.getDamageMultiplier() * 0.5F);
					player.jump();
					event.getEntity().playSound(GTSounds.SPRING, 1.0F, 1.0F
							+ player.getEntityWorld().rand.nextFloat());
				}
			}
		}
	}
}
 
Example 2
Source File: GTItemSpringBoots.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
	Potion jump = MobEffects.JUMP_BOOST;
	if (!player.isPotionActive(jump)) {
		player.addPotionEffect(new PotionEffect(jump, 10, 2, false, false));
	}
	if (player.onGround && player.isSprinting()) {
		player.jump();
		player.playSound(GTSounds.SPRING, 1.0F, 1.0F + world.rand.nextFloat());
		if (world.rand.nextInt(2) == 0) {
			stack.damageItem(1, player);
		}
	}
}