net.minecraft.util.EnumFacing#Axis ( )源码实例Demo

下面列出了net.minecraft.util.EnumFacing#Axis ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: AgriCraft   文件: ItemBlockGrate.java
/**
 * Sets the freshly placed TileEntityGrate's orientation.
 *
 * @param grate the grate in question.
 * @param hitX the hit x-coordinate.
 * @param hitY the hit y-coordinate.
 * @param hitZ the hit z-coordinate.
 * @param axis the axis the block is on.
 */
private static void setOffsetOrientation(TileEntityGrate grate, float hitX, float hitY, float hitZ, EnumFacing.Axis axis) {
    // Set the grate's axis.
    grate.setAxis(axis);

    // Resolve the hit value.
    final float hit = getAxialValue(axis, hitX, hitY, hitZ);

    // Set the grate's offset.
    if (hit <= 0.3333F) {
        grate.setOffset(TileEntityGrate.EnumOffset.NEAR);
    } else if (hit <= 0.6666F) {
        grate.setOffset(TileEntityGrate.EnumOffset.CENTER);
    } else {
        grate.setOffset(TileEntityGrate.EnumOffset.FAR);
    }
}
 
源代码2 项目: TFC2   文件: TileSmallVessel.java
@SideOnly(Side.CLIENT)
public static PropertyItem.PItem getDisplayItem(ItemStack stack, World world, EntityLivingBase entity, float x, float z, EnumFacing.Axis axis) {
	if(stack == null)
		return null;

	IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(stack, world, entity);
	if(model == null || model.isBuiltInRenderer()) {
		// missing model so people don't go paranoid when their chests go missing
		model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager().getMissingModel();
	}
	float rotation = 0;
	if(axis == EnumFacing.Axis.X)
	{
		rotation = (float)Math.PI /2f;
	}
	PropertyItem.PItem item = new PropertyItem.PItem(model, x,0,z, 0.45f, axis == EnumFacing.Axis.X ? (float) (Math.PI/2f) : 0);
	if(stack.getItem() instanceof ItemBlock) {
		item.y = -0.3125f;
		item.s = 0.375f;
		item.r = 0;
	}
	return item;
}
 
源代码3 项目: CommunityMod   文件: SquashableMod.java
@SubscribeEvent
public static void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
    EntityLivingBase entity = event.getEntityLiving();
    if (entity.world.isRemote) {
        return;
    }

    if (entity.collidedHorizontally && isBeingPushedByPiston(entity)) {
        Squashable squashable = entity.getCapability(squashableCap(), null);
        if (squashable == null) {
            return;
        }

        double[] pistonDeltas = getPistonDeltas(entity);
        double pushedAngle = Math.atan2(pistonDeltas[2], pistonDeltas[0]);

        EnumFacing.Axis faceAxis = EnumFacing.fromAngle(entity.rotationYaw).getAxis();
        EnumFacing.Axis pushAxis = EnumFacing.fromAngle(pushedAngle).getAxis();

        EnumFacing.Axis squashAxis = faceAxis == pushAxis ? EnumFacing.Axis.Z : EnumFacing.Axis.X;

        squashable.squash(squashAxis);

        NETWORK.sendToAllTracking(new SquashEntityMessage(entity, squashAxis), entity);
    }
}
 
源代码4 项目: AgriCraft   文件: RenderBlockGrate.java
@Override
protected void renderWorldBlockWoodStatic(ITessellator tess, IExtendedBlockState state, BlockGrate block, EnumFacing side, TextureAtlasSprite sprite) {
    // Setup
    final TileEntityGrate.EnumOffset offset = AgriProperties.OFFSET.getValue(state);
    final EnumFacing.Axis axis = AgriProperties.AXIS.getValue(state);
    
    // Rotate
    RenderUtilBase.rotateBlock(tess, EnumFacing.getFacingFromAxis(EnumFacing.AxisDirection.POSITIVE, axis));

    // Offset
    tess.translate(0, 0, offset.getOffset());

    // Draw Grate
    tess.drawScaledPrism(1, 0, 0, 3, 16, 2, sprite);
    tess.drawScaledPrism(5, 0, 0, 7, 16, 2, sprite);
    tess.drawScaledPrism(9, 0, 0, 11, 16, 2, sprite);
    tess.drawScaledPrism(13, 0, 0, 15, 16, 2, sprite);
    tess.drawScaledPrism(0, 1, 0, 16, 3, 2, sprite);
    tess.drawScaledPrism(0, 5, 0, 16, 7, 2, sprite);
    tess.drawScaledPrism(0, 9, 0, 16, 11, 2, sprite);
    tess.drawScaledPrism(0, 13, 0, 16, 15, 2, sprite);

}
 
