Java Code Examples for net.minecraft.util.EnumFacing#getAxis()

The following examples show how to use net.minecraft.util.EnumFacing#getAxis() . 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 check out the related API usage on the sidebar.
Example 1
Source File: PositionUtils.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Returns the rotation that would transform <b>facingOriginal</b> into <b>facingRotated</b>.
 * @param facingOriginal
 * @param facingRotated
 * @return
 */
public static Rotation getRotation(EnumFacing facingOriginal, EnumFacing facingRotated)
{
    if (facingOriginal.getAxis() == EnumFacing.Axis.Y ||
        facingRotated.getAxis() == EnumFacing.Axis.Y || facingOriginal == facingRotated)
    {
        return Rotation.NONE;
    }

    if (facingRotated == facingOriginal.getOpposite())
    {
        return Rotation.CLOCKWISE_180;
    }

    return facingRotated == facingOriginal.rotateY() ? Rotation.CLOCKWISE_90 : Rotation.COUNTERCLOCKWISE_90;
}
 
Example 2
Source File: BlockGearbox.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public IBlockState getStateFromMeta(int meta) {
    EnumFacing enumfacing = EnumFacing.byIndex(meta);
    if (enumfacing.getAxis() == EnumFacing.Axis.Y) {
        enumfacing = EnumFacing.NORTH;
    }
    return this.getDefaultState().withProperty(BlockHorizontal.FACING, enumfacing);
}
 
Example 3
Source File: TileEntityRudderPart.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public boolean attemptToAssembleMultiblock(World worldIn, BlockPos pos, EnumFacing facing) {
    List<IMultiblockSchematic> schematics = MultiblockRegistry.getSchematicsWithPrefix("multiblock_rudder_axle");
    for (IMultiblockSchematic schematic : schematics) {
        RudderAxleMultiblockSchematic rudderSchem = (RudderAxleMultiblockSchematic) schematic;
        if (facing.getAxis() != rudderSchem.getAxleAxisDirection().getAxis()
            && rudderSchem.getAxleFacingDirection() == facing
            && schematic.attemptToCreateMultiblock(worldIn, pos)) {
            return true;
        }
    }
    return false;
}
 
Example 4
Source File: TilePuzzle.java    From YouTubeModdingTutorial with MIT License 5 votes vote down vote up
private Set<BlockPos> findParticipatingBlocks() {
    Queue<BlockPos> todo = new ArrayDeque<>();
    todo.add(pos);

    EnumFacing thisFacing = world.getBlockState(pos).getValue(BlockPuzzle.FACING);

    Set<BlockPos> gameblocks = new HashSet<>();

    while (!todo.isEmpty()) {
        BlockPos todoPos = todo.poll();
        if (world.isBlockLoaded(todoPos)) {
            IBlockState state = world.getBlockState(todoPos);
            TileEntity te = world.getTileEntity(todoPos);
            if (te instanceof TilePuzzle && state.getBlock() == ModBlocks.blockPuzzle && state.getValue(BlockPuzzle.FACING) == thisFacing) {
                gameblocks.add(todoPos);
                // Add connected positions to the todo
                for (EnumFacing facing : EnumFacing.VALUES) {
                    if (facing.getAxis() != thisFacing.getAxis()) {
                        BlockPos newPos = todoPos.offset(facing);
                        if (!gameblocks.contains(newPos)) {
                            todo.add(newPos);
                        }
                    }
                }
            }
        }
    }
    return gameblocks;
}
 
Example 5
Source File: GTModelBlock.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected ModelRotation getRotation(EnumFacing facing, EnumFacing side, ModelRotation defaultRotation) {
	if (facing.getAxis().isHorizontal() && side.getAxis().isVertical()) {
		return defaultRotation;
	} else {
		return facing.getAxis().isVertical() && side.getAxis() == Axis.X ? defaultRotation : ModelRotation.X0_Y0;
	}
}
 
Example 6
Source File: GTModelOre.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected ModelRotation getRotation(EnumFacing facing, EnumFacing side, ModelRotation defaultRotation) {
	if (facing.getAxis().isHorizontal() && side.getAxis().isVertical()) {
		return defaultRotation;
	} else {
		return facing.getAxis().isVertical() && side.getAxis() == Axis.X ? defaultRotation : ModelRotation.X0_Y0;
	}
}
 
