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


Java EntityPlayer.getLookVec方法代码示例

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


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

示例1: onCast

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onCast(World world, EntityPlayer player, ItemStack stack) {

	if (consumePower(player)) {
		if (world.isRemote) {
			Vec3d lookVector = player.getLookVec();
			if (!player.isSneaking()) {
				player.setVelocity(lookVector.xCoord * 1.2, lookVector.yCoord * 1.2, lookVector.zCoord * 1.2);
			} else {
				player.setVelocity(lookVector.xCoord * -1.2, lookVector.yCoord * -1.2, lookVector.zCoord * -1.2);
			}
			player.fallDistance = 0;
			player.velocityChanged = true;
		} else if (!world.isRemote) {
			player.fallDistance = 0;
			if (world instanceof WorldServer) {
				((WorldServer) world).spawnParticle(EnumParticleTypes.CLOUD, true, player.posX, player.posY,
						player.posZ, world.rand.nextInt(12) + 8, 0.5, 0.5, 0.5, 0.5);
			}
		}

	}

}
 
开发者ID:the-realest-stu,项目名称:Infernum,代码行数:25,代码来源:SpellGhastlyPulse.java

示例2: onCastTick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onCastTick(World world, EntityPlayer player, ItemStack stack) {
	if (!world.isRemote) {
		
		if (player.getItemInUseCount() % 2 == 0 && consumePower(player)) {
			Vec3d lookVec = player.getLookVec();
			double x = player.posX + lookVec.xCoord;
			double y = player.posY + lookVec.yCoord + player.getEyeHeight();
			double z = player.posZ + lookVec.zCoord;
			EntityFireBreath fireBreath = new EntityFireBreath(world, player, 5);
			fireBreath.setPosition(x, y, z);
			fireBreath.setAim(player, player.rotationPitch, player.rotationYaw, 1F, 0.1F);
			world.spawnEntity(fireBreath);
		}
	}
}
 
开发者ID:the-realest-stu,项目名称:Infernum,代码行数:17,代码来源:SpellFireBreath.java

