Java 类net.minecraft.util.EnumFacing.AxisDirection 实例源码

项目:Qbar    文件:MultiblockComponent.java   
private BlockPos internalGetCoreOffset(EnumFacing facing)
{
    BlockPos rtn = BlockPos.ORIGIN;

    if (this.getLength() % 2 == 0 || this.getWidth() % 2 == 0)
    {
        if (this.getWidth() % 2 == 0 && facing.getAxis() == Axis.Z
                && facing.getAxisDirection() == AxisDirection.NEGATIVE)
            rtn = rtn.add(-1, 0, 0);
        if (this.getWidth() % 2 == 0 && facing.getAxis() == Axis.X
                && facing.getAxisDirection() == AxisDirection.POSITIVE)
            rtn = rtn.add(0, 0, -1);
        if (this.getLength() % 2 == 0 && facing.getAxis() == Axis.Z
                && facing.getAxisDirection() == AxisDirection.NEGATIVE)
            rtn = rtn.add(0, 0, -1);
        if (this.getLength() % 2 == 0 && facing.getAxis() == Axis.X
                && facing.getAxisDirection() == AxisDirection.NEGATIVE)
            rtn = rtn.add(-1, 0, 0);
    }
    return rtn;
}
项目:runesofwizardry-classics    文件:RuneEntityRebirth.java   
@Override
public void onRuneActivatedbyPlayer(EntityPlayer player,ItemStack[] sacrifice, boolean negated) {
    World world = player.world;
    if(!world.isRemote){
        //take xp if not negated
        if(!negated){
            if(player.experienceLevel>=10){
                player.addExperienceLevel(-10);
            }else{
                //kill the rune
                this.onPatternBrokenByPlayer(player);
                return;
            }
        }
        double x,y,z,offset=0.25;
        x=y=z=0;
        int dir = face.getAxisDirection()==AxisDirection.NEGATIVE? -1:1;
        switch(face.getAxis()){
        case X:x=offset*dir;
            break;
        case Y:y=offset*dir;
            break;
        case Z:z=offset*dir;
            break;
        }
        entity.setupStar(0xFFFFFF, 0xFFFFFF,1,1,new Vec3d(x, y, z));
        entity.setDrawStar(true);
    }
}
项目:Nuclear-Foundation    文件:ModelUtil.java   
/**
 * A method for calculating the points of a face for an axis-aligned cuboid, with a given center and radius.
 */
