当前位置: 首页>>代码示例>>Java>>正文


Java EntityPlayer.getPositionVector方法代码示例

本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.getPositionVector方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.getPositionVector方法的具体用法?Java EntityPlayer.getPositionVector怎么用?Java EntityPlayer.getPositionVector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.player.EntityPlayer的用法示例。


在下文中一共展示了EntityPlayer.getPositionVector方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onExecutionTick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的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);
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:23,代码来源:Stab.java

示例2: onExecutionStart

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的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);
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:27,代码来源:ShieldSlam.java

示例3: onExecutionStart

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的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);
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:27,代码来源:DownStrike.java

示例4: findSuitablePositionNearPlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static BlockPos findSuitablePositionNearPlayer(@Nonnull EntityMeeCreeps meeCreep, @Nonnull EntityPlayer player, double distance) {
    Vec3d playerPos = player.getPositionVector();
    Vec3d entityPos = meeCreep.getPositionVector();

    if (entityPos.distanceTo(playerPos) < (distance * 1.2)) {
        // No need to move
        return meeCreep.getPosition();
    }

    double dx = playerPos.x - entityPos.x;
    double dy = playerPos.x - entityPos.x;
    double dz = playerPos.x - entityPos.x;
    Vec3d v = new Vec3d(-dx, -dy, -dz);
    v = v.normalize();
    Vec3d pos = new Vec3d(playerPos.x + v.x * distance, playerPos.y + v.y * distance, playerPos.z + v.z * distance);
    // First find a good spot at the specific location
    World world = player.getEntityWorld();

    float width = meeCreep.width;
    float eyeHeight = meeCreep.getEyeHeight();

    // First try on the prefered spot
    BlockPos p = scanSuitablePos(new BlockPos(pos.x, pos.y + .5, pos.z), world, width, eyeHeight);
    if (p != null) return p;
    // No good spot to stand on found. Try other spots around the prefered spot
    p = scanAround(pos, world, width, eyeHeight);
    if (p != null) return p;
    // No good spot to stand on found. Try other spots around the player
    p = scanAround(playerPos, world, width, eyeHeight);
    if (p != null) return p;

    // If all else fails we go stand where the player is
    return player.getPosition();
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:35,代码来源:WorkerHelper.java

示例5: onExecutionStart

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的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));
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:35,代码来源:Slash.java

示例6: onExecutionStart

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的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);
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:32,代码来源:PiercingDash.java

示例7: onExecutionStart

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的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);
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:29,代码来源:Behead.java

示例8: onExecutionTick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的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));
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:29,代码来源:Spin.java

示例9: projectileTrajectoryHitsEntity

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Will simulate a shot made from an angle to see if it hits our target
 */
public static boolean projectileTrajectoryHitsEntity(Entity target, Vec3d shootPos, Vec3d targetPos, ProjectileTraceResult result) {
    // gg fps
    EntityPlayer localPlayer = MC.player;
    Vec3d selfPos = localPlayer.getPositionVector();
    ItemStack heldItem = localPlayer.getHeldItemMainhand();
    // work backwards
    // this is actually just a coincidence that the
    // sequence and min value are same
    // im just abusing it so that I can get it to work with other projectile items
    double min = getMinForce(heldItem);
    double max = getMaxForce(heldItem);
    for(double force = max; force >= min; force -= min) {
        Angle angle = getShootAngle(heldItem, shootPos, targetPos, force);

        if(angle == null)
            continue;

        Angle initAngle = new Angle(-angle.getPitch(), angle.getYaw() + 90.D, 0.D);

        double fixX = Math.cos(initAngle.getYaw(true) - Math.PI / 2.0) * 0.16;
        double fixY = ProjectileUtils.PROJECTILE_SHOOTPOS_OFFSET;
        double fixZ = Math.sin(initAngle.getYaw(true) - Math.PI / 2.0) * 0.16;
        Vec3d initPos = new Vec3d(-fixX, localPlayer.getEyeHeight() - fixY, -fixZ);

        Vec3d acceleration = ProjectileUtils.getGravity(heldItem);
        Vec3d airResistance = ProjectileUtils.getAirResistance(heldItem);
        // convert polar coords to cartesian coords
        Vec3d velocity = initAngle.getCartesianCoords().normalize().scale(force);

        Vec3d startPos = initPos;
        Vec3d endPos = startPos;
        for (int i = 0; i < 100; i++) {
            // add velocity
            startPos = startPos.add(velocity);
            // add air resistance
            velocity = VectorUtils.multiplyBy(velocity, airResistance);
            // add gravity (acceleration)
            velocity = velocity.add(acceleration);

            Vec3d wrlStart = selfPos.add(startPos), wrlEnd = selfPos.add(endPos);

            RayTraceResult tr = getWorld().rayTraceBlocks(wrlStart, wrlEnd);
            // if we have hit a block
            if (tr != null &&
                    !getWorld().getBlockState(tr.getBlockPos()).getBlock().isPassable(getWorld(), tr.getBlockPos())) {
                break;
            }

            // if we have hit our target
            tr = target.getEntityBoundingBox().calculateIntercept(wrlStart, wrlEnd);
            if (tr != null) {
                if(result != null) {
                    result.maxForce = force;
                    result.shootAngle = angle;
                }
                return true;
            }
            endPos = startPos;
        }
    }
    return false;
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:66,代码来源:ProjectileUtils.java


注:本文中的net.minecraft.entity.player.EntityPlayer.getPositionVector方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。