Java Code Examples for net.minecraft.util.Facing#oppositeSide()

The following examples show how to use net.minecraft.util.Facing#oppositeSide() . 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: TileEntityQuantumComputer.java    From qcraft-mod with Apache License 2.0 5 votes vote down vote up
private boolean isPortalCorner( int x, int y, int z, int dir )
{
    if( y < 0 || y >= 256 )
    {
        return false;
    }

    TileEntity entity = worldObj.getTileEntity( x, y, z );
    if( entity != null && entity instanceof TileEntityQBlock )
    {
        TileEntityQBlock quantum = (TileEntityQBlock) entity;
        int[] types = quantum.getTypes();
        for( int i = 0; i < 6; ++i )
        {
            if( i == dir || i == Facing.oppositeSide[ dir ] )
            {
                if( types[ i ] != 31 ) // GOLD
                {
                    return false;
                }
            }
            else
            {
                if( types[ i ] != 21 ) // OBSIDIAN
                {
                    return false;
                }
            }
        }
        return true;
    }
    return false;
}
 
Example 2
Source File: BlockQuantumLogic.java    From qcraft-mod with Apache License 2.0 5 votes vote down vote up
private void updateOutput( World world, int x, int y, int z )
{
    if( world.isRemote )
    {
        return;
    }

    // Redetermine subtype
    int metadata = world.getBlockMetadata( x, y, z );
    int direction = getDirection( metadata );
    int subType = getSubType( metadata );
    int newSubType = evaluateInput( world, x, y, z ) ? SubType.ObserverOn : SubType.ObserverOff;
    if( newSubType != subType )
    {
        // Set new subtype
        setDirectionAndSubType( world, x, y, z, direction, newSubType );
        subType = newSubType;

        // Notify
        world.markBlockForUpdate( x, y, z );
        world.notifyBlocksOfNeighborChange( x, y, z, this );
    }

    // Observe
    int facing = Facing.oppositeSide[ Direction.directionToFacing[ direction ] ];
    observe( world, x, y, z, facing, subType == SubType.ObserverOn );
}
 
Example 3
Source File: BlockQuantumLogic.java    From qcraft-mod with Apache License 2.0 5 votes vote down vote up
private boolean evaluateInput( World world, int i, int j, int k )
{
    int metadata = world.getBlockMetadata( i, j, k );
    int direction = Facing.oppositeSide[ Direction.directionToFacing[ getDirection( metadata ) ] ];
    int backDir = Facing.oppositeSide[ direction ];
    return getRedstoneSignal( world, i, j, k, backDir );
}
 
Example 4
Source File: BlockQuantumLogic.java    From qcraft-mod with Apache License 2.0 5 votes vote down vote up
private boolean getRedstoneSignal( World world, int i, int j, int k, int dir )
{
    i += Facing.offsetsXForSide[ dir ];
    j += Facing.offsetsYForSide[ dir ];
    k += Facing.offsetsZForSide[ dir ];
    int side = Facing.oppositeSide[ dir ];
    return QuantumUtil.getRedstoneSignal( world, i, j, k, side );
}
 
Example 5
Source File: BlockOmnidirectionalHopper.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
 */
@Override
public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9){
    return Facing.oppositeSide[par5];
}