示例3: entityHurtEvent

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SubscribeEvent
public void entityHurtEvent(LivingHurtEvent event) {
	if (!EtFuturum.enableDmgIndicator)
		return;
	int amount = MathHelper.floor_float(Math.min(event.entityLiving.getHealth(), event.ammount) / 2F);
	if (amount <= 0)
		return;

	// If the attacker is a player spawn the hearts aligned and facing it
	if (event.source instanceof EntityDamageSource) {
		EntityDamageSource src = (EntityDamageSource) event.source;
		Entity attacker = src.getSourceOfDamage();
		if (attacker instanceof EntityPlayer && !(attacker instanceof FakePlayer)) {
			EntityPlayer player = (EntityPlayer) attacker;
			Vec3 look = player.getLookVec();
			look.rotateAroundY((float) Math.PI / 2);
			for (int i = 0; i < amount; i++) {
				double x = event.entityLiving.posX - amount * 0.35 * look.xCoord / 2 + i * 0.35 * look.xCoord;
				double y = event.entityLiving.posY + 1.5 + event.entityLiving.worldObj.rand.nextGaussian() * 0.05;
				double z = event.entityLiving.posZ - amount * 0.35 * look.zCoord / 2 + i * 0.35 * look.zCoord;
				EtFuturum.networkWrapper.sendToAllAround(new BlackHeartParticlesMessage(x, y, z), new TargetPoint(player.worldObj.provider.dimensionId, x, y, z, 64));
			}
		}
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:26,代码来源:ServerEventHandler.java

示例4: onReceived

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onReceived(MessagePacketSummonFirework message, EntityPlayer player) {	
	Vec3d vec3d = player.getLookVec();
       player.motionX += vec3d.x * 0.1D + (vec3d.x * 2.5D - player.motionX) * 0.5D;
       player.motionY += vec3d.y * 0.1D + (vec3d.y * 2.5D - player.motionY) * 0.5D;
       player.motionZ += vec3d.z * 0.1D + (vec3d.z * 2.5D - player.motionZ) * 0.5D;
	HarshenUtils.damageFirstOccuringItem(player, HarshenItems.ELYTRA_PENDANT);
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:9,代码来源:MessagePacketSummonFirework.java

示例5: onCastTick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onCastTick(World world, EntityPlayer player, ItemStack stack) {
	if (!world.isRemote && world instanceof WorldServer) {
		Vec3d lookVec = player.getLookVec();
		double x = player.posX + lookVec.xCoord;
		double y = player.posY + lookVec.yCoord + player.eyeHeight;
		double z = player.posZ + lookVec.zCoord;
		((WorldServer) world).spawnParticle(EnumParticleTypes.SMOKE_NORMAL, true, x, y, z, world.rand.nextInt(2), 0.01, 0.01, 0.01, 0);
	}
}
 
开发者ID:the-realest-stu,项目名称:Infernum,代码行数:11,代码来源:SpellWitheringBolt.java

示例6: onCastFinish

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onCastFinish(World world, EntityPlayer player, ItemStack stack) {
	if (!world.isRemote && consumePower(player)) {
		Vec3d lookVec = player.getLookVec();
		double x = player.posX + lookVec.xCoord;
		double y = player.posY + lookVec.yCoord + player.eyeHeight;
		double z = player.posZ + lookVec.zCoord;
		EntityWitheringBolt bolt = new EntityWitheringBolt(world, player, 1, x, y, z);
		bolt.setAim(player, player.rotationPitch, player.rotationYaw, 0.75F, 0.08F);
		world.spawnEntity(bolt);
	}
}
 
开发者ID:the-realest-stu,项目名称:Infernum,代码行数:13,代码来源:SpellWitheringBolt.java

示例7: getFluidCostBlink

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static int getFluidCostBlink(World world, EntityPlayer player, int distance) {

        Vec3d eye = new Vec3d(player.posX, player.posY + player.getEyeHeight(), + player.posZ);
        Vec3d look = player.getLookVec();
        Vec3d end = eye.add(new Vec3d(look.x * distance, look.y * distance, look.z * distance));

        RayTraceResult res = world.rayTraceBlocks(eye, end, false, true, false);
        if(res == null) {
           return 0;
        }
        else {
            return ItemTransporter.teleportFluidBlinkCost;
        }
    }
 
开发者ID:ImbaKnugel,项目名称:Whoosh,代码行数:15,代码来源:TeleportUtil.java

示例8: performBlink

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static boolean performBlink(World world, EntityPlayer player, int distance) {

        Vec3d eye = new Vec3d(player.posX, player.posY + player.getEyeHeight() - 0.08, + player.posZ);
        Vec3d look = player.getLookVec();
        Vec3d end = eye.add(new Vec3d(look.x * distance, look.y * distance, look.z * distance));

        RayTraceResult res = world.rayTraceBlocks(eye, end, false, true, false);
        if(res == null) {
            movePlayer(end, player, true);
            return true;
        }
        else {

            List<BlockPos> empty = getBlinkPositions(res, eye, end, distance, world);
            if(empty.size() == 0) {
                return false;
            }

            BlockPos target = empty.get(empty.size() / 2);

            if(target != null) {
                movePlayer(new Vec3d(target.getX() + 0.5, target.getY(), target.getZ() + 0.5), player, false);
                return true;
            }
        }

        return false;
    }
 
开发者ID:ImbaKnugel,项目名称:Whoosh,代码行数:29,代码来源:TeleportUtil.java

示例9: movePlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private static void movePlayer(Vec3d destination, EntityPlayer player, boolean keepMomentum) {

        player.setPositionAndUpdate(destination.x, destination.y, destination.z);

        if(keepMomentum) {
            Vec3d velocity = player.getLookVec();
            velocity = velocity.scale(0.25);
            SPacketEntityVelocity p = new SPacketEntityVelocity(player.getEntityId(), velocity.x, velocity.y, velocity.z);
            ((EntityPlayerMP) player).connection.sendPacket(p);
        }
    }
 
开发者ID:ImbaKnugel,项目名称:Whoosh,代码行数:12,代码来源:TeleportUtil.java

示例10: 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

示例11: 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

示例12: onPlayerStoppedUsing

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entity, int count)
{	
	if (entity instanceof EntityPlayer)
	{
		EntityPlayer player = (EntityPlayer) entity;
		Stats statsCap = (Stats) player.getCapability(CapabilityPlayerStats.STATS, null);	
		PlayerInformation info = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
		NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
		
		if (info != null)
		{
			// check to see if we have held it long enough
			double attackSpeed = nbt.getDouble("AttackSpeed") + (PlayerStatHelper.ATTACK_SPEED_MULTIPLIER * (info.getTotalAgility()));
			
			if (count > (this.getMaxItemUseDuration(stack) - ((1 / attackSpeed) * 20))) 
			{
				return;
			}
			
			// fire projectile because check passed
			if (statsCap != null)
			{
				world.playSound(player, player.getPosition(), SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 1.0F, 1.0F);
				
				if (!world.isRemote)
				{
					// spawn entity and set position to specified direction
					Vec3d look = player.getLookVec();

					fireProjectile(world, player, stack, nbt, look);
					
					// update mana and send to client
					statsCap.decreaseMana(this.manaPerUse);
					LootSlashConquer.network.sendTo(new PacketUpdateStats(statsCap), (EntityPlayerMP) player);
					
					// damage item
					stack.damageItem(1, player);
				}
			}
		}
	}
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:44,代码来源:ItemLEMagical.java

示例13: onReceived

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

示例14: onLocalPlayerUpdate

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SubscribeEvent
public void onLocalPlayerUpdate(LocalPlayerUpdateEvent event) {
    EntityPlayer localPlayer = MC.player;
    Entity target = LocalPlayerUtils.getTargetEntity();
    // local player eye pos
    Vec3d selfPos = EntityUtils.getEyePos(localPlayer);
    // local player look vec
    Vec3d selfLookVec = localPlayer.getLookVec();
    // local player view angles
    Angle viewAngles = VectorUtils.vectorAngle(selfLookVec);
    if(hold_target.get()) {
        if(target == null ||
                !isValidTarget(target, EntityUtils.getOBBCenter(target), selfPos, selfLookVec, viewAngles)) {
            target = findTargetEntity(selfPos, selfLookVec, viewAngles);
        }
    } else {
        target = findTargetEntity(selfPos, selfLookVec, viewAngles);
    }
    if(target != null) {
        if(!isHoldingProjectileItem()) {
            Angle aim = Utils.getLookAtAngles(target);
            if (!silent.get())
                LocalPlayerUtils.setViewAngles(aim);
            if (canAttack(localPlayer, target)) {
                // attack entity
                MC.playerController.attackEntity(MC.player, target);
                // swing hand
                localPlayer.swingArm(EnumHand.MAIN_HAND);
                // for rotation packets
                if (silent.get()) {
                    LocalPlayerUtils.setActiveFakeAngles(true);
                    LocalPlayerUtils.setFakeViewAngles(aim);
                    LocalPlayerUtils.sendRotatePacket(aim);
                    return;
                }
            }
        } else {
            ItemStack heldItem = localPlayer.getHeldItemMainhand();
            //Vec3d startPos = EntityUtils.getInterpolatedPos(target, 1).addVector(0, target.getEyeHeight(), 0);
            //Vec3d endPos = EntityUtils.getInterpolatedPos(target, 5).addVector(0, target.getEyeHeight() / 2, 0);
            // this will find the angle we need to shoot at
            ProjectileUtils.ProjectileTraceResult result = new ProjectileUtils.ProjectileTraceResult();
            boolean exists = ProjectileUtils.projectileTrajectoryHitsEntity(target, selfPos, getAimPos(target), result);
            if(!exists || result.shootAngle == null) {
                LocalPlayerUtils.setProjectileTargetAcquired(false);
            } else {
                // we have a projectile target
                LocalPlayerUtils.setProjectileTargetAcquired(true);
                // set view angles
                LocalPlayerUtils.setFakeViewAngles(result.shootAngle);
                if (!silent.get() && Bindings.use.getBinding().isKeyDown()) {
                    LocalPlayerUtils.setViewAngles(result.shootAngle);
                }
                // fake angles no active (wont change rotation packets)
                LocalPlayerUtils.setActiveFakeAngles(false);
                // bow auto attack will release the use key when
                // the force is greater than or equal to the max force
                if(projectile_auto_attack.get() &&
                        Bindings.use.getBinding().isKeyDown() &&
                        ProjectileUtils.getForce(heldItem) >= result.maxForce) {
                    Bindings.use.setPressed(false);
                }
                return;
            }
        }
    }
    // disable aiming from last tick
    LocalPlayerUtils.setActiveFakeAngles(false);
    LocalPlayerUtils.setProjectileTargetAcquired(false);
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:71,代码来源:AimbotMod.java


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