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


Java EnumFacing.getDirectionVec方法代码示例

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


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

示例1: getFacingFromVertexData

import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
public static EnumFacing getFacingFromVertexData(int[] faceData)
{
    Vector3f vector3f = new Vector3f(Float.intBitsToFloat(faceData[0]), Float.intBitsToFloat(faceData[1]), Float.intBitsToFloat(faceData[2]));
    Vector3f vector3f1 = new Vector3f(Float.intBitsToFloat(faceData[7]), Float.intBitsToFloat(faceData[8]), Float.intBitsToFloat(faceData[9]));
    Vector3f vector3f2 = new Vector3f(Float.intBitsToFloat(faceData[14]), Float.intBitsToFloat(faceData[15]), Float.intBitsToFloat(faceData[16]));
    Vector3f vector3f3 = new Vector3f();
    Vector3f vector3f4 = new Vector3f();
    Vector3f vector3f5 = new Vector3f();
    Vector3f.sub(vector3f, vector3f1, vector3f3);
    Vector3f.sub(vector3f2, vector3f1, vector3f4);
    Vector3f.cross(vector3f4, vector3f3, vector3f5);
    float f = (float)Math.sqrt((double)(vector3f5.x * vector3f5.x + vector3f5.y * vector3f5.y + vector3f5.z * vector3f5.z));
    vector3f5.x /= f;
    vector3f5.y /= f;
    vector3f5.z /= f;
    EnumFacing enumfacing = null;
    float f1 = 0.0F;

    for (EnumFacing enumfacing1 : EnumFacing.values())
    {
        Vec3i vec3i = enumfacing1.getDirectionVec();
        Vector3f vector3f6 = new Vector3f((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ());
        float f2 = Vector3f.dot(vector3f5, vector3f6);

        if (f2 >= 0.0F && f2 > f1)
        {
            f1 = f2;
            enumfacing = enumfacing1;
        }
    }

    if (enumfacing == null)
    {
        return EnumFacing.UP;
    }
    else
    {
        return enumfacing;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:41,代码来源:FaceBakery.java

示例2: rotate

import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
public static EnumFacing rotate(Matrix4f matrix, EnumFacing facing)
{
    Vec3i dir = facing.getDirectionVec();
    Vector4f vec = new Vector4f(dir.getX(), dir.getY(), dir.getZ(), 0);
    matrix.transform(vec);
    return EnumFacing.getFacingFromVector(vec.x, vec.y, vec.z);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:8,代码来源:TRSRTransformation.java

示例3: placeBlockLegit

import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
public static boolean placeBlockLegit(BlockPos pos)
{
	Vec3d eyesPos = RotationUtils.getEyesPos();
	Vec3d posVec = new Vec3d(pos).addVector(0.5, 0.5, 0.5);
	double distanceSqPosVec = eyesPos.squareDistanceTo(posVec);
	
	for(EnumFacing side : EnumFacing.values())
	{
		BlockPos neighbor = pos.offset(side);
		
		// check if neighbor can be right clicked
		if(!WBlock.canBeClicked(neighbor))
			continue;
		
		Vec3d dirVec = new Vec3d(side.getDirectionVec());
		Vec3d hitVec = posVec.add(dirVec.scale(0.5));
		
		// check if hitVec is within range (4.25 blocks)
		if(eyesPos.squareDistanceTo(hitVec) > 18.0625)
			continue;
		
		// check if side is visible (facing away from player)
		if(distanceSqPosVec > eyesPos.squareDistanceTo(posVec.add(dirVec)))
			continue;
		
		// check line of sight
		if(WMinecraft.getWorld().rayTraceBlocks(eyesPos, hitVec, false,
			true, false) != null)
			continue;
		
		// face block
		RotationUtils.faceVectorPacketInstant(hitVec);
		
		// place block
		WPlayerController.processRightClickBlock(neighbor,
			side.getOpposite(), hitVec);
		WPlayer.swingArmClient();
		mc.rightClickDelayTimer = 4;
		
		return true;
	}
	
	return false;
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12,代码行数:45,代码来源:BlockUtils.java

示例4: getFacingFromVertexData

import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
public static EnumFacing getFacingFromVertexData(int[] faceData)
{
    Vector3f vector3f = new Vector3f(Float.intBitsToFloat(faceData[0]), Float.intBitsToFloat(faceData[1]), Float.intBitsToFloat(faceData[2]));
    Vector3f vector3f1 = new Vector3f(Float.intBitsToFloat(faceData[7]), Float.intBitsToFloat(faceData[8]), Float.intBitsToFloat(faceData[9]));
    Vector3f vector3f2 = new Vector3f(Float.intBitsToFloat(faceData[14]), Float.intBitsToFloat(faceData[15]), Float.intBitsToFloat(faceData[16]));
    Vector3f vector3f3 = new Vector3f();
    Vector3f vector3f4 = new Vector3f();
    Vector3f vector3f5 = new Vector3f();
    Vector3f.sub(vector3f, vector3f1, vector3f3);
    Vector3f.sub(vector3f2, vector3f1, vector3f4);
    Vector3f.cross(vector3f4, vector3f3, vector3f5);
    float f = (float)Math.sqrt((double)(vector3f5.x * vector3f5.x + vector3f5.y * vector3f5.y + vector3f5.z * vector3f5.z));
    vector3f5.x /= f;
    vector3f5.y /= f;
    vector3f5.z /= f;
    EnumFacing enumfacing = null;
    float f1 = 0.0F;

    for (EnumFacing enumfacing1 : EnumFacing.values())
    {
        Vec3i vec3i = enumfacing1.getDirectionVec();
        Vector3f vector3f6 = new Vector3f((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ());
        float f2 = Vector3f.dot(vector3f5, vector3f6);

        if (f2 >= 0.0F && f2 > f1)
        {
            f1 = f2;
            enumfacing = enumfacing1;
        }
    }

    if (f1 < 0.719F)
    {
        if (enumfacing != EnumFacing.EAST && enumfacing != EnumFacing.WEST && enumfacing != EnumFacing.NORTH && enumfacing != EnumFacing.SOUTH)
        {
            enumfacing = EnumFacing.UP;
        }
        else
        {
            enumfacing = EnumFacing.NORTH;
        }
    }

    return enumfacing == null ? EnumFacing.UP : enumfacing;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:46,代码来源:FaceBakery.java

示例5: getDirectionVec

import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
public static Vec3i getDirectionVec(EnumFacing facing) {
    return facing.getDirectionVec();
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:4,代码来源:ZWrapper.java

示例6: getFacingFromVertexData

import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
public static EnumFacing getFacingFromVertexData(int[] faceData)
{
    int i = faceData.length / 4;
    int j = i * 2;
    Vector3f vector3f = new Vector3f(Float.intBitsToFloat(faceData[0]), Float.intBitsToFloat(faceData[1]), Float.intBitsToFloat(faceData[2]));
    Vector3f vector3f1 = new Vector3f(Float.intBitsToFloat(faceData[i]), Float.intBitsToFloat(faceData[i + 1]), Float.intBitsToFloat(faceData[i + 2]));
    Vector3f vector3f2 = new Vector3f(Float.intBitsToFloat(faceData[j]), Float.intBitsToFloat(faceData[j + 1]), Float.intBitsToFloat(faceData[j + 2]));
    Vector3f vector3f3 = new Vector3f();
    Vector3f vector3f4 = new Vector3f();
    Vector3f vector3f5 = new Vector3f();
    Vector3f.sub(vector3f, vector3f1, vector3f3);
    Vector3f.sub(vector3f2, vector3f1, vector3f4);
    Vector3f.cross(vector3f4, vector3f3, vector3f5);
    float f = (float)Math.sqrt((double)(vector3f5.x * vector3f5.x + vector3f5.y * vector3f5.y + vector3f5.z * vector3f5.z));
    vector3f5.x /= f;
    vector3f5.y /= f;
    vector3f5.z /= f;
    EnumFacing enumfacing = null;
    float f1 = 0.0F;

    for (EnumFacing enumfacing1 : EnumFacing.values())
    {
        Vec3i vec3i = enumfacing1.getDirectionVec();
        Vector3f vector3f6 = new Vector3f((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ());
        float f2 = Vector3f.dot(vector3f5, vector3f6);

        if (f2 >= 0.0F && f2 > f1)
        {
            f1 = f2;
            enumfacing = enumfacing1;
        }
    }

    if (enumfacing == null)
    {
        return EnumFacing.UP;
    }
    else
    {
        return enumfacing;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:43,代码来源:FaceBakery.java


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