源代码5 项目: enderutilities   文件: PositionUtils.java
public static EnumFacing[] getSidesForAxis(EnumFacing.Axis axis)
{
    if (axis == EnumFacing.Axis.X)
    {
        return ADJACENT_SIDES_ZY;
    }

    return axis == EnumFacing.Axis.Z ? ADJACENT_SIDES_XY : ADJACENT_SIDES_XZ;
}
 
源代码6 项目: Sakura_mod   文件: BlockBambooBlock.java
public static EnumAxis fromFacingAxis(EnumFacing.Axis axis)
{
    switch (axis)
    {
        case X:
            return X;
        case Y:
            return Y;
        case Z:
            return Z;
        default:
            return NONE;
    }
}
 
源代码7 项目: CommunityMod   文件: SquashEntityMessage.java
@Override
public void fromBytes(ByteBuf buf) {
    this.entityId = buf.readInt();

    EnumFacing.Axis[] values = EnumFacing.Axis.values();
    this.axis = values[buf.readByte() % values.length];
}
 
源代码8 项目: AgriCraft   文件: TileEntityGrate.java
public void setAxis(@Nonnull EnumFacing.Axis axis) {
    // Validate.
    Preconditions.checkNotNull(axis);

    // Set.
    if (this.axis != axis) {
        this.axis = axis;
        this.markForUpdate();
    }
}
 
源代码9 项目: AgriCraft   文件: ItemBlockGrate.java
private static float getAxialValue(@Nonnull EnumFacing.Axis axis, float x, float y, float z) {
    switch (axis) {
        case X:
            return x;
        case Y:
            return y;
        case Z:
            return z;
        default:
            throw new NullPointerException();
    }
}
 
源代码10 项目: litematica   文件: TaskCountBlocksBase.java
protected void countBlocksInChunkRespectingLayerRange(ChunkPos pos, LayerRange range)
{
    EnumFacing.Axis axis = range.getAxis();
    BlockPos.MutableBlockPos posMutable = new BlockPos.MutableBlockPos();

    for (IntBoundingBox bb : this.getBoxesInChunk(pos))
    {
        final int startX = axis == EnumFacing.Axis.X ? Math.max(bb.minX, range.getLayerMin()) : bb.minX;
        final int startY = axis == EnumFacing.Axis.Y ? Math.max(bb.minY, range.getLayerMin()) : bb.minY;
        final int startZ = axis == EnumFacing.Axis.Z ? Math.max(bb.minZ, range.getLayerMin()) : bb.minZ;
        final int endX = axis == EnumFacing.Axis.X ? Math.min(bb.maxX, range.getLayerMax()) : bb.maxX;
        final int endY = axis == EnumFacing.Axis.Y ? Math.min(bb.maxY, range.getLayerMax()) : bb.maxY;
        final int endZ = axis == EnumFacing.Axis.Z ? Math.min(bb.maxZ, range.getLayerMax()) : bb.maxZ;

        for (int y = startY; y <= endY; ++y)
        {
            for (int z = startZ; z <= endZ; ++z)
            {
                for (int x = startX; x <= endX; ++x)
                {
                    posMutable.setPos(x, y, z);
                    this.countAtPosition(posMutable);
                }
            }
        }
    }
}
 
源代码11 项目: customstuff4   文件: BlockFenceGate.java
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
    EnumFacing.Axis enumfacing$axis = state.getValue(FACING).getAxis();

    if (enumfacing$axis == EnumFacing.Axis.Z && (canFenceGateConnectTo(worldIn, pos, EnumFacing.WEST) || canFenceGateConnectTo(worldIn, pos, EnumFacing.EAST)) || enumfacing$axis == EnumFacing.Axis.X && (canFenceGateConnectTo(worldIn, pos, EnumFacing.NORTH) || canFenceGateConnectTo(worldIn, pos, EnumFacing.SOUTH)))
    {
        state = state.withProperty(IN_WALL, Boolean.TRUE);
    }

    return state;
}
 
源代码12 项目: TFC2   文件: TileSmallVessel.java
public EnumFacing.Axis getRotation() {
	return rotation;
}
 
