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

The following examples show how to use net.minecraft.entity.player.EntityPlayer#getLook() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
public RayTraceResult rayTrace(EntityPlayer player, double blockReachDistance, float partialTicks)
{
	Vec3d vec3d = player.getPositionEyes(partialTicks);
	Vec3d vec3d1 = player.getLook(partialTicks);
	Vec3d vec3d2 = vec3d.addVector(vec3d1.xCoord * blockReachDistance, vec3d1.yCoord * blockReachDistance, vec3d1.zCoord * blockReachDistance);
	return player.world.rayTraceBlocks(vec3d, vec3d2, false, false, true);
}
 
Example 2
/**
 * @param player The placing player, used for obtaining the look vector
 * @param side The side of the block being placed on
 * @return The rotation for the face == side^1
 */
public static int getSidedRotation(EntityPlayer player, int side) {
    Vector3 look = new Vector3(player.getLook(1));
    double max = 0;
    int maxr = 0;
    for (int r = 0; r < 4; r++) {
        Vector3 axis = Rotation.axes[rotateSide(side ^ 1, r)];
        double d = look.scalarProject(axis);
        if (d > max) {
            max = d;
            maxr = r;
        }
    }
    return maxr;
}
 
Example 3
public static MovingObjectPosition retraceBlock(World world, EntityPlayer player, BlockPos pos) {
    IBlockState b = world.getBlockState(pos);
    Vec3 headVec = getCorrectedHeadVec(player);
    Vec3 lookVec = player.getLook(1.0F);
    double reach = getBlockReachDistance(player);
    Vec3 endVec = headVec.addVector(lookVec.xCoord * reach, lookVec.yCoord * reach, lookVec.zCoord * reach);
    return b.getBlock().collisionRayTrace(world, pos, headVec, endVec);
}
 
Example 4
Source Project: Artifacts   File: ComponentFireball.java    License: MIT License 5 votes vote down vote up
@Override
public boolean hitEntity(ItemStack itemStack, EntityLivingBase entityLivingHit, EntityLivingBase entityLivingPlayer) {
	
	if(!entityLivingPlayer.worldObj.isRemote && entityLivingPlayer instanceof EntityPlayer) {
		System.out.println("Entity was hit. Summoning fireball.");
		EntityPlayer player = (EntityPlayer) entityLivingPlayer;
		World world = player.worldObj;
		
		Vec3 vec3 = player.getLook(1.0F);
		double d8 = 4.0D;
		//System.out.println(vec3);
		//EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, p.posX + vec3.xCoord * d8, p.posY, p.posZ + vec3.zCoord * d8, vec3.xCoord, vec3.yCoord, vec3.zCoord);
		EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, player, vec3.xCoord, vec3.yCoord, vec3.zCoord);
		entitylargefireball.posX += vec3.xCoord * d8;
		entitylargefireball.posZ += vec3.zCoord * d8;
		entitylargefireball.accelerationX = vec3.xCoord;
		entitylargefireball.accelerationY = vec3.yCoord;
		entitylargefireball.accelerationZ = vec3.zCoord;
		entitylargefireball.field_92057_e = 1;
		/*entitylargefireball.posX = p.posX;// + vec3.xCoord * d8;
               entitylargefireball.posY = p.posY + (double)(p.height / 2.0F);
               entitylargefireball.posZ = p.posZ;// + vec3.zCoord * d8;*/
		//System.out.println(entitylargefireball.posX + "," + entitylargefireball.posY + "," + entitylargefireball.posZ);
		world.spawnEntityInWorld(entitylargefireball);
		itemStack.damageItem(1, player);
		
	}
	return false;
}
 
Example 5
Source Project: Logistics-Pipes-2   File: ParticleRenderer.java    License: MIT License 4 votes vote down vote up
public void renderParticles(EntityPlayer aPlayer, float pTicks) {
	float f = ActiveRenderInfo.getRotationX();
       float f1 = ActiveRenderInfo.getRotationZ();
       float f2 = ActiveRenderInfo.getRotationYZ();
       float f3 = ActiveRenderInfo.getRotationXY();
       float f4 = ActiveRenderInfo.getRotationXZ();
       EntityPlayer player = Minecraft.getMinecraft().player;
       if(player!=null) {
       	Particle.interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * pTicks;
        Particle.interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * pTicks;
        Particle.interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * pTicks;
        Particle.cameraViewDir = player.getLook(pTicks);
        GlStateManager.enableAlpha();
        GlStateManager.enableBlend();
        GlStateManager.alphaFunc(516, 0.003921569F);
           GlStateManager.disableCull();
           
           GlStateManager.depthMask(false);
           
           Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
		Tessellator tess = Tessellator.getInstance();
		VertexBuffer buffer = tess.getBuffer();
		
		GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
			buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP);
			for(int i = 0; i < particles.size(); i ++) {
				if(!((ILP2Particle) particles.get(i)).isAdditive()) {
					particles.get(i).renderParticle(buffer, player, pTicks, f, f4, f1, f2, f3);
				}
			}
			tess.draw();
		
		GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
			buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP);
			for(int i = 0; i < particles.size(); i ++) {
				if(((ILP2Particle) particles.get(i)).isAdditive()) {
					particles.get(i).renderParticle(buffer, player, pTicks, f, f4, f1, f2, f3);
				}
			}
			tess.draw();
		
		GlStateManager.enableCull();
           GlStateManager.depthMask(true);
        GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
        GlStateManager.disableBlend();
        GlStateManager.alphaFunc(516, 0.1F);
       }
}
 
Example 6
public static MovingObjectPosition retrace(EntityPlayer player, double reach) {
    Vec3 headVec = getCorrectedHeadVec(player);
    Vec3 lookVec = player.getLook(1);
    Vec3 endVec = headVec.addVector(lookVec.xCoord * reach, lookVec.yCoord * reach, lookVec.zCoord * reach);
    return player.worldObj.rayTraceBlocks(headVec, endVec, true, false, true);
}
 
Example 7
public static Vec3 getEndVec(EntityPlayer player) {
    Vec3 headVec = getCorrectedHeadVec(player);
    Vec3 lookVec = player.getLook(1.0F);
    double reach = getBlockReachDistance(player);
    return headVec.addVector(lookVec.xCoord * reach, lookVec.yCoord * reach, lookVec.zCoord * reach);
}