本文整理汇总了Java中net.minecraft.entity.projectile.EntityTippedArrow.setKnockbackStrength方法的典型用法代码示例。如果您正苦于以下问题:Java EntityTippedArrow.setKnockbackStrength方法的具体用法?Java EntityTippedArrow.setKnockbackStrength怎么用?Java EntityTippedArrow.setKnockbackStrength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.projectile.EntityTippedArrow
的用法示例。
在下文中一共展示了EntityTippedArrow.setKnockbackStrength方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: attackEntityWithRangedAttack
import net.minecraft.entity.projectile.EntityTippedArrow; //导入方法依赖的package包/类
public void attackEntityWithRangedAttack(EntityLivingBase target, float arrowSpeed)
{
EntityTippedArrow entitytippedarrow = new EntityTippedArrow(this.world, this);
double d0 = target.posX - this.posX;
double d1 = target.getEntityBoundingBox().minY + (double)(target.height / 3.0F) - entitytippedarrow.posY;
double d2 = target.posZ - this.posZ;
double d3 = (double)MathHelper.sqrt(d0 * d0 + d2 * d2);
entitytippedarrow.setThrowableHeading(d0, d1 + d3 * 0.2, d2, 1.6F, (float)(14 - this.world.getDifficulty().getDifficultyId() * 4));
int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.POWER, this);
int j = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.PUNCH, this);
entitytippedarrow.setDamage((double)(arrowSpeed * 2.0F) + this.rand.nextGaussian() * 0.25D + (double)((float)this.world.getDifficulty().getDifficultyId() * 0.11F));
if (i > 0)
entitytippedarrow.setDamage(entitytippedarrow.getDamage() + (double)i * 0.5D + 0.5D);
if (j > 0)
entitytippedarrow.setKnockbackStrength(j);
boolean flag = this.isBurning() && this.rand.nextBoolean();
flag = flag || EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.FLAME, this) > 0;
if (flag)
entitytippedarrow.setFire(100);
ItemStack itemstack = this.getHeldItem(EnumHand.OFF_HAND);
if (itemstack != null && itemstack.getItem() == Items.TIPPED_ARROW)
entitytippedarrow.setPotionEffect(itemstack);
this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
this.world.spawnEntity(entitytippedarrow);
}
示例2: attackEntityWithRangedAttack
import net.minecraft.entity.projectile.EntityTippedArrow; //导入方法依赖的package包/类
/**
* Attack the specified entity using a ranged attack.
*
* @param distanceFactor How far the target is, normalized and clamped between 0.1 and 1.0
*/
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor)
{
EntityTippedArrow entitytippedarrow = new EntityTippedArrow(this.worldObj, this);
double d0 = target.posX - this.posX;
double d1 = target.getEntityBoundingBox().minY + (double)(target.height / 3.0F) - entitytippedarrow.posY;
double d2 = target.posZ - this.posZ;
double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2);
entitytippedarrow.setThrowableHeading(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float)(14 - this.worldObj.getDifficulty().getDifficultyId() * 4));
int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.POWER, this);
int j = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.PUNCH, this);
DifficultyInstance difficultyinstance = this.worldObj.getDifficultyForLocation(new BlockPos(this));
entitytippedarrow.setDamage((double)(distanceFactor * 2.0F) + this.rand.nextGaussian() * 0.25D + (double)((float)this.worldObj.getDifficulty().getDifficultyId() * 0.11F));
if (i > 0)
{
entitytippedarrow.setDamage(entitytippedarrow.getDamage() + (double)i * 0.5D + 0.5D);
}
if (j > 0)
{
entitytippedarrow.setKnockbackStrength(j);
}
boolean flag = this.isBurning() && difficultyinstance.isHard() && this.rand.nextBoolean() || this.getSkeletonType() == SkeletonType.WITHER;
flag = flag || EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.FLAME, this) > 0;
if (flag)
{
entitytippedarrow.setFire(100);
}
ItemStack itemstack = this.getHeldItem(EnumHand.OFF_HAND);
if (itemstack != null && itemstack.getItem() == Items.TIPPED_ARROW)
{
entitytippedarrow.setPotionEffect(itemstack);
}
else if (this.getSkeletonType() == SkeletonType.STRAY)
{
entitytippedarrow.addEffect(new PotionEffect(MobEffects.SLOWNESS, 600));
}
this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
this.worldObj.spawnEntityInWorld(entitytippedarrow);
}
示例3: onArrowLoose
import net.minecraft.entity.projectile.EntityTippedArrow; //导入方法依赖的package包/类
@SubscribeEvent
public void onArrowLoose(ArrowLooseEvent event) {
EntityPlayer player = event.getEntityPlayer();
if (this.isActive(player)) {
if (!event.hasAmmo()) {
ItemStack stack = event.getBow();
World world = player.getEntityWorld();
EntitySkeleton skeleton = (EntitySkeleton) PossessHandler.get(player).getPossessing();
float velocity = ItemBow.getArrowVelocity(event.getCharge());
if (velocity >= 0.1) {
if (!world.isRemote) {
EntityTippedArrow arrow = new EntityTippedArrow(world, player);
if (skeleton.getSkeletonType() != SkeletonType.STRAY) {
arrow.setPotionEffect(new ItemStack(Items.ARROW));
} else {
arrow.setPotionEffect(new ItemStack(Items.TIPPED_ARROW));
arrow.addEffect(new PotionEffect(MobEffects.SLOWNESS, 600));
}
arrow.setAim(player, player.rotationPitch, player.rotationYaw, 0.0F, velocity * 3.0F, 1.0F);
arrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY;
if (velocity == 1.0F) {
arrow.setIsCritical(true);
}
int power = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack);
if (power > 0) {
arrow.setDamage(arrow.getDamage() + (double) power * 0.5 + 0.5);
}
int punch = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack);
if (punch > 0) {
arrow.setKnockbackStrength(punch);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) {
arrow.setFire(100);
}
stack.damageItem(1, player);
world.spawnEntityInWorld(arrow);
}
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 1.0F, 1.0F / (world.rand.nextFloat() * 0.4F + 1.2F) + velocity * 0.5F);
player.addStat(StatList.getObjectUseStats(stack.getItem()));
}
}
}
}
示例4: attackEntityWithRangedAttack
import net.minecraft.entity.projectile.EntityTippedArrow; //导入方法依赖的package包/类
/**
* Attack the specified entity using a ranged attack.
*/
public void attackEntityWithRangedAttack(EntityLivingBase target, float p_82196_2_)
{
EntityTippedArrow entitytippedarrow = new EntityTippedArrow(this.worldObj, this);
double d0 = target.posX - this.posX;
double d1 = target.getEntityBoundingBox().minY + (double)(target.height / 3.0F) - entitytippedarrow.posY;
double d2 = target.posZ - this.posZ;
double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2);
entitytippedarrow.setThrowableHeading(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float)(14 - this.worldObj.getDifficulty().getDifficultyId() * 4));
int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.POWER, this);
int j = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.PUNCH, this);
DifficultyInstance difficultyinstance = this.worldObj.getDifficultyForLocation(new BlockPos(this));
entitytippedarrow.setDamage((double)(p_82196_2_ * 2.0F) + this.rand.nextGaussian() * 0.25D + (double)((float)this.worldObj.getDifficulty().getDifficultyId() * 0.11F));
if (i > 0)
{
entitytippedarrow.setDamage(entitytippedarrow.getDamage() + (double)i * 0.5D + 0.5D);
}
if (j > 0)
{
entitytippedarrow.setKnockbackStrength(j);
}
boolean flag = this.isBurning() && difficultyinstance.func_190083_c() && this.rand.nextBoolean() || this.func_189771_df() == SkeletonType.WITHER;
flag = flag || EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.FLAME, this) > 0;
if (flag)
{
entitytippedarrow.setFire(100);
}
ItemStack itemstack = this.getHeldItem(EnumHand.OFF_HAND);
if (itemstack != null && itemstack.getItem() == Items.TIPPED_ARROW)
{
entitytippedarrow.setPotionEffect(itemstack);
}
else if (this.func_189771_df() == SkeletonType.STRAY)
{
entitytippedarrow.addEffect(new PotionEffect(MobEffects.SLOWNESS, 600));
}
this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
this.worldObj.spawnEntityInWorld(entitytippedarrow);
}