源代码13 项目: CommunityMod   文件: FlattenedModel.java
public FlattenedModel(ModelBase wrapped, EnumFacing.Axis squashedAxis) {
    this.wrapped = wrapped;
    this.squashedAxis = squashedAxis;
}
 
@Override
public void render(TileEntityRotationAxle tileentity, double x, double y, double z,
    float partialTick, int destroyStage, float alpha) {
    this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    GlStateManager.pushMatrix();
    GlStateManager.disableLighting();

    GlStateManager.translate(x, y, z);
    GlStateManager.disableAlpha();
    GlStateManager.disableBlend();

    int brightness = tileentity.getWorld().getCombinedLight(tileentity.getPos(), 0);
    IBlockState gearState = Minecraft.getMinecraft().world.getBlockState(tileentity.getPos());
    if (gearState.getBlock() instanceof BlockRotationAxle) {
        EnumFacing.Axis facingAxis = gearState.getValue(BlockRotationAxle.AXIS);

        GlStateManager.translate(0.5, 0.5, 0.5);
        switch (facingAxis) {
            case X:
                // Rotates (1, 0, 0) -> (1, 0, 0)
                break;
            case Y:
                // Rotates (1, 0, 0) -> (0, 1, 0)
                GL11.glRotated(90, 0, 0, 1);
                break;
            case Z:
                // Rotates (1, 0, 0) -> (0, 0, 1)
                GL11.glRotated(-90, 0, 1, 0);
                break;
        }
        GL11.glRotated(Math.toDegrees(tileentity.getRenderRotationRadians(partialTick)), 1, 0,
            0);
        GlStateManager.translate(-0.5, -0.5, -0.5);
    }

    double keyframe = 1;
    GibsAnimationRegistry.getAnimation("rotation_axle")
        .renderAnimation(keyframe, brightness);

    GlStateManager.popMatrix();
    GlStateManager.enableLighting();
    GlStateManager.resetColor();
}
 
源代码15 项目: TFC2   文件: TileSmallVessel.java
public void setRotation(EnumFacing.Axis axis)
{
	rotation = axis;
}
 
源代码16 项目: CommunityMod   文件: Squashable.java
@Nullable
public EnumFacing.Axis getSquashedAxis() {
    return this.squashedAxis;
}
 
源代码17 项目: Valkyrien-Skies   文件: TileEntityRotationAxle.java
public TileEntityRotationAxle(EnumFacing.Axis axleAxis) {
    super();
    setAxleAxis(axleAxis);
}
 
源代码18 项目: litematica   文件: RenderChunkSchematicVbo.java
protected void renderOverlayReducedEdges(BlockPos pos, OverlayType[][][] adjTypes, OverlayType typeSelf, Color4f overlayColor, BufferBuilder bufferOverlayOutlines)
{
    OverlayType[] neighborTypes = new OverlayType[4];
    Vec3i[] neighborPositions = new Vec3i[4];
    int lines = 0;

    for (EnumFacing.Axis axis : PositionUtils.AXES_ALL)
    {
        for (int corner = 0; corner < 4; ++corner)
        {
            Vec3i[] offsets = PositionUtils.getEdgeNeighborOffsets(axis, corner);
            int index = -1;
            boolean hasCurrent = false;

            // Find the position(s) around a given edge line that have the shared greatest rendering priority
            for (int i = 0; i < 4; ++i)
            {
                Vec3i offset = offsets[i];
                OverlayType type = adjTypes[offset.getX() + 1][offset.getY() + 1][offset.getZ() + 1];

                // type NONE
                if (type == OverlayType.NONE)
                {
                    continue;
                }

                // First entry, or sharing at least the current highest found priority
                if (index == -1 || type.getRenderPriority() >= neighborTypes[index - 1].getRenderPriority())
                {
                    // Actually a new highest priority, add it as the first entry and rewind the index
                    if (index < 0 || type.getRenderPriority() > neighborTypes[index - 1].getRenderPriority())
                    {
                        index = 0;
                    }
                    // else: Same priority as a previous entry, append this position

                    //System.out.printf("plop 0 axis: %s, corner: %d, i: %d, index: %d, type: %s\n", axis, corner, i, index, type);
                    neighborPositions[index] = new Vec3i(pos.getX() + offset.getX(), pos.getY() + offset.getY(), pos.getZ() + offset.getZ());
                    neighborTypes[index] = type;
                    // The self position is the first (offset = [0, 0, 0]) in the arrays
                    hasCurrent |= (i == 0);
                    ++index;
                }
            }

            //System.out.printf("plop 1 index: %d, pos: %s\n", index, pos);
            // Found something to render, and the current block is among the highest priority for this edge
            if (index > 0 && hasCurrent)
            {
                Vec3i posTmp = new Vec3i(pos.getX(), pos.getY(), pos.getZ());
                int ind = -1;

                for (int i = 0; i < index; ++i)
                {
                    Vec3i tmp = neighborPositions[i];
                    //System.out.printf("posTmp: %s, tmp: %s\n", posTmp, tmp);

                    // Just prioritize the position to render a shared highest priority edge by the coordinates
                    if (tmp.getX() <= posTmp.getX() && tmp.getY() <= posTmp.getY() && tmp.getZ() <= posTmp.getZ())
                    {
                        posTmp = tmp;
                        ind = i;
                    }
                }

                // The current position is the one that should render this edge
                if (posTmp.getX() == pos.getX() && posTmp.getY() == pos.getY() && posTmp.getZ() == pos.getZ())
                {
                    //System.out.printf("plop 2 index: %d, ind: %d, pos: %s, off: %s\n", index, ind, pos, posTmp);
                    RenderUtils.drawBlockBoxEdgeBatchedLines(pos, axis, corner, overlayColor, bufferOverlayOutlines);
                    lines++;
                }
            }
        }
    }
    //System.out.printf("typeSelf: %s, pos: %s, lines: %d\n", typeSelf, pos, lines);
}
 
