本文整理汇总了Java中net.minecraft.entity.EntityLivingBase.getPositionVector方法的典型用法代码示例。如果您正苦于以下问题:Java EntityLivingBase.getPositionVector方法的具体用法?Java EntityLivingBase.getPositionVector怎么用?Java EntityLivingBase.getPositionVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.EntityLivingBase
的用法示例。
在下文中一共展示了EntityLivingBase.getPositionVector方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onExecutionTick
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onExecutionTick(EntityPlayer player, int progress)
{
player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, SoundCategory.PLAYERS, 1, 2F);
Vec3d look = player.getLookVec().scale(3);
Vec3d pos = player.getPositionVector();
List<EntityLivingBase> targets = Helpers.rayTraceEntities(player.world, pos.addVector(0, player.getEyeHeight(), 0), look, Optional.of(e -> e != player), EntityLivingBase.class);
EntityLivingBase assumedToBeLookedAt = Helpers.getClosest(targets, player);
if (assumedToBeLookedAt != null)
{
assumedToBeLookedAt.hurtResistantTime = 0;
assumedToBeLookedAt.attackEntityFrom(DamageSource.causePlayerDamage(player), Math.max(1, (float) player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue() / 10));
player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, SoundCategory.PLAYERS, 1, 0.1F);
Vec3d targetPos = assumedToBeLookedAt.getPositionVector();
player.world.spawnParticle(EnumParticleTypes.CRIT, targetPos.x + player.world.rand.nextDouble() / 2 - player.world.rand.nextDouble() / 2, targetPos.y + assumedToBeLookedAt.getEyeHeight() + player.world.rand.nextDouble() / 2 - player.world.rand.nextDouble() / 2, targetPos.z + player.world.rand.nextDouble() / 2 - player.world.rand.nextDouble() / 2, 0, 0, 0);
if (!player.world.isRemote)
{
ItemStack is = player.getHeldItemMainhand().isEmpty() ? player.getHeldItemOffhand() : player.getHeldItemMainhand();
is.damageItem(1, player);
}
}
}
示例2: onExecutionStart
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onExecutionStart(EntityPlayer player)
{
if (player.getActiveItemStack().isEmpty())
{
return;
}
Vec3d look = player.getLookVec().scale(5);
Vec3d pos = player.getPositionVector();
List<EntityLivingBase> targets = Helpers.rayTraceEntities(player.world, pos.addVector(0, player.getEyeHeight(), 0), look, Optional.of(e -> e != player), EntityLivingBase.class);
EntityLivingBase assumedToBeLookedAt = Helpers.getClosest(targets, player);
if (assumedToBeLookedAt != null)
{
if (!player.world.isRemote)
{
assumedToBeLookedAt.addPotionEffect(new PotionEffect(ExPPotions.stunned, 40, 0, false, false));
}
player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_KNOCKBACK, SoundCategory.PLAYERS, 1, 0.1F);
Vec3d targetPos = assumedToBeLookedAt.getPositionVector();
assumedToBeLookedAt.knockBack(player, 2, pos.x - targetPos.x, pos.z - targetPos.z);
}
player.getActiveItemStack().damageItem(3, player);
}
示例3: onExecutionStart
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onExecutionStart(EntityPlayer player)
{
ItemStack is = player.getHeldItemMainhand().isEmpty() ? player.getHeldItemOffhand() : player.getHeldItemMainhand();
EnumWeaponWeight weight = EnumWeaponWeight.getWeaponWeight(is);
player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, SoundCategory.PLAYERS, 1, 1F);
Vec3d look = player.getLookVec().scale(5);
Vec3d pos = player.getPositionVector();
List<EntityLivingBase> targets = Helpers.rayTraceEntities(player.world, pos.addVector(0, player.getEyeHeight(), 0), look, Optional.of(e -> e != player), EntityLivingBase.class);
EntityLivingBase assumedToBeLookedAt = Helpers.getClosest(targets, player);
if (assumedToBeLookedAt != null)
{
if (!player.world.isRemote)
{
assumedToBeLookedAt.addPotionEffect(new PotionEffect(ExPPotions.stunned, weight == EnumWeaponWeight.NORMAL ? 20 : 30, 0, false, false));
}
player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_KNOCKBACK, SoundCategory.PLAYERS, 1, 1F);
Vec3d targetPos = assumedToBeLookedAt.getPositionVector();
assumedToBeLookedAt.knockBack(player, 1, pos.x - targetPos.x, pos.z - targetPos.z);
for (int i = 0; i < 50; ++i)
{
player.world.spawnParticle(EnumParticleTypes.CRIT_MAGIC, targetPos.x + player.world.rand.nextDouble() - player.world.rand.nextDouble(), targetPos.z + assumedToBeLookedAt.getEyeHeight() + player.world.rand.nextDouble() - player.world.rand.nextDouble(), targetPos.z + player.world.rand.nextDouble() - player.world.rand.nextDouble(), 0, -0.1, 0);
}
}
}
示例4: onExecutionStart
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onExecutionStart(EntityPlayer player)
{
ItemStack is = player.getHeldItemMainhand().isEmpty() ? player.getHeldItemOffhand() : player.getHeldItemMainhand();
EnumWeaponWeight weight = EnumWeaponWeight.getWeaponWeight(is);
player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, SoundCategory.PLAYERS, 1, 1F);
Vec3d playerLook = player.getLookVec();
Vec3d playerPos = player.getPositionVector();
player.world.spawnParticle(EnumParticleTypes.SWEEP_ATTACK, playerPos.x + playerLook.x, playerPos.y + player.getEyeHeight() * 0.5F, playerPos.z + playerLook.z, 0, 0, 0);
AxisAlignedBB aabb = new AxisAlignedBB(playerPos.addVector(-3, -1, -3), playerPos.addVector(3, 3, 3));
List<EntityLivingBase> lst = player.world.getEntitiesWithinAABB(EntityLivingBase.class, aabb, e -> e != player);
for (EntityLivingBase ent : lst)
{
if (ent instanceof EntityTameable && ((EntityTameable)ent).getOwner() == player)
{
continue;
}
Vec3d ePos = ent.getPositionVector();
Vec3d player2ent = ePos.subtract(playerPos).normalize();
float angle = (float) Math.toDegrees(Math.acos(player2ent.dotProduct(playerLook)));
if (angle > 60)
{
continue;
}
ent.attackEntityFrom(DamageSource.causePlayerDamage(player), (float) (player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue() * 0.85F));
player.world.playSound(player, ent.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, SoundCategory.PLAYERS, 1, 2F);
if (!player.world.isRemote && weight == EnumWeaponWeight.HEAVY && player.world.rand.nextBoolean())
{
ent.addPotionEffect(new PotionEffect(ExPPotions.stunned, 100, 0, false, false));
}
}
}
示例5: onExecutionStart
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onExecutionStart(EntityPlayer player)
{
ItemStack is = player.getHeldItemMainhand().isEmpty() ? player.getHeldItemOffhand() : player.getHeldItemMainhand();
EnumWeaponWeight weight = EnumWeaponWeight.getWeaponWeight(is);
player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, SoundCategory.PLAYERS, 1, 1F);
Vec3d look = player.getLookVec().scale(6);
Vec3d pos = player.getPositionVector();
List<EntityLivingBase> targets = Helpers.rayTraceEntities(player.world, pos.addVector(0, player.getEyeHeight(), 0), look, Optional.of(e -> e != player), EntityLivingBase.class);
for (EntityLivingBase target : targets)
{
Vec3d targetPos = target.getPositionVector();
target.knockBack(player, 3, pos.x - targetPos.x, pos.z - targetPos.z);
double distance = Math.max(0.3, targetPos.distanceTo(pos));
target.attackEntityFrom(DamageSource.causePlayerDamage(player), (float) (player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue() * (1 - (distance / 6))));
player.world.playSound(player, target.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_KNOCKBACK, SoundCategory.PLAYERS, 1, 2F);
if (!player.world.isRemote && weight == EnumWeaponWeight.HEAVY && player.world.rand.nextDouble() <= 0.25)
{
target.addPotionEffect(new PotionEffect(ExPPotions.stunned, 100, 0, false, false));
}
}
player.motionX += look.x / 5;
player.motionZ += look.z / 5;
for (int i = 0; i < 50; ++i)
{
double randomMagnitude = player.world.rand.nextDouble();
Vec3d at = new Vec3d(pos.x + look.x * randomMagnitude, pos.y + player.getEyeHeight() - 0.25 + look.y * randomMagnitude, pos.z + look.z * randomMagnitude);
player.world.spawnParticle(EnumParticleTypes.CRIT, at.x, at.y, at.z, 0, 0, 0);
}
}
示例6: onExecutionStart
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onExecutionStart(EntityPlayer player)
{
ItemStack is = player.getHeldItemMainhand().isEmpty() ? player.getHeldItemOffhand() : player.getHeldItemMainhand();
player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, SoundCategory.PLAYERS, 1, 1F);
Vec3d look = player.getLookVec().scale(5);
Vec3d pos = player.getPositionVector();
List<EntityLivingBase> targets = Helpers.rayTraceEntities(player.world, pos.addVector(0, player.getEyeHeight(), 0), look, Optional.of(e -> e != player), EntityLivingBase.class);
EntityLivingBase assumedToBeLookedAt = Helpers.getClosest(targets, player);
if (assumedToBeLookedAt != null)
{
if (!player.world.isRemote)
{
is.damageItem(1, player);
}
assumedToBeLookedAt.attackEntityFrom(DamageSource.causePlayerDamage(player), (float) player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue());
player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, SoundCategory.PLAYERS, 1, 0.1F);
Vec3d targetPos = assumedToBeLookedAt.getPositionVector();
player.world.spawnParticle(EnumParticleTypes.SWEEP_ATTACK, targetPos.x, targetPos.y + assumedToBeLookedAt.getEyeHeight(), targetPos.z, 0, 0, 0);
float chance = (1 - assumedToBeLookedAt.getHealth() / assumedToBeLookedAt.getMaxHealth());
if (!player.world.isRemote && player.world.rand.nextFloat() < chance / 10)
{
assumedToBeLookedAt.hurtResistantTime = assumedToBeLookedAt.hurtTime = 0;
assumedToBeLookedAt.attackEntityFrom(DamageSource.causePlayerDamage(player), Float.MAX_VALUE);
}
}
}
示例7: onExecutionTick
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onExecutionTick(EntityPlayer player, int progress)
{
player.rotationYaw += 40;
Vec3d playerLook = player.getLookVec();
Vec3d playerPos = player.getPositionVector();
player.world.spawnParticle(EnumParticleTypes.SWEEP_ATTACK, playerPos.x + playerLook.x, playerPos.y + player.getEyeHeight() * 0.5F, playerPos.z + playerLook.z, 0, 0, 0);
AxisAlignedBB aabb = new AxisAlignedBB(playerPos.addVector(-3, -1, -3), playerPos.addVector(3, 3, 3));
List<EntityLivingBase> lst = player.world.getEntitiesWithinAABB(EntityLivingBase.class, aabb, e -> e != player);
for (EntityLivingBase ent : lst)
{
if (ent instanceof EntityTameable && ((EntityTameable)ent).getOwner() == player)
{
continue;
}
Vec3d ePos = ent.getPositionVector();
Vec3d player2ent = ePos.subtract(playerPos).normalize();
float angle = (float) Math.toDegrees(Math.acos(player2ent.dotProduct(playerLook)));
if (angle > 40)
{
continue;
}
player.world.playSound(player, ent.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, SoundCategory.PLAYERS, 0.2F, 1.5F);
ent.attackEntityFrom(DamageSource.causePlayerDamage(player), (float) (player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue() * 0.75F));
}
}
示例8: onReceived
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onReceived(MessagePacketRingUpdate message, EntityPlayer player) {
if(message.ringType < 2)
{
ArrayList<Item> ringTypeItem = new ArrayList<Item>();
ringTypeItem.add(HarshenItems.TELERING);
ringTypeItem.add(HarshenItems.MINERING);
if(HarshenUtils.containsItem(player,ringTypeItem.get(message.ringType)))
{
World world = player.world;
Vec3d vec = new Vec3d(player.posX + (player.getLookVec().x * 4f),
player.posY + (player.getLookVec().y * 4f), player.posZ + (player.getLookVec().z* 4f));
BlockPos blockpos = message.ringType == 0? HarshenUtils.getTopBlock(world, vec) : HarshenUtils.getBottomBlockAir(world, vec);
Vec3d vecPos = new Vec3d(blockpos).addVector(0.5, 0, 0.5);
if(blockpos.getY() != -1 && player.getFoodStats().getFoodLevel() > 0)
{
((EntityPlayerMP)player).velocityChanged = true;
((EntityPlayerMP)player).fallDistance = 0;
HarshenNetwork.sendToPlayer(player, new MessagePacketPlayerTeleportEffects(vecPos));
((EntityPlayerMP)player).setPositionAndUpdate(vecPos.x, vecPos.y, vecPos.z);
world.playSound((EntityPlayer)null, player.posX, player.posY, player.posZ, SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);
player.playSound(SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, 1.0F, 1.0F);
player.addExhaustion(0.5F);
HarshenUtils.damageFirstOccuringItem(player, ringTypeItem.get(message.ringType));
}
}
}
else if(message.ringType == 2 && HarshenUtils.containsItem(player, HarshenItems.COMBAT_PENDANT))
{
EntityLivingBase entityToAttack = HarshenUtils.getFirstEntityInDirection(player.world, player.getPositionVector(), player.getLookVec().normalize(), 5, EntityLivingBase.class);
if(entityToAttack == null)
{
List<EntityLivingBase> list = player.world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(player.posX - 4d, player.posY - 4d, player.posZ - 4d, player.posX + 4d, player.posY + 4d, player.posZ + 4d));
if(!list.isEmpty())
entityToAttack = list.get(0);
}
if(!player.equals(entityToAttack) && (entityToAttack != null || (entityToAttack instanceof EntityPlayerMP && player.canAttackPlayer((EntityPlayerMP)entityToAttack)
&& HarshenUtils.toArray(GameType.SURVIVAL, GameType.ADVENTURE).contains(((EntityPlayerMP)entityToAttack).interactionManager.getGameType()))))
{
Vec3d position = entityToAttack.getPositionVector();
Vec3d playerPosNoY = position.addVector(movePos(), 0, movePos());
Vec3d pos = new Vec3d(playerPosNoY.x, HarshenUtils.getTopBlock(player.world, new BlockPos(playerPosNoY)).getY(), playerPosNoY.z);
double d0 = position.x - pos.x;
double d1 = position.y - (pos.y + (double)player.getEyeHeight() - entityToAttack.height / 2f + 0.1f);
double d2 = position.z - pos.z;
double d3 = (double)MathHelper.sqrt(d0 * d0 + d2 * d2);
float yaw = (float)(MathHelper.atan2(d2, d0) * (180D / Math.PI)) - 90.0F;
float pitch = (float)(-(MathHelper.atan2(d1, d3) * (180D / Math.PI)));
((EntityPlayerMP)player).velocityChanged = true;
((EntityPlayerMP)player).connection.setPlayerLocation(pos.x, pos.y, pos.z, yaw, pitch);
}
}
}