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

The following are Jave code examples for showing how to use getLook() of the net.minecraft.entity.player.EntityPlayer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: EndermanEvolution   File: ParticleRenderer.java   View Source Code Vote up 5 votes
public void renderParticles(EntityPlayer dumbplayer, float partialTicks) {
	float f = ActiveRenderInfo.getRotationX();
	float f1 = ActiveRenderInfo.getRotationZ();
	float f2 = ActiveRenderInfo.getRotationYZ();
	float f3 = ActiveRenderInfo.getRotationXY();
	float f4 = ActiveRenderInfo.getRotationXZ();
	EntityPlayer player = EasyMappings.player();
	if (player != null) {
		Particle.interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
		Particle.interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
		Particle.interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;

		Particle.cameraViewDir = player.getLook(partialTicks);
		//GlStateManager.glTexParameterf(3553, 10242, 10497.0F);
		//GlStateManager.glTexParameterf(3553, 10243, 10497.0F);
		GlStateManager.enableAlpha();
		GlStateManager.enableBlend();
		GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
		//GlStateManager.alphaFunc(GL11.GL_GREATER, 0F);
		GlStateManager.disableCull();

		GlStateManager.depthMask(false);

		Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
		Tessellator tess = Tessellator.getInstance();
		BufferBuilder buffer = tess.getBuffer();
		buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP);
		for (int i = 0; i < particles.size(); i++) {
			particles.get(i).renderParticle(buffer, player, partialTicks, 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 2
Project: DankNull   File: ItemDankNull.java   View Source Code Vote up 4 votes
public RayTraceResult rayTrace(EntityPlayer player, double blockReachDistance, float partialTicks) {
	Vec3d vec3d = player.getPositionEyes(partialTicks);
	Vec3d vec3d1 = player.getLook(partialTicks);
	Vec3d vec3d2 = vec3d.addVector(vec3d1.x * blockReachDistance, vec3d1.y * blockReachDistance, vec3d1.z * blockReachDistance);
	return player.world.rayTraceBlocks(vec3d, vec3d2, false, false, true);
}
 
Example 3
Project: Melodium   File: ParticleRenderer.java   View Source Code Vote up 4 votes
public void renderParticles(EntityPlayer dumbplayer, float partialTicks) {
	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) * partialTicks;
        Particle.interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
        Particle.interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
        Particle.cameraViewDir = player.getLook(partialTicks);
        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 (particles.get(i) instanceof IParticle){
				if (!((IParticle)particles.get(i)).isAdditive()){
					particles.get(i).renderParticle(buffer, player, partialTicks, 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 (particles.get(i) != null){
				if (((IParticle)particles.get(i)).isAdditive()){
					particles.get(i).renderParticle(buffer, player, partialTicks, f, f4, f1, f2, f3);
				}
			}
		}
		tess.draw();
		
        GlStateManager.disableDepth();
		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 (particles.get(i) instanceof IParticle){
				if (!((IParticle)particles.get(i)).isAdditive() && ((IParticle)particles.get(i)).renderThroughBlocks()){
					particles.get(i).renderParticle(buffer, player, partialTicks, 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 (particles.get(i) != null){
				if (((IParticle)particles.get(i)).isAdditive() && ((IParticle)particles.get(i)).renderThroughBlocks()){
					particles.get(i).renderParticle(buffer, player, partialTicks, f, f4, f1, f2, f3);
				}
			}
		}
		tess.draw();
		GlStateManager.enableDepth();

           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 4
Project: SimpleTractor   File: ItemTractor.java   View Source Code Vote up 4 votes
@Override
@Nonnull
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
    float f1 = playerIn.prevRotationPitch + (playerIn.rotationPitch - playerIn.prevRotationPitch) * 1.0F;
    float f2 = playerIn.prevRotationYaw + (playerIn.rotationYaw - playerIn.prevRotationYaw) * 1.0F;
    double d0 = playerIn.prevPosX + (playerIn.posX - playerIn.prevPosX) * 1.0D;
    double d1 = playerIn.prevPosY + (playerIn.posY - playerIn.prevPosY) * 1.0D + (double)playerIn.getEyeHeight();
    double d2 = playerIn.prevPosZ + (playerIn.posZ - playerIn.prevPosZ) * 1.0D;
    Vec3d vec3d = new Vec3d(d0, d1, d2);
    float f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI);
    float f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI);
    float f5 = -MathHelper.cos(-f1 * 0.017453292F);
    float f6 = MathHelper.sin(-f1 * 0.017453292F);
    float f7 = f4 * f5;
    float f8 = f3 * f5;
    Vec3d vec3d1 = vec3d.addVector((double)f7 * 5.0D, (double)f6 * 5.0D, (double)f8 * 5.0D);
    RayTraceResult raytraceresult = worldIn.rayTraceBlocks(vec3d, vec3d1, false);

    if (raytraceresult == null)
    {
        return new ActionResult<>(EnumActionResult.PASS, itemStackIn);
    }
    else
    {
        Vec3d vec3d2 = playerIn.getLook(1.0F);
        boolean flag = false;
        List<Entity> list = worldIn.getEntitiesWithinAABBExcludingEntity(playerIn, playerIn.getEntityBoundingBox().addCoord(vec3d2.xCoord * 5.0D, vec3d2.yCoord * 5.0D, vec3d2.zCoord * 5.0D).expandXyz(1.0D));

        for (int i = 0; i < list.size(); ++i)
        {
            Entity entity = list.get(i);

            if (entity.canBeCollidedWith())
            {
                AxisAlignedBB axisalignedbb = entity.getEntityBoundingBox().expandXyz((double)entity.getCollisionBorderSize());

                if (axisalignedbb.isVecInside(vec3d))
                {
                    flag = true;
                }
            }
        }

        if (flag)
        {
            return new ActionResult<>(EnumActionResult.PASS, itemStackIn);
        }
        else if (raytraceresult.typeOfHit != RayTraceResult.Type.BLOCK)
        {
            return new ActionResult<>(EnumActionResult.PASS, itemStackIn);
        }
        else
        {
            EntityTractor entityTractor = new EntityTractor(worldIn, raytraceresult.hitVec.xCoord, raytraceresult.hitVec.yCoord, raytraceresult.hitVec.zCoord);
            entityTractor.rotationYaw = playerIn.rotationYaw;

            if (!worldIn.getCollisionBoxes(entityTractor, entityTractor.getEntityBoundingBox().expandXyz(-0.1D)).isEmpty())
            {
                return new ActionResult<>(EnumActionResult.FAIL, itemStackIn);
            }
            else
            {
                if (!worldIn.isRemote)
                {
                    worldIn.spawnEntity(entityTractor);
                }

                if (!playerIn.capabilities.isCreativeMode)
                {
                    --itemStackIn.stackSize;
                }

                playerIn.addStat(StatList.getObjectUseStats(this));
                return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
            }
        }
    }
}