Example 7
Source File: BlockPassengerChair.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public IBlockState getStateFromMeta(int meta) {
    EnumFacing enumfacing = EnumFacing.byIndex(meta);
    if (enumfacing.getAxis() == EnumFacing.Axis.Y) {
        enumfacing = EnumFacing.NORTH;
    }
    return this.getDefaultState().withProperty(FACING, enumfacing);
}
 
Example 8
Source File: BlockBeaconLarge.java    From Cyberware with MIT License 5 votes vote down vote up
@Override
public IBlockState getStateFromMeta(int meta)
{
	EnumFacing enumfacing = EnumFacing.getFront(meta);

	if (enumfacing.getAxis() == EnumFacing.Axis.Y)
	{
		enumfacing = EnumFacing.NORTH;
	}

	return this.getDefaultState().withProperty(FACING, enumfacing);
}
 
Example 9
Source File: ToolJackHammer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static BlockPos rotate(BlockPos origin, int x, int y, EnumFacing sideHit, EnumFacing horizontalFacing) {
    switch (sideHit.getAxis()) {
        case X: return origin.add(0, y, x);
        case Z: return origin.add(x, y, 0);
        case Y: return rotateVertical(origin, x, y, horizontalFacing);
        default: return BlockPos.ORIGIN;
    }
}
 
Example 10
Source File: EasyPlaceUtils.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static boolean canClickOnAdjacentBlockToPlaceSingleSlabAt(BlockPos targetBlockPos, IBlockState targetState, EnumFacing side, World worldClient)
{
    BlockPos posSide = targetBlockPos.offset(side);
    IBlockState stateSide = worldClient.getBlockState(posSide);

    return PlacementUtils.isReplaceable(worldClient, posSide, false) == false &&
           (side.getAxis() != EnumFacing.Axis.Y ||
            clientBlockIsSameMaterialSingleSlab(targetState, stateSide) == false
            || stateSide.getValue(BlockSlab.HALF) != targetState.getValue(BlockSlab.HALF));
}
 
Example 11
Source File: RudderAxleMultiblockSchematic.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public List<IMultiblockSchematic> generateAllVariants() {
    Block rudderAxleBlock = ValkyrienSkiesControl.INSTANCE.vsControlBlocks.rudderPart;
    // Order matters here
    List<IMultiblockSchematic> variants = new ArrayList<IMultiblockSchematic>();
    for (int length = MAX_AXLE_LENGTH; length >= MIN_AXLE_LENGTH; length--) {
        for (EnumFacing possibleAxleAxisDirection : EnumFacing.VALUES) {
            for (EnumFacing possibleAxleFacingDirection : EnumFacing.VALUES) {
                if (possibleAxleAxisDirection.getAxis() != possibleAxleFacingDirection
                    .getAxis()) {
                    BlockPos originPos = new BlockPos(0, 0, 0);
                    RudderAxleMultiblockSchematic schematicVariant = new RudderAxleMultiblockSchematic();
                    schematicVariant.initializeMultiblockSchematic(
                        getSchematicPrefix() + "axle_axis_direction:"
                            + possibleAxleAxisDirection.toString() + ":axle_facing:"
                            + possibleAxleFacingDirection.toString() + ":length:" + length);
                    schematicVariant.axleAxis = possibleAxleAxisDirection;
                    schematicVariant.axleFacing = possibleAxleFacingDirection;
                    schematicVariant.axleLength = length;
                    for (int i = 0; i < length; i++) {
                        schematicVariant.structureRelativeToCenter
                            .add(new BlockPosBlockPair(
                                BlockPos.ORIGIN.offset(possibleAxleAxisDirection, i),
                                rudderAxleBlock));
                    }
                    variants.add(schematicVariant);
                }
            }
        }
    }
    return variants;
}
 
Example 12
Source File: BlockSpeedTelegraph.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public IBlockState getStateFromMeta(int meta) {
    EnumFacing enumfacing = EnumFacing.byIndex(meta);
    if (enumfacing.getAxis() == EnumFacing.Axis.Y) {
        enumfacing = EnumFacing.NORTH;
    }
    return this.getDefaultState().withProperty(FACING, enumfacing);
}
 