源代码19 项目: enderutilities   文件: PortalFormer.java
private boolean walkFrameLoop(BlockPos pos, EnumFacing.Axis axis, EnumFacing frameSide, int distanceLimit)
{
    int counter = 0;
    int turns = 0;
    int tries = 0;
    IBlockState state;
    Block block;
    BlockPos startPos = pos;
    BlockPos posLast = startPos;
    EnumFacing firstTrySide = frameSide;
    EnumFacing moveDirection = frameSide;

    while (counter < distanceLimit)
    {
        moveDirection = firstTrySide;

        for (tries = 0; tries < 4; tries++)
        {
            pos = posLast.offset(moveDirection);
            state = this.world.getBlockState(pos);
            block = state.getBlock();

            if (block.isAir(state, this.world, pos))
            {
                posLast = pos;

                // The firstTrySide is facing into the adjacent portal frame when traveling
                // along a straight frame. Thus we need to rotate it once to keep going straight.
                // If we need to rotate it more than once, then we have hit a "right hand corner".
                if (tries > 1)
                {
                    turns++;
                }
                // If we didn't have to rotate the firstTrySide at all, then we hit a "left hand turn"
                // ie. traveled through an outer bend.
                else if (tries == 0)
                {
                    turns--;
                }

                // Set the firstTrySide one rotation back from the side that we successfully moved to
                // so that we can go around possible outer bends.
                firstTrySide = moveDirection.rotateAround(axis).getOpposite();

                break;
            }
            // Found a portal frame block, try the next adjacent side...
            else if (block == this.blockFrame)
            {
                moveDirection = moveDirection.rotateAround(axis);
            }
            // Found a non-air, non-portal-frame block -> invalid area.
            else
            {
                return false;
            }
        }

        // If we can return to the starting position hugging the portal frame,
        // then this is a valid portal frame loop.
        // Note that it is only valid if it forms an inside area, thus the turns check.
        // the tries == 4 && counter == 0 check is for a 1x1 area special case
        if ((tries == 4 && counter == 0) || pos.equals(startPos))
        {
            return turns >= 0;
        }

        counter++;
    }

    return false;
}
 
源代码20 项目: TofuCraftReload   文件: BlockTofuPortal.java
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {

    EnumFacing.Axis enumfacing$axis = state.getValue(AXIS);


    if (enumfacing$axis == EnumFacing.Axis.X) {

        Size blockportal$size = new Size(worldIn, pos, EnumFacing.Axis.X);


        if (!blockportal$size.isValid() ||

                blockportal$size.portalBlockCount < blockportal$size.width * blockportal$size.height) {

            worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());

        }

    } else if (enumfacing$axis == EnumFacing.Axis.Z) {

        Size blockportal$size1 = new Size(worldIn, pos, EnumFacing.Axis.Z);


        if (!blockportal$size1.isValid() ||

                blockportal$size1.portalBlockCount < blockportal$size1.width * blockportal$size1.height) {

            worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());

        }

    }

}