public static Point3f[] getPointsForFace(EnumFacing face, Tuple3f center, Tuple3f radius) {
    Point3f centerOfFace = new Point3f(center);
    Point3f faceAdd = new Point3f(face.getFrontOffsetX() * radius.x, face.getFrontOffsetY() * radius.y, face.getFrontOffsetZ() * radius.z);
    centerOfFace.add(faceAdd);
    Vector3f faceRadius = new Vector3f(radius);
    if (face.getAxisDirection() == AxisDirection.POSITIVE) {
        faceRadius.sub(faceAdd);
    } else {
        faceRadius.add(faceAdd);
    }
    return getPoints(centerOfFace, faceRadius);
}
项目:Hard-Science    文件:CableMeshFactory.java   
private List<RawQuad> makeBox(@Nonnull EnumFacing face, @Nonnull RawQuad template, boolean isBothEnds)
{
    AxisAlignedBB aabb;

    switch(face.getAxis())
    {
    case X:
        aabb = isBothEnds 
            ? new AxisAlignedBB(0.0, yLow, xzMin, 1.0, yHigh, xzMax)
            : face.getAxisDirection() == AxisDirection.POSITIVE
                ? new AxisAlignedBB(xzMin, yLow, xzMin, 1.0, yHigh, xzMax)
                : new AxisAlignedBB(0.0, yLow, xzMin, xzMax, yHigh, xzMax);  
        break;

    case Y:
        aabb = isBothEnds 
            ? new AxisAlignedBB(xzMin, 0.0, xzMin, xzMax, 1.0, xzMax)
            : face.getAxisDirection() == AxisDirection.POSITIVE
                ? new AxisAlignedBB(xzMin, yLow, xzMin, xzMax, 1.0, xzMax)
                : new AxisAlignedBB(xzMin, 0.0, xzMin, xzMax, yHigh, xzMax);  
        break;

    case Z:
    default:
        aabb = isBothEnds 
            ? new AxisAlignedBB(xzMin, yLow, 0.0, xzMax, yHigh, 1.0)
            : face.getAxisDirection() == AxisDirection.POSITIVE
                ? new AxisAlignedBB(xzMin, yLow, xzMin, xzMax, yHigh, 1.0)
                : new AxisAlignedBB(xzMin, yLow, 0.0, xzMax, yHigh, xzMax);  
        break;

    }
    return QuadHelper.makeBox(aabb, template);
}
项目:enderutilities    文件:ItemBuildersWand.java   
public Area3D adjustArea(EnumFacing facing, int amount)
{
    if (facing.getAxisDirection() == AxisDirection.POSITIVE)
    {
        this.pos.move(facing, amount);
        this.clampBounds(this.pos);
    }
    else
    {
        this.neg.move(facing, -amount);
        this.clampBounds(this.neg);
    }

    return this;
}
项目:Toms-Mod    文件:TileEntityCreativeCellRenderer.java   
@Override
public void renderTileEntityAt(TileEntityCreativeCell te, double x, double y, double z, float partialTicks, int destroyStage, IBlockState state) {
    GlStateManager.pushMatrix();// main
    GlStateManager.enableTexture2D();
    GlStateManager.enableBlend();
    GlStateManager.disableLighting();
    GlStateManager.pushMatrix();// side
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer renderer = tessellator.getBuffer();
    double u1 = 0.0D, v1 = 1.0D, u2 = 1.0D, v2 = 0.0D;
    int w = 1;
    int h = 1;
    bindTexture(new ResourceLocation("tomsmodenergy:textures/blocks/energyCellOut.png"));
    try {
        for (EnumFacing f : EnumFacing.VALUES) {
            if (te.contains(f)) {
                boolean isPositive = f.getAxisDirection() == AxisDirection.POSITIVE;
                if (f.getAxis() == Axis.X) {
                    if (isPositive) {
                        renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
                        renderer.pos(x + 1.001, y, z + w).tex(u2, v1).endVertex();
                        renderer.pos(x + 1.001, y, z).tex(u1, v1).endVertex();
                        renderer.pos(x + 1.001, y + h, z).tex(u1, v2).endVertex();
                        renderer.pos(x + 1.001, y + h, z + w).tex(u2, v2).endVertex();
                        tessellator.draw();
                        continue;
                    } else {
                        renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
                        renderer.pos(x - 0.001, y, z - w + 1).tex(u2, v1).endVertex();
                        renderer.pos(x - 0.001, y, z + 1).tex(u1, v1).endVertex();
                        renderer.pos(x - 0.001, y + h, z + 1).tex(u1, v2).endVertex();
                        renderer.pos(x - 0.001, y + h, z - w + 1).tex(u2, v2).endVertex();
                        tessellator.draw();
                        continue;
                    }
                } else if (f.getAxis() == Axis.Y) {
                    if (isPositive) {
                        renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
                        renderer.pos(x + w, y + 1.001, z).tex(u2, v1).endVertex();
                        renderer.pos(x, y + 1.001, z).tex(u1, v1).endVertex();
                        renderer.pos(x, y + 1.001, z + h).tex(u1, v2).endVertex();
                        renderer.pos(x + w, y + 1.001, z + h).tex(u2, v2).endVertex();
                        tessellator.draw();
                        continue;
                    } else {
                        renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
                        renderer.pos(x - w + 1, y - 0.001, z).tex(u2, v1).endVertex();
                        renderer.pos(x + 1, y - 0.001, z).tex(u1, v1).endVertex();
                        renderer.pos(x + 1, y - 0.001, z + h).tex(u1, v2).endVertex();
                        renderer.pos(x - w + 1, y - 0.001, z + h).tex(u2, v2).endVertex();
                        tessellator.draw();
                        continue;
                    }
                } else {
                    if (isPositive) {
                        renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
                        renderer.pos(x - w + 1, y, z + 1.001).tex(u2, v1).endVertex();
                        renderer.pos(x + 1, y, z + 1.001).tex(u1, v1).endVertex();
                        renderer.pos(x + 1, y + h, z + 1.001).tex(u1, v2).endVertex();
                        renderer.pos(x - w + 1, y + h, z + 1.001).tex(u2, v2).endVertex();
                        tessellator.draw();
                        continue;
                    }
                }
                renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
                renderer.pos(x + w, y, z - 0.001).tex(u2, v1).endVertex();
                renderer.pos(x, y, z - 0.001).tex(u1, v1).endVertex();
                renderer.pos(x, y + h, z - 0.001).tex(u1, v2).endVertex();
                renderer.pos(x + w, y + h, z - 0.001).tex(u2, v2).endVertex();
                tessellator.draw();
            }
        }
    } catch (Exception e) {
    }
    GlStateManager.disableBlend();
    GlStateManager.popMatrix();// side
    GlStateManager.enableLighting();
    GlStateManager.popMatrix();// main
}
项目:Hard-Science    文件:AdditivePlacementHandler.java   
public List<Pair<BlockPos, ItemStack>> getPlacementResults(EntityPlayer playerIn, World worldIn, BlockPos posOn, EnumHand hand, EnumFacing facing, float hitX,
        float hitY, float hitZ, ItemStack stack)
{

    if(!(stack.getItem() instanceof SuperItemBlock)) return Collections.emptyList();

    PlacementItem item = (PlacementItem)stack.getItem();

    if(item.isBlockOrientationFixed(stack)) 
        return CubicPlacementHandler.INSTANCE.getPlacementResults(playerIn, worldIn, posOn, hand, facing, hitX, hitY, hitZ, stack);

    final SuperBlock stackBlock = (SuperBlock) ((SuperItemBlock)stack.getItem()).getBlock();
    final ModelState stackModelState = PlacementItem.getStackModelState(stack);

    final IBlockState onBlockState = worldIn.getBlockState(posOn);

    if(onBlockState.getBlock() instanceof SuperBlock)
    {
        final SuperBlock onBlock = (SuperBlock) onBlockState.getBlock();
        final ModelState onModelState = onBlock.getModelStateAssumeStateIsCurrent(onBlockState, worldIn, posOn, true);

        if(onBlock == stackBlock 
                && onModelState != null
                && onModelState.getShape() == stackModelState.getShape()
                && onModelState.doesAppearanceMatch(stackModelState)) 
        {
            // target is this additive block

            if(!onModelState.hasAxis() 
                    || (onModelState.getAxis() == facing.getAxis()
                    && (!onModelState.hasAxisOrientation() || onModelState.isAxisInverted() == (facing.getAxisDirection() == AxisDirection.NEGATIVE))))
            {
                // we clicked on an additive face

                // confirm have space to add - the ItemStack handler will allow us to get 
                // here if the adjacent position contains another additive block
                if(onModelState.getMetaData() < 0xF || WorldHelper.isBlockReplaceable(worldIn, posOn.offset(facing), !VirtualBlock.isVirtualBlock(stackBlock)))
                {
                    return addToBlockAtPosition(worldIn, stack, stackModelState, onModelState, posOn);
                }
            }
        }
    }

    // is there an additive block against the face we clicked?
    final BlockPos facePos = posOn.offset(facing);
    final IBlockState faceBlockState = worldIn.getBlockState(facePos);
    if(faceBlockState.getBlock() instanceof SuperBlock)
    {
        final SuperBlock faceBlock = (SuperBlock) faceBlockState.getBlock();
        final ModelState faceModelState = faceBlock.getModelStateAssumeStateIsCurrent(faceBlockState, worldIn, facePos, true);

        if((    faceBlock == stackBlock 
                && faceModelState.getShape() == stackModelState.getShape())
                && faceModelState.doesAppearanceMatch(stackModelState)) 
         {
            // add to the adjacent block 
            return addToBlockAtPosition(worldIn, stack, stackModelState, faceModelState, facePos);
         }
    }

    // fall back to standard placement logic
    return CubicPlacementHandler.INSTANCE.getPlacementResults(playerIn, worldIn, posOn, hand, facing, hitX, hitY, hitZ, stack);

}
项目:Hard-Science    文件:BlockOrientationHandler.java   
/** handle hit-sensitive placement for stairs, wedges */
public static void applyDynamicOrientation(ItemStack stack, EntityPlayer player, PlacementPosition pPos)
{
    ModelState outputModelState = PlacementItem.getStackModelState(stack);

    boolean isRotationDone = false;

    if(outputModelState.isAxisOrthogonalToPlacementFace())
    {
        EnumFacing adjacentFace = WorldHelper.closestAdjacentFace(
                pPos.onFace, 
                (float)pPos.hitX, 
                (float)pPos.hitY, 
                (float)pPos.hitZ);

        BlockCorner corner = BlockCorner.find(pPos.onFace.getOpposite(), adjacentFace);

        if(corner == null)
        {
            Log.warn("Unable to find block corner from placement. This is very strange but probably harmless.");
        }
        else
        {
            outputModelState.setAxis(corner.orthogonalAxis);

            if(outputModelState.hasAxisRotation())
            {
                outputModelState.setAxisRotation(corner.modelRotation);
                isRotationDone = true;
            }
        }
    }
    else
    {
        outputModelState.setAxis(pPos.onFace.getAxis());
        if(outputModelState.hasAxisOrientation())
        {
            outputModelState.setAxisInverted(pPos.onFace.getAxisDirection() == AxisDirection.NEGATIVE);
        }
    }

    if(!isRotationDone && outputModelState.hasAxisRotation())
    {
        outputModelState.setAxisRotation(
                Rotation.fromHorizontalFacing(player.getHorizontalFacing().getOpposite()));
    }

    PlacementItem.setStackModelState(stack, outputModelState);
}