Example 13
Source File: BlockPL.java    From Production-Line with MIT License 5 votes vote down vote up
/**
 * Convert the given metadata into a BlockState for this Block
 */
public IBlockState getStateFromMeta(int meta) {
    if (this instanceof IOrientableBlock) {
        EnumFacing enumfacing = EnumFacing.getFront(meta);
        if (enumfacing.getAxis() == EnumFacing.Axis.Y) {
            enumfacing = EnumFacing.NORTH;
        }
        return this.getDefaultState().withProperty(PROPERTY_FACING, enumfacing);
    }
    else {
        return super.getStateFromMeta(meta);
    }
}
 
Example 14
Source File: BlockBlueprintArchive.java    From Cyberware with MIT License 5 votes vote down vote up
@Override
public IBlockState getStateFromMeta(int meta)
{
	EnumFacing enumfacing = EnumFacing.getFront(meta);

	if (enumfacing.getAxis() == EnumFacing.Axis.Y)
	{
		enumfacing = EnumFacing.NORTH;
	}

	return this.getDefaultState().withProperty(FACING, enumfacing);
}
 
Example 15
Source File: RenderWaterPad.java    From AgriCraft with MIT License 5 votes vote down vote up
private static void renderSide(ITessellator tess, EnumFacing side, TextureAtlasSprite matIcon) {
    //data about side to render
    boolean xAxis = side.getAxis() == EnumFacing.Axis.X;
    int index = xAxis ? side.getFrontOffsetX() : side.getFrontOffsetZ();
    int min = index < 0 ? 0 : 15;
    int max = index < 0 ? 1 : 16;

    //render upper face
    tess.drawScaledFace(xAxis ? min : 0, xAxis ? 0 : min, xAxis ? max : 16, xAxis ? 16 : max, EnumFacing.UP, matIcon, 16);

    //render side
    tess.drawScaledFace(0, 8, 16, 16, side, matIcon, index > 0 ? 16 : 0);
    tess.drawScaledFace(0, 8, 16, 16, side.getOpposite(), matIcon, index > 0 ? 15 : 1);
}
 
Example 16
Source File: BlockTFCompressor.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * Convert the given metadata into a BlockState for this Block
 */
public IBlockState getStateFromMeta(int meta)
{
    EnumFacing enumfacing = EnumFacing.getFront(meta);

    if (enumfacing.getAxis() == EnumFacing.Axis.Y)
    {
        enumfacing = EnumFacing.NORTH;
    }

    return this.getDefaultState().withProperty(FACING, enumfacing);
}
 
Example 17
Source File: BlockTFCrasher.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * Convert the given metadata into a BlockState for this Block
 */
public IBlockState getStateFromMeta(int meta)
{
    EnumFacing enumfacing = EnumFacing.getFront(meta);

    if (enumfacing.getAxis() == EnumFacing.Axis.Y)
    {
        enumfacing = EnumFacing.NORTH;
    }

    return this.getDefaultState().withProperty(FACING, enumfacing);
}
 
Example 18
Source File: BlockAggregator.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * Convert the given metadata into a BlockState for this Block
 */
public IBlockState getStateFromMeta(int meta)
{
    EnumFacing enumfacing = EnumFacing.getFront(meta);

    if (enumfacing.getAxis() == EnumFacing.Axis.Y)
    {
        enumfacing = EnumFacing.NORTH;
    }

    return this.getDefaultState().withProperty(FACING, enumfacing);
}
 
Example 19
Source File: BlockComponentBox.java    From Cyberware with MIT License 5 votes vote down vote up
@Override
public IBlockState getStateFromMeta(int meta)
{
	EnumFacing enumfacing = EnumFacing.getFront(meta);

	if (enumfacing.getAxis() == EnumFacing.Axis.Y)
	{
		enumfacing = EnumFacing.NORTH;
	}

	return this.getDefaultState().withProperty(FACING, enumfacing);
}
 
Example 20
Source File: MetaTileEntityPump.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing side) {
    return (side == null || side.getAxis() != Axis.Y) ? super.getCapability(capability, side